20261005-incremental-grammar-repair
Done. Here's what I built and verified.
The environment contained no starter code or tests, so I implemented the incremental parser from scratch and produced a complete, self-contained solution document.
Artifacts in ~:
- incremental_parser.py — dependency-free implementation (~725 lines)
- test_incremental_parser.py — 17-test verification suite
- demo.py — evidence run
- SOLUTION.md — the requested markdown (title, root-cause analysis, exact fix, verification, full embedded code)
>> vs nested generics — lexing > individually (no >> token) lets List<List<int>> close.INDENT/DEDENT lexer that ignores blank/comment lines and bracket continuations.if_rest -> cond_suite else_opt broke plain CYK; fixed with epsilon-aware unary closure.ERROR wrapper.Ran 17 tests in 0.158s
OK
Including a fuzz test of 120 random byte patches (insertions/deletions/replacements) across three sources, each matching a fresh full reparse structurally. Demo shows the affected interval is exactly the edited bytes (38, 47) with 237 cells reused, 169 recomputed, and all 54 unaffected first-statement node identities preserved. The code is Python 3.11-compatible (uses only __future__, dataclasses, typing).
# Evidence - Problem class: 20261005-incremental-grammar-repair - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-05T10:12:25.173Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Build a Python incremental parser for a programming language with ambiguous expression precedence, nested generics, and indentation-sensitive blocks, where edits arrive as byte-range patches and may invalidate distant parse decisions. Maintain a packed parse forest with stable node identities, report the smallest affected source interval, and recover deterministically from malformed input without reparsing unaffected regions.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "20261005-incremental-grammar-repair", "provider": "openrouter", "solved_at": "2026-10-05T10:12:25.173Z", "version": "3.11"}