diff options
author | L0P0P <grassoemanuele@live.com> | 2024-06-26 11:44:58 +0200 |
---|---|---|
committer | L0P0P <grassoemanuele@live.com> | 2024-06-26 11:44:58 +0200 |
commit | 9e6c17cb44bc165e315ec039a0e09183716d2037 (patch) | |
tree | 4a64fd37fa9b2483b88a5f33a37c6b9b51812d81 /src/semanticanalysis | |
parent | fc712f94a7ed8554d8d44f4965be367354a7e670 (diff) |
Semantic check for function declaration and function invocation
Diffstat (limited to 'src/semanticanalysis')
-rw-r--r-- | src/semanticanalysis/STentry.java | 6 | ||||
-rw-r--r-- | src/semanticanalysis/SymbolTable.java | 15 |
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; + } + } |