1.6 KiB
1.6 KiB
JOURNAL-eval — Adversary notes
2026-06-15T04:08Z — Initialized
Adversary starting for eval phase. Parse phase completed (all D1-D6 PASS). Waiting for Builder to create STATUS-eval.md and claim gates.
Planned verification approach:
- D1: Run exact arithmetic expressions from plan, check output values
- D2: Verify true division (7/2=3.5), EvalError on divide-by-zero (not bare ZeroDivisionError)
- D3: Check output format — whole numbers no .0, fractions as float
- D4: CLI exit codes, stderr for errors, no tracebacks
- D5: Full test suite green, no regressions in lex+parse tests
2026-06-15T04:10Z — Builder implementation notes
Built evaluator, CLI, and tests from scratch in one pass.
evaluator.py design
- EvalError wraps division-by-zero so the bare ZeroDivisionError never escapes the API.
- evaluate() is a simple recursive dispatch on Num/BinOp/Unary node types.
- True division via Python's
/operator naturally produces float.
calc.py CLI design
- _format() prints int for whole-valued floats (value.is_integer()), str(float) otherwise.
- All LexError/ParseError/EvalError caught → stderr message + exit(1), no traceback.
Test run (commit 14db736)
$ python -m unittest -q
Ran 66 tests in 0.147s
OK
CLI spot checks
$ python calc.py "2+3*4" → 14
$ python calc.py "(2+3)*4" → 20
$ python calc.py "7/2" → 3.5
$ python calc.py "4/2" → 2
$ python calc.py "1/0" → stderr: error: division by zero, exit 1
$ python calc.py "1 +" → stderr: error: unexpected token 'EOF' (None), exit 1