lexeme

fun <T : Token> lexeme(lexeme: Lexeme<T>): Lexeme<T>

Registers a lexeme definition with this Grammar Builder.

Lexemes are matched in the order they are registered. The registered lexeme is returned to allow capturing it for later reference in rule definitions.

Return

lexeme

Parameters

T

The token type produced by this Lexeme

lexeme

The Lexeme to register


fun <T : Token> lexeme(lexeme: Lexeme<T>, factoryOverride: (value: CharSequence) -> T): Lexeme<T>

Registers a lexeme definition with this Grammar Builder and assigns a factoryOverride for it.

Lexemes are matched in the order they are registered. The registered lexeme is returned to allow capturing it for later reference in rule definitions.

Return

lexeme

Parameters

T

The token type produced by this Lexeme

lexeme

The Lexeme to register

factoryOverride

A factory override definition assigned to the lexeme