// StaticTypeCheck.java import java.util.*; // Static type checking for Jay is defined by the functions // V and the auxiliary functions typing and typeOf. These // functions use the classes in the Abstract Syntax of Jay. class TypeMap extends Hashtable { // TypeMap is implemented as a Java Hashtable. // It has a 'display' method added to facilitate experimentation. public void display () { System.out.print("{ "); for (Enumeration e = this.keys(); e.hasMoreElements(); ) { Variable key = (Variable)e.nextElement(); Type t = (Type)this.get(key); System.out.print("<" + key.id + ", " + t.id + ">"); if (e.hasMoreElements()) System.out.print(", "); } System.out.println(" }"); } } class StaticTypeCheck { public TypeMap typing (Declarations d) { // put the variables and their types into a new // Dictionary (symbol table) and return it. TypeMap map = new TypeMap(); for (int i=0; i