diff options
Diffstat (limited to 'src/piglet/visitor/GJNoArguDepthFirst.java')
-rw-r--r-- | src/piglet/visitor/GJNoArguDepthFirst.java | 360 |
1 files changed, 360 insertions, 0 deletions
diff --git a/src/piglet/visitor/GJNoArguDepthFirst.java b/src/piglet/visitor/GJNoArguDepthFirst.java new file mode 100644 index 0000000..f4a460e --- /dev/null +++ b/src/piglet/visitor/GJNoArguDepthFirst.java @@ -0,0 +1,360 @@ +// +// Generated by JTB 1.3.2 +//
+
+package piglet.visitor;
+import java.util.Enumeration; + +import piglet.syntaxtree.BinOp; +import piglet.syntaxtree.CJumpStmt; +import piglet.syntaxtree.Call; +import piglet.syntaxtree.ErrorStmt; +import piglet.syntaxtree.Exp; +import piglet.syntaxtree.Goal; +import piglet.syntaxtree.HAllocate; +import piglet.syntaxtree.HLoadStmt; +import piglet.syntaxtree.HStoreStmt; +import piglet.syntaxtree.IntegerLiteral; +import piglet.syntaxtree.JumpStmt; +import piglet.syntaxtree.Label; +import piglet.syntaxtree.MoveStmt; +import piglet.syntaxtree.NoOpStmt; +import piglet.syntaxtree.Node; +import piglet.syntaxtree.NodeList; +import piglet.syntaxtree.NodeListOptional; +import piglet.syntaxtree.NodeOptional; +import piglet.syntaxtree.NodeSequence; +import piglet.syntaxtree.NodeToken; +import piglet.syntaxtree.Operator; +import piglet.syntaxtree.PrintStmt; +import piglet.syntaxtree.Procedure; +import piglet.syntaxtree.Stmt; +import piglet.syntaxtree.StmtExp; +import piglet.syntaxtree.StmtList; +import piglet.syntaxtree.Temp; +
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJNoArguDepthFirst<R> implements GJNoArguVisitor<R> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n) { + R _ret=null; + int _count=0; + for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { + e.nextElement().accept(this); + _count++; + } + return _ret; + } +
+ public R visit(NodeListOptional n) { + if ( n.present() ) { + R _ret=null; + int _count=0; + for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { + e.nextElement().accept(this); + _count++; + } + return _ret; + } + else + return null; + } +
+ public R visit(NodeOptional n) { + if ( n.present() ) + return n.node.accept(this); + else + return null; + } +
+ public R visit(NodeSequence n) { + R _ret=null; + int _count=0; + for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { + e.nextElement().accept(this); + _count++; + } + return _ret; + } +
+ public R visit(NodeToken n) { return null; } +
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public R visit(HStoreStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public R visit(PrintStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(Exp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public R visit(HAllocate n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public R visit(BinOp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ } +
+}
|