processToken

fun <T> LexerContext<Token<T>>.processToken(type: T, back: Int = 1, length: Int = back, offset: Int = 0)

Emits a token to the lexer, based off the current state of the LexerContext.

When called with default values, the returned token matches the last character consumed.

Parameters

type

The type of the token to be created.

back

The amount of characters to offset back from the lexer's current index.

length

The amount of characters this section is composed off.

offset

This value added to back and length as an offset.

fun <T> LexerContext<Token<T>>.processToken(type: T, value: String, back: Int = value.length, length: Int = back, offset: Int = 0)

Emits a token with a value, based off the current state of the LexerContext.

When called with default values, the returned token matches the last N character consumers, where N is value's length.

Parameters

type

The type of the token to be created.

value

The value of the token to be created.

back

The amount of characters to offset back from the lexer's current index.

length

The amount of characters this section is composed off.

offset

This value added to back and length as an offset.