com.go.tea.parsetree
Class TreeMutator

java.lang.Object
  |
  +--com.go.tea.parsetree.TreeMutator
All Implemented Interfaces:
NodeVisitor

public abstract class TreeMutator
extends java.lang.Object
implements NodeVisitor

TreeMutator is similar to TreeWalker in that it traverses a parse tree in canonocal order, and only a few visit methods should be overridden. The key difference is that visit methods must return a node of the same type as the one passed in. By returning a node which isn't the same as the one passed in, a node can be replaced.

Version:
20 , 5/31/01
Author:
Brian S O'Neill

Constructor Summary
TreeMutator()
           
 
Method Summary
 java.lang.Object visit(AndExpression node)
           
 java.lang.Object visit(ArithmeticExpression node)
           
 java.lang.Object visit(ArrayLookup node)
           
 java.lang.Object visit(AssignmentStatement node)
           
 java.lang.Object visit(Block node)
           
 java.lang.Object visit(BooleanLiteral node)
           
 java.lang.Object visit(BreakStatement node)
           
 java.lang.Object visit(ConcatenateExpression node)
           
 java.lang.Object visit(ExceptionGuardStatement node)
           
 java.lang.Object visit(Expression node)
           
 java.lang.Object visit(ExpressionList node)
           
 java.lang.Object visit(ExpressionStatement node)
           
 java.lang.Object visit(ForeachStatement node)
           
 java.lang.Object visit(FunctionCallExpression node)
           
 java.lang.Object visit(IfStatement node)
           
 java.lang.Object visit(Lookup node)
           
 java.lang.Object visit(Name node)
           
 java.lang.Object visit(NegateExpression node)
           
 java.lang.Object visit(NewArrayExpression node)
           
 java.lang.Object visit(NotExpression node)
           
 java.lang.Object visit(NullLiteral node)
           
 java.lang.Object visit(NumberLiteral node)
           
 java.lang.Object visit(OrExpression node)
           
 java.lang.Object visit(ParenExpression node)
           
 java.lang.Object visit(RelationalExpression node)
           
 java.lang.Object visit(ReturnStatement node)
           
 java.lang.Object visit(Statement node)
           
 java.lang.Object visit(StatementList node)
           
 java.lang.Object visit(StringLiteral node)
           
 java.lang.Object visit(SubstitutionStatement node)
           
 java.lang.Object visit(Template node)
           
 java.lang.Object visit(TemplateCallExpression node)
           
 java.lang.Object visit(TypeName node)
           
 java.lang.Object visit(Variable node)
           
 java.lang.Object visit(VariableRef node)
           
protected  Block visitBlock(Block block)
          Visit a Block to ensure that new Statement is a Block.
protected  Expression visitExpression(Expression expr)
          All expressions pass through this method to ensure the expression's type is preserved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeMutator

public TreeMutator()
Method Detail

visit

public java.lang.Object visit(Template node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Name node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(TypeName node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Variable node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ExpressionList node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Statement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(StatementList node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Block node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(AssignmentStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(BreakStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ForeachStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(IfStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(SubstitutionStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ExpressionStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ReturnStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ExceptionGuardStatement node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Expression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ParenExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(NewArrayExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(FunctionCallExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(TemplateCallExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(VariableRef node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(Lookup node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ArrayLookup node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(NegateExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(NotExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ConcatenateExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(ArithmeticExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(RelationalExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(AndExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(OrExpression node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(NullLiteral node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(BooleanLiteral node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(StringLiteral node)
Specified by:
visit in interface NodeVisitor

visit

public java.lang.Object visit(NumberLiteral node)
Specified by:
visit in interface NodeVisitor

visitExpression

protected Expression visitExpression(Expression expr)
All expressions pass through this method to ensure the expression's type is preserved.

visitBlock

protected Block visitBlock(Block block)
Visit a Block to ensure that new Statement is a Block.