summaryrefslogtreecommitdiff
path: root/src/spiglet/visitor/DepthFirstVisitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/spiglet/visitor/DepthFirstVisitor.java')
-rw-r--r--src/spiglet/visitor/DepthFirstVisitor.java305
1 files changed, 305 insertions, 0 deletions
diff --git a/src/spiglet/visitor/DepthFirstVisitor.java b/src/spiglet/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..e9920b8
--- /dev/null
+++ b/src/spiglet/visitor/DepthFirstVisitor.java
@@ -0,0 +1,305 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import java.util.Enumeration;
+
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.Node;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * 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 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <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);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ 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);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ 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 -> Temp()
+ * 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 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public void visit(HStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * 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 -> Temp()
+ * 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 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * 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 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n) {
+ n.f0.accept(this);
+ n.f1.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);
+ }
+
+}