summaryrefslogtreecommitdiff
path: root/typecheck/library/SymTableVis.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-03-27 22:53:08 -0600
committerbd-912 <bdunahu@colostate.edu>2024-03-27 22:53:08 -0600
commitb01fe1e8e5541d6c11f905d7fbb949d747f29230 (patch)
treed348b6b471fa2ebb2cece61daaf672c8b27b4299 /typecheck/library/SymTableVis.java
parent8131ddc22af5d39114a55349d71bcdc467599187 (diff)
SymbolTable to separate library, Class/Method Instances
Diffstat (limited to 'typecheck/library/SymTableVis.java')
-rw-r--r--typecheck/library/SymTableVis.java101
1 files changed, 0 insertions, 101 deletions
diff --git a/typecheck/library/SymTableVis.java b/typecheck/library/SymTableVis.java
deleted file mode 100644
index 615b1c9..0000000
--- a/typecheck/library/SymTableVis.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package typecheck.library;
-
-import syntaxtree.*;
-import visitor.*;
-import java.util.*;
-
-/**
- * Provides default methods which visit each node in the tree in depth-first
- * order. Your visitors may extend this class.
- */
-public class SymTableVis<R,A> extends GJDepthFirst<R,A> {
-
- public HashMap<String,TypeInstance> symt = new HashMap<>();
-
- /**
- * f0 -> "class"
- * f1 -> Identifier()
- * f2 -> "{"
- * f3 -> "public"
- * f4 -> "static"
- * f5 -> "void"
- * f6 -> "main"
- * f7 -> "("
- * f8 -> "String"
- * f9 -> "["
- * f10 -> "]"
- * f11 -> Identifier()
- * f12 -> ")"
- * f13 -> "{"
- * f14 -> ( VarDeclaration() )*
- * f15 -> ( Statement() )*
- * f16 -> "}"
- * f17 -> "}"
- */
- public R visit(MainClass n, A argu) {
-
- n.f1.accept(this, argu);
- n.f11.accept(this, argu);
- n.f14.accept(this, argu);
- n.f15.accept(this, argu);
-
- Utilities.print_filter("Processing main", true);
-
- String id = n.f1.f0.tokenImage;
-
- TypeInstance type = new TypeInstance(id, TypeEnum.classname);
- Utilities.print_filter("Inserting " + id + " => " + type, true);
- symt.put(id, type);
-
- return null;
-
- }
-
- /**
- * f0 -> Type()
- * f1 -> Identifier()
- * f2 -> ";"
- */
- public R visit(VarDeclaration n, A argu) {
-
- Utilities.print_filter("Processing declaration", true);
-
- String id = n.f1.f0.tokenImage;
- TypeInstance type = new TypeInstance("ERROR", TypeEnum.ERROR);
- switch (n.f0.f0.which) {
- case 0:
- type = new TypeInstance("int_array", TypeEnum.int_array); break;
- case 1:
- type = new TypeInstance("bool", TypeEnum.bool); break;
- case 2:
- type = new TypeInstance("int", TypeEnum.integer); break;
- case 3:
- type = new TypeInstance(id, TypeEnum.classname); break;
- default:
- Utilities.print_filter("Unsupported case", true);
- }
-
- Utilities.print_filter("Inserting " + id + " => " + type, true);
- // Safe?
- symt.put(id, type);
-
- return null;
- }
-
- public R visit(ClassDeclaration n, A argu) {
-
- Utilities.print_filter("Processing class", true);
-
- String id = n.f1.f0.tokenImage;
-
- TypeInstance type = new TypeInstance(id, TypeEnum.classname);
- Utilities.print_filter("Inserting " + id + " => " + type, true);
- // Safe?
- symt.put(id, type);
-
- return null;
-
- }
-
-
-}