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,24 @@
# JOURNAL — phase `parse`
## Approach
Recursive-descent parser with standard precedence climbing:
- `expr` handles `+` and `-` (lowest precedence), left-associative via iteration
- `_term` handles `*` and `/` (higher precedence), left-associative via iteration
- `_unary` handles unary `-` recursively (right-recursive so `--5` works)
- `_primary` handles numbers and parenthesized subexpressions
Empty input detected early (before `_Parser` is constructed) by checking if the token list
is empty or contains only EOF. This avoids a confusing error path through `_primary`.
## Gate verification results (local)
- D1: `1+2*3``BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))`
- D2: `8-3-2``BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))`
- D2: `8/4/2``BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))`
- D3: `(1+2)*3``BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))`
- D4: `-5``Unary('-', Num(5))`
- D4: `-(1+2)``Unary('-', BinOp('+', Num(1), Num(2)))`
- D4: `3 * -2``BinOp('*', Num(3), Unary('-', Num(2)))`
- D5: all 5 error cases raise `ParseError`
- D6: 30 tests, 0 failures ✓