diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-03-17 21:37:38 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-03-17 21:37:38 -0600 |
commit | acb209e4bef36186744ee09c67fcad77550e78d2 (patch) | |
tree | 85e27346b897200f2c06ee74b27ad6d2c798065b /minijava/SymTableVis.java | |
parent | 6a24c69232901de51f50beab9c3d3b3760dee334 (diff) |
Pretty printing for TypeCheckSimp, start for symbol table
Diffstat (limited to 'minijava/SymTableVis.java')
-rw-r--r-- | minijava/SymTableVis.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/minijava/SymTableVis.java b/minijava/SymTableVis.java index 3d8003b..e0854f0 100644 --- a/minijava/SymTableVis.java +++ b/minijava/SymTableVis.java @@ -8,9 +8,9 @@ import java.util.*; * Provides default methods which visit each node in the tree in depth-first * order. Your visitors may extend this class. */ -public class SymTableVis<R,A> implements GJVisitor<R,A> { +public class SymTableVis<R,A> extends GJDepthFirst<R,A> { - public HashMap<String,String> symt = new HashMap<>(); + public HashMap<String,TypeEnum> symt = new HashMap<>(); private void print_filter(String message) { boolean debug = true; @@ -18,26 +18,30 @@ public class SymTableVis<R,A> implements GJVisitor<R,A> { System.out.println(message); } - public R visit(VarDeclaraction n, A argu) { - R _ret=null; + /** + * f0 -> Type() + * f1 -> Identifier() + * f2 -> ";" + */ + public R visit(VarDeclaration n, A argu) { this.print_filter("Processing declaration"); - String type = ""; + TypeEnum type = TypeEnum.ERROR; switch (n.f0.f0.which) { case 2: - type = "Int"; break; + type = TypeEnum.integer; break; default: this.print_filter("Unsupported case"); } String id = n.f1.f0.tokenImage; - this.printfilter("Inserting " + id + " => " + type); + this.print_filter("Inserting " + id + " => " + type); // Safe? symt.put(id, type); - return _ret; + return null; } } |