Package dev.omnist.schema
Class OsdLexer
java.lang.Object
dev.omnist.schema.OsdLexer
Tokenizer for OSD (Omnist Schema Definition) grammar (omnist-spec §5.3).
Recognizes four lexical rules in priority order:
- STRING — a double-quoted field name (
"label") - CARDINALITY — a bracket-enclosed cardinality expression (
[m,n]) - Punctuation —
{ } : , ? - IDENT / Keywords —
record,root, or any other identifier
#-comments are silently skipped between tokens.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn individual token produced byOsdLexer.static enumToken types produced by the OSD lexer (omnist-spec §5.3). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionScans and returns the next token, advancing the lexer position.Tokenizes the entire source, returning a list ending with a singleOsdLexer.TokenType.EOFtoken.
-
Constructor Details
-
OsdLexer
Constructs a lexer for the given OSD source text.- Parameters:
source- the OSD text to tokenize;nullis treated as an empty string
-
-
Method Details
-
tokenizeAll
Tokenizes the entire source, returning a list ending with a singleOsdLexer.TokenType.EOFtoken.- Returns:
- the complete token list, never empty (always contains at least EOF)
- Throws:
OsdParseException- if any lexical error is encountered
-
nextToken
Scans and returns the next token, advancing the lexer position. Whitespace, newlines, and#-to-end-of-line comments are skipped first.- Returns:
- the next
OsdLexer.Token;OsdLexer.TokenType.EOFat end of input - Throws:
OsdParseException- if no rule matches the current character
-