Worked reconstruction
Consider the expression 8 - 2 * 3:
| Stage |
Output |
What it has decided |
| Lex |
NUMBER 8, MINUS, NUMBER 2, STAR, NUMBER 3, EOF |
Character boundaries and positions |
| Parse |
Sub(8, Mul(2,3)) |
Multiplication binds more tightly |
| Lower |
PUSH 8; PUSH 2; PUSH 3; MUL; SUB |
Evaluation order and stack protocol |
| Hand execution |
[8,2,3] → [8,6] → [2] |
Numeric result under runtime rules |
The expression lexer can tokenize missing + 1; it does not know whether
missing has a binding. Likewise a parser can construct a well-formed tree for
a name that semantic analysis will reject. Later let x = ; fails parsing
before names can be checked. In v2, let x = "a" - 1; has valid syntax and
names but fails runtime numeric checks; v6 can reject that mismatch earlier.