Skip to content

fix(lexer): Make sure character string type is terminated - #216

Open
Rawk wants to merge 1 commit into
librasn:mainfrom
Rawk:ws-after-string-type
Open

fix(lexer): Make sure character string type is terminated#216
Rawk wants to merge 1 commit into
librasn:mainfrom
Rawk:ws-after-string-type

Conversation

@Rawk

@Rawk Rawk commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Fix so that for example "GraphicString64" is not parsed as a CharacterStringType::GraphicString. Fixed for all string types.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant