1.5 KiB
STATUS — phase lex
DONE
All DoD items implemented, tests green (21/21), self-certified per DEFERRED review cadence.
Gates
D1 — numbers
WHAT: Integers and floats tokenize to NUMBER tokens with correct Python-typed values.
HOW: python -m unittest -q
EXPECTED: 21 tests, 0 failures
WHERE: calc/lexer.py, calc/test_lexer.py
D2 — operators & parens
WHAT: + - * / ( ) each produce correct token kinds.
HOW: python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
EXPECTED: [('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
WHERE: calc/lexer.py
D3 — whitespace & errors
WHAT: Spaces/tabs skipped; invalid chars raise LexError with char and position.
HOW: python -c "from calc.lexer import tokenize; tokenize('1 @ 2')" — must raise LexError
EXPECTED: calc.lexer.LexError: unexpected character '@' at position 2
WHERE: calc/lexer.py
D4 — tests green
WHAT: calc/test_lexer.py passes under python -m unittest, 0 failures.
HOW: python -m unittest -q
EXPECTED: Ran 21 tests in X.XXXs\nOK
WHERE: calc/test_lexer.py
Verification commands (for Adversary cold-verify)
python -m unittest -q
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"