Add more tests of lexer's skipToLeadingKeyword behavior#1971
Merged
Conversation
ISSOtm
approved these changes
May 9, 2026
Member
ISSOtm
left a comment
There was a problem hiding this comment.
Behaviour looks fine, thanks :)
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.
These three tests are related to how "skipping" and "capturing" work. ("Skipping" occurs when an untaken
if/elif/elseneeds to skip to the nextelif/else/endc, or when abreakinside arept/forskips to itsendr. "Capturing" occurs when arept/foror amacrobody stores its contents up to itsendr/endm.)Skipping and capturing both use the
skipToLeadingKeywordfunction to skip lines until finding one that starts with an appropriate "ending" keyword (endc/endr/endm/etc). Expansions are disabled during this process, so you can't do e.g.def s equs "endr"and then{s}to end a loop."Blue-painting", however, does occur while skipping and capturing (naturally -- it's a low-level behavior of
peek()andskipChar(), which are used byskipToLeadingKeywordjust like everywhere else in the lexer that advances through the assembly code). So to detect the ending keyword, the character after the ending keyword has already beenpeeked and thus painted blue -- and this happens while expansions are disabled, so even if that character is a{brace it won't start an interpolation, nor will\start a macro argument.Currently the Rust rewrite does not blue-paint during its equivalent of skipping/capturing, so it handles these tests differently (see https://codeberg.org/ISSOtm/rsgbds/issues/53). This is considered a bug, but we may want to further change/refine its behavior in ways inconsistent with how C++ RGBASM currently behaves.
These tests are also intended to allow more confidently optimizing
skipToLeadingKeyword, since it's a fairly significant part of the overall runtime on real-world projects (see #1968).