harpoon.Analysis.Tree
Class Simplification.Rule

java.lang.Object
  extended by harpoon.Analysis.Tree.Simplification.Rule
Enclosing class:
Simplification

public abstract static class Simplification.Rule
extends Object

A simplification rule for use with the tree simplifier.


Constructor Summary
Simplification.Rule(String name)
           
 
Method Summary
 Exp apply(TreeFactory tf, Exp exp, DerivationGenerator dg)
          Applies this rule to exp, and returns the result.
 Stm apply(TreeFactory tf, Stm stm, DerivationGenerator dg)
          Applies this rule to stm, and returns the result.
 boolean match(Exp exp)
          Returns true if exp matches this rule.
 boolean match(Stm stm)
          Returns true if stm matches this rule.
 String toString()
          Returns a human-readable name for this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Simplification.Rule

public Simplification.Rule(String name)
Method Detail

toString

public String toString()
Returns a human-readable name for this rule.

Overrides:
toString in class Object

match

public boolean match(Exp exp)
Returns true if exp matches this rule.


apply

public Exp apply(TreeFactory tf,
                 Exp exp,
                 DerivationGenerator dg)
Applies this rule to exp, and returns the result. apply() should always succeed when match() returns true. Otherwise, the behavior of apply is undefined. The returned Exp cannot contain the parameter exp, although it can contain its children. (use exp.build(tf, exp.kids()) to workaround this limitation.)


match

public boolean match(Stm stm)
Returns true if stm matches this rule.


apply

public Stm apply(TreeFactory tf,
                 Stm stm,
                 DerivationGenerator dg)
Applies this rule to stm, and returns the result. apply() should always succeed when match() returns true. Otherwise, the behavior of apply is undefined. The returned Stm cannot contain the parameter stm, although it can contain its children. (use stm.build(tf, stm.kids()) to workaround this limitation.)