Externum โ Architecture
Project Structureโ
externum/
โโโ externum/
โ โโโ __init__.py # Package init
โ โโโ cli.py # CLI entry point
โ โโโ lexer.py # Tokeniser
โ โโโ parser.py # Recursive descent parser
โ โโโ ast_nodes.py # AST node definitions
โ โโโ transpiler/
โ โ โโโ __init__.py
โ โ โโโ python.py # Python backend
โ โ โโโ bash.py # Bash backend
โ โ โโโ binary.py # Binary backend
โ โโโ repl.py # Interactive shell
โ โโโ module_loader.py # Module resolution
โ โโโ stdlib/ # Standard library (in Externum)
โ โโโ math.ext
โ โโโ string.ext
โ โโโ io.ext
โ โโโ list.ext
โ โโโ random.ext
โโโ examples/ # Example programs
โ โโโ fibonacci.ext
โ โโโ pokedex.ext
โ โโโ ...
โโโ tests/ # 120 test cases
โ โโโ test_lexer.py
โ โโโ test_parser.py
โ โโโ test_transpiler.py
โ โโโ test_stdlib.py
โโโ setup.py # pip install -e .
โโโ README.md
โโโ README.pl.md # Polish documentation
Data Flowโ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Source โโโโโบโ Lexer โโโโโบโ Parser โโโโโบโ AST โ
โ (.ext) โ โ (tokens) โ โ (tree) โ โ โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโฌโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Python โ โ Bash โ โ Binary โ
โ transpiler โ โ transpiler โ โ compiler โ
โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ .py output โ โ .sh output โ โ .bin output โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
Key Design Decisionsโ
- Python implementation โ the transpiler itself is written in Python, making it easy to extend and maintain
- Three targets โ compile once, run anywhere (Python ecosystem, shell scripts, standalone binaries)
- Own stdlib โ the standard library is written in Externum, proving the language is self-hosting capable
- Browser execution โ via Pyodide (Python โ WebAssembly), no server needed
- 100% test coverage โ 120 tests ensure every feature works across all backends
REPLโ
Interactive shell with:
- History navigation (up/down arrows)
- Tab completion
- Multi-line input (auto-detects incomplete blocks)
- Direct execution mode (no compilation needed)
- Variable persistence between lines
Module Systemโ
# Relative imports
from . import local_module
from .sub import something
# Absolute imports
import externum.utils
from externum.math import sqrt
Modules are resolved by:
- Checking the current directory for
.extfiles - Checking for package directories with
__init__.ext - Checking the standard library