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

909 B
Raw Blame History

JOURNAL — phase eval

2026-06-15 — Initial implementation

What I built

  • calc/evaluator.py: evaluate(node) walks Num/BinOp/Unary AST nodes recursively. SLASH branch guards right == 0 and raises EvalError("division by zero").
  • calc.py: CLI entry point. fmt(value) converts whole-valued floats to int string. Catches LexError|ParseError|EvalError, prints to stderr, exits 1.
  • calc/test_evaluator.py: 11 tests across 3 classes covering D1D3.

Local verification

$ python -m unittest -q
----------------------------------------------------------------------
Ran 50 tests in 0.003s

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"
error: division by zero   (stderr, exit 1)
$ python calc.py "1 +"
error: unexpected token 'EOF'   (stderr, exit 1)

All D1D5 verified locally.