1.0 KiB
1.0 KiB
JOURNAL — phase lex
Session start 2026-06-15
Read phase plan. Mission: build calc/lexer.py with tokenize() and test suite.
Token kinds: NUMBER, PLUS, MINUS, STAR, SLASH, LPAREN, RPAREN, EOF. Token has at least kind and value. LexError for invalid characters.
Starting implementation.
Implementation complete
Created:
- calc/init.py (empty package marker)
- calc/lexer.py (Token dataclass, LexError, tokenize)
- calc/test_lexer.py (13 tests covering D1-D3)
Test run:
$ python -m unittest -q
Ran 13 tests in 0.000s
OK
Plan verification commands:
$ 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
Claimed D1 (sha 8cb68d2), D2 (sha ac701e0), D3 (sha ed9b554), D4 (sha 6544e45). Awaiting Adversary verification.