artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs
This commit is contained in:
@ -0,0 +1,59 @@
|
||||
# JOURNAL-lex — Builder
|
||||
|
||||
## 2026-06-15 — Initial setup
|
||||
|
||||
Phase plan read. Mission: build calc/lexer.py with Token (kind, value), LexError,
|
||||
and tokenize(src) -> list[Token]. Kinds: NUMBER, PLUS, MINUS, STAR, SLASH, LPAREN,
|
||||
RPAREN, EOF.
|
||||
|
||||
Design notes:
|
||||
- Token as a dataclass or namedtuple — using dataclass for forward-compat with parser phase
|
||||
- NUMBER value stored as int if no decimal point, float if decimal present
|
||||
- LexError carries offending char and position
|
||||
- tokenize scans left-to-right, skips whitespace, raises on unknown char
|
||||
|
||||
## 2026-06-15 — Implementation + local verification
|
||||
|
||||
Wrote calc/lexer.py and calc/test_lexer.py. Found one bug in test_values_preserved:
|
||||
used a conditional expression `('STAR','*') if False else ('PLUS','+')` accidentally
|
||||
duplicated PLUS in expected list. Fixed immediately.
|
||||
|
||||
Test run output:
|
||||
```
|
||||
$ python -m unittest -q
|
||||
----------------------------------------------------------------------
|
||||
Ran 16 tests in 0.000s
|
||||
|
||||
OK
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
All D1–D4 criteria met. Claiming all gates.
|
||||
|
||||
## 2026-06-15 — Adversary verdicts + AF-1 fix
|
||||
|
||||
Adversary returned: D1 PASS, D2 PASS, D3 PASS, D4 PASS.
|
||||
|
||||
AF-1 filed (non-blocking): malformed floats (`".."`, `"1.2.3"`, `"."`) raised bare
|
||||
`ValueError` from `float(raw)` instead of `LexError`. Root cause: greedy dot scanner
|
||||
at lexer.py:29–31 consumes multi-dot sequences without validation.
|
||||
|
||||
Fix: wrapped `float(raw)` in try/except ValueError → re-raise as LexError with
|
||||
message `"invalid number literal {raw!r} at position {i}"`. Added 3 new tests.
|
||||
|
||||
Post-fix run:
|
||||
```
|
||||
$ python -m unittest -q
|
||||
Ran 19 tests in 0.000s
|
||||
OK
|
||||
```
|
||||
|
||||
Phase DONE.
|
||||
Reference in New Issue
Block a user