put pause_parse/unpause_parse in RAII - #7749
Open
Goober5000 wants to merge 1 commit into
Open
Conversation
Replace pause_parse()/unpause_parse() with a PauseParseGuard class that bookmarks the parse state, points the parser at the supplied text and filename, and restores the bookmarked state on destruction or an explicit early unpause(). Lookahead sites construct the guard with the current parse position and rewind on unpause. Unlike pause_parse(), the guard also bookmarks Parse_text, so get_line_num() now walks the correct buffer during nested parses. Consequently, allocate_parse_text() now asserts that parsing is not paused, since clearing or reallocating the shared buffers mid-pause has always silently corrupted the paused parse. Also remove the unused text parameter from reset_parse(), which recreated the Parse_text/Mp mismatch with no bookmark to restore from. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Goober5000
force-pushed
the
refactor/raii_pause_parse
branch
from
August 27, 2026 22:32
32ade80 to
3916acb
Compare
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.
Replace pause_parse()/unpause_parse() with a PauseParseGuard class that bookmarks the parse state, points the parser at the supplied text and filename, and restores the bookmarked state on destruction or an explicit early unpause(). Lookahead sites construct the guard with the current parse position and rewind on unpause.
Unlike pause_parse(), the guard also bookmarks Parse_text, so get_line_num() now walks the correct buffer during nested parses. Consequently, allocate_parse_text() now asserts that parsing is not paused, since clearing or reallocating the shared buffers mid-pause has always silently corrupted the paused parse.
Also remove the unused text parameter from reset_parse(), which recreated the Parse_text/Mp mismatch with no bookmark to restore from.