blob: 2e634d83435307889938461d2cd462814fbbf37d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}
}
|