Module regex/node
regex/node
Regex AST node types.
The parser produces a tree of RegexNode objects representing the
structure of a regex pattern. Nodes are reference-counted objects
since they form a recursive tree.
Types
RegexNode
object
RegexNode
Fields
| Name | Type | Description |
|---|---|---|
kind | NodeKind | |
children | ArrayList(object(kind: NodeKind)) | |
codepoint | u32 | |
ranges | ArrayList(CharRange) | |
negated | bool | |
q_min | usize | |
q_max | usize | |
q_greedy | bool | |
group_index | usize | |
anchor | AnchorKind |
impl(RegexNode, ...)
literal : (RegexNode) fn(cp : u32) -> RegexNodedot : (RegexNode) fn() -> RegexNodeReturns: RegexNode
char_class : (RegexNode) fn(ranges : ArrayList(CharRange), negated : bool) -> RegexNodeanchor_node : (RegexNode) fn(kind : AnchorKind) -> RegexNodesequence : (RegexNode) fn(nodes : ArrayList(object(kind: NodeKind))) -> RegexNodealternation : (RegexNode) fn(left : RegexNode, right : RegexNode) -> RegexNodequantifier : (RegexNode) fn(child : RegexNode, min_val : usize, max_val : usize, greedy : bool) -> RegexNodegroup : (RegexNode) fn(child : RegexNode, index : usize) -> RegexNodenon_capturing_group : (RegexNode) fn(child : RegexNode) -> RegexNodebackreference : (RegexNode) fn(group_idx : usize) -> RegexNodelookahead : (RegexNode) fn(child : RegexNode, positive : bool) -> RegexNode
NodeKind
enum
NodeKind
Variants
| Variant | Fields | Description |
|---|---|---|
Literal | ||
Dot | ||
CharClass | ||
Anchor | ||
Sequence | ||
Alternation | ||
Quantifier | ||
Group | ||
NonCapturingGroup | ||
Backreference | ||
Lookahead | ||
Lookbehind |
CharRange
struct
CharRange
A range of characters for character classes, e.g. a–z.
Fields
| Name | Type | Description |
|---|---|---|
low | u32 | |
high | u32 |
AnchorKind
enum
AnchorKind
Variants
| Variant | Fields | Description |
|---|---|---|
Start | ||
End | ||
WordBoundary | ||
NonWordBoundary |
GroupNameEntry
struct