summaryrefslogtreecommitdiff
path: root/Typecheck.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-06 21:39:15 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-06 21:39:15 -0600
commit1eac68a0e5fd00ee563ac43cb6f4dac3a4fb2c33 (patch)
tree5cf93e6f94a0adb8d6821968a0710d8c599eea34 /Typecheck.java
parentbb8d3aff71f8f89bed2ab94f382675a2312b1893 (diff)
Added SymTableFirst, the completed first visitor
Diffstat (limited to 'Typecheck.java')
-rw-r--r--Typecheck.java33
1 files changed, 14 insertions, 19 deletions
diff --git a/Typecheck.java b/Typecheck.java
index 23f2efc..070b71e 100644
--- a/Typecheck.java
+++ b/Typecheck.java
@@ -21,28 +21,23 @@ public class Typecheck {
// Build the symbol table. Top-down visitor, inherits from
// GJDepthFirst<R,A>. R=Void, A=Integer.
- SymTableVis pv = new SymTableVis();
- root.accept(pv, new ArrayList<TypeInstance>());
- HashMap<String, AbstractInstance> symt = pv.symt;
+ SymbolTable st = new SymbolTable();
+ root.accept(new SymTableFirst<Void>(), st);
+ // root.accept(new SymTableSecond(), st);
PrintFilter.print("===================================================", true);
- // Do type checking. Bottom-up visitor, also inherits from
- // GJDepthFirst. Visit functions return MyTpe (=R), and
- // take a symbol table (HashMap<String,String>) as
- // argument (=A). You may implement things differently of
- // course!
- TypeCheckSimp ts = new TypeCheckSimp();
- TypeInstance res = root.accept(ts, symt);
+ // TypeCheckSimp ts = new TypeCheckSimp();
+ // TypeInstance res = root.accept(ts, 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.get_type() != TypeEnum.ERROR)
- System.out.println("Program type checked successfully");
- else
- System.out.println("Type error");
+ // // 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.get_type() != TypeEnum.ERROR)
+ // System.out.println("Program type checked successfully");
+ // else
+ // System.out.println("Type error");
}
catch (ParseException e) {
System.out.println(e.toString());