TokenRegexPattern

data class TokenRegexPattern(val name: String, val wrap: (TokenData) -> Token, val regex: String, val groupNames: List<String> = emptyList(), val walker: (TokenData, CharSequence) -> WalkedToken?? = null) : NamedRegexPattern

A Regex pattern that captures a corresponding Node from a raw string.

Parameters

name

name of this pattern. A name should not contain special characters (including underscores) in order to prevent Regex compilation errors

wrap

a function that wraps a general token into its specific wrapper

regex

regex pattern to match

groupNames

names of the named groups that appear the regex pattern

walker

if present, upon being captured, receives the TokenData from the regex match and the remaining source after the match, then produces a WalkedToken containing a fully typed token and the number of additional characters consumed, or null to reject the match (e.g., when a block function call determines it is actually inline-level content). Used when regex alone cannot capture complex tokens (e.g., balanced delimiters in function call arguments)

Constructors

Link copied to clipboard
constructor(name: String, wrap: (TokenData) -> Token, regex: String, groupNames: List<String> = emptyList(), walker: (TokenData, CharSequence) -> WalkedToken?? = null)

Properties

Link copied to clipboard
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val regex: String
Link copied to clipboard
Link copied to clipboard
val wrap: (TokenData) -> Token