artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
# JOURNAL — eval phase
|
||||
|
||||
## Implementation run
|
||||
|
||||
Ran all checks locally before commit:
|
||||
|
||||
```
|
||||
$ python -m unittest -q
|
||||
----------------------------------------------------------------------
|
||||
Ran 45 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"
|
||||
error: division by zero
|
||||
(exit 1)
|
||||
$ python calc.py "1 +"
|
||||
error: unexpected end of input
|
||||
(exit 1)
|
||||
```
|
||||
|
||||
All 45 tests pass (20 from parse phase, 14 from lex phase, 11 from evaluator tests).
|
||||
|
||||
### Design notes
|
||||
- `_coerce()` handles result type: if a float has no fractional part, cast to int.
|
||||
- Division by zero caught explicitly and re-raised as `EvalError`.
|
||||
- CLI catches `LexError`, `ParseError`, `EvalError` — no raw tracebacks.
|
||||
Reference in New Issue
Block a user