RegexLexer

abstract class RegexLexer(val source: CharSequence, patterns: List<TokenRegexPattern>) : AbstractLexer

A Lexer that identifies tokens by matching Regex patterns.

Tokenization uses an iterative find loop: each iteration calls Regex.find starting from currentIndex, so that walker-driven position advances are respected without restarting the entire regex search.

Parameters

source

the content to be tokenized

patterns

the patterns to search for, in descending order of priority

Inheritors

Constructors

Link copied to clipboard
constructor(source: CharSequence, patterns: List<TokenRegexPattern>)

Properties

Link copied to clipboard
open override var currentIndex: Int

Index of the latest scanned character within source.

Link copied to clipboard
open override val source: CharSequence

Functions

Link copied to clipboard
abstract fun createFillToken(position: IntRange): Token?
Link copied to clipboard
open override fun tokenize(): Sequence<Token>

Disassembles some raw string into smaller tokens.