Struct egg::FlatTerm

source ·
pub struct FlatTerm<L: Language> {
    pub node: L,
    pub backward_rule: Option<Symbol>,
    pub forward_rule: Option<Symbol>,
    pub children: FlatExplanation<L>,
}
Expand description

A single term in an flattened explanation. After the first term in a FlatExplanation, each term will be annotated with exactly one backward_rule or one forward_rule. This can appear in children FlatTerms, indicating that the child is being rewritten.

When forward_rule is provided, the previous FlatTerm can be rewritten to this FlatTerm by applying the rule. When backward_rule is provided, the previous FlatTerm is given by applying the rule to this FlatTerm. Rules are either the string of the name of the rule or the reason provided to union_instantiations.

Fields§

§node: L

The node representing this FlatTerm’s operator. The children of the node should be ignored.

§backward_rule: Option<Symbol>

A rule rewriting this FlatTerm back to the last FlatTerm.

§forward_rule: Option<Symbol>

A rule rewriting the last FlatTerm to this FlatTerm.

§children: FlatExplanation<L>

The children of this FlatTerm.

Implementations§

source§

impl<L: Language> FlatTerm<L>

source

pub fn remove_rewrites(&self) -> FlatTerm<L>

Remove the rewrite annotation from this flatterm, if any.

source§

impl<L: Language + Display + FromOp> FlatTerm<L>

source

pub fn get_string(&self) -> String

Convert this FlatTerm to an S-expression. See get_flat_string for the format of these expressions.

source

pub fn get_recexpr(&self) -> RecExpr<L>

Convert this FlatTerm to a RecExpr.

source§

impl<L: Language> FlatTerm<L>

source

pub fn new(node: L, children: FlatExplanation<L>) -> FlatTerm<L>

Construct a new FlatTerm given a node and its children.

source

pub fn rewrite(&self, lhs: &PatternAst<L>, rhs: &PatternAst<L>) -> FlatTerm<L>

Rewrite the FlatTerm by matching the lhs and substituting the rhs. The lhs must be guaranteed to match.

source

pub fn has_rewrite_forward(&self) -> bool

Checks if this term or any child has a forward_rule.

source

pub fn has_rewrite_backward(&self) -> bool

Checks if this term or any child has a backward_rule.

Trait Implementations§

source§

impl<L: Clone + Language> Clone for FlatTerm<L>

source§

fn clone(&self) -> FlatTerm<L>

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<L: Debug + Language> Debug for FlatTerm<L>

source§

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

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

impl<L: Language + Display + FromOp> Display for FlatTerm<L>

source§

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

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

impl<L: Language> PartialEq<FlatTerm<L>> for FlatTerm<L>

source§

fn eq(&self, other: &FlatTerm<L>) -> 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<L: Eq + Language> Eq for FlatTerm<L>

source§

impl<L: Language> StructuralEq for FlatTerm<L>

Auto Trait Implementations§

§

impl<L> RefUnwindSafe for FlatTerm<L>where L: RefUnwindSafe,

§

impl<L> Send for FlatTerm<L>where L: Send,

§

impl<L> Sync for FlatTerm<L>where L: Sync,

§

impl<L> Unpin for FlatTerm<L>where L: Unpin,

§

impl<L> UnwindSafe for FlatTerm<L>where L: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.