summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-rw-r--r--st/SymTableExtend.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/st/SymTableExtend.java b/st/SymTableExtend.java
new file mode 100644
index 0000000..2e634d8
--- /dev/null
+++ b/st/SymTableExtend.java
@@ -0,0 +1,44 @@
+package st;
+
+import syntaxtree.*;
+import visitor.*;
+import java.util.*;
+import misc.*;
+
+/**
+ * Performs a bottom-up preliminary visit through the AST
+ * initializing all ClassInstances and placing them in the passed ST
+ */
+public class SymTableExtend<R> extends GJDepthFirst<R,SymbolTable> {
+
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public R visit(ClassExtendsDeclaration n, SymbolTable symt) {
+ String act = n.f1.f0.tokenImage;
+ symt.setActive(TypeEnum.classname, symt.getClass(act));
+ n.f0.accept(this, symt);
+ n.f1.accept(this, symt);
+ n.f2.accept(this, symt);
+ n.f3.accept(this, symt);
+ n.f4.accept(this, symt);
+ n.f5.accept(this, symt);
+ n.f6.accept(this, symt);
+ n.f7.accept(this, symt);
+
+
+ symt.setExtend(n.f3.f0.tokenImage);
+
+
+ return null;
+ }
+
+}