Scanner
Constructors
Properties
Functions
Link copied to clipboard
Consumes the current token and returns its text content.
fun consume(type: T, errorMessage: (Token<T>) -> String = { "Token type $type expected." }): Token<T>
Consumes a token with the given type and returns it. If the current token has a different type, an exception is thrown.
fun consume(text: String, ignoreCase: Boolean = false, errorMessage: (Token<T>) -> String = {"Expected: '$text'"}): Token<T>
Consume and return a token with the given text value. If the current token type does not match, an exception is thrown.
Link copied to clipboard
Wraps the given exception in a parsing exception if it's not a parsing exception already. Parsing exceptions are returned unchanged. Useful to associate other exceptions encountered during parsing with a token (including the corresponding input position).
Link copied to clipboard
Creates an illegal state exception with position context information.
Link copied to clipboard
Link copied to clipboard
If the current token text value matches the given string, it is consumed and true is returned. Otherwise, false is returned.