2.2 KiB
STATUS-lex
Phase: lex
Commit: c37b70f
Gate Results
D1 — numbers
What: Integers and floats tokenize to NUMBER tokens with correct Python values (int or float).
Command: python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('42')])"
Expected: [('NUMBER', 42), ('EOF', None)]
Observed: [('NUMBER', 42), ('EOF', None)]
Result: PASS
Float test: tokenize("3.14") → [('NUMBER', 3.14), ('EOF', None)] ✓
Leading dot: tokenize(".5") → [('NUMBER', 0.5), ('EOF', None)] ✓
Trailing dot: tokenize("10.") → [('NUMBER', 10.0), ('EOF', None)] ✓
D2 — operators & parens
What: + - * / ( ) tokenize to correct kinds; "1+2*3" yields NUMBER PLUS NUMBER STAR NUMBER EOF.
Command: python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize('1+2*3')])"
Expected: ['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']
Observed: Confirmed via test suite (15/15 tests pass)
Result: PASS
D3 — whitespace & errors
What: Spaces/tabs skipped; invalid chars raise LexError with char and position.
Command (whitespace): python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize(' 12 + 3 ')])"
Observed: ['NUMBER', 'PLUS', 'NUMBER', 'EOF'] ✓
Command (error): python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
Expected: raises LexError with @ and position in message
Observed:
calc.lexer.LexError: unexpected character '@' at position 2
Result: PASS
D4 — tests green
Command: python -m unittest -q
Expected: 0 failures
Observed:
----------------------------------------------------------------------
Ran 15 tests in 0.000s
OK
Result: PASS
Plan verification commands (from plan's "Verify" section)
python -m unittest -q
→ Ran 15 tests in 0.000s / OK
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
→ [('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
→ calc.lexer.LexError: unexpected character '@' at position 2