summaryrefslogtreecommitdiff
path: root/src/piglet/syntaxtree
diff options
context:
space:
mode:
Diffstat (limited to 'src/piglet/syntaxtree')
-rw-r--r--src/piglet/syntaxtree/BinOp.java37
-rw-r--r--src/piglet/syntaxtree/CJumpStmt.java43
-rw-r--r--src/piglet/syntaxtree/Call.java51
-rw-r--r--src/piglet/syntaxtree/ErrorStmt.java35
-rw-r--r--src/piglet/syntaxtree/Exp.java37
-rw-r--r--src/piglet/syntaxtree/Goal.java51
-rw-r--r--src/piglet/syntaxtree/HAllocate.java39
-rw-r--r--src/piglet/syntaxtree/HLoadStmt.java47
-rw-r--r--src/piglet/syntaxtree/HStoreStmt.java47
-rw-r--r--src/piglet/syntaxtree/IntegerLiteral.java31
-rw-r--r--src/piglet/syntaxtree/JumpStmt.java39
-rw-r--r--src/piglet/syntaxtree/Label.java31
-rw-r--r--src/piglet/syntaxtree/MoveStmt.java43
-rw-r--r--src/piglet/syntaxtree/NoOpStmt.java35
-rw-r--r--src/piglet/syntaxtree/Node.java16
-rw-r--r--src/piglet/syntaxtree/NodeChoice.java36
-rw-r--r--src/piglet/syntaxtree/NodeList.java45
-rw-r--r--src/piglet/syntaxtree/NodeListInterface.java22
-rw-r--r--src/piglet/syntaxtree/NodeListOptional.java46
-rw-r--r--src/piglet/syntaxtree/NodeOptional.java41
-rw-r--r--src/piglet/syntaxtree/NodeSequence.java46
-rw-r--r--src/piglet/syntaxtree/NodeToken.java88
-rw-r--r--src/piglet/syntaxtree/Operator.java34
-rw-r--r--src/piglet/syntaxtree/PrintStmt.java39
-rw-r--r--src/piglet/syntaxtree/Procedure.java51
-rw-r--r--src/piglet/syntaxtree/Stmt.java38
-rw-r--r--src/piglet/syntaxtree/StmtExp.java51
-rw-r--r--src/piglet/syntaxtree/StmtList.java31
-rw-r--r--src/piglet/syntaxtree/Temp.java39
29 files changed, 1189 insertions, 0 deletions
diff --git a/src/piglet/syntaxtree/BinOp.java b/src/piglet/syntaxtree/BinOp.java
new file mode 100644
index 0000000..4ef5e2c
--- /dev/null
+++ b/src/piglet/syntaxtree/BinOp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Exp f1;
+ public Exp f2;
+
+ public BinOp(Operator n0, Exp n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/CJumpStmt.java b/src/piglet/syntaxtree/CJumpStmt.java
new file mode 100644
index 0000000..68827ba
--- /dev/null
+++ b/src/piglet/syntaxtree/CJumpStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Exp n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Exp n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Call.java b/src/piglet/syntaxtree/Call.java
new file mode 100644
index 0000000..6592374
--- /dev/null
+++ b/src/piglet/syntaxtree/Call.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+public class Call implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Call(NodeToken n0, Exp n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Call(Exp n0, NodeListOptional n1) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ f2 = new NodeToken("(");
+ f3 = n1;
+ f4 = new NodeToken(")");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/ErrorStmt.java b/src/piglet/syntaxtree/ErrorStmt.java
new file mode 100644
index 0000000..7811766
--- /dev/null
+++ b/src/piglet/syntaxtree/ErrorStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ERROR"
+ */
+public class ErrorStmt implements Node {
+ public NodeToken f0;
+
+ public ErrorStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public ErrorStmt() {
+ f0 = new NodeToken("ERROR");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Exp.java b/src/piglet/syntaxtree/Exp.java
new file mode 100644
index 0000000..62f1fb0
--- /dev/null
+++ b/src/piglet/syntaxtree/Exp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Goal.java b/src/piglet/syntaxtree/Goal.java
new file mode 100644
index 0000000..43dc3be
--- /dev/null
+++ b/src/piglet/syntaxtree/Goal.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+public class Goal implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Goal(NodeToken n0, StmtList n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Goal(StmtList n0, NodeListOptional n1) {
+ f0 = new NodeToken("MAIN");
+ f1 = n0;
+ f2 = new NodeToken("END");
+ f3 = n1;
+ f4 = new NodeToken("");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HAllocate.java b/src/piglet/syntaxtree/HAllocate.java
new file mode 100644
index 0000000..495ef0e
--- /dev/null
+++ b/src/piglet/syntaxtree/HAllocate.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+public class HAllocate implements Node {
+ public NodeToken f0;
+ public Exp f1;
+
+ public HAllocate(NodeToken n0, Exp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public HAllocate(Exp n0) {
+ f0 = new NodeToken("HALLOCATE");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HLoadStmt.java b/src/piglet/syntaxtree/HLoadStmt.java
new file mode 100644
index 0000000..423972c
--- /dev/null
+++ b/src/piglet/syntaxtree/HLoadStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Exp f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Temp n1, Exp n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Temp n0, Exp n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HStoreStmt.java b/src/piglet/syntaxtree/HStoreStmt.java
new file mode 100644
index 0000000..8384618
--- /dev/null
+++ b/src/piglet/syntaxtree/HStoreStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public IntegerLiteral f2;
+ public Exp f3;
+
+ public HStoreStmt(NodeToken n0, Exp n1, IntegerLiteral n2, Exp n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Exp n0, IntegerLiteral n1, Exp n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/IntegerLiteral.java b/src/piglet/syntaxtree/IntegerLiteral.java
new file mode 100644
index 0000000..2f50375
--- /dev/null
+++ b/src/piglet/syntaxtree/IntegerLiteral.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/JumpStmt.java b/src/piglet/syntaxtree/JumpStmt.java
new file mode 100644
index 0000000..759ffd6
--- /dev/null
+++ b/src/piglet/syntaxtree/JumpStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+public class JumpStmt implements Node {
+ public NodeToken f0;
+ public Label f1;
+
+ public JumpStmt(NodeToken n0, Label n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public JumpStmt(Label n0) {
+ f0 = new NodeToken("JUMP");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Label.java b/src/piglet/syntaxtree/Label.java
new file mode 100644
index 0000000..4db8432
--- /dev/null
+++ b/src/piglet/syntaxtree/Label.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/MoveStmt.java b/src/piglet/syntaxtree/MoveStmt.java
new file mode 100644
index 0000000..8a034c3
--- /dev/null
+++ b/src/piglet/syntaxtree/MoveStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+public class MoveStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Exp f2;
+
+ public MoveStmt(NodeToken n0, Temp n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MoveStmt(Temp n0, Exp n1) {
+ f0 = new NodeToken("MOVE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/NoOpStmt.java b/src/piglet/syntaxtree/NoOpStmt.java
new file mode 100644
index 0000000..c5116f4
--- /dev/null
+++ b/src/piglet/syntaxtree/NoOpStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "NOOP"
+ */
+public class NoOpStmt implements Node {
+ public NodeToken f0;
+
+ public NoOpStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public NoOpStmt() {
+ f0 = new NodeToken("NOOP");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Node.java b/src/piglet/syntaxtree/Node.java
new file mode 100644
index 0000000..3b31a93
--- /dev/null
+++ b/src/piglet/syntaxtree/Node.java
@@ -0,0 +1,16 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * The interface which all syntax tree classes must implement.
+ */
+public interface Node extends java.io.Serializable {
+ public void accept(piglet.visitor.Visitor v);
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/piglet/syntaxtree/NodeChoice.java b/src/piglet/syntaxtree/NodeChoice.java
new file mode 100644
index 0000000..d6daa49
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeChoice.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Represents a grammar choice, e.g. ( A | B )
+ */
+public class NodeChoice implements Node {
+ public NodeChoice(Node node) {
+ this(node, -1);
+ }
+
+ public NodeChoice(Node node, int whichChoice) {
+ choice = node;
+ which = whichChoice;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ choice.accept(v);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return choice.accept(v,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return choice.accept(v);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ choice.accept(v,argu);
+ }
+
+ public Node choice;
+ public int which;
+}
+
diff --git a/src/piglet/syntaxtree/NodeList.java b/src/piglet/syntaxtree/NodeList.java
new file mode 100644
index 0000000..c8b5c9d
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeList.java
@@ -0,0 +1,45 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a grammar list, e.g. ( A )+
+ */
+public class NodeList implements NodeListInterface {
+ public NodeList() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeList(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeListInterface.java b/src/piglet/syntaxtree/NodeListInterface.java
new file mode 100644
index 0000000..7fbd7a8
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeListInterface.java
@@ -0,0 +1,22 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * The interface which NodeList, NodeListOptional, and NodeSequence
+ * implement.
+ */
+public interface NodeListInterface extends Node {
+ public void addNode(Node n);
+ public Node elementAt(int i);
+ public java.util.Enumeration<Node> elements();
+ public int size();
+
+ public void accept(piglet.visitor.Visitor v);
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/piglet/syntaxtree/NodeListOptional.java b/src/piglet/syntaxtree/NodeListOptional.java
new file mode 100644
index 0000000..975ccea
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeListOptional.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents an optional grammar list, e.g. ( A )*
+ */
+public class NodeListOptional implements NodeListInterface {
+ public NodeListOptional() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeListOptional(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public boolean present() { return nodes.size() != 0; }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeOptional.java b/src/piglet/syntaxtree/NodeOptional.java
new file mode 100644
index 0000000..160ba16
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeOptional.java
@@ -0,0 +1,41 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Represents an grammar optional node, e.g. ( A )? or [ A ]
+ */
+public class NodeOptional implements Node {
+ public NodeOptional() {
+ node = null;
+ }
+
+ public NodeOptional(Node n) {
+ addNode(n);
+ }
+
+ public void addNode(Node n) {
+ if ( node != null) // Oh oh!
+ throw new Error("Attempt to set optional node twice");
+
+ node = n;
+ }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+ public boolean present() { return node != null; }
+
+ public Node node;
+}
+
diff --git a/src/piglet/syntaxtree/NodeSequence.java b/src/piglet/syntaxtree/NodeSequence.java
new file mode 100644
index 0000000..b935394
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeSequence.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a sequence of nodes nested within a choice, list,
+ * optional list, or optional, e.g. ( A B )+ or [ C D E ]
+ */
+public class NodeSequence implements NodeListInterface {
+ public NodeSequence(int n) {
+ nodes = new Vector<Node>(n);
+ }
+
+ public NodeSequence(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public int size() { return nodes.size(); }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeToken.java b/src/piglet/syntaxtree/NodeToken.java
new file mode 100644
index 0000000..5d9c6e6
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeToken.java
@@ -0,0 +1,88 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+/**
+ * Represents a single token in the grammar. If the "-tk" option
+ * is used, also contains a Vector of preceding special tokens.
+ */
+public class NodeToken implements Node {
+ public NodeToken(String s) {
+ this(s, -1, -1, -1, -1, -1); }
+
+ public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) {
+ tokenImage = s;
+ specialTokens = null;
+ this.kind = kind;
+ this.beginLine = beginLine;
+ this.beginColumn = beginColumn;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+
+ public NodeToken getSpecialAt(int i) {
+ if ( specialTokens == null )
+ throw new java.util.NoSuchElementException("No specials in token");
+ return specialTokens.elementAt(i);
+ }
+
+ public int numSpecials() {
+ if ( specialTokens == null ) return 0;
+ return specialTokens.size();
+ }
+
+ public void addSpecial(NodeToken s) {
+ if ( specialTokens == null ) specialTokens = new Vector<NodeToken>();
+ specialTokens.addElement(s);
+ }
+
+ public void trimSpecials() {
+ if ( specialTokens == null ) return;
+ specialTokens.trimToSize();
+ }
+
+ public String toString() { return tokenImage; }
+
+ public String withSpecials() {
+ if ( specialTokens == null )
+ return tokenImage;
+
+ StringBuffer buf = new StringBuffer();
+
+ for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); )
+ buf.append(e.nextElement().toString());
+
+ buf.append(tokenImage);
+ return buf.toString();
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public String tokenImage;
+
+ // Stores a list of NodeTokens
+ public Vector<NodeToken> specialTokens;
+
+ // -1 for these ints means no position info is available.
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ // Equal to the JavaCC token "kind" integer.
+ // -1 if not available.
+ public int kind;
+}
+
diff --git a/src/piglet/syntaxtree/Operator.java b/src/piglet/syntaxtree/Operator.java
new file mode 100644
index 0000000..15a3a4c
--- /dev/null
+++ b/src/piglet/syntaxtree/Operator.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+public class Operator implements Node {
+ public NodeChoice f0;
+
+ public Operator(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/PrintStmt.java b/src/piglet/syntaxtree/PrintStmt.java
new file mode 100644
index 0000000..0a61ea0
--- /dev/null
+++ b/src/piglet/syntaxtree/PrintStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+public class PrintStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+
+ public PrintStmt(NodeToken n0, Exp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public PrintStmt(Exp n0) {
+ f0 = new NodeToken("PRINT");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Procedure.java b/src/piglet/syntaxtree/Procedure.java
new file mode 100644
index 0000000..99088cd
--- /dev/null
+++ b/src/piglet/syntaxtree/Procedure.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+public class Procedure implements Node {
+ public Label f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public StmtExp f4;
+
+ public Procedure(Label n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, StmtExp n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Procedure(Label n0, IntegerLiteral n1, StmtExp n2) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Stmt.java b/src/piglet/syntaxtree/Stmt.java
new file mode 100644
index 0000000..de54076
--- /dev/null
+++ b/src/piglet/syntaxtree/Stmt.java
@@ -0,0 +1,38 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+public class Stmt implements Node {
+ public NodeChoice f0;
+
+ public Stmt(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/StmtExp.java b/src/piglet/syntaxtree/StmtExp.java
new file mode 100644
index 0000000..3bdb951
--- /dev/null
+++ b/src/piglet/syntaxtree/StmtExp.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+public class StmtExp implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public Exp f3;
+ public NodeToken f4;
+
+ public StmtExp(NodeToken n0, StmtList n1, NodeToken n2, Exp n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public StmtExp(StmtList n0, Exp n1) {
+ f0 = new NodeToken("BEGIN");
+ f1 = n0;
+ f2 = new NodeToken("RETURN");
+ f3 = n1;
+ f4 = new NodeToken("END");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/StmtList.java b/src/piglet/syntaxtree/StmtList.java
new file mode 100644
index 0000000..ef87ebd
--- /dev/null
+++ b/src/piglet/syntaxtree/StmtList.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Temp.java b/src/piglet/syntaxtree/Temp.java
new file mode 100644
index 0000000..38d7fba
--- /dev/null
+++ b/src/piglet/syntaxtree/Temp.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+public class Temp implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+
+ public Temp(NodeToken n0, IntegerLiteral n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public Temp(IntegerLiteral n0) {
+ f0 = new NodeToken("TEMP");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+