Pat

Enum Pat 

Source
pub enum Pat<L>{
    PatVar(Var),
    Wrap(Signature<L, Box<Pat<L>>>),
}
Expand description

Recursive AST for patterns in language L. This can be converted to/from Pattern<AsLanguage<L>>.

User can also define [From<L> for Pat<L>] for concrete L with Self::wrap.

Language derive macro will genrate a newtype wrapper of this type, which implements egg::Searcher and egg::Applier too, and it can have (otherwise orphan) custom instances.

Variants§

§

PatVar(Var)

Variable in pattern.

§

Wrap(Signature<L, Box<Pat<L>>>)

Recursive pattern.

Implementations§

Source§

impl<L> Pat<L>

Source

pub fn pat_var<'a, S: Into<Cow<'a, str>>>(v: S) -> Self

Smart constructor for a variable. NOTE: this DOES NOT require ?-prefix before the identifier.

Source

pub fn unwrap(self) -> ENodeOrVar<Signature<L, Self>>

Unwraps the pattern recursion by one layer.

Source

pub fn wrap(inner: Signature<L, Self>) -> Self

Wraps the pattern recursion by one layer.

Source§

impl<L> Pat<L>

Source

pub fn into_pattern_ast(self) -> PatternAst<AsLanguage<L>>

Convert a recursive pattern into a PatternAst<L>. See also: Self::to_pattern_ast.

Source

pub fn to_pattern_ast(&self) -> PatternAst<AsLanguage<L>>

Convert a borrowed recursive pattern to a PatternAst<L>. See also: Self::into_pattern_ast.

Source

pub fn from_pattern_ast(ast: &PatternAst<AsLanguage<L>>, id: Id) -> Self

Convert a PatternAst<L> into a recursive pattern.

Source

pub fn add_into_pattern_ast(self, ast: &mut PatternAst<AsLanguage<L>>) -> Id

Adds the pattern into an existing PatternAst and returns the id of the root node. See also: Self::into_pattern_ast, Self::add_to_pattern_ast.

Source

pub fn add_to_pattern_ast(&self, ast: &mut PatternAst<AsLanguage<L>>) -> Id

Adds the borrowed pattern into an existing PatternAst and returns the id of the root node. See also: Self::to_pattern_ast, Self::add_into_pattern_ast.

Trait Implementations§

Source§

impl<L, N> Applier<<L as Functor>::Container<Id>, N> for Pat<L>

Source§

fn apply_one( &self, egraph: &mut EGraph<AsLanguage<L>, N>, eclass: Id, subst: &Subst, searcher_ast: Option<&PatternAst<AsLanguage<L>>>, rule_name: Symbol, ) -> Vec<Id>

Apply a single substitution. Read more
Source§

fn apply_matches( &self, egraph: &mut EGraph<L, N>, matches: &[SearchMatches<'_, L>], rule_name: GlobalSymbol, ) -> Vec<Id>

Apply many substitutions. Read more
Source§

fn get_pattern_ast(&self) -> Option<&RecExpr<ENodeOrVar<L>>>

For patterns, get the ast directly as a reference.
Source§

fn vars(&self) -> Vec<Var>

Returns a list of variables that this Applier assumes are bound. Read more
Source§

impl<L> Clone for Pat<L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<L> From<&Pat<L>> for Pattern<AsLanguage<L>>

Source§

fn from(value: &Pat<L>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<&Pat<L>> for PatternAst<AsLanguage<L>>

Source§

fn from(value: &Pat<L>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<L> for Pat<L>

Source§

fn from(value: L) -> Self

Converts to this type from the input type.
Source§

impl<L> From<Pat<L>> for Pattern<AsLanguage<L>>

Source§

fn from(value: Pat<L>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<Pat<L>> for PatternAst<AsLanguage<L>>

Source§

fn from(value: Pat<L>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<Pattern<<L as Functor>::Container<Id>>> for Pat<L>

Source§

fn from(value: Pattern<AsLanguage<L>>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<RecExpr<ENodeOrVar<<L as Functor>::Container<Id>>>> for Pat<L>

Source§

fn from(value: PatternAst<AsLanguage<L>>) -> Self

Converts to this type from the input type.
Source§

impl<L> From<Var> for Pat<L>

Source§

fn from(value: Var) -> Self

Converts to this type from the input type.
Source§

impl<L, N> Searcher<<L as Functor>::Container<Id>, N> for Pat<L>

Source§

fn search_eclass_with_limit( &self, egraph: &EGraph<AsLanguage<L>, N>, eclass: Id, limit: usize, ) -> Option<SearchMatches<'_, AsLanguage<L>>>

Similar to search_eclass, but return at most limit many matches. Read more
Source§

fn vars(&self) -> Vec<Var>

Returns a list of the variables bound by this Searcher
Source§

fn search_eclass( &self, egraph: &EGraph<L, N>, eclass: Id, ) -> Option<SearchMatches<'_, L>>

Search one eclass, returning None if no matches can be found. This should not return a SearchMatches with no substs.
Source§

fn search(&self, egraph: &EGraph<L, N>) -> Vec<SearchMatches<'_, L>>

Search the whole EGraph, returning a list of all the SearchMatches where something was found. This just calls Searcher::search_with_limit with a big limit.
Source§

fn search_with_limit( &self, egraph: &EGraph<L, N>, limit: usize, ) -> Vec<SearchMatches<'_, L>>

Similar to search, but return at most limit many matches.
Source§

fn n_matches(&self, egraph: &EGraph<L, N>) -> usize

Returns the number of matches in the e-graph
Source§

fn get_pattern_ast(&self) -> Option<&RecExpr<ENodeOrVar<L>>>

For patterns, return the ast directly as a reference

Auto Trait Implementations§

§

impl<L> Freeze for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: Freeze,

§

impl<L> RefUnwindSafe for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: RefUnwindSafe,

§

impl<L> Send for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: Send,

§

impl<L> Sync for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: Sync,

§

impl<L> Unpin for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: Unpin,

§

impl<L> UnwindSafe for Pat<L>
where <L as Functor>::Container<Id>: Sized, <L as Functor>::Container<Box<Pat<L>>>: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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

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

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.