Regex Parser¶
| Spice | |
|---|---|
RegexParser struct¶
Recursive-descent parser for regex patterns.
Use parseRegexPattern for one-shot parsing; the struct is exposed so "std/text/regex/regex" can also read groupCount after a successful parse, to size the capture-slot array of the compiled program.
Supported syntax: literals, ., character classes ([abc], [^abc], [a-z]), the shorthand classes \d \D \w \W \s \S (only \d \w \s inside a [...] class), anchors ^ $, the quantifiers * + ? {n} {n,} {n,m} (greedy only), alternation |, and groups (...) / (?:...). Lazy quantifiers, backreferences, lookaround and multiline mode are not supported.
The AST data model lives in "std/text/regex/regex-ast" and compilation to a runnable program in "std/text/regex/regex-compiler".
Fields¶
| Name | Type | Description |
|---|---|---|
groupCount |
long |
Constructors¶
ctor¶
| Spice | |
|---|---|
Construct a regex parser over the given pattern
Parameters
| Name | Type | Description |
|---|---|---|
pattern |
const String& |
Regex pattern to parse |
Methods¶
parse¶
| Spice | |
|---|---|
Parse the pattern into a regex AST
Returns: Result<RegexNode*> — Result holding the root AST node, or an error describing the first problem encountered
Functions¶
parseRegexPattern¶
| Spice | |
|---|---|
Parse a regex pattern.
On success returns the root AST node, which the caller owns and releases with deleteRegexNode from "std/text/regex/regex-ast" (compiling it via "std/text/regex/regex-compiler" also consumes and releases it). On failure an error describing the first problem encountered is returned.
Parameters
| Name | Type | Description |
|---|---|---|
pattern |
const String& |
Returns: Result<RegexNode*>
charToDigit¶
| Spice | |
|---|---|
Parameters
| Name | Type | Description |
|---|---|---|
c |
char |
Returns: long