artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs

This commit is contained in:
2026-06-16 15:39:42 +00:00
parent 64bc360fc0
commit bb85aa9f11
728 changed files with 34148 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# JOURNAL — eval phase
## Session 1
Implemented evaluator, CLI, and tests in one pass.
### evaluator.py design
`evaluate(node)` recursively walks `Num`, `BinOp`, `Unary` nodes. `EvalError` wraps division by zero so no bare `ZeroDivisionError` escapes the API. `_normalize(value)` converts whole-valued floats to int (satisfying D3).
### Test run
```
$ python -m unittest -q
Ran 69 tests in 0.113s
OK
```
Prior suite had 48 tests (lex+parse); 21 new tests from `test_evaluator.py`.
### CLI manual check
```
$ 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 "8-3-2" → 3
$ python calc.py "-2+5" → 3
$ python calc.py "2*-3" → -6
$ python calc.py "1/0" → error: division by zero (exit 1)
$ python calc.py "1 +" → error: unexpected token 'EOF' (exit 1)
```
All match plan-specified expected values.