2.0 KiB
REVIEW-parse — Adversary verdicts
Status
All gates D1–D6 cold-verified PASS @ 2026-06-15T05:59:19Z.
Verdicts
parse/D1: PASS @ 2026-06-15T05:59:19Z
Cold-run:
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(repr(parse(tokenize('1+2*3'))))"
# -> BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))
Grammar: _expr calls _term (mul/div) which binds tighter than add/sub. Confirmed with 5-2*3, 4+6/2, 1*2+3*4, 6-2/2. All correct.
parse/D2: PASS @ 2026-06-15T05:59:19Z
Cold-run:
8-3-2 -> BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))
8/4/2 -> BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))
While-loop in _expr and _term implements left-fold correctly. Also verified 1+2+3, 6/2*3. All correct.
parse/D3: PASS @ 2026-06-15T05:59:19Z
Cold-run:
(1+2)*3 -> BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))
_primary handles (expr) via recursive _expr() + _consume('RPAREN'). Also checked ((3)) -> Num(3). Correct.
parse/D4: PASS @ 2026-06-15T05:59:19Z
Cold-run:
-5 -> Unary('-', Num(5))
-(1+2) -> Unary('-', BinOp('+', Num(1), Num(2)))
3 * -2 -> BinOp('*', Num(3), Unary('-', Num(2)))
Also probed: --5 -> Unary('-', Unary('-', Num(5))) (recursive unary), -1+2 -> BinOp('+', Unary('-', Num(1)), Num(2)), 1+-2 -> BinOp('+', Num(1), Unary('-', Num(2))). All correct.
parse/D5: PASS @ 2026-06-15T05:59:19Z
Cold-run for all 5 specified cases ('1 +', '(1', '1 2', ')(', ''): all raise ParseError, no other exceptions.
Extended probes: +, *1, 1*, )(, 1++2, ((, 1 2 3, (), all raise ParseError. No ValueError/IndexError/etc. found.
parse/D6: PASS @ 2026-06-15T05:59:19Z
Cold-run:
python -m unittest -q
# -> Ran 31 tests in 0.001s OK
Tests use assertEqual on node objects (dataclass structural equality) — not on evaluation results. Satisfies plan requirement of asserting on tree structure.
Adversary findings
None. All gates PASS, no break-it probes produced unexpected behavior.