Enum pest_meta::ast::Expr

source ·
pub enum Expr {
Show 18 variants Str(String), Insens(String), Range(String, String), Ident(String), PeekSlice(i32, Option<i32>), PosPred(Box<Expr>), NegPred(Box<Expr>), Seq(Box<Expr>, Box<Expr>), Choice(Box<Expr>, Box<Expr>), Opt(Box<Expr>), Rep(Box<Expr>), RepOnce(Box<Expr>), RepExact(Box<Expr>, u32), RepMin(Box<Expr>, u32), RepMax(Box<Expr>, u32), RepMinMax(Box<Expr>, u32, u32), Skip(Vec<String>), Push(Box<Expr>),
}
Expand description

All possible rule expressions

§Warning: Semantic Versioning

There may be non-breaking changes to the meta-grammar between minor versions. Those non-breaking changes, however, may translate into semver-breaking changes due to the additional variants propaged from the Rule enum. This is a known issue and will be fixed in the future (e.g. by increasing MSRV and non_exhaustive annotations).

Variants§

§

Str(String)

Matches an exact string, e.g. "a"

§

Insens(String)

Matches an exact string, case insensitively (ASCII only), e.g. ^"a"

§

Range(String, String)

Matches one character in the range, e.g. 'a'..'z'

§

Ident(String)

Matches the rule with the given name, e.g. a

§

PeekSlice(i32, Option<i32>)

Matches a custom part of the stack, e.g. PEEK[..]

§

PosPred(Box<Expr>)

Positive lookahead; matches expression without making progress, e.g. &e

§

NegPred(Box<Expr>)

Negative lookahead; matches if expression doesn’t match, without making progress, e.g. !e

§

Seq(Box<Expr>, Box<Expr>)

Matches a sequence of two expressions, e.g. e1 ~ e2

§

Choice(Box<Expr>, Box<Expr>)

Matches either of two expressions, e.g. e1 | e2

§

Opt(Box<Expr>)

Optionally matches an expression, e.g. e?

§

Rep(Box<Expr>)

Matches an expression zero or more times, e.g. e*

§

RepOnce(Box<Expr>)

Matches an expression one or more times, e.g. e+

§

RepExact(Box<Expr>, u32)

Matches an expression an exact number of times, e.g. e{n}

§

RepMin(Box<Expr>, u32)

Matches an expression at least a number of times, e.g. e{n,}

§

RepMax(Box<Expr>, u32)

Matches an expression at most a number of times, e.g. e{,n}

§

RepMinMax(Box<Expr>, u32, u32)

Matches an expression a number of times within a range, e.g. e{m, n}

§

Skip(Vec<String>)

Continues to match expressions until one of the strings in the Vec is found

§

Push(Box<Expr>)

Matches an expression and pushes it to the stack, e.g. push(e)

Implementations§

source§

impl Expr

source

pub fn iter_top_down(&self) -> ExprTopDownIterator

Returns the iterator that steps the expression from top to bottom.

source

pub fn map_top_down<F>(self, f: F) -> Expr
where F: FnMut(Expr) -> Expr,

Applies f to the expression and all its children (top to bottom).

source

pub fn map_bottom_up<F>(self, f: F) -> Expr
where F: FnMut(Expr) -> Expr,

Applies f to the expression and all its children (bottom up).

Trait Implementations§

source§

impl Clone for Expr

source§

fn clone(&self) -> Expr

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 Expr

source§

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

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

impl Display for Expr

source§

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

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

impl PartialEq for Expr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Expr

source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

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> 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,

§

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>,

§

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>,

§

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.