// // Generated by JTB 1.3.2 // package jay.visitor; import jay.syntaxtree.*; import java.util.*; import jay.*; /** * Provides default methods which visit each node in the tree in depth-first * order. Your visitors may extend this class. */ public class ToASTVisitor extends DepthFirstVisitor { private jay.abssyntree.Program progResult; public jay.abssyntree.Program getResul() { return progResult; } private Vector declsResult; private jay.abssyntree.Block blockResult; /** * f0 -> * f1 ->
* f2 -> * f3 -> * f4 -> * f5 -> Declarations() * f6 -> Statements() * f7 -> * f8 -> */ public void visit(Program n) { n.f5.accept(this); Vector decls = declsResult; n.f6.accept(this); jay.abssyntree.Block block = blockResult; progResult = new jay.abssyntree.Program(decls, block); } private jay.abssyntree.Operator opResult; /** * f0 -> * | */ public void visit(MultiplicationOperator n) { opResult = new jay.abssyntree.Operator(n.f0.choice.toString()); } private jay.abssyntree.Expression exprResult; /** * f0 -> [ ] * f1 -> Factor() */ public void visit(Negation n) { n.f1.accept(this); jay.abssyntree.Expression ex = exprResult; if (n.f0.present()) exprResult = new jay.abssyntree.UnaryExpr(new jay.abssyntree.Operator("!"), ex); else exprResult = ex; } }