Package nz.org.riskscape.dsl
Class Lexer<T extends TokenType>
java.lang.Object
nz.org.riskscape.dsl.Lexer<T>
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Lexer.Tokens<T extends TokenType>
Meta-class object for token type enumeration. -
Constructor Summary
-
Method Summary
-
Constructor Details
-
Lexer
-
-
Method Details
-
next
- Returns:
- the next
Token
orLexer.Tokens.eofToken
if parsing as reached the end. - Throws:
LexerException
-
remaining
- Returns:
- the remaining source String that still needs to be parsed. This can be useful for error reporting, i.e. show the user the unadulterated string that we were trying to parse next. Note that you may want to truncate this string in error messages, when parsing a large file.
-
peek
- Returns:
- the
Token
that will be returned from theLexer
when you callnext()
, without consuming it. - Throws:
LexerException
-
isEOF
- Returns:
- true if the
Lexer
is at the end of the source - Throws:
LexerException
-
peekType
- Returns:
- shortcut for peek().getTokenType()
-
rewind
- Parameters:
backTo
-
-
expect
-
expect
-
tryThese
-
consumeIf
-
consumeIf
-