summaryrefslogtreecommitdiff
path: root/src/kanga/visitor/DepthFirstVisitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/kanga/visitor/DepthFirstVisitor.java')
-rw-r--r--src/kanga/visitor/DepthFirstVisitor.java385
1 files changed, 385 insertions, 0 deletions
diff --git a/src/kanga/visitor/DepthFirstVisitor.java b/src/kanga/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..39d3338
--- /dev/null
+++ b/src/kanga/visitor/DepthFirstVisitor.java
@@ -0,0 +1,385 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import java.util.Enumeration;
+
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.Node;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class DepthFirstVisitor implements Visitor {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeListOptional n) {
+ if ( n.present() )
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeOptional n) {
+ if ( n.present() )
+ n.node.accept(this);
+ }
+
+ public void visit(NodeSequence n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeToken n) { }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public void visit(Goal n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ n.f13.accept(this);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public void visit(Procedure n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public void visit(Stmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public void visit(HStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public void visit(ALoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public void visit(AStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public void visit(PassArgStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public void visit(CallStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(SpilledArg n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public void visit(Reg n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n) {
+ n.f0.accept(this);
+ }
+
+}