token

inline fun <T : Token> token(): RuleBuilder<N>

Adds a TokenElement that matches tokens of type T.

Return

this RuleBuilder for chaining

Parameters

T

The token type to match


fun token(lexeme: Lexeme<*>): RuleBuilder<N>

Adds a TokenElement that matches tokens produced by the specified lexeme.

Return

this RuleBuilder for chaining

Parameters

lexeme

The Lexeme whose tokens should be matched


inline fun <T : Token> token(noinline predicate: (T) -> Boolean): RuleBuilder<N>

Adds a TokenElement that matches tokens of type T satisfying the given predicate.

Return

this RuleBuilder for chaining

Parameters

T

The token type to match

predicate

A function that tests whether a token should be matched