|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface NodeVisitor
A NodeVisitor enables operations to be performed on a parse tree. The Visitor design pattern is discussed in detail in Design Patterns (ISBN 0-201-63361-2) by Gamma, Helm, Johnson and Vlissides.
The traditional operations performed on parse trees are type checking and code generation. The Visitor allows those operations to all be encapsulated into one place instead of having that functionality spread out into every Node subclass. It also makes it easy to target multiple languages by allowing any kind of code generation Visitor to be designed.
When using a Visitor to traverse a parse tree, the code responsible for moving the traversal into children nodes can either be placed in the nodes or in the Visitor implementation. The NodeVisitor places that responsibility onto NodeVisitor implementations because it is much more flexible. As a result, all Nodes have the same simple implementation for their "accept" method, but do not inherit it.
Every visit method in this interface returns an Object. The definition of that returned Object is left up to the specific implementation of the NodeVisitor. Most NodeVisitors can simply return null, but those that are modifying a parse tree or are using one to create another can use the returned Object to pass around newly created Nodes.
Node.accept(NodeVisitor)| Method Detail |
|---|
Object visit(Template node)
Object visit(Name node)
Object visit(TypeName node)
Object visit(Variable node)
Object visit(ExpressionList node)
Object visit(Statement node)
Object visit(StatementList node)
Object visit(Block node)
Object visit(AssignmentStatement node)
Object visit(ForeachStatement node)
Object visit(IfStatement node)
Object visit(SubstitutionStatement node)
Object visit(ExpressionStatement node)
Object visit(ReturnStatement node)
Object visit(ExceptionGuardStatement node)
Object visit(BreakStatement node)
Object visit(ContinueStatement node)
Object visit(Expression node)
Object visit(ParenExpression node)
Object visit(NewArrayExpression node)
Object visit(FunctionCallExpression node)
Object visit(TemplateCallExpression node)
Object visit(VariableRef node)
Object visit(Lookup node)
Object visit(ArrayLookup node)
Object visit(NegateExpression node)
Object visit(NotExpression node)
Object visit(ConcatenateExpression node)
Object visit(ArithmeticExpression node)
Object visit(RelationalExpression node)
Object visit(AndExpression node)
Object visit(OrExpression node)
Object visit(TernaryExpression node)
Object visit(CompareExpression node)
Object visit(NoOpExpression node)
Object visit(SpreadExpression node)
Object visit(TypeExpression node)
Object visit(NullLiteral node)
Object visit(BooleanLiteral node)
Object visit(StringLiteral node)
Object visit(NumberLiteral node)
Object visit(ImportDirective node)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||