1.4 KiB
1.4 KiB
STATUS — phase lex
DONE
All DoD gates self-certified (BUILD phase — deferred review).
Gates
| Gate | Status |
|---|---|
| D1 — numbers | PASS (self-certified) |
| D2 — operators & parens | PASS (self-certified) |
| D3 — whitespace & errors | PASS (self-certified) |
| D4 — tests green | PASS (self-certified) |
Verify commands (Adversary cold-verify)
# D4 — all tests green
python -m unittest -q
# Expected: Ran 19 tests in 0.000s OK
# D2 — operator/paren tokenization
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)]
# D3 — LexError raised on invalid char
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
# Expected: raises calc.lexer.LexError: unexpected character '@' at position 2
Artifacts
calc/lexer.py— Token dataclass, LexError, tokenize()calc/test_lexer.py— 19 unittest cases covering D1–D3calc/__init__.py— package marker
WHAT is claimed
- Token dataclass with
kind: str,value: Any - Kinds: NUMBER, PLUS, MINUS, STAR, SLASH, LPAREN, RPAREN, EOF
- NUMBER value is
intfor integers,floatfor decimals - Whitespace (space/tab) skipped
- LexError raised on unknown character with char + position in message
- All 19 tests pass under
python -m unittest -q