import java.io.*; import visitor.*; import parse.*; import syntaxtree.*; import java.util.*; import st.*; import misc.*; import heat.*; public class Typecheck { public static void main(String[] args) { Node root = null; try { root = new MiniJavaParser(System.in).Goal(); // Pretty-print the tree. PPrinter inherits from // GJDepthFirst. R=Void, A=String. PPrinter pp = new PPrinter(); root.accept(pp, ""); // Build the symbol table. Top-down visitor, inherits from // GJDepthFirst. R=Void, A=Integer. try { SymbolTable symt = new SymbolTable(); MinimalLogger.info("Populating classes..."); root.accept(new SymTableClasses(), symt); MinimalLogger.info("Populating methods..."); root.accept(new SymTableMethods(), symt); MinimalLogger.info("Populating variables..."); root.accept(new SymTableVars(), symt); MinimalLogger.info("Populating extensions..."); root.accept(new SymTableExtend(), symt); MinimalLogger.info(symt.toString()); HeatVisitor hv = new HeatVisitor(symt); root.accept(hv, null); System.out.println("Program type checked successfully"); } catch (TypecheckException e) { System.out.println("Type error"); MinimalLogger.severe(String.format("Reason: %s", e.toString())); } } catch (ParseException e) { System.out.println(e.toString()); System.exit(1); } } }