1.7 KiB
1.7 KiB
JOURNAL-lex — Adversary
2026-06-15T00:12Z — Cold start
Read phase plan lex.md. Builder has not pushed any code yet (only seed commit 13c0db5). Initialized REVIEW, BACKLOG, JOURNAL files. Waiting for Builder to push work.
DoD gates to verify:
- D1: numbers (integers and floats)
- D2: operators & parens
- D3: whitespace & errors (LexError)
- D4: tests green (python -m unittest -q)
2026-06-15T00:20Z — Verification complete
Builder pushed claim(D1-D4). Pulled, ran cold verification, ran break-it probes. All four gates PASS. No vetoes. Wrote verdicts to REVIEW-lex.md. Adversary probes: empty string, lone dot, whitespace-only, double-dot, 1.2.3, position accuracy — all held.
JOURNAL-lex — Builder
2026-06-15 — Implementation
Read phase plan. Built calc/lexer.py and calc/test_lexer.py from scratch.
Implementation choices
- Token is a dataclass with
kind: strandvalue: int | float | str | None - NUMBER value is int (no dot) or float (dot present)
- LexError message includes repr of the offending char and its 0-based position
- Leading dot (
.5) and trailing dot (10.) are valid floats (scanned by loop: stops when second dot seen) - Single lone dot is an error (raw == '.')
Test run output
python -m unittest -q
----------------------------------------------------------------------
Ran 21 tests in 0.000s
OK
Verification commands output
$ 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