fix(lexer): Make sure character string type is terminated - #216
Open
Rawk wants to merge 1 commit into
Open
Conversation
Fix so that for example `GraphicString64` is not parsed as a `CharacterStringType::GraphicString`. Fixed for all string types.
HauserV
added a commit
to HauserV/rasn-compiler
that referenced
this pull request
Aug 6, 2026
TIME, NULL, REAL, BOOLEAN, INTEGER and ANY are the six builtin type
productions whose lexer shape is preceded(tag("KEYWORD"), opt(...)) --
no structure is mandatory after the keyword. tag() alone is satisfied
by a bare keyword prefix, so a standard X.680 type reference that
merely starts with one of these keywords (TIMESTAMP, NULLABLE,
INTEGERVALUE, REALITY, BOOLEANFLAG, ANYTHING) is mis-lexed as the
keyword plus leftover garbage and fails to parse when it occurs in a
type position (e.g. as a SEQUENCE member's type).
SET/SEQUENCE/CHOICE/BIT/OCTET/ENUMERATED/OBJECT are unaffected: their
productions require mandatory trailing structure (e.g. in_braces(...)
right after the keyword), so a mismatched continuation like SETTINGS
already fails that structure and backtracks cleanly to try a
defined-type reference instead.
Guard each of the six with terminated(tag(KEYWORD),
not(alt((tag("-"), alphanumeric1)))), mirroring the word-boundary
idiom from upstream PR librasn#216 (open), which fixed the
same bug class for character-string keywords. Matches open upstream
issue librasn#230.
Adds rasn-compiler-tests/tests/builtin_keyword_word_boundary.rs
covering: each hazardous prefix as a top-level type name and as a
member type (both all-caps, which is the actual repro, and PascalCase
for broader coverage); the bare builtins still parsing; and a
regression check that the mandatory-structure keywords are untouched.
UNSIGNED pending re-sign.
HauserV
added a commit
to HauserV/rasn-compiler
that referenced
this pull request
Aug 6, 2026
TIME, NULL, REAL, BOOLEAN, INTEGER and ANY are the six builtin type
productions whose lexer shape is preceded(tag("KEYWORD"), opt(...)) --
no structure is mandatory after the keyword. tag() alone is satisfied
by a bare keyword prefix, so a standard X.680 type reference that
merely starts with one of these keywords (TIMESTAMP, NULLABLE,
INTEGERVALUE, REALITY, BOOLEANFLAG, ANYTHING) is mis-lexed as the
keyword plus leftover garbage and fails to parse when it occurs in a
type position (e.g. as a SEQUENCE member's type).
SET/SEQUENCE/CHOICE/BIT/OCTET/ENUMERATED/OBJECT are unaffected: their
productions require mandatory trailing structure (e.g. in_braces(...)
right after the keyword), so a mismatched continuation like SETTINGS
already fails that structure and backtracks cleanly to try a
defined-type reference instead.
Guard each of the six with terminated(tag(KEYWORD),
not(alt((tag("-"), alphanumeric1)))), mirroring the word-boundary
idiom from upstream PR librasn#216 (open), which fixed the
same bug class for character-string keywords. Matches open upstream
issue librasn#230.
Adds rasn-compiler-tests/tests/builtin_keyword_word_boundary.rs
covering: each hazardous prefix as a top-level type name and as a
member type (both all-caps, which is the actual repro, and PascalCase
for broader coverage); the bare builtins still parsing; and a
regression check that the mandatory-structure keywords are untouched.
UNSIGNED pending re-sign.
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.
Fix so that for example
"GraphicString64"is not parsed as aCharacterStringType::GraphicString. Fixed for all string types.