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/spiglet/syntaxtree | |
download | minijava-748308e11e6791284b302f61e5bc0d99a0957b6a.tar.xz |
First commit
Diffstat (limited to 'src/spiglet/syntaxtree')
30 files changed, 1219 insertions, 0 deletions
diff --git a/src/spiglet/syntaxtree/BinOp.java b/src/spiglet/syntaxtree/BinOp.java new file mode 100644 index 0000000..9d8b9ec --- /dev/null +++ b/src/spiglet/syntaxtree/BinOp.java @@ -0,0 +1,37 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Temp f1;
+ public SimpleExp f2;
+
+ public BinOp(Operator n0, Temp n1, SimpleExp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/CJumpStmt.java b/src/spiglet/syntaxtree/CJumpStmt.java new file mode 100644 index 0000000..9bee49f --- /dev/null +++ b/src/spiglet/syntaxtree/CJumpStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Temp n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Temp n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Call.java b/src/spiglet/syntaxtree/Call.java new file mode 100644 index 0000000..ba64469 --- /dev/null +++ b/src/spiglet/syntaxtree/Call.java @@ -0,0 +1,51 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+public class Call implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Call(NodeToken n0, SimpleExp n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Call(SimpleExp n0, NodeListOptional n1) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ f2 = new NodeToken("(");
+ f3 = n1;
+ f4 = new NodeToken(")");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/ErrorStmt.java b/src/spiglet/syntaxtree/ErrorStmt.java new file mode 100644 index 0000000..3f1ff3f --- /dev/null +++ b/src/spiglet/syntaxtree/ErrorStmt.java @@ -0,0 +1,35 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Exp.java b/src/spiglet/syntaxtree/Exp.java new file mode 100644 index 0000000..41fd9ea --- /dev/null +++ b/src/spiglet/syntaxtree/Exp.java @@ -0,0 +1,34 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Goal.java b/src/spiglet/syntaxtree/Goal.java new file mode 100644 index 0000000..6e662d0 --- /dev/null +++ b/src/spiglet/syntaxtree/Goal.java @@ -0,0 +1,51 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HAllocate.java b/src/spiglet/syntaxtree/HAllocate.java new file mode 100644 index 0000000..61cdf0b --- /dev/null +++ b/src/spiglet/syntaxtree/HAllocate.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HLoadStmt.java b/src/spiglet/syntaxtree/HLoadStmt.java new file mode 100644 index 0000000..6d27be2 --- /dev/null +++ b/src/spiglet/syntaxtree/HLoadStmt.java @@ -0,0 +1,47 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Temp f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Temp n1, Temp n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Temp n0, Temp n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HStoreStmt.java b/src/spiglet/syntaxtree/HStoreStmt.java new file mode 100644 index 0000000..e4ac434 --- /dev/null +++ b/src/spiglet/syntaxtree/HStoreStmt.java @@ -0,0 +1,47 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public IntegerLiteral f2;
+ public Temp f3;
+
+ public HStoreStmt(NodeToken n0, Temp n1, IntegerLiteral n2, Temp n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Temp n0, IntegerLiteral n1, Temp n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/IntegerLiteral.java b/src/spiglet/syntaxtree/IntegerLiteral.java new file mode 100644 index 0000000..ec17808 --- /dev/null +++ b/src/spiglet/syntaxtree/IntegerLiteral.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/JumpStmt.java b/src/spiglet/syntaxtree/JumpStmt.java new file mode 100644 index 0000000..74f26d3 --- /dev/null +++ b/src/spiglet/syntaxtree/JumpStmt.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Label.java b/src/spiglet/syntaxtree/Label.java new file mode 100644 index 0000000..c05f209 --- /dev/null +++ b/src/spiglet/syntaxtree/Label.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/MoveStmt.java b/src/spiglet/syntaxtree/MoveStmt.java new file mode 100644 index 0000000..0eafce3 --- /dev/null +++ b/src/spiglet/syntaxtree/MoveStmt.java @@ -0,0 +1,43 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/NoOpStmt.java b/src/spiglet/syntaxtree/NoOpStmt.java new file mode 100644 index 0000000..a7d6514 --- /dev/null +++ b/src/spiglet/syntaxtree/NoOpStmt.java @@ -0,0 +1,35 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Node.java b/src/spiglet/syntaxtree/Node.java new file mode 100644 index 0000000..5a04ac3 --- /dev/null +++ b/src/spiglet/syntaxtree/Node.java @@ -0,0 +1,16 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree; + +/** + * The interface which all syntax tree classes must implement. + */ +public interface Node extends java.io.Serializable { + public void accept(spiglet.visitor.Visitor v); + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu); + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v); + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu); +} +
diff --git a/src/spiglet/syntaxtree/NodeChoice.java b/src/spiglet/syntaxtree/NodeChoice.java new file mode 100644 index 0000000..eb5b377 --- /dev/null +++ b/src/spiglet/syntaxtree/NodeChoice.java @@ -0,0 +1,36 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + choice.accept(v); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return choice.accept(v,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return choice.accept(v); + } + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) { + choice.accept(v,argu); + } + + public Node choice; + public int which; +} +
diff --git a/src/spiglet/syntaxtree/NodeList.java b/src/spiglet/syntaxtree/NodeList.java new file mode 100644 index 0000000..6126ec5 --- /dev/null +++ b/src/spiglet/syntaxtree/NodeList.java @@ -0,0 +1,45 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/spiglet/syntaxtree/NodeListInterface.java b/src/spiglet/syntaxtree/NodeListInterface.java new file mode 100644 index 0000000..1244586 --- /dev/null +++ b/src/spiglet/syntaxtree/NodeListInterface.java @@ -0,0 +1,22 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v); + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu); + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v); + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu); +} +
diff --git a/src/spiglet/syntaxtree/NodeListOptional.java b/src/spiglet/syntaxtree/NodeListOptional.java new file mode 100644 index 0000000..775f1ff --- /dev/null +++ b/src/spiglet/syntaxtree/NodeListOptional.java @@ -0,0 +1,46 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/spiglet/syntaxtree/NodeOptional.java b/src/spiglet/syntaxtree/NodeOptional.java new file mode 100644 index 0000000..01e83f2 --- /dev/null +++ b/src/spiglet/syntaxtree/NodeOptional.java @@ -0,0 +1,41 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + public boolean present() { return node != null; } + + public Node node; +} +
diff --git a/src/spiglet/syntaxtree/NodeSequence.java b/src/spiglet/syntaxtree/NodeSequence.java new file mode 100644 index 0000000..4ea40e0 --- /dev/null +++ b/src/spiglet/syntaxtree/NodeSequence.java @@ -0,0 +1,46 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + + public Vector<Node> nodes; +} +
diff --git a/src/spiglet/syntaxtree/NodeToken.java b/src/spiglet/syntaxtree/NodeToken.java new file mode 100644 index 0000000..ef5fd9a --- /dev/null +++ b/src/spiglet/syntaxtree/NodeToken.java @@ -0,0 +1,88 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(spiglet.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/spiglet/syntaxtree/Operator.java b/src/spiglet/syntaxtree/Operator.java new file mode 100644 index 0000000..c7f0a9e --- /dev/null +++ b/src/spiglet/syntaxtree/Operator.java @@ -0,0 +1,34 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/PrintStmt.java b/src/spiglet/syntaxtree/PrintStmt.java new file mode 100644 index 0000000..52db4d5 --- /dev/null +++ b/src/spiglet/syntaxtree/PrintStmt.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Procedure.java b/src/spiglet/syntaxtree/Procedure.java new file mode 100644 index 0000000..7c38b8f --- /dev/null +++ b/src/spiglet/syntaxtree/Procedure.java @@ -0,0 +1,51 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/SimpleExp.java b/src/spiglet/syntaxtree/SimpleExp.java new file mode 100644 index 0000000..155fd8a --- /dev/null +++ b/src/spiglet/syntaxtree/SimpleExp.java @@ -0,0 +1,33 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class SimpleExp implements Node {
+ public NodeChoice f0;
+
+ public SimpleExp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Stmt.java b/src/spiglet/syntaxtree/Stmt.java new file mode 100644 index 0000000..2b0ce88 --- /dev/null +++ b/src/spiglet/syntaxtree/Stmt.java @@ -0,0 +1,38 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/StmtExp.java b/src/spiglet/syntaxtree/StmtExp.java new file mode 100644 index 0000000..c3a495e --- /dev/null +++ b/src/spiglet/syntaxtree/StmtExp.java @@ -0,0 +1,51 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+public class StmtExp implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public SimpleExp f3;
+ public NodeToken f4;
+
+ public StmtExp(NodeToken n0, StmtList n1, NodeToken n2, SimpleExp n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public StmtExp(StmtList n0, SimpleExp n1) {
+ f0 = new NodeToken("BEGIN");
+ f1 = n0;
+ f2 = new NodeToken("RETURN");
+ f3 = n1;
+ f4 = new NodeToken("END");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/StmtList.java b/src/spiglet/syntaxtree/StmtList.java new file mode 100644 index 0000000..ef2fbb3 --- /dev/null +++ b/src/spiglet/syntaxtree/StmtList.java @@ -0,0 +1,31 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Temp.java b/src/spiglet/syntaxtree/Temp.java new file mode 100644 index 0000000..ea6cc24 --- /dev/null +++ b/src/spiglet/syntaxtree/Temp.java @@ -0,0 +1,39 @@ +// +// Generated by JTB 1.3.2 +//
+
+package spiglet.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(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
|