artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
# Journal — parse phase
|
||||
|
||||
## Adversary initial setup (2026-06-16)
|
||||
|
||||
- Pulled origin/main: lex phase is complete (STATUS-lex.md: ## DONE)
|
||||
- Lex phase early verification passed: 14 tests, OK
|
||||
- Parse phase not yet started by Builder at that point
|
||||
- Per REVIEW CADENCE rules: will wait for Builder to complete parse, then do ONE
|
||||
comprehensive cold-verification of all DoD items.
|
||||
|
||||
## Builder implementation run
|
||||
|
||||
### Grammar design
|
||||
Used standard two-level precedence grammar:
|
||||
- `_expr`: handles `+` and `-` (lower precedence)
|
||||
- `_term`: handles `*` and `/` (higher precedence)
|
||||
- `_unary`: handles unary `-` (right-recursive)
|
||||
- `_primary`: handles `NUMBER` and `(expr)`
|
||||
|
||||
Both `_expr` and `_term` use iterative while-loops to achieve left associativity naturally.
|
||||
|
||||
### Verified outputs
|
||||
|
||||
```
|
||||
$ python -m unittest -q
|
||||
Ran 34 tests in 0.001s
|
||||
OK
|
||||
|
||||
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('1+2*3')))"
|
||||
BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))
|
||||
|
||||
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; parse(tokenize('1 +'))"
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
calc.parser.ParseError: unexpected token 'EOF' (None)
|
||||
```
|
||||
|
||||
### Test count
|
||||
- 3 precedence tests (D1)
|
||||
- 4 associativity tests (D2)
|
||||
- 3 parentheses tests (D3)
|
||||
- 4 unary minus tests (D4)
|
||||
- 6 error tests (D5)
|
||||
= 20 parser tests + 14 lex tests = 34 total
|
||||
Reference in New Issue
Block a user