Package dev.omnist.oml
Class OmlLexer
java.lang.Object
dev.omnist.oml.OmlLexer
Normative OML Tokenizer (omnist-spec §4.2).
Scans with maximal munch under a fixed 9-rule priority order:
1. STRING family (dquote or raw/multiline)
2. Punctuation: { } [ ] : ,
3. DATETIME
4. DATE (with T+TIME lookahead rule)
5. TIME
6. NUMBER
7. Reserved float spellings nan, inf, -inf (emitted as NUMBER)
8. INTEGER (maxIntegerDigits limit enforced here)
9. IDENT
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn individual token produced byOmlLexer.static enumToken types produced by the OML lexer (omnist-spec §4.2). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionScans and returns the next token from the source, advancing the lexer position.Tokenizes the entire source, returning a list ending with a singleOmlLexer.TokenType.EOFtoken.
-
Constructor Details
-
OmlLexer
Constructs a lexer for the given OML source text.- Parameters:
source- the OML text to tokenize;nullis treated as an empty stringlimits- safety limits applied during tokenization (e.g.Limits.maxIntegerDigits());nulldefaults toLimits.DEFAULT
-
-
Method Details
-
tokenizeAll
Tokenizes the entire source, returning a list ending with a singleOmlLexer.TokenType.EOFtoken. CallsnextToken()repeatedly until EOF is reached.- Returns:
- an unmodifiable snapshot of all tokens, never empty (always contains at least EOF)
- Throws:
OmlParseException- if any lexical error is encountered
-
nextToken
Scans and returns the next token from the source, advancing the lexer position. Applies the 9-rule priority order described in the class Javadoc (omnist-spec §4.2). Horizontal whitespace and#-comments are silently skipped before each token.- Returns:
- the next
OmlLexer.Token; returnsOmlLexer.TokenType.EOFat end of input - Throws:
OmlParseException- if the character sequence does not match any rule, or if an integer literal exceedsLimits.maxIntegerDigits(), or if a string literal is malformed or unterminated
-