diff options
Diffstat (limited to 'Typecheck.java')
-rw-r--r-- | Typecheck.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/Typecheck.java b/Typecheck.java index 8c4559b..d153f7a 100644 --- a/Typecheck.java +++ b/Typecheck.java @@ -5,7 +5,7 @@ import syntaxtree.*; import java.util.*; import st.*; import misc.*; -import typecheck.*; +import heat.*; public class Typecheck { public static void main(String[] args) { @@ -17,27 +17,29 @@ public class Typecheck { // GJDepthFirst<R,A>. R=Void, A=String. PPrinter<Void,String> pp = new PPrinter<Void,String>(); root.accept(pp, ""); - MinimalLogger.info("==================================================="); // Build the symbol table. Top-down visitor, inherits from // GJDepthFirst<R,A>. R=Void, A=Integer. SymbolTable symt = new SymbolTable(); - root.accept(new SymTableBottomUp<Void>(), symt); - root.accept(new SymTableTopDown<Void>(), symt); - MinimalLogger.info("==================================================="); + MinimalLogger.info("Populating classes..."); + root.accept(new SymTableClasses<Void>(), symt); + MinimalLogger.info("Populating methods..."); + root.accept(new SymTableMethods<Void>(), symt); + MinimalLogger.info("Populating variables..."); + root.accept(new SymTableVars<Void>(), symt); + MinimalLogger.info("Populating extensions..."); + root.accept(new SymTableExtend<Void>(), symt); + MinimalLogger.info(symt.toString()); - TypeCheckSimp ts = new TypeCheckSimp(); - TypeInstance res = root.accept(ts, symt); + HeatVisitor hv = new HeatVisitor(symt); - // Ugly code not to be inspired from: "my" way of storing - // type info / typecheck property: if some of my internal - // structure is empty, then things don't typecheck for - // me. This is specific to my own implementation. - // if (res != null && res.type_array.size() > 0) - if (res.getType() != TypeEnum.ERROR) + try { + root.accept(hv, null); System.out.println("Program type checked successfully"); - else + } catch (TypecheckException e) { System.out.println("Type error"); + } + } catch (ParseException e) { System.out.println(e.toString()); |