package minijava; import syntaxtree.*; import visitor.*; 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 implements GJVisitor { public HashMap symt = new HashMap<>(); private void print_filter(String message) { boolean debug = true; if (debug) System.out.println(message); } public R visit(VarDeclaraction n, A argu) { R _ret=null; this.print_filter("Processing declaration"); String type = ""; switch (n.f0.f0.which) { case 2: type = "Int"; break; default: this.print_filter("Unsupported case"); } String id = n.f1.f0.tokenImage; this.printfilter("Inserting " + id + " => " + type); // Safe? symt.put(id, type); return _ret; } }