When writing your typechecker you need to construct visitor that returns a String. In order to facilitate the generation of code later, I recommend that you also store the actual type inside each abstract syntax node. I did this by adding the following field to baseinfo, which is inherited by every node: String mjtype = "void"; // "void" is just the convenient default type Now, whatever type you decide to return after a visit, you should also set this variable to the same value. For example: public String visit(lessthanexp x) { String t1 = x.e1.accept(this); String t2 = x.e2.accept(this); if (!t1.equals("int") || !t2.equals("int")) report("malformed arithmetic expression",x.line); x.mjtype = "boolean"; return "boolean"; } Now when you compile a callexp, you nolonger have to lookup the symbol table, all you have to say is: String classname = x.e1.mjtype;