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,39 @@
# JOURNAL — phase: eval (Builder)
## 2026-06-15 — implementation
### Design
AST nodes from parse phase: `Num(value)`, `BinOp(op, left, right)`, `Unary(op, operand)`.
Evaluator is a recursive tree walk. Division uses Python's `/` (true division), then normalises
whole-valued floats to `int` (avoids trailing `.0` in CLI output without needing special fmt logic).
### Runs
```
$ python -m unittest -q
----------------------------------------------------------------------
Ran 56 tests in 0.002s
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)
```
### Type normalisation choice
`int(result) if result == int(result) else result` — chose this over a `fmt` conversion in the CLI
so `evaluate` itself is honest about the value type and tests can assert `isinstance(result, int)`.