Skip to main content

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โ€‹

  1. Python implementation โ€” the transpiler itself is written in Python, making it easy to extend and maintain
  2. Three targets โ€” compile once, run anywhere (Python ecosystem, shell scripts, standalone binaries)
  3. Own stdlib โ€” the standard library is written in Externum, proving the language is self-hosting capable
  4. Browser execution โ€” via Pyodide (Python โ†’ WebAssembly), no server needed
  5. 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:

  1. Checking the current directory for .ext files
  2. Checking for package directories with __init__.ext
  3. Checking the standard library