summaryrefslogtreecommitdiff
path: root/src/semanticanalysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/semanticanalysis')
-rw-r--r--src/semanticanalysis/STentry.java6
-rw-r--r--src/semanticanalysis/SymbolTable.java15
2 files changed, 21 insertions, 0 deletions
diff --git a/src/semanticanalysis/STentry.java b/src/semanticanalysis/STentry.java
index 0e4b00e..07b62c8 100644
--- a/src/semanticanalysis/STentry.java
+++ b/src/semanticanalysis/STentry.java
@@ -52,4 +52,10 @@ public class STentry {
return label;
}
+ @Override
+ public String toString() {
+ // Print all the fields of the STentry
+ return "Type: " + type + ", Offset: " + offset + ", Nesting: " + nesting + ", Label: " + label;
+ }
+
}
diff --git a/src/semanticanalysis/SymbolTable.java b/src/semanticanalysis/SymbolTable.java
index 617b48a..6756ec4 100644
--- a/src/semanticanalysis/SymbolTable.java
+++ b/src/semanticanalysis/SymbolTable.java
@@ -153,4 +153,19 @@ public class SymbolTable {
this.offset.add(offs);
}
+ @Override
+ public String toString() {
+ // Print the symbol table
+ String str = "";
+ for (int i = 0; i < this.symbolTable.size(); i++) {
+ str += "Level " + i + "\n";
+ HashMap<String, STentry> H = this.symbolTable.get(i);
+ for (String key : H.keySet()) {
+ STentry T = H.get(key);
+ str += key + " -> " + T.toString() + "\n";
+ }
+ }
+ return str;
+ }
+
}