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.md
## Session 1
### Implementation
Created three files:
- `calc/evaluator.py``evaluate(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.