pub enum Ast {
Empty(Box<Span>),
Flags(Box<SetFlags>),
Literal(Box<Literal>),
Dot(Box<Span>),
Assertion(Box<Assertion>),
ClassUnicode(Box<ClassUnicode>),
ClassPerl(Box<ClassPerl>),
ClassBracketed(Box<ClassBracketed>),
Repetition(Box<Repetition>),
Group(Box<Group>),
Alternation(Box<Alternation>),
Concat(Box<Concat>),
}
Expand description
An abstract syntax tree for a single regular expression.
An Ast
’s fmt::Display
implementation uses constant stack space and heap
space proportional to the size of the Ast
.
This type defines its own destructor that uses constant stack space and
heap space proportional to the size of the Ast
.
Variants§
Empty(Box<Span>)
An empty regex that matches everything.
Flags(Box<SetFlags>)
A set of flags, e.g., (?is)
.
Literal(Box<Literal>)
A single character literal, which includes escape sequences.
Dot(Box<Span>)
The “any character” class.
Assertion(Box<Assertion>)
A single zero-width assertion.
ClassUnicode(Box<ClassUnicode>)
A single Unicode character class, e.g., \pL
or \p{Greek}
.
ClassPerl(Box<ClassPerl>)
A single perl character class, e.g., \d
or \W
.
ClassBracketed(Box<ClassBracketed>)
A single bracketed character class set, which may contain zero or more
character ranges and/or zero or more nested classes. e.g.,
[a-zA-Z\pL]
.
Repetition(Box<Repetition>)
A repetition operator applied to an arbitrary regular expression.
Group(Box<Group>)
A grouped regular expression.
Alternation(Box<Alternation>)
An alternation of regular expressions.
Concat(Box<Concat>)
A concatenation of regular expressions.
Implementations§
Source§impl Ast
impl Ast
Sourcepub fn class_unicode(e: ClassUnicode) -> Ast
pub fn class_unicode(e: ClassUnicode) -> Ast
Create a “Unicode class” AST item.
Sourcepub fn class_perl(e: ClassPerl) -> Ast
pub fn class_perl(e: ClassPerl) -> Ast
Create a “Perl class” AST item.
Sourcepub fn class_bracketed(e: ClassBracketed) -> Ast
pub fn class_bracketed(e: ClassBracketed) -> Ast
Create a “bracketed class” AST item.
Sourcepub fn repetition(e: Repetition) -> Ast
pub fn repetition(e: Repetition) -> Ast
Create a “repetition” AST item.
Sourcepub fn alternation(e: Alternation) -> Ast
pub fn alternation(e: Alternation) -> Ast
Create a “alternation” AST item.
Trait Implementations§
Source§impl Display for Ast
impl Display for Ast
Print a display representation of this Ast.
This does not preserve any of the original whitespace formatting that may have originally been present in the concrete syntax from which this Ast was generated.
This implementation uses constant stack space and heap space proportional
to the size of the Ast
.
Source§impl Drop for Ast
impl Drop for Ast
A custom Drop
impl is used for Ast
such that it uses constant stack
space but heap space proportional to the depth of the Ast
.
impl Eq for Ast
impl StructuralPartialEq for Ast
Auto Trait Implementations§
impl Freeze for Ast
impl RefUnwindSafe for Ast
impl Send for Ast
impl Sync for Ast
impl Unpin for Ast
impl UnwindSafe for Ast
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes
Size for each variant:
Empty
: 8 bytesFlags
: 8 bytesLiteral
: 8 bytesDot
: 8 bytesAssertion
: 8 bytesClassUnicode
: 8 bytesClassPerl
: 8 bytesClassBracketed
: 8 bytesRepetition
: 8 bytesGroup
: 8 bytesAlternation
: 8 bytesConcat
: 8 bytes