pub enum Ast {
Show 19 variants
Empty,
Literal {
text: String,
fuzziness: Fuzziness,
},
Char(char),
CharClass(CharClass),
Concat(Vec<Ast>),
Alternation(Vec<Ast>),
Quantified {
expr: Box<Ast>,
quantifier: Quantifier,
greedy: bool,
},
Group {
index: usize,
name: Option<String>,
expr: Box<Ast>,
},
NonCapturingGroup {
expr: Box<Ast>,
fuzziness: Fuzziness,
},
Anchor(Anchor),
Lookahead {
positive: bool,
expr: Box<Ast>,
},
Lookbehind {
positive: bool,
expr: Box<Ast>,
},
Backreference {
group: usize,
fuzziness: Fuzziness,
},
NamedList {
name: String,
},
ResetMatchStart,
AtomicGroup {
expr: Box<Ast>,
},
RecursivePattern,
RecursiveGroup {
group: usize,
},
RecursiveNamedGroup {
name: String,
},
}Expand description
AST node representing a parsed regex pattern.
Variants§
Empty
Empty pattern.
Literal
Literal string with optional fuzziness: hello, hello~2.
Fields
Char(char)
Single character (from escape or plain char outside literals).
CharClass(CharClass)
Character class: [a-z], [^abc], \d, \w, \s, .
Concat(Vec<Ast>)
Concatenation of patterns.
Alternation(Vec<Ast>)
Alternation: a|b|c.
Quantified
Quantified expression: a*, a+, a?, a{n,m}.
Fields
quantifier: QuantifierThe quantifier specifying repetition bounds.
Group
Capture group: (expr).
Fields
NonCapturingGroup
Non-capturing group: (?:expr).
Fields
Anchor(Anchor)
Anchor: ^, $.
Lookahead
Lookahead: (?=...), (?!...).
Fields
Lookbehind
Lookbehind: (?<=...), (?<!...).
Fields
Backreference
Backreference: \1, \2, optionally with fuzziness \1{e<=1}.
Fields
NamedList
Named list reference: \L<name>.
ResetMatchStart
Reset match start: \K
Resets the starting point of the match. Everything before \K is matched
but not included in the final match result.
AtomicGroup
Atomic group: (?>...)
Once the group matches, backtracking is disabled within the group.
RecursivePattern
Recursive entire pattern: (?R)
Recursively matches the entire pattern.
RecursiveGroup
Recursive numbered group: (?1), (?2), etc.
Recursively matches a specific capture group.
RecursiveNamedGroup
Recursive named group: (?&name) or (?P>name)
Recursively matches a named capture group.
Implementations§
Source§impl Ast
impl Ast
Sourcepub fn literal(text: impl Into<String>) -> Self
pub fn literal(text: impl Into<String>) -> Self
Create a literal AST node with inherited fuzziness.
Sourcepub fn literal_fuzzy(text: impl Into<String>, fuzziness: Fuzziness) -> Self
pub fn literal_fuzzy(text: impl Into<String>, fuzziness: Fuzziness) -> Self
Create a literal AST node with specific fuzziness.
Sourcepub fn quantified(expr: Ast, quantifier: Quantifier, greedy: bool) -> Self
pub fn quantified(expr: Ast, quantifier: Quantifier, greedy: bool) -> Self
Create a quantified AST node.