Regex Program¶
| Spice | |
|---|---|
Instr struct¶
A single instruction of a compiled regex program. Which fields are meaningful depends on kind:
ch for CHAR, classIndex for CLASS, x for JMP, x/y for SPLIT, saveSlot for SAVE. The
remaining kinds (ANY, ANCHOR_START, ANCHOR_END, MATCH) carry no extra payload.
Fields are public, like "std/runtime/error_rt"'s Error - plain internal data shared by the compiler/matcher files of this module, not an encapsulated type.
Fields¶
| Name | Type | Description |
|---|---|---|
kind |
InstrKind |
|
ch |
char |
|
classIndex |
long |
|
x |
long |
|
y |
long |
|
saveSlot |
long |
Constructors¶
ctor¶
| Spice | |
|---|---|
Parameters
| Name | Type | Description |
|---|---|---|
kind |
InstrKind |
CharClass struct¶
A character class: a set of inclusive ranges, optionally negated. Used to implement [...], [^...] and the expansions of \d \D \w \W \s \S.
Fields¶
| Name | Type | Description |
|---|---|---|
ranges |
Vector<Pair<char, char>> |
|
negated |
bool |
Methods¶
matches¶
| Spice | |
|---|---|
Check whether the given character is a member of this class, accounting for negation.
Parameters
| Name | Type | Description |
|---|---|---|
c |
char |
Character to test |
Returns: bool — Whether c is matched by this class
RegexProgram struct¶
A compiled regex program: a flat list of instructions (Thompson-construction bytecode, executed by the Pike's-VM matcher in "std/text/regex/regex-matcher") plus the character classes it references and the number of capturing groups it declares (excluding group 0, the whole match).
Fields¶
| Name | Type | Description |
|---|---|---|
instrs |
Vector<Instr> |
|
classes |
Vector<CharClass> |
|
groupCount |
long |
InstrKind enum¶
Tag for what a single compiled instruction does.
| Item | Value | Description |
|---|---|---|
CHAR |