CharSequencePredicate

open class CharSequencePredicate(name: String? = null, val predicate: (CharSequence) -> Int) : AbstractLexeme<Token.Generic>

A Lexeme that matches any character sequence satisfying predicate.

The predicate is evaluated on a substring of the input starting at the current position. The predicate should return a positive number indicating the number of characters matched, or 0 (or a negative value) to indicate no match.

Generally, as the CharSequence passed to the predicate is a substring of the input starting at the current position and extending to the end of the input, you may want to use kotlin.CharSequence.startsWith to test against specific conditions at the current context position when building your predicate.

Constructors

Link copied to clipboard
constructor(name: String? = null, predicate: (CharSequence) -> Int)

Properties

Link copied to clipboard
open override val defaultFactory: (CharSequence) -> Token.Generic

A default Token factory that creates new instances of T for matches of this Lexeme, given the CharSequence which captures the Token (equal to Token.value).

Link copied to clipboard
open override val name: String?

An optional name for this Lexeme

Link copied to clipboard

A function that returns the number of characters from input to match

Functions

Link copied to clipboard
override fun match(): LexemeMatch<Token.Generic>?
Link copied to clipboard
open override fun toString(): String