PredicateMatcher

class PredicateMatcher<K : Token>(val type: KClass<K>, val predicate: (K) -> Boolean) : TokenElement.TokenMatcher

A matcher that matches tokens by type and a custom predicate.

The token must be of type K (like TypeMatcher), and satisfy the predicate to be matched. The predicate's result is returned.

Parameters

K

The token type to match

Constructors

Link copied to clipboard
constructor(type: KClass<K>, predicate: (K) -> Boolean)

Properties

Link copied to clipboard
val predicate: (K) -> Boolean

A function that tests whether the token should be matched

Link copied to clipboard
val type: KClass<K>

The class of the token type to match

Functions

Link copied to clipboard
open override fun matches(token: Token): Boolean

Tests whether the given token satisfies this matcher's criterion.