summaryrefslogtreecommitdiff
path: root/src/kanga/kanga2mips
diff options
context:
space:
mode:
Diffstat (limited to 'src/kanga/kanga2mips')
-rw-r--r--src/kanga/kanga2mips/KangaSym.java24
-rw-r--r--src/kanga/kanga2mips/Main.java5
2 files changed, 27 insertions, 2 deletions
diff --git a/src/kanga/kanga2mips/KangaSym.java b/src/kanga/kanga2mips/KangaSym.java
new file mode 100644
index 0000000..2b49e3c
--- /dev/null
+++ b/src/kanga/kanga2mips/KangaSym.java
@@ -0,0 +1,24 @@
+package kanga.kanga2mips;
+
+public class KangaSym {
+ public enum Type { HALLOC, BINOP, SIMPLE };
+ public enum SimpleType { REG, INT, LABEL };
+
+ public Type e_type;
+ public SimpleType s_type;
+ public int value; // for integer simple type
+ public int binop; // Binary operator
+ public String name; // for register or label name
+ public String name2; // for second oprand
+ public KangaSym oprand2; // for second oprand
+
+ public KangaSym(Type t) {
+ e_type = t;
+ }
+
+ public KangaSym(Type t, SimpleType s) {
+ e_type = t;
+ s_type = s;
+ }
+
+}
diff --git a/src/kanga/kanga2mips/Main.java b/src/kanga/kanga2mips/Main.java
index 7b5a49c..d57fa77 100644
--- a/src/kanga/kanga2mips/Main.java
+++ b/src/kanga/kanga2mips/Main.java
@@ -5,6 +5,7 @@ import kanga.ParseException;
import kanga.TokenMgrError;
import kanga.syntaxtree.Node;
import kanga.visitor.GJDepthFirst;
+import kanga.visitor.GenMIPSVisitor;
public class Main {
@@ -14,10 +15,10 @@ public class Main {
/*
* TODO: Implement your own Visitors and other classes.
*/
- GJDepthFirst v = new GJDepthFirst<Object, Object>() {
- };
+ GenMIPSVisitor v = new GenMIPSVisitor();
// Traverse the Abstract Grammar Tree
root.accept(v, null);
+ v.prn.printAll();
} catch (TokenMgrError e) {
// Handle Lexical Errors
e.printStackTrace();