47 |
47 |
48 |
48 |
49 |
49 |
50 |
50 |
51 /* The base class of all symbols */ |
51 /* The base class of all symbols */ |
52 symbol_c::symbol_c(void) { |
52 symbol_c::symbol_c( |
53 this->first_line = 0; |
53 int first_line, int first_column, const char *ffile, long int first_order, |
54 this->first_column = 0; |
54 int last_line, int last_column, const char *lfile, long int last_order ) { |
55 this->last_line = 0; |
55 this->first_file = ffile, |
56 this->last_column = 0; |
|
57 } |
|
58 |
|
59 symbol_c::symbol_c(int first_line, int first_column, int last_line, int last_column) { |
|
60 this->first_line = first_line; |
56 this->first_line = first_line; |
61 this->first_column = first_column; |
57 this->first_column = first_column; |
|
58 this->first_order = first_order; |
|
59 this->last_file = lfile, |
62 this->last_line = last_line; |
60 this->last_line = last_line; |
63 this->last_column = last_column; |
61 this->last_column = last_column; |
64 } |
62 this->last_order = last_order; |
65 |
63 } |
66 |
64 |
67 |
65 |
68 token_c::token_c(const char *value, int fl, int fc, int ll, int lc) |
66 |
69 :symbol_c(fl, fc, ll, lc) { |
67 token_c::token_c(const char *value, |
|
68 int fl, int fc, const char *ffile, long int forder, |
|
69 int ll, int lc, const char *lfile, long int lorder) |
|
70 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { |
70 this->value = value; |
71 this->value = value; |
71 // printf("New token: %s\n", value); |
72 // printf("New token: %s\n", value); |
72 } |
73 } |
73 |
74 |
74 |
75 |
75 |
76 |
76 |
77 |
77 |
78 |
78 |
79 |
79 list_c::list_c(int fl, int fc, int ll, int lc) |
80 list_c::list_c( |
80 :symbol_c(fl, fc, ll, lc) { |
81 int fl, int fc, const char *ffile, long int forder, |
|
82 int ll, int lc, const char *lfile, long int lorder) |
|
83 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { |
81 n = 0; |
84 n = 0; |
82 elements = NULL; |
85 elements = NULL; |
83 } |
86 } |
84 |
87 |
85 list_c::list_c(symbol_c *elem, int fl, int fc, int ll, int lc) |
88 list_c::list_c(symbol_c *elem, |
86 :symbol_c(fl, fc, ll, lc) { |
89 int fl, int fc, const char *ffile, long int forder, |
|
90 int ll, int lc, const char *lfile, long int lorder) |
|
91 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { |
87 n = 0; |
92 n = 0; |
88 elements = NULL; |
93 elements = NULL; |
89 add_element(elem); |
94 add_element(elem); |
90 } |
95 } |
91 |
96 |
121 } |
126 } |
122 |
127 |
123 |
128 |
124 |
129 |
125 |
130 |
126 #define SYM_LIST(class_name_c) \ |
131 #define SYM_LIST(class_name_c) \ |
127 class_name_c::class_name_c(int fl, int fc, int ll, int lc) \ |
132 class_name_c::class_name_c( \ |
128 :list_c(fl, fc, ll, lc) {} \ |
133 int fl, int fc, const char *ffile, long int forder, \ |
129 class_name_c::class_name_c(symbol_c *elem, int fl, int fc, int ll, int lc) \ |
134 int ll, int lc, const char *lfile, long int lorder) \ |
130 :list_c(elem, fl, fc, ll, lc) {} \ |
135 :list_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {} \ |
131 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
136 class_name_c::class_name_c(symbol_c *elem, \ |
132 |
137 int fl, int fc, const char *ffile, long int forder, \ |
133 #define SYM_TOKEN(class_name_c) \ |
138 int ll, int lc, const char *lfile, long int lorder) \ |
134 class_name_c::class_name_c(const char *value, int fl, int fc, int ll, int lc) \ |
139 :list_c(elem, fl, fc, ffile, forder, ll, lc, lfile, lorder) {} \ |
135 :token_c(value, fl, fc, ll, lc) {} \ |
140 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
136 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
141 |
137 |
142 #define SYM_TOKEN(class_name_c) \ |
138 #define SYM_REF0(class_name_c) \ |
143 class_name_c::class_name_c(const char *value, \ |
139 class_name_c::class_name_c(int fl, int fc, \ |
144 int fl, int fc, const char *ffile, long int forder, \ |
140 int ll, int lc \ |
145 int ll, int lc, const char *lfile, long int lorder) \ |
141 ): symbol_c(fl, fc, ll, lc) {} \ |
146 :token_c(value, fl, fc, ffile, forder, ll, lc, lfile, lorder) {} \ |
142 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
147 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
143 |
148 |
144 |
149 #define SYM_REF0(class_name_c) \ |
145 #define SYM_REF1(class_name_c, ref1) \ |
150 class_name_c::class_name_c( \ |
146 class_name_c::class_name_c(symbol_c *ref1, \ |
151 int fl, int fc, const char *ffile, long int forder, \ |
147 int fl, int fc, \ |
152 int ll, int lc, const char *lfile, long int lorder) \ |
148 int ll, int lc \ |
153 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {} \ |
149 ): symbol_c(fl, fc, ll, lc) { \ |
154 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
150 this->ref1 = ref1; \ |
155 |
151 } \ |
156 |
152 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
157 #define SYM_REF1(class_name_c, ref1) \ |
153 |
158 class_name_c::class_name_c(symbol_c *ref1, \ |
154 |
159 int fl, int fc, const char *ffile, long int forder, \ |
155 #define SYM_REF2(class_name_c, ref1, ref2) \ |
160 int ll, int lc, const char *lfile, long int lorder) \ |
156 class_name_c::class_name_c(symbol_c *ref1, \ |
161 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
157 symbol_c *ref2, \ |
162 this->ref1 = ref1; \ |
158 int fl, int fc, \ |
163 } \ |
159 int ll, int lc \ |
164 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
160 ): symbol_c(fl, fc, ll, lc) { \ |
165 |
161 this->ref1 = ref1; \ |
166 |
162 this->ref2 = ref2; \ |
167 #define SYM_REF2(class_name_c, ref1, ref2) \ |
163 } \ |
168 class_name_c::class_name_c(symbol_c *ref1, \ |
164 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
169 symbol_c *ref2, \ |
165 |
170 int fl, int fc, const char *ffile, long int forder, \ |
166 |
171 int ll, int lc, const char *lfile, long int lorder) \ |
167 #define SYM_REF3(class_name_c, ref1, ref2, ref3) \ |
172 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
168 class_name_c::class_name_c(symbol_c *ref1, \ |
173 this->ref1 = ref1; \ |
169 symbol_c *ref2, \ |
174 this->ref2 = ref2; \ |
170 symbol_c *ref3, \ |
175 } \ |
171 int fl, int fc, \ |
176 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
172 int ll, int lc \ |
177 |
173 ): symbol_c(fl, fc, ll, lc) { \ |
178 |
174 this->ref1 = ref1; \ |
179 #define SYM_REF3(class_name_c, ref1, ref2, ref3) \ |
175 this->ref2 = ref2; \ |
180 class_name_c::class_name_c(symbol_c *ref1, \ |
176 this->ref3 = ref3; \ |
181 symbol_c *ref2, \ |
177 } \ |
182 symbol_c *ref3, \ |
178 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
183 int fl, int fc, const char *ffile, long int forder, \ |
179 |
184 int ll, int lc, const char *lfile, long int lorder) \ |
180 |
185 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
181 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4) \ |
186 this->ref1 = ref1; \ |
182 class_name_c::class_name_c(symbol_c *ref1, \ |
187 this->ref2 = ref2; \ |
183 symbol_c *ref2, \ |
188 this->ref3 = ref3; \ |
184 symbol_c *ref3, \ |
189 } \ |
185 symbol_c *ref4, \ |
190 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
186 int fl, int fc, \ |
191 |
187 int ll, int lc \ |
192 |
188 ): symbol_c(fl, fc, ll, lc) { \ |
193 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4) \ |
189 this->ref1 = ref1; \ |
194 class_name_c::class_name_c(symbol_c *ref1, \ |
190 this->ref2 = ref2; \ |
195 symbol_c *ref2, \ |
191 this->ref3 = ref3; \ |
196 symbol_c *ref3, \ |
192 this->ref4 = ref4; \ |
197 symbol_c *ref4, \ |
193 } \ |
198 int fl, int fc, const char *ffile, long int forder, \ |
194 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
199 int ll, int lc, const char *lfile, long int lorder) \ |
195 |
200 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
196 |
201 this->ref1 = ref1; \ |
197 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5) \ |
202 this->ref2 = ref2; \ |
198 class_name_c::class_name_c(symbol_c *ref1, \ |
203 this->ref3 = ref3; \ |
199 symbol_c *ref2, \ |
204 this->ref4 = ref4; \ |
200 symbol_c *ref3, \ |
205 } \ |
201 symbol_c *ref4, \ |
206 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
202 symbol_c *ref5, \ |
207 |
203 int fl, int fc, \ |
208 |
204 int ll, int lc \ |
209 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5) \ |
205 ): symbol_c(fl, fc, ll, lc) { \ |
210 class_name_c::class_name_c(symbol_c *ref1, \ |
206 this->ref1 = ref1; \ |
211 symbol_c *ref2, \ |
207 this->ref2 = ref2; \ |
212 symbol_c *ref3, \ |
208 this->ref3 = ref3; \ |
213 symbol_c *ref4, \ |
209 this->ref4 = ref4; \ |
214 symbol_c *ref5, \ |
210 this->ref5 = ref5; \ |
215 int fl, int fc, const char *ffile, long int forder, \ |
211 } \ |
216 int ll, int lc, const char *lfile, long int lorder) \ |
212 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
217 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
213 |
218 this->ref1 = ref1; \ |
214 |
219 this->ref2 = ref2; \ |
215 |
220 this->ref3 = ref3; \ |
216 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6) \ |
221 this->ref4 = ref4; \ |
217 class_name_c::class_name_c(symbol_c *ref1, \ |
222 this->ref5 = ref5; \ |
218 symbol_c *ref2, \ |
223 } \ |
219 symbol_c *ref3, \ |
224 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
220 symbol_c *ref4, \ |
225 |
221 symbol_c *ref5, \ |
226 |
222 symbol_c *ref6, \ |
227 |
223 int fl, int fc, \ |
228 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6) \ |
224 int ll, int lc \ |
229 class_name_c::class_name_c(symbol_c *ref1, \ |
225 ): symbol_c(fl, fc, ll, lc) { \ |
230 symbol_c *ref2, \ |
226 this->ref1 = ref1; \ |
231 symbol_c *ref3, \ |
227 this->ref2 = ref2; \ |
232 symbol_c *ref4, \ |
228 this->ref3 = ref3; \ |
233 symbol_c *ref5, \ |
229 this->ref4 = ref4; \ |
234 symbol_c *ref6, \ |
230 this->ref5 = ref5; \ |
235 int fl, int fc, const char *ffile, long int forder, \ |
231 this->ref6 = ref6; \ |
236 int ll, int lc, const char *lfile, long int lorder) \ |
232 } \ |
237 :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) { \ |
|
238 this->ref1 = ref1; \ |
|
239 this->ref2 = ref2; \ |
|
240 this->ref3 = ref3; \ |
|
241 this->ref4 = ref4; \ |
|
242 this->ref5 = ref5; \ |
|
243 this->ref6 = ref6; \ |
|
244 } \ |
233 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
245 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);} |
234 |
246 |
235 |
247 |
236 |
248 |
237 #include "absyntax.def" |
249 #include "absyntax.def" |