-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbolTableModified.java
More file actions
45 lines (40 loc) · 1.5 KB
/
Copy pathSymbolTableModified.java
File metadata and controls
45 lines (40 loc) · 1.5 KB
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
45
import syntaxtree.*;
import java.util.HashMap;
public class SymbolTableModified {
public MainClass mainClass;
public String mainClassName;
public HashMap<String,ClassDecl> classes = new HashMap<String, ClassDecl>();
public HashMap<String,String> methods = new HashMap<String, String>();
public HashMap<String,VarDecl> variables = new HashMap<String, VarDecl>() ;
public HashMap<String,Formal> formals = new HashMap<String, Formal>() ;
public HashMap<String,String> typeName = new HashMap<String, String>();
public SymbolTableModified() {
}
public String toString(){
String result="";
if (mainClass!=null){
result = "\nMain Class:\n "+ mainClassName+":"+mainClass.toString() + "\n";
result += "\nClasses: \n";
}
if (classes !=null){
for (String key : classes.keySet()) {
result += key + ": "+ classes.get(key).toString() + ", \n";
}
}
result += "\nMethods: \n";
for (String key : methods.keySet()) {
result += key + ": "+ methods.get(key) + ", \n";
}
result += "\n";
result += "Variables: \n";
for (String key : variables.keySet()) {
result += key + ": " + variables.get(key).toString() + ", \n";
}
result += "\n";
result += "TypeNames: \n";
for (String key : typeName.keySet()) {
result += key + ": "+ typeName.get(key) + ",\n ";
}
return result;
}
}