Skip to content

Architecture

NXL is divided into several stages:

NXL SOURCE
│
▼
┌───────────────┐
│ CLI │
│ main.rs │
└───────┬───────┘
│
▼
┌───────────────┐
│ Lexer │
│ lexer.rs │
└───────┬───────┘
│
▼
Tokens
│
▼
┌───────────────┐
│ Parser │
│ parser.rs │
└───────┬───────┘
│
▼
AST
│
▼
┌───────────────┐
│ Interpreter │
│interpreter.rs │
└───────┬───────┘
│
┌────┴─────┐
▼ ▼
Environment Runtime
environment runtime
│ │
└────┬─────┘
▼
OUTPUT

Suppose the source is:

let age = 23
if age >= 18 {
print("Adult")
}

NXL processes this in stages:

Source Code
↓
Lexer
↓
Tokens
↓
Parser
↓
AST
↓
Interpreter
↓
Environment + Runtime Values
↓
Output

Each stage has a focused responsibility.

hello.nxl
│ source text
▼
main.rs
│
▼
lexer.rs
│ Vec<Token>
▼
parser.rs
│ Program
▼
ast.rs
│
▼
interpreter.rs
│
├── environment.rs
└── runtime.rs
│
▼
stdout