Repository navigation
refactor(parser): delete the hand-modeled bison recovery the error oracle replaced - #3063
Merged
Merged
Conversation
robcohen
force-pushed
the
feat/lalr-oracle-on
branch
from
November 27, 2026 11:35
a2acccc to
02039dd
Compare
The hand-modeled copy of bison's recovery (quiet_bison_recovery, its phantom re-parses and accepts()) no longer runs; the oracle's trace of beancount's own parse decides which lines its recovery keeps quiet: - a line beancount discards whole (it reads no token there) keeps none of rledger's errors, builder checks included; so does a tokenless tail read while recovering; - entries beancount's recovery starts mid-line carry its verdict on their lines, built or dropped, with the builder errors of the built ones (parsed once on their own) and the pipe warnings of the dropped ones; - rledger's own errors on a line beancount reports (a stray \r) count against that line's slots first; - a number beancount's lexer rejects is synthesized as InvalidNumber, and synthesized messages quote tokens as rledger's own do. Parity: 122,378 of 123,394 inputs match beancount 3.2.3 where 120,099 did, none lost; BOM matrix unchanged at 13,349 rows. The linear-time test of the deleted pass is ported to the oracle path. WASM cache v149. Co-Authored-By: Claude Opus 5.5 <[email protected]>
model_stray_cr_lines parsed the input a second time with each stray \r read as a blank, and was the last user of BcLexer, the recovery model's port of beancount's lexer. The error oracle already reads beancount's own tokens, a stray \r among them as a blank, and a comment already runs through a stray \r as beancount's does (#3060), so the second parse hid nothing more: the rest of cst/recovery.rs goes. Parity unchanged: 122,378 of 123,394 inputs match beancount 3.2.3, none lost; BOM matrix and corpus baselines unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The windows convert.rs kept quiet after a line a BOM starts, or a column-0 dated line that opens no directive, are beancount's recovery windows, which the error oracle now replays from its own grammar. Removing the pass changes no error count on any parity input (122,376 of 123,394 still match, none lost); the BOM matrix and corpus baselines are unchanged. Its linear-time counter test goes with it, its shapes ported to the oracle's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
feat/lalr-delete-recovery
branch
from
November 27, 2026 12:25
a28c9b4 to
cb6ff42
Compare
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on main (#3061 and #3062 merged).
What
Phase 5: delete the hand-modeled bison recovery, one piece per commit, now that the error oracle (#3061, on by default in #3062) decides which lines beancount reports. Every commit passes these gates:
scripts/compat-parse-error-parity.py --check(each commit re-pinned with--updateon its own, on top of main);STRICT_BASELINEcorpus tests;1.
refactor(parser): retire quiet_bison_recovery for the error oracleThis removes
quiet_bison_recovery, the phantom re-parses (phantom_errors,MAX_PHANTOM_DEPTH),accepts(), and their helpers. The reconciler takes over what they did, from the oracle's trace of beancount's own parse:\r) count against that line's slots before anything else, and are capped at the slot count. The stray-\roverlay now claims those errors, not whole lines, and nothing on a swallowed line. Arithmetic errors aren't claimed inside recovery.docs/reference/compatibility.mdP3 is updated to match.InvalidNumber. Synthesized messages quote the token with"as rledger's own do. They are placed on the line their slot is reported on (multi-line strings), and show only the token's first line.test_quiet_bison_recovery_scans_linear_bytes) is ported to the oracle path astest_parse_with_the_oracle_is_linear_on_recovery_shapes. It uses the same shapes and adds the new ones (pipes in dropped entries, rebuilt entries with builder errors).format_roundtrip_properties::test_format_source_keeps_a_leading_indented_comment_indented(fix(format): never change what a file means; round-trip properties for the formatter #3060) expected\t;then\t+to parse clean: it did only because this pass emptied the errors before the oracle ran. It now gets one error, as main already does for; cthen!(a parse rledger finds an error in never comes out clean). The formatting and round-trip it pins are unchanged.2.
refactor(parser): delete cst/recovery.rsmodel_stray_cr_linesre-parsed the input with each stray\ras a blank. It was the last user ofBcLexer, the tainted port of beancount's lexer. The real lexer difference it hid, a comment ending at a stray\r, is already fixed on main by #3060. This PR first carried its own regex fix for it; that is dropped in favour of #3060's, so there is one implementation. The whole file is deleted: 2,640 lines, includingBcLexer.3.
refactor(parser): delete quiet_after_failed_line_startsThis pass kept convert.rs's windows quiet after a line a BOM starts, or a dated line that opens no directive. Removing it changes no error count on any parity input. Its counter-based linear test measured only that pass, so it goes too; its shapes are added to the oracle's parse-level linear test.
Measurements
quiet_bison_recoverygonerecovery.rsgonequiet_after_failed_line_startsgoneThe BOM combination matrix stays at 13,349 matching rows throughout. The
STRICT_BASELINEcorpus tests pass at every step.What remains
Each of these was tried and kept, with the reason measured:
quiet_after_invalid_tokens(convert.rs). Parity doesn't move without it. But the BOM matrix loses 7 rows: on a line whose BOM-led accounts beancount reads as valid tokens (beancount reports nothing there), rledger would report each mid-file BOM instead of one per line. That one-per-line rule is a deliberate difference the oracle doesn't express yet, so it needs an overlay first.drop_errors_inside_a_line_error. Parity is unchanged, but 8 tests break. That includestransaction_holds_invalid_token, the validator's predicate for transactions beancount discards, which reads the error kinds this pass leaves. The dropped-statement work below replaces that predicate with the oracle trace's "dropped" bit, after which this pass can go.report_at_multi_line_string_ends. Parity is unchanged, but 4 tests break. It places rledger's own error on a multi-line string's last line for every surface (LSP, check). The reconciler only places the errors it synthesizes there, so deleting this pass needs the reconciler to move an assigned error's start the same way.BcLexer-dependent logos patches.BcLexeritself is gone. The logos lexer's own patches (lone-capital runs, BOM runs, the comment splits of perf(parser): a long run of mid-line #! or #+ with no blank lexes in quadratic time #2989) are what rledger's CST is built from, so they're not part of the error model. The one that hid a real difference, comments ending at a stray\r, is fixed on main (fix(format): never change what a file means; round-trip properties for the formatter #3060).transaction_holds_invalid_token(and a balance-directive equivalent) with the oracle's raw trace: is the directive's own statement dropped? Then the validator skips the residual (casc2,1,23), the inventory update (casc3,$mid-posting, so the later balance doesn't fail) and the balance check (casc4, tolerance after the currency), with regression tests.🤖 Generated with Claude Code