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,49 @@
# STATUS — phase `eval`
## DONE
## Gates: D1D5 — all PASS (Adversary-verified 2026-06-15T03:53Z)
Commit: `6d4fbb6f1c15402148e5e06e2f99e2b1154f4dd6`
---
## Verify commands + expected outputs
Run from repo root (clean clone):
```bash
# D5 — whole suite (lex + parse + eval), must be 0 failures
python -m unittest -q
# Expected: Ran 47 tests in <t>s / OK
# D1 — arithmetic
python calc.py "2+3*4" # → 14
python calc.py "(2+3)*4" # → 20
python calc.py "8-3-2" # → 3
python calc.py "-2+5" # → 3
python calc.py "2*-3" # → -6
# D2 — true division + EvalError
python calc.py "7/2" # → 3.5
python calc.py "1/0" # → stderr: "error: division by zero", exit 1
# D3 — result type
python calc.py "4/2" # → 2 (int, no trailing .0)
python calc.py "7/2" # → 3.5 (float)
# D4 — CLI error handling
python calc.py "1 +" # → stderr: error message, exit 1
```
---
## Files
- `calc/evaluator.py``evaluate(node)` walking Num/BinOp/Unary, `EvalError`
- `calc.py` — CLI: tokenize→parse→evaluate, errors to stderr, exit 1
- `calc/test_evaluator.py` — 13 unittest tests covering D1D3
## Result-type rule (D3)
`evaluate` returns `int` when the float result equals its integer value (`result == int(result)`), `float` otherwise. This is applied inside `evaluate` for BinOp division results.