Files
agent-orchestrator-benchmark/calculators/builder-adversary-stateless/run-01/machine-docs/REVIEW-parse.md

2.1 KiB
Raw Blame History

REVIEW — parse phase (Adversary)

Status

All gates verified. Awaiting Builder to write ## DONE to STATUS-parse.md.

Gate verdicts

D1 (precedence): PASS @2026-06-15T03:40Z

  • parse(tokenize('1+2*3'))BinOp(op='+', left=Num(value=1), right=BinOp(op='*', left=Num(value=2), right=Num(value=3)))
  • parse(tokenize('2*3+1'))BinOp(op='+', left=BinOp(op='*', ...), right=Num(1))
  • parse(tokenize('2+3*4*5'))+ at root, nested * tree under right ✓

D2 (left assoc): PASS @2026-06-15T03:40Z

  • 8-3-2BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))
  • 8/4/2BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))
  • 12/6*2BinOp('*', BinOp('/', Num(12), Num(6)), Num(2)) ✓ (left-assoc across same-level ops)
  • 1-2+3BinOp('+', BinOp('-', Num(1), Num(2)), Num(3))

D3 (parentheses): PASS @2026-06-15T03:40Z

  • (1+2)*3BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))
  • ((3))Num(3)

D4 (unary minus): PASS @2026-06-15T03:40Z

  • -5Unary('-', Num(5))
  • -(1+2)Unary('-', BinOp('+', Num(1), Num(2)))
  • 3 * -2BinOp('*', Num(3), Unary('-', Num(2)))
  • --5Unary('-', Unary('-', Num(5))) ✓ (right-recursive _unary)
  • -(-5)Unary('-', Unary('-', Num(5)))

D5 (errors): PASS @2026-06-15T03:40Z All 5 plan-mandated cases raise ParseError (not a Python built-in):

  • '1 +' → ParseError ✓
  • '(1' → ParseError ✓
  • '1 2' → ParseError ✓
  • ')(' → ParseError ✓
  • '' → ParseError ✓ Additional probes also raise ParseError: *5, (), 1+2), +-5, + alone.

D6 (tests green): PASS @2026-06-15T03:40Z

  • python -m unittest -qRan 36 tests in 0.001s / OK
  • Tests assert on tree structure via dataclass equality (not evaluation) ✓
  • 7 error-case tests, 20 structural tests across D1D4

Adversary findings

None. No defects found.

Implementation notes (post-verdict)

Recursive-descent parser is structurally sound: _expr → _term → _unary → _primary. ParseError(Exception) is a proper subclass. EOF sentinel token prevents index OOB.