Files
agent-orchestrator-benchmark/calculators/builder-adversary-stateless/run-05/machine-docs/JOURNAL-eval.md

985 B

JOURNAL-eval.md

Session 1

Implementation

Created three files:

  • calc/evaluator.pyevaluate(node) walks Num/BinOp/Unary nodes. Division uses Python / (true division). After division, normalizes whole-valued floats to int via int(result).
  • calc/test_evaluator.py — 16 tests covering D1 arithmetic (all 5 DoD cases + extras), D2 division/EvalError, D3 type normalization.
  • calc.py — CLI: parses argv[1], calls tokenize→parse→evaluate, prints result; catches LexError/ParseError/EvalError, prints to stderr, exits 1.

Verification run

$ python -m unittest -q
Ran 65 tests in 0.001s
OK

$ 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" 2>&1; echo "exit: $?"
error: division by zero
exit: 1
$ python calc.py "1 +" 2>&1; echo "exit: $?"
error: unexpected end of input
exit: 1

All outputs match DoD specs. 65 tests (lex + parse + eval) pass, zero failures.