[−][src]Trait libslide::grammar::transformer::Transformer
A trait for transforming one grammar into another. This transformer takes ownership of the grammar it transforms.
Required methods
fn transform(&self, item: T) -> U
Implementors
impl Transformer<RcExprPat, RcExprPat> for Rule
[src]
fn transform(&self, target: RcExprPat) -> RcExprPat
[src]
Bootstraps a rule with another (or possibly the same) rule.
impl Transformer<RcExprPat, RcExprPat> for PatternMatch<RcExprPat>
[src]
impl Transformer<RcExprPat, RcExpr> for PatternMatch<RcExpr>
[src]
fn transform(&self, item: RcExprPat) -> RcExpr
[src]
Transforms a pattern expression into an expression by replacing patterns with target
expressions known by the PatternMatch
.
This transformation can be used to apply a rule on an expression by transforming the RHS using patterns matched between the LHS of the rule and the target expression.
impl Transformer<RcExpr, RcExpr> for Rule
[src]
fn transform(&self, target: RcExpr) -> RcExpr
[src]
Attempts to apply a rule on a target expression by
-
Applying the rule recursively on the target's subexpression to obtain a partially-transformed target expression.
-
Pattern matching the lhs of the rule with the partially-transformed target expression.
- If pattern matching is unsuccessful, no application is done and the original expression is returned.
- Expanding the rhs of the rule using the results of the pattern matching.
Examples:
ⓘThis example is not tested
"$x + 0 -> $x".try_apply("x + 0") // Some(x) "$x + 0 -> $x".try_apply("x + 1") // None "$x + 0 -> $x".try_apply("x") // None