pub enum Expr {
Empty,
Literal {
chars: Vec<char>,
casei: bool,
},
AnyChar,
AnyCharNoNL,
Class(CharClass),
StartLine,
EndLine,
StartText,
EndText,
WordBoundary,
NotWordBoundary,
Group {
e: Box<Expr>,
i: Option<usize>,
name: Option<String>,
},
Repeat {
e: Box<Expr>,
r: Repeater,
greedy: bool,
},
Concat(Vec<Expr>),
Alternate(Vec<Expr>),
}
A regular expression abstract syntax tree.
An Expr
represents the abstract syntax of a regular expression.
Variants
Empty | An empty regex (which never matches any text).
|
Literal | A sequence of one or more literal characters to be matched.
Fields
chars | | casei | Whether to match case insensitively.
|
|
AnyChar | Match any character, excluding new line.
|
AnyCharNoNL | |
Class | |
StartLine | Match the start of a line or beginning of input.
|
EndLine | Match the end of a line or end of input.
|
StartText | Match the beginning of input.
|
EndText | |
WordBoundary | Match a word boundary (word character on one side and a non-word
character on the other).
|
NotWordBoundary | Match a position that is not a word boundary (word or non-word
characters on both sides).
|
Group | A group, possibly non-capturing.
Fields
e | The expression inside the group.
| i | The capture index (starting at 1 ) only for capturing groups.
| name | The capture name, only for capturing named groups.
|
|
Repeat | A repeat operator (? , * , + or {m,n} ).
Fields
e | The expression to be repeated. Limited to literals, . , classes
or grouped expressions.
| r | The type of repeat operator used.
| greedy | Whether the repeat is greedy (match the most) or not (match the
least).
|
|
Concat | A concatenation of expressions. Must be matched one after the other.
N.B. A concat expression can only appear at the top-level or
immediately inside a group expression.
|
Alternate | An alternation of expressions. Only one must match.
N.B. An alternate expression can only appear at the top-level or
immediately inside a group expression.
|
Methods
Parses a string in a regular expression syntax tree.
Trait Implementations
This implementation of Display
will write a regular expression from the
syntax tree. It does not write the original string parsed.
Derived Implementations