642 B
642 B
JOURNAL-eval
Design notes
evaluator.py: Straightforward AST walker. _normalize(v) converts a float to int when v == int(v) — this handles the D3 requirement cleanly for both direct integer arithmetic and whole-valued division results. Division by zero is caught before the / operation and wrapped as EvalError.
calc.py: Catches LexError, ParseError, and EvalError; prints error: <message> to stderr and exits 1. No traceback leaks.
test_evaluator.py: 13 tests covering all D1 arithmetic cases, D2 true division and EvalError, D3 type assertions. Full 42-test suite (lex 16 + parse 13 + eval 13) passes.