summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-rw-r--r--st/SymTableTopDown.java4
-rw-r--r--st/SymbolTable.java4
2 files changed, 5 insertions, 3 deletions
diff --git a/st/SymTableTopDown.java b/st/SymTableTopDown.java
index a4c641c..2f65919 100644
--- a/st/SymTableTopDown.java
+++ b/st/SymTableTopDown.java
@@ -116,7 +116,9 @@ public class SymTableTopDown<R> extends GJDepthFirst<R,SymbolTable> {
* f2 -> ";"
*/
public R visit(VarDeclaration n, SymbolTable symt) {
- String cls = ((Identifier) n.f0.f0.choice).f0.tokenImage;
+ String cls = (n.f0.f0.which == 4) ?
+ ((Identifier) n.f0.f0.choice).f0.tokenImage :
+ null;
String id = n.f1.f0.tokenImage;
symt.addLocal(id);
symt.addClassInstance(id, cls);
diff --git a/st/SymbolTable.java b/st/SymbolTable.java
index 1c0af09..93d3af9 100644
--- a/st/SymbolTable.java
+++ b/st/SymbolTable.java
@@ -8,8 +8,8 @@ import java.util.*;
* of each symbol consistent.
*/
public class SymbolTable {
- private HashMap<String,AbstractInstance> symt; // the mapping of ids to Instances
- private HashMap<TypeEnum,String> active; // the current scope of the visitor (class, method)
+ private HashMap<String,AbstractInstance> symt; // the mapping of ids to Instances
+ private HashMap<TypeEnum,String> active; // the current scope of the visitor (class, method)
public SymbolTable() {
this.symt = new HashMap<>();