-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArgdeclList.java
31 lines (25 loc) · 881 Bytes
/
ArgdeclList.java
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
class ArgdeclList extends SuperToken implements Token{
Argdecl argdecl;
ArgdeclList argdeclList;
public ArgdeclList(Argdecl argdecl, ArgdeclList argdeclList){
this.argdecl = argdecl;
this.argdeclList = argdeclList;
}
public ArgdeclList(Argdecl argdecl){
this.argdecl = argdecl;
this.argdeclList = null;
}
public String toString(int t){
if (argdecl == null && argdeclList == null)
return "";
return argdecl.toString(t) + (argdeclList == null ? "" : ", " + argdeclList.toString(t));
}
public void typeCheck(String fnName) throws Exception{
if (argdecl != null) {
VarType argType = argdecl.typeCheck();
symbolTable.findVar(fnName).methodArgs.add(argType);
}
if (argdeclList != null)
argdeclList.typeCheck(fnName);
}
}