regex_syntax::ast

Enum Ast

Source
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

Source

pub fn empty(span: Span) -> Ast

Create an “empty” AST item.

Source

pub fn flags(e: SetFlags) -> Ast

Create a “flags” AST item.

Source

pub fn literal(e: Literal) -> Ast

Create a “literal” AST item.

Source

pub fn dot(span: Span) -> Ast

Create a “dot” AST item.

Source

pub fn assertion(e: Assertion) -> Ast

Create a “assertion” AST item.

Source

pub fn class_unicode(e: ClassUnicode) -> Ast

Create a “Unicode class” AST item.

Source

pub fn class_perl(e: ClassPerl) -> Ast

Create a “Perl class” AST item.

Source

pub fn class_bracketed(e: ClassBracketed) -> Ast

Create a “bracketed class” AST item.

Source

pub fn repetition(e: Repetition) -> Ast

Create a “repetition” AST item.

Source

pub fn group(e: Group) -> Ast

Create a “group” AST item.

Source

pub fn alternation(e: Alternation) -> Ast

Create a “alternation” AST item.

Source

pub fn concat(e: Concat) -> Ast

Create a “concat” AST item.

Source

pub fn span(&self) -> &Span

Return the span of this abstract syntax tree.

Source

pub fn is_empty(&self) -> bool

Return true if and only if this Ast is empty.

Trait Implementations§

Source§

impl Clone for Ast

Source§

fn clone(&self) -> Ast

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ast

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Ast

Source§

fn eq(&self, other: &Ast) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Ast

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.