diff options
author | Iru Cai <mytbk920423@gmail.com> | 2014-10-08 21:15:43 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2014-10-08 21:15:43 +0800 |
commit | 748308e11e6791284b302f61e5bc0d99a0957b6a (patch) | |
tree | 31b88d40d043f39d54ab90393656300656aaa209 /src/kanga/syntaxtree | |
download | minijava-748308e11e6791284b302f61e5bc0d99a0957b6a.tar.xz |
First commit
Diffstat (limited to 'src/kanga/syntaxtree')
33 files changed, 1406 insertions, 0 deletions
diff --git a/src/kanga/syntaxtree/ALoadStmt.java b/src/kanga/syntaxtree/ALoadStmt.java new file mode 100644 index 0000000..e3959b0 --- /dev/null +++ b/src/kanga/syntaxtree/ALoadStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+public class ALoadStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public SpilledArg f2;
+
+ public ALoadStmt(NodeToken n0, Reg n1, SpilledArg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public ALoadStmt(Reg n0, SpilledArg n1) {
+ f0 = new NodeToken("ALOAD");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/AStoreStmt.java b/src/kanga/syntaxtree/AStoreStmt.java new file mode 100644 index 0000000..fb90f0c --- /dev/null +++ b/src/kanga/syntaxtree/AStoreStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+public class AStoreStmt implements Node {
+ public NodeToken f0;
+ public SpilledArg f1;
+ public Reg f2;
+
+ public AStoreStmt(NodeToken n0, SpilledArg n1, Reg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public AStoreStmt(SpilledArg n0, Reg n1) {
+ f0 = new NodeToken("ASTORE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/BinOp.java b/src/kanga/syntaxtree/BinOp.java new file mode 100644 index 0000000..73a9876 --- /dev/null +++ b/src/kanga/syntaxtree/BinOp.java @@ -0,0 +1,37 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Reg f1;
+ public SimpleExp f2;
+
+ public BinOp(Operator n0, Reg n1, SimpleExp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/CJumpStmt.java b/src/kanga/syntaxtree/CJumpStmt.java new file mode 100644 index 0000000..3f89bf8 --- /dev/null +++ b/src/kanga/syntaxtree/CJumpStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Reg n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Reg n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/CallStmt.java b/src/kanga/syntaxtree/CallStmt.java new file mode 100644 index 0000000..2f50353 --- /dev/null +++ b/src/kanga/syntaxtree/CallStmt.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+public class CallStmt implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public CallStmt(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public CallStmt(SimpleExp n0) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/ErrorStmt.java b/src/kanga/syntaxtree/ErrorStmt.java new file mode 100644 index 0000000..b6a5b97 --- /dev/null +++ b/src/kanga/syntaxtree/ErrorStmt.java @@ -0,0 +1,35 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Exp.java b/src/kanga/syntaxtree/Exp.java new file mode 100644 index 0000000..634327b --- /dev/null +++ b/src/kanga/syntaxtree/Exp.java @@ -0,0 +1,33 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Goal.java b/src/kanga/syntaxtree/Goal.java new file mode 100644 index 0000000..541376e --- /dev/null +++ b/src/kanga/syntaxtree/Goal.java @@ -0,0 +1,87 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+public class Goal implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public IntegerLiteral f5;
+ public NodeToken f6;
+ public NodeToken f7;
+ public IntegerLiteral f8;
+ public NodeToken f9;
+ public StmtList f10;
+ public NodeToken f11;
+ public NodeListOptional f12;
+ public NodeToken f13;
+
+ public Goal(NodeToken n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, NodeToken n4, IntegerLiteral n5, NodeToken n6, NodeToken n7, IntegerLiteral n8, NodeToken n9, StmtList n10, NodeToken n11, NodeListOptional n12, NodeToken n13) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ f12 = n12;
+ f13 = n13;
+ }
+
+ public Goal(IntegerLiteral n0, IntegerLiteral n1, IntegerLiteral n2, StmtList n3, NodeListOptional n4) {
+ f0 = new NodeToken("MAIN");
+ f1 = new NodeToken("[");
+ f2 = n0;
+ f3 = new NodeToken("]");
+ f4 = new NodeToken("[");
+ f5 = n1;
+ f6 = new NodeToken("]");
+ f7 = new NodeToken("[");
+ f8 = n2;
+ f9 = new NodeToken("]");
+ f10 = n3;
+ f11 = new NodeToken("END");
+ f12 = n4;
+ f13 = new NodeToken("");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HAllocate.java b/src/kanga/syntaxtree/HAllocate.java new file mode 100644 index 0000000..97fd8bd --- /dev/null +++ b/src/kanga/syntaxtree/HAllocate.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+public class HAllocate implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public HAllocate(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public HAllocate(SimpleExp n0) {
+ f0 = new NodeToken("HALLOCATE");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HLoadStmt.java b/src/kanga/syntaxtree/HLoadStmt.java new file mode 100644 index 0000000..5185583 --- /dev/null +++ b/src/kanga/syntaxtree/HLoadStmt.java @@ -0,0 +1,47 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Reg f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Reg n1, Reg n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Reg n0, Reg n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HStoreStmt.java b/src/kanga/syntaxtree/HStoreStmt.java new file mode 100644 index 0000000..074eb9c --- /dev/null +++ b/src/kanga/syntaxtree/HStoreStmt.java @@ -0,0 +1,47 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public IntegerLiteral f2;
+ public Reg f3;
+
+ public HStoreStmt(NodeToken n0, Reg n1, IntegerLiteral n2, Reg n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Reg n0, IntegerLiteral n1, Reg n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/IntegerLiteral.java b/src/kanga/syntaxtree/IntegerLiteral.java new file mode 100644 index 0000000..9359606 --- /dev/null +++ b/src/kanga/syntaxtree/IntegerLiteral.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/JumpStmt.java b/src/kanga/syntaxtree/JumpStmt.java new file mode 100644 index 0000000..6ef09f4 --- /dev/null +++ b/src/kanga/syntaxtree/JumpStmt.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Label.java b/src/kanga/syntaxtree/Label.java new file mode 100644 index 0000000..a2bc07c --- /dev/null +++ b/src/kanga/syntaxtree/Label.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/MoveStmt.java b/src/kanga/syntaxtree/MoveStmt.java new file mode 100644 index 0000000..88a1f87 --- /dev/null +++ b/src/kanga/syntaxtree/MoveStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+public class MoveStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Exp f2;
+
+ public MoveStmt(NodeToken n0, Reg n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MoveStmt(Reg n0, Exp n1) {
+ f0 = new NodeToken("MOVE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/NoOpStmt.java b/src/kanga/syntaxtree/NoOpStmt.java new file mode 100644 index 0000000..8b722b2 --- /dev/null +++ b/src/kanga/syntaxtree/NoOpStmt.java @@ -0,0 +1,35 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Node.java b/src/kanga/syntaxtree/Node.java new file mode 100644 index 0000000..945ac77 --- /dev/null +++ b/src/kanga/syntaxtree/Node.java @@ -0,0 +1,16 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree; + +/** + * The interface which all syntax tree classes must implement. + */ +public interface Node extends java.io.Serializable { + public void accept(kanga.visitor.Visitor v); + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu); + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v); + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu); +} +
diff --git a/src/kanga/syntaxtree/NodeChoice.java b/src/kanga/syntaxtree/NodeChoice.java new file mode 100644 index 0000000..4230240 --- /dev/null +++ b/src/kanga/syntaxtree/NodeChoice.java @@ -0,0 +1,36 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + choice.accept(v); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return choice.accept(v,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return choice.accept(v); + } + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) { + choice.accept(v,argu); + } + + public Node choice; + public int which; +} +
diff --git a/src/kanga/syntaxtree/NodeList.java b/src/kanga/syntaxtree/NodeList.java new file mode 100644 index 0000000..050a920 --- /dev/null +++ b/src/kanga/syntaxtree/NodeList.java @@ -0,0 +1,45 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/kanga/syntaxtree/NodeListInterface.java b/src/kanga/syntaxtree/NodeListInterface.java new file mode 100644 index 0000000..e09eb36 --- /dev/null +++ b/src/kanga/syntaxtree/NodeListInterface.java @@ -0,0 +1,22 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v); + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu); + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v); + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu); +} +
diff --git a/src/kanga/syntaxtree/NodeListOptional.java b/src/kanga/syntaxtree/NodeListOptional.java new file mode 100644 index 0000000..7d0581d --- /dev/null +++ b/src/kanga/syntaxtree/NodeListOptional.java @@ -0,0 +1,46 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/kanga/syntaxtree/NodeOptional.java b/src/kanga/syntaxtree/NodeOptional.java new file mode 100644 index 0000000..5f60850 --- /dev/null +++ b/src/kanga/syntaxtree/NodeOptional.java @@ -0,0 +1,41 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + public boolean present() { return node != null; } + + public Node node; +} +
diff --git a/src/kanga/syntaxtree/NodeSequence.java b/src/kanga/syntaxtree/NodeSequence.java new file mode 100644 index 0000000..4b55d11 --- /dev/null +++ b/src/kanga/syntaxtree/NodeSequence.java @@ -0,0 +1,46 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/kanga/syntaxtree/NodeToken.java b/src/kanga/syntaxtree/NodeToken.java new file mode 100644 index 0000000..840b92d --- /dev/null +++ b/src/kanga/syntaxtree/NodeToken.java @@ -0,0 +1,88 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(kanga.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/kanga/syntaxtree/Operator.java b/src/kanga/syntaxtree/Operator.java new file mode 100644 index 0000000..3bb8c0c --- /dev/null +++ b/src/kanga/syntaxtree/Operator.java @@ -0,0 +1,34 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.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(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/PassArgStmt.java b/src/kanga/syntaxtree/PassArgStmt.java new file mode 100644 index 0000000..ac7671d --- /dev/null +++ b/src/kanga/syntaxtree/PassArgStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+public class PassArgStmt implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+ public Reg f2;
+
+ public PassArgStmt(NodeToken n0, IntegerLiteral n1, Reg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public PassArgStmt(IntegerLiteral n0, Reg n1) {
+ f0 = new NodeToken("PASSARG");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/PrintStmt.java b/src/kanga/syntaxtree/PrintStmt.java new file mode 100644 index 0000000..40f5f6e --- /dev/null +++ b/src/kanga/syntaxtree/PrintStmt.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+public class PrintStmt implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public PrintStmt(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public PrintStmt(SimpleExp n0) {
+ f0 = new NodeToken("PRINT");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Procedure.java b/src/kanga/syntaxtree/Procedure.java new file mode 100644 index 0000000..08f8abd --- /dev/null +++ b/src/kanga/syntaxtree/Procedure.java @@ -0,0 +1,79 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+public class Procedure implements Node {
+ public Label f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public IntegerLiteral f5;
+ public NodeToken f6;
+ public NodeToken f7;
+ public IntegerLiteral f8;
+ public NodeToken f9;
+ public StmtList f10;
+ public NodeToken f11;
+
+ public Procedure(Label n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, NodeToken n4, IntegerLiteral n5, NodeToken n6, NodeToken n7, IntegerLiteral n8, NodeToken n9, StmtList n10, NodeToken n11) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ }
+
+ public Procedure(Label n0, IntegerLiteral n1, IntegerLiteral n2, IntegerLiteral n3, StmtList n4) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = new NodeToken("[");
+ f5 = n2;
+ f6 = new NodeToken("]");
+ f7 = new NodeToken("[");
+ f8 = n3;
+ f9 = new NodeToken("]");
+ f10 = n4;
+ f11 = new NodeToken("END");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Reg.java b/src/kanga/syntaxtree/Reg.java new file mode 100644 index 0000000..0f1bcbd --- /dev/null +++ b/src/kanga/syntaxtree/Reg.java @@ -0,0 +1,54 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * 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 class Reg implements Node {
+ public NodeChoice f0;
+
+ public Reg(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/SimpleExp.java b/src/kanga/syntaxtree/SimpleExp.java new file mode 100644 index 0000000..51343aa --- /dev/null +++ b/src/kanga/syntaxtree/SimpleExp.java @@ -0,0 +1,33 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class SimpleExp implements Node {
+ public NodeChoice f0;
+
+ public SimpleExp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/SpilledArg.java b/src/kanga/syntaxtree/SpilledArg.java new file mode 100644 index 0000000..75b9416 --- /dev/null +++ b/src/kanga/syntaxtree/SpilledArg.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+public class SpilledArg implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+
+ public SpilledArg(NodeToken n0, IntegerLiteral n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public SpilledArg(IntegerLiteral n0) {
+ f0 = new NodeToken("SPILLEDARG");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Stmt.java b/src/kanga/syntaxtree/Stmt.java new file mode 100644 index 0000000..bb9b396 --- /dev/null +++ b/src/kanga/syntaxtree/Stmt.java @@ -0,0 +1,42 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+public class Stmt implements Node {
+ public NodeChoice f0;
+
+ public Stmt(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/StmtList.java b/src/kanga/syntaxtree/StmtList.java new file mode 100644 index 0000000..e8d350e --- /dev/null +++ b/src/kanga/syntaxtree/StmtList.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
|