Lexer Context
A lexing context, created by a Lexer.parse call, which exposes an interface for advanced lexing.
Author
AdrianTodt
Parameters
T
The type of tokens the lexer generates.
Functions
next String
Link copied to clipboard
Returns a predefined length of characters of the reader, as a String.
peek String
Link copied to clipboard
Peeks a string with a predefined length of the reader.
process
Link copied to clipboard
Calls the Lexer.parse's token consumer.
Properties
Extensions
process Token
Link copied to clipboard
fun <T> LexerContext<in Token<T>>.processToken(type: T, back: Int = 1, length: Int = back, offset: Int = 0)
Content copied to clipboard
Emits a token to the lexer, based off the current state of the LexerContext.
fun <T> LexerContext<in StringToken<T>>.processToken(type: T, value: String, back: Int = value.length, length: Int = back, offset: Int = 0)
Content copied to clipboard
Emits a token with a value, based off the current state of the LexerContext.
read Identifier
Link copied to clipboard
Reads a C-like identifier.
read Number
Link copied to clipboard
Reads a number.
read String
Link copied to clipboard
Reads a String up until a delimiter.
section
Link copied to clipboard
Creates a section, based off the current state of the LexerContext.
token
Link copied to clipboard
Creates a token, based off the current state of the LexerContext.
fun <T> LexerContext<in StringToken<T>>.token(type: T, value: String, back: Int = value.length, length: Int = back, offset: Int = 0): StringToken<T>
Content copied to clipboard
Creates a token with a value, based off the current state of the LexerContext.