-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsymbol.cpp
More file actions
42 lines (36 loc) · 1.06 KB
/
symbol.cpp
File metadata and controls
42 lines (36 loc) · 1.06 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
#include "symbol.h"
void Symbol::print_symbol(){
if(type == STRING){
cout << gpl_type_to_string(type) << " " << name << " = \"" << value->s << "\"" << endl;
}
else if (type == INT_ARRAY){
for(int i = 0; i < value->length; i++){
cout << gpl_type_to_base_string(type) << " " << name << "[" << i << "] = " << value->ia[i] << endl;
}
}
else if (type == DOUBLE_ARRAY){
for(int i = 0; i < value->length; i++){
cout << gpl_type_to_base_string(type) << " " << name << "[" << i << "] = " << value->da[i] << endl;
}
}
else if (type == STRING_ARRAY){
for(int i = 0; i < value->length; i++){
cout << gpl_type_to_base_string(type) << " " << name << "[" << i << "] = \"" << value->sa[i] << "\"" << endl;
}
}
else if (type == INT){
cout << gpl_type_to_string(type) << " " << name << " = " << value->i << endl;
}
else if (type == DOUBLE){
cout << gpl_type_to_string(type) << " " << name << " = " << value->d << endl;
}
}
string Symbol::get_name(){
return name;
}
Gpl_type Symbol::get_type(){
return type;
}
V* Symbol::get_value(){
return value;
}