StateBuilder

This classed is used to build a lexer state (LexerState) using a DSL, and is used inside a lambda-with receiver. It also defines high level functions for constructing matchers, such as anyOf or matches, and using custom matchers with the + operator.

States themselves are only constructed when calling build, since LexerState objects are immutable and the goal of the DSL is to provide a way to configure them.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Default

Special object for using the default class in the Niwen Lexer DSL

Properties

Link copied to clipboard

State label for the default state.

Link copied to clipboard

Anything that matches the given recognizer (or pseudo-recognizer) exactly will be ignored when encountered. This would be equivalent to a isToken that does not actually create any token.

Functions

Link copied to clipboard
open override fun build(): LexerState
Link copied to clipboard

Add a matcher to this state that matches the recognizer (or pseudo-recognizer) on the left to the token type on the right.

Link copied to clipboard

Create a recognizer that recognizes the given regular expression. Use this before isToken to create a matcher that matches against a regular expression.

Link copied to clipboard
operator fun TokenMatcher.unaryPlus()

Add an already defined matcher to this state