Debian Codegraph @

CodeLite/cpp_expr_parser.cpp

raw
1 #ifndef lint
2 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
3 #endif
4 #define YYBYACC 1
5 #define YYMAJOR 1
6 #define YYMINOR 9
7 #define yyclearin (yychar=(-1))
8 #define yyerrok (yyerrflag=0)
9 #define YYRECOVERING (yyerrflag!=0)
10 #define yyparse cl_expr_parse
11 #define yylex cl_expr_lex
12 #define yyerror cl_expr_error
13 #define yychar cl_expr_char
14 #define yyval cl_expr_val
15 #define yylval cl_expr_lval
16 #define yydebug cl_expr_debug
17 #define yynerrs cl_expr_nerrs
18 #define yyerrflag cl_expr_errflag
19 #define yyss cl_expr_ss
20 #define yyssp cl_expr_ssp
21 #define yyvs cl_expr_vs
22 #define yyvsp cl_expr_vsp
23 #define yylhs cl_expr_lhs
24 #define yylen cl_expr_len
25 #define yydefred cl_expr_defred
26 #define yydgoto cl_expr_dgoto
27 #define yysindex cl_expr_sindex
28 #define yyrindex cl_expr_rindex
29 #define yygindex cl_expr_gindex
30 #define yytable cl_expr_table
31 #define yycheck cl_expr_check
32 #define yyname cl_expr_name
33 #define yyrule cl_expr_rule
34 #define YYPREFIX "cl_expr_"
35 /* Copyright Eran Ifrah(c)*/
36 /*************** Includes and Defines *****************************/
37 #include "string"
38 #include "vector"
39 #include "stdio.h"
40 #include "map"
41 #include "expression_result.h"
42
43 #define YYSTYPE std::string
44 #define YYDEBUG 0 /* get the pretty debugging code to compile*/
45
46 void cl_expr_error(char *string);
47
48 static ExpressionResult result;
49
50 /*---------------------------------------------*/
51 /* externs defined in the lexer*/
52 /*---------------------------------------------*/
53 extern char *cl_expr_text;
54 extern int cl_expr_lex();
55 extern int cl_expr_parse();
56 extern int cl_expr_lineno;
57 extern std::vector<std::string> currentScope;
58 extern bool setExprLexerInput(const std::string &in);
59 extern void cl_expr_lex_clean();
60
61 /*************** Standard ytab.c continues here *********************/
62 #define LE_AUTO 257
63 #define LE_DOUBLE 258
64 #define LE_INT 259
65 #define LE_STRUCT 260
66 #define LE_BREAK 261
67 #define LE_ELSE 262
68 #define LE_LONG 263
69 #define LE_SWITCH 264
70 #define LE_CASE 265
71 #define LE_ENUM 266
72 #define LE_REGISTER 267
73 #define LE_TYPEDEF 268
74 #define LE_CHAR 269
75 #define LE_EXTERN 270
76 #define LE_RETURN 271
77 #define LE_UNION 272
78 #define LE_CONST 273
79 #define LE_FLOAT 274
80 #define LE_SHORT 275
81 #define LE_UNSIGNED 276
82 #define LE_BOOL 277
83 #define LE_CONTINUE 278
84 #define LE_FOR 279
85 #define LE_SIGNED 280
86 #define LE_VOID 281
87 #define LE_DEFAULT 282
88 #define LE_GOTO 283
89 #define LE_SIZEOF 284
90 #define LE_VOLATILE 285
91 #define LE_DO 286
92 #define LE_IF 287
93 #define LE_STATIC 288
94 #define LE_WHILE 289
95 #define LE_NEW 290
96 #define LE_DELETE 291
97 #define LE_THIS 292
98 #define LE_OPERATOR 293
99 #define LE_CLASS 294
100 #define LE_PUBLIC 295
101 #define LE_PROTECTED 296
102 #define LE_PRIVATE 297
103 #define LE_VIRTUAL 298
104 #define LE_FRIEND 299
105 #define LE_INLINE 300
106 #define LE_OVERLOAD 301
107 #define LE_OVERRIDE 302
108 #define LE_FINAL 303
109 #define LE_TEMPLATE 304
110 #define LE_TYPENAME 305
111 #define LE_THROW 306
112 #define LE_CATCH 307
113 #define LE_IDENTIFIER 308
114 #define LE_STRINGliteral 309
115 #define LE_FLOATINGconstant 310
116 #define LE_INTEGERconstant 311
117 #define LE_CHARACTERconstant 312
118 #define LE_OCTALconstant 313
119 #define LE_HEXconstant 314
120 #define LE_POUNDPOUND 315
121 #define LE_CComment 316
122 #define LE_CPPComment 317
123 #define LE_NAMESPACE 318
124 #define LE_USING 319
125 #define LE_TYPEDEFname 320
126 #define LE_ARROW 321
127 #define LE_ICR 322
128 #define LE_DECR 323
129 #define LE_LS 324
130 #define LE_RS 325
131 #define LE_LE 326
132 #define LE_GE 327
133 #define LE_EQ 328
134 #define LE_NE 329
135 #define LE_ANDAND 330
136 #define LE_OROR 331
137 #define LE_ELLIPSIS 332
138 #define LE_CLCL 333
139 #define LE_DOTstar 334
140 #define LE_ARROWstar 335
141 #define LE_MULTassign 336
142 #define LE_DIVassign 337
143 #define LE_MODassign 338
144 #define LE_PLUSassign 339
145 #define LE_MINUSassign 340
146 #define LE_LSassign 341
147 #define LE_RSassign 342
148 #define LE_ANDassign 343
149 #define LE_ERassign 344
150 #define LE_ORassign 345
151 #define LE_MACRO 346
152 #define LE_DYNAMIC_CAST 347
153 #define LE_STATIC_CAST 348
154 #define LE_CONST_CAST 349
155 #define LE_REINTERPRET_CAST 350
156 #define LE_SIZE_T 351
157 #define LE_TIME_T 352
158 #define YYERRCODE 256
159 short cl_expr_lhs[] = { -1,
160 0, 0, 3, 1, 1, 4, 4, 5, 5, 5,
161 5, 5, 5, 5, 5, 5, 5, 6, 6, 6,
162 6, 6, 7, 7, 7, 8, 8, 8, 2, 2,
163 2, 2, 2, 2, 14, 15, 15, 16, 16, 12,
164 12, 12, 12, 18, 18, 19, 19, 10, 11, 11,
165 11, 13, 13, 9, 9, 20, 17, 17,
166 };
167 short cl_expr_len[] = { 2,
168 0, 2, 0, 2, 1, 0, 1, 1, 1, 1,
169 1, 1, 1, 1, 1, 1, 1, 2, 2, 1,
170 2, 2, 0, 1, 3, 4, 4, 7, 6, 2,
171 3, 3, 5, 8, 2, 0, 3, 0, 1, 1,
172 1, 1, 1, 0, 1, 0, 2, 2, 0, 1,
173 1, 6, 3, 0, 2, 2, 0, 1,
174 };
175 short cl_expr_defred[] = { 1,
176 0, 5, 2, 0, 50, 51, 4, 0, 30, 40,
177 41, 42, 43, 0, 0, 0, 0, 54, 31, 0,
178 32, 0, 0, 55, 54, 0, 0, 58, 35, 56,
179 0, 0, 0, 0, 46, 7, 54, 0, 24, 39,
180 33, 0, 0, 53, 0, 0, 0, 0, 37, 29,
181 0, 47, 45, 48, 0, 13, 8, 0, 9, 12,
182 0, 0, 17, 0, 16, 0, 20, 46, 25, 46,
183 34, 22, 21, 11, 10, 15, 14, 18, 19, 0,
184 26, 27, 52, 0, 46, 28,
185 };
186 short cl_expr_dgoto[] = { 1,
187 3, 7, 4, 37, 67, 68, 38, 39, 26, 44,
188 8, 17, 27, 21, 32, 41, 29, 54, 45, 24,
189 };
190 short cl_expr_sindex[] = { 0,
191 -221, 0, 0, 3, 0, 0, 0, -17, 0, 0,
192 0, 0, 0, -3, -254, -264, -14, 0, 0, -16,
193 0, -87, 17, 0, 0, -227, 41, 0, 0, 0,
194 -175, 59, 40, -60, 0, 0, 0, -22, 0, 0,
195 0, 78, -175, 0, -11, -203, -189, -175, 0, 0,
196 -5, 0, 0, 0, 71, 0, 0, -138, 0, 0,
197 -138, -118, 0, -118, 0, -57, 0, 0, 0, 0,
198 0, 0, 0, 0, 0, 0, 0, 0, 0, -175,
199 0, 0, 0, 22, 0, 0,
200 };
201 short cl_expr_rindex[] = { 0,
202 -25, 0, 0, -21, 0, 0, 0, -195, 0, 0,
203 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
204 0, 5, 9, 0, 0, 0, 0, 0, 0, 0,
205 -42, 13, 0, -12, 0, 0, 0, 0, 0, 0,
206 0, 0, -42, 0, -34, 0, 0, -180, 0, 0,
207 0, 0, 0, 0, 0, 0, 0, -30, 0, 0,
208 14, 65, 0, 72, 0, 73, 0, 0, 0, 0,
209 0, 0, 0, 0, 0, 0, 0, 0, 0, -42,
210 0, 0, 0, 0, 0, 0,
211 };
212 short cl_expr_gindex[] = { 0,
213 0, 0, 0, 0, -46, 32, -32, 74, 16, 38,
214 0, 0, 99, -10, 0, 0, 0, 0, 0, 0,
215 };
216 #define YYTABLESIZE 363
217 short cl_expr_table[] = { 43,
218 57, 23, 80, 28, 57, 23, 44, 11, 36, 44,
219 51, 11, 38, 11, 3, 78, 3, 79, 49, 23,
220 49, 48, 14, 16, 15, 46, 53, 44, 46, 46,
221 52, 11, 3, 3, 2, 55, 18, 19, 48, 49,
222 57, 57, 57, 22, 57, 25, 57, 84, 36, 46,
223 36, 10, 47, 20, 38, 10, 70, 10, 57, 57,
224 6, 5, 57, 57, 57, 48, 36, 36, 56, 57,
225 38, 38, 46, 58, 28, 10, 31, 6, 6, 59,
226 34, 35, 6, 85, 60, 61, 62, 63, 6, 72,
227 64, 65, 73, 6, 6, 6, 6, 36, 40, 6,
228 6, 42, 15, 81, 20, 82, 15, 83, 15, 14,
229 46, 71, 54, 14, 46, 14, 46, 50, 66, 56,
230 57, 69, 86, 33, 58, 0, 15, 6, 0, 0,
231 59, 0, 0, 14, 46, 60, 61, 62, 63, 56,
232 57, 64, 65, 0, 74, 0, 0, 0, 0, 0,
233 59, 0, 0, 0, 0, 60, 75, 76, 63, 0,
234 0, 77, 65, 0, 0, 0, 0, 0, 0, 0,
235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 0, 6, 6, 0, 0, 0,
240 6, 0, 0, 0, 0, 0, 6, 0, 0, 0,
241 0, 6, 6, 6, 6, 0, 0, 6, 6, 0,
242 0, 0, 0, 0, 0, 30, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 57, 0, 0, 0,
244 57, 0, 0, 0, 36, 6, 3, 0, 38, 0,
245 49, 0, 30, 44, 9, 30, 0, 0, 0, 0,
246 0, 0, 3, 0, 0, 0, 49, 0, 0, 0,
247 0, 0, 57, 0, 0, 0, 57, 0, 0, 0,
248 36, 0, 0, 0, 38, 0, 0, 0, 57, 0,
249 0, 0, 57, 0, 0, 0, 36, 0, 0, 0,
250 38, 3, 3, 3, 3, 49, 49, 49, 49, 10,
251 11, 12, 13, 0, 0, 0, 0, 0, 0, 0,
252 0, 0, 0, 0, 0, 0, 0, 57, 57, 57,
253 57, 57, 57, 57, 57, 36, 36, 36, 36, 38,
254 38, 38, 38,
255 };
256 short cl_expr_check[] = { 60,
257 0, 44, 60, 91, 0, 16, 41, 38, 0, 44,
258 43, 42, 0, 44, 40, 62, 42, 64, 40, 62,
259 42, 44, 40, 8, 42, 38, 38, 62, 41, 42,
260 42, 62, 58, 59, 256, 46, 40, 292, 44, 62,
261 40, 41, 42, 308, 40, 60, 42, 80, 40, 62,
262 42, 38, 37, 308, 42, 42, 62, 44, 58, 59,
263 58, 59, 58, 59, 60, 44, 58, 59, 258, 259,
264 58, 59, 35, 263, 91, 62, 60, 258, 259, 269,
265 308, 41, 263, 62, 274, 275, 276, 277, 269, 58,
266 280, 281, 61, 274, 275, 276, 277, 273, 40, 280,
267 281, 62, 38, 66, 308, 68, 42, 70, 44, 38,
268 38, 41, 308, 42, 42, 44, 44, 40, 308, 258,
269 259, 48, 85, 25, 263, -1, 62, 308, -1, -1,
270 269, -1, -1, 62, 62, 274, 275, 276, 277, 258,
271 259, 280, 281, -1, 263, -1, -1, -1, -1, -1,
272 269, -1, -1, -1, -1, 274, 275, 276, 277, -1,
273 -1, 280, 281, -1, -1, -1, -1, -1, -1, -1,
274 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
275 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
278 -1, -1, -1, -1, -1, 258, 259, -1, -1, -1,
279 263, -1, -1, -1, -1, -1, 269, -1, -1, -1,
280 -1, 274, 275, 276, 277, -1, -1, 280, 281, -1,
281 -1, -1, -1, -1, -1, 333, -1, -1, -1, -1,
282 -1, -1, -1, -1, -1, -1, 256, -1, -1, -1,
283 256, -1, -1, -1, 256, 308, 292, -1, 256, -1,
284 292, -1, 333, 308, 292, 333, -1, -1, -1, -1,
285 -1, -1, 308, -1, -1, -1, 308, -1, -1, -1,
286 -1, -1, 292, -1, -1, -1, 292, -1, -1, -1,
287 292, -1, -1, -1, 292, -1, -1, -1, 308, -1,
288 -1, -1, 308, -1, -1, -1, 308, -1, -1, -1,
289 308, 347, 348, 349, 350, 347, 348, 349, 350, 347,
290 348, 349, 350, -1, -1, -1, -1, -1, -1, -1,
291 -1, -1, -1, -1, -1, -1, -1, 347, 348, 349,
292 350, 347, 348, 349, 350, 347, 348, 349, 350, 347,
293 348, 349, 350,
294 };
295 #define YYFINAL 1
296 #ifndef YYDEBUG
297 #define YYDEBUG 1
298 #endif
299 #define YYMAXTOKEN 352
300 #if YYDEBUG
301 char *cl_expr_name[] = {
302 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
303 0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'","';'",
304 "'<'",0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,0,
305 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
306 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
307 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
308 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
309 0,0,0,"LE_AUTO","LE_DOUBLE","LE_INT","LE_STRUCT","LE_BREAK","LE_ELSE","LE_LONG",
310 "LE_SWITCH","LE_CASE","LE_ENUM","LE_REGISTER","LE_TYPEDEF","LE_CHAR",
311 "LE_EXTERN","LE_RETURN","LE_UNION","LE_CONST","LE_FLOAT","LE_SHORT",
312 "LE_UNSIGNED","LE_BOOL","LE_CONTINUE","LE_FOR","LE_SIGNED","LE_VOID",
313 "LE_DEFAULT","LE_GOTO","LE_SIZEOF","LE_VOLATILE","LE_DO","LE_IF","LE_STATIC",
314 "LE_WHILE","LE_NEW","LE_DELETE","LE_THIS","LE_OPERATOR","LE_CLASS","LE_PUBLIC",
315 "LE_PROTECTED","LE_PRIVATE","LE_VIRTUAL","LE_FRIEND","LE_INLINE","LE_OVERLOAD",
316 "LE_OVERRIDE","LE_FINAL","LE_TEMPLATE","LE_TYPENAME","LE_THROW","LE_CATCH",
317 "LE_IDENTIFIER","LE_STRINGliteral","LE_FLOATINGconstant","LE_INTEGERconstant",
318 "LE_CHARACTERconstant","LE_OCTALconstant","LE_HEXconstant","LE_POUNDPOUND",
319 "LE_CComment","LE_CPPComment","LE_NAMESPACE","LE_USING","LE_TYPEDEFname",
320 "LE_ARROW","LE_ICR","LE_DECR","LE_LS","LE_RS","LE_LE","LE_GE","LE_EQ","LE_NE",
321 "LE_ANDAND","LE_OROR","LE_ELLIPSIS","LE_CLCL","LE_DOTstar","LE_ARROWstar",
322 "LE_MULTassign","LE_DIVassign","LE_MODassign","LE_PLUSassign","LE_MINUSassign",
323 "LE_LSassign","LE_RSassign","LE_ANDassign","LE_ERassign","LE_ORassign",
324 "LE_MACRO","LE_DYNAMIC_CAST","LE_STATIC_CAST","LE_CONST_CAST",
325 "LE_REINTERPRET_CAST","LE_SIZE_T","LE_TIME_T",
326 };
327 char *cl_expr_rule[] = {
328 "$accept : translation_unit",
329 "translation_unit :",
330 "translation_unit : translation_unit primary_expr",
331 "$$1 :",
332 "primary_expr : $$1 simple_expr",
333 "primary_expr : error",
334 "const_spec :",
335 "const_spec : LE_CONST",
336 "basic_type_name_inter : LE_INT",
337 "basic_type_name_inter : LE_CHAR",
338 "basic_type_name_inter : LE_SHORT",
339 "basic_type_name_inter : LE_LONG",
340 "basic_type_name_inter : LE_FLOAT",
341 "basic_type_name_inter : LE_DOUBLE",
342 "basic_type_name_inter : LE_SIGNED",
343 "basic_type_name_inter : LE_UNSIGNED",
344 "basic_type_name_inter : LE_VOID",
345 "basic_type_name_inter : LE_BOOL",
346 "basic_type_name : LE_UNSIGNED basic_type_name_inter",
347 "basic_type_name : LE_SIGNED basic_type_name_inter",
348 "basic_type_name : basic_type_name_inter",
349 "basic_type_name : LE_SHORT basic_type_name",
350 "basic_type_name : LE_LONG basic_type_name",
351 "parameter_list :",
352 "parameter_list : template_parameter",
353 "parameter_list : parameter_list ',' template_parameter",
354 "template_parameter : const_spec nested_scope_specifier LE_IDENTIFIER special_star_amp",
355 "template_parameter : const_spec nested_scope_specifier basic_type_name special_star_amp",
356 "template_parameter : const_spec nested_scope_specifier LE_IDENTIFIER '<' parameter_list '>' special_star_amp",
357 "simple_expr : stmnt_starter special_cast '<' cast_type '>' '('",
358 "simple_expr : stmnt_starter LE_THIS",
359 "simple_expr : stmnt_starter '*' LE_THIS",
360 "simple_expr : stmnt_starter '*' identifier_name",
361 "simple_expr : stmnt_starter nested_scope_specifier identifier_name optional_template_init_list optinal_postifx",
362 "simple_expr : stmnt_starter '(' '(' cast_type ')' special_star_amp identifier_name ')'",
363 "identifier_name : LE_IDENTIFIER array_brackets",
364 "optional_template_init_list :",
365 "optional_template_init_list : '<' parameter_list '>'",
366 "optinal_postifx :",
367 "optinal_postifx : '('",
368 "special_cast : LE_DYNAMIC_CAST",
369 "special_cast : LE_STATIC_CAST",
370 "special_cast : LE_CONST_CAST",
371 "special_cast : LE_REINTERPRET_CAST",
372 "amp_item :",
373 "amp_item : '&'",
374 "star_list :",
375 "star_list : star_list '*'",
376 "special_star_amp : star_list amp_item",
377 "stmnt_starter :",
378 "stmnt_starter : ';'",
379 "stmnt_starter : ':'",
380 "cast_type : nested_scope_specifier LE_IDENTIFIER '<' parameter_list '>' special_star_amp",
381 "cast_type : nested_scope_specifier LE_IDENTIFIER special_star_amp",
382 "nested_scope_specifier :",
383 "nested_scope_specifier : nested_scope_specifier scope_specifier",
384 "scope_specifier : LE_IDENTIFIER LE_CLCL",
385 "array_brackets :",
386 "array_brackets : '['",
387 };
388 #endif
389 #ifndef YYSTYPE
390 typedef int YYSTYPE;
391 #endif
392 #ifdef YYSTACKSIZE
393 #undef YYMAXDEPTH
394 #define YYMAXDEPTH YYSTACKSIZE
395 #else
396 #ifdef YYMAXDEPTH
397 #define YYSTACKSIZE YYMAXDEPTH
398 #else
399 #define YYSTACKSIZE 500
400 #define YYMAXDEPTH 500
401 #endif
402 #endif
403 int yydebug;
404 int yynerrs;
405 int yyerrflag;
406 int yychar;
407 short *yyssp;
408 YYSTYPE *yyvsp;
409 YYSTYPE yyval;
410 YYSTYPE yylval;
411 short yyss[YYSTACKSIZE];
412 YYSTYPE yyvs[YYSTACKSIZE];
413 #define yystacksize YYSTACKSIZE
414 void yyerror(char *s) {}
415
416 void expr_consumBracketsContent(char openBrace)
417 {
418 char closeBrace;
419
420 switch(openBrace) {
421 case '(': closeBrace = ')'; break;
422 case '[': closeBrace = ']'; break;
423 case '<': closeBrace = '>'; break;
424 case '{': closeBrace = '}'; break;
425 default:
426 openBrace = '(';
427 closeBrace = ')';
428 break;
429 }
430
431 int depth = 1;
432 while(depth > 0)
433 {
434 int ch = cl_expr_lex();
435 //printf("ch=%d\n", ch);
436 //fflush(stdout);
437 if(ch == 0){
438 break;
439 }
440
441 if(ch == closeBrace)
442 {
443 depth--;
444 continue;
445 }
446 else if(ch == openBrace)
447 {
448 depth ++ ;
449 continue;
450 }
451 }
452 }
453
454 void expr_FuncArgList()
455 {
456 int depth = 1;
457 while(depth > 0)
458 {
459 int ch = cl_expr_lex();
460 //printf("ch=%d\n", ch);
461 //fflush(stdout);
462 if(ch ==0){
463 break;
464 }
465
466 if(ch == ')')
467 {
468 depth--;
469 continue;
470 }
471 else if(ch == '(')
472 {
473 depth ++ ;
474 continue;
475 }
476 }
477 }
478
479 void expr_consumeTemplateDecl()
480 {
481 int depth = 1;
482 while(depth > 0)
483 {
484 int ch = cl_expr_lex();
485 //printf("ch=%d\n", ch);
486 fflush(stdout);
487 if(ch ==0){
488 break;
489 }
490
491 if(ch == '>')
492 {
493 depth--;
494 continue;
495 }
496 else if(ch == '<')
497 {
498 depth ++ ;
499 continue;
500 }
501 }
502 }
503
504 void expr_syncParser(){
505 //dont do anything, a hook to allow us to implement some
506 //nice error recovery if needed
507 }
508
509 // return the scope name at the end of the input string
510 ExpressionResult &parse_expression(const std::string &in)
511 {
512 result.Reset();
513 //provide the lexer with new input
514 if( !setExprLexerInput(in) ){
515 return result;
516 }
517
518 //printf("parsing...\n");
519 cl_expr_parse();
520 //do the lexer cleanup
521 cl_expr_lex_clean();
522
523 return result;
524 }
525 #define YYABORT goto yyabort
526 #define YYREJECT goto yyabort
527 #define YYACCEPT goto yyaccept
528 #define YYERROR goto yyerrlab
529 int
530 yyparse()
531 {
532 register int yym, yyn, yystate;
533 #if YYDEBUG
534 register char *yys;
535 extern char *getenv();
536
537 if (yys = getenv("YYDEBUG"))
538 {
539 yyn = *yys;
540 if (yyn >= '0' && yyn <= '9')
541 yydebug = yyn - '0';
542 }
543 #endif
544
545 yynerrs = 0;
546 yyerrflag = 0;
547 yychar = (-1);
548
549 yyssp = yyss;
550 yyvsp = yyvs;
551 *yyssp = yystate = 0;
552
553 yyloop:
554 if (yyn = yydefred[yystate]) goto yyreduce;
555 if (yychar < 0)
556 {
557 if ((yychar = yylex()) < 0) yychar = 0;
558 #if YYDEBUG
559 if (yydebug)
560 {
561 yys = 0;
562 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
563 if (!yys) yys = "illegal-symbol";
564 printf("%sdebug: state %d, reading %d (%s)\n",
565 YYPREFIX, yystate, yychar, yys);
566 }
567 #endif
568 }
569 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
570 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
571 {
572 #if YYDEBUG
573 if (yydebug)
574 printf("%sdebug: state %d, shifting to state %d\n",
575 YYPREFIX, yystate, yytable[yyn]);
576 #endif
577 if (yyssp >= yyss + yystacksize - 1)
578 {
579 goto yyoverflow;
580 }
581 *++yyssp = yystate = yytable[yyn];
582 *++yyvsp = yylval;
583 yychar = (-1);
584 if (yyerrflag > 0) --yyerrflag;
585 goto yyloop;
586 }
587 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
588 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
589 {
590 yyn = yytable[yyn];
591 goto yyreduce;
592 }
593 if (yyerrflag) goto yyinrecovery;
594 #ifdef lint
595 goto yynewerror;
596 #endif
597 yynewerror:
598 yyerror("syntax error");
599 #ifdef lint
600 goto yyerrlab;
601 #endif
602 yyerrlab:
603 ++yynerrs;
604 yyinrecovery:
605 if (yyerrflag < 3)
606 {
607 yyerrflag = 3;
608 for (;;)
609 {
610 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
611 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
612 {
613 #if YYDEBUG
614 if (yydebug)
615 printf("%sdebug: state %d, error recovery shifting\
616 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
617 #endif
618 if (yyssp >= yyss + yystacksize - 1)
619 {
620 goto yyoverflow;
621 }
622 *++yyssp = yystate = yytable[yyn];
623 *++yyvsp = yylval;
624 goto yyloop;
625 }
626 else
627 {
628 #if YYDEBUG
629 if (yydebug)
630 printf("%sdebug: error recovery discarding state %d\n",
631 YYPREFIX, *yyssp);
632 #endif
633 if (yyssp <= yyss) goto yyabort;
634 --yyssp;
635 --yyvsp;
636 }
637 }
638 }
639 else
640 {
641 if (yychar == 0) goto yyabort;
642 #if YYDEBUG
643 if (yydebug)
644 {
645 yys = 0;
646 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
647 if (!yys) yys = "illegal-symbol";
648 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
649 YYPREFIX, yystate, yychar, yys);
650 }
651 #endif
652 yychar = (-1);
653 goto yyloop;
654 }
655 yyreduce:
656 #if YYDEBUG
657 if (yydebug)
658 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
659 YYPREFIX, yystate, yyn, yyrule[yyn]);
660 #endif
661 yym = yylen[yyn];
662 yyval = yyvsp[1-yym];
663 switch (yyn)
664 {
665 case 3:
666 {result.Reset();}
667 break;
668 case 5:
669 {
670 yyclearin; /*clear lookahead token*/
671 yyerrok;
672 /*fprintf(stderr, "CodeLite: syntax error, unexpected token '%s' found at line %d \n", cl_expr_text, cl_expr_lineno);*/
673 /*fflush(stderr);*/
674 expr_syncParser();
675 }
676 break;
677 case 6:
678 {yyval = ""; }
679 break;
680 case 7:
681 { yyval = yyvsp[0]; }
682 break;
683 case 8:
684 { yyval = yyvsp[0]; }
685 break;
686 case 9:
687 { yyval = yyvsp[0]; }
688 break;
689 case 10:
690 { yyval = yyvsp[0]; }
691 break;
692 case 11:
693 { yyval = yyvsp[0]; }
694 break;
695 case 12:
696 { yyval = yyvsp[0]; }
697 break;
698 case 13:
699 { yyval = yyvsp[0]; }
700 break;
701 case 14:
702 { yyval = yyvsp[0]; }
703 break;
704 case 15:
705 { yyval = yyvsp[0]; }
706 break;
707 case 16:
708 { yyval = yyvsp[0]; }
709 break;
710 case 17:
711 { yyval = yyvsp[0]; }
712 break;
713 case 18:
714 { yyval = yyvsp[-1] + " " + yyvsp[0]; }
715 break;
716 case 19:
717 { yyval = yyvsp[-1] + " " + yyvsp[0]; }
718 break;
719 case 20:
720 { yyval = yyvsp[0]; }
721 break;
722 case 21:
723 { yyval = yyvsp[-1] + " " + yyvsp[0];}
724 break;
725 case 22:
726 { yyval = yyvsp[-1] + " " + yyvsp[0]; }
727 break;
728 case 23:
729 {yyval = "";}
730 break;
731 case 24:
732 {yyval = yyvsp[0];}
733 break;
734 case 25:
735 {yyval = yyvsp[-2] + yyvsp[-1] + yyvsp[0];}
736 break;
737 case 26:
738 {
739 if(yyvsp[-3].empty()) {
740 yyval = yyvsp[-2] + yyvsp[-1] +yyvsp[0];
741
742 } else {
743 yyval = yyvsp[-3] + " " + yyvsp[-2] + yyvsp[-1] +yyvsp[0];
744 }
745 }
746 break;
747 case 27:
748 {
749 if(yyvsp[-3].empty()) {
750 yyval = yyvsp[-2] + yyvsp[-1] +yyvsp[0];
751
752 } else {
753 yyval = yyvsp[-3] + " " + yyvsp[-2] + yyvsp[-1] +yyvsp[0];
754 }
755 }
756 break;
757 case 28:
758 {
759 if(yyvsp[-6].empty()) {
760 yyval = yyvsp[-5] + yyvsp[-4] + yyvsp[-3] + yyvsp[-2] + yyvsp[-1] + " ";
761 } else {
762 yyval = yyvsp[-6] + " " + yyvsp[-5] + yyvsp[-4] + yyvsp[-3] + yyvsp[-2] + yyvsp[-1] + " ";
763 }
764 }
765 break;
766 case 29:
767 {
768 expr_FuncArgList();
769 yyval = yyvsp[-2];
770 result.m_isaType = true;
771 result.m_name = yyvsp[-2];
772 result.m_isFunc = false;
773 /*printf("Rule 1\n");*/
774 /*result.Print();*/
775 }
776 break;
777 case 30:
778 {
779 yyval = yyvsp[0];
780 result.m_isaType = false;
781 result.m_name = yyval;
782 result.m_isFunc = false;
783 result.m_isThis = true;
784 result.m_isPtr = true;
785 /*result.Print();*/
786 }
787 break;
788 case 31:
789 {
790 yyval = yyvsp[0];
791 result.m_isaType = false;
792 result.m_name = yyval;
793 result.m_isFunc = false;
794 result.m_isThis = true;
795 /*result.Print();*/
796 }
797 break;
798 case 32:
799 {
800 yyval = yyvsp[0];
801 result.m_isaType = false;
802 result.m_name = yyval;
803 result.m_isFunc = false;
804 result.m_isThis = false;
805 result.m_isPtr = false;
806 /*result.Print();*/
807 }
808 break;
809 case 33:
810 {
811 result.m_isaType = false;
812 result.m_name = yyvsp[-2];
813 result.m_isThis = false;
814 yyvsp[-3].erase(yyvsp[-3].find_last_not_of(":")+1);
815 result.m_scope = yyvsp[-3];
816 result.m_isTemplate = yyvsp[-1].empty() ? false : true;
817 result.m_templateInitList = yyvsp[-1];
818 /*result.Print();*/
819 }
820 break;
821 case 34:
822 {
823 yyval = yyvsp[-4];
824 result.m_isaType = true;
825 result.m_name = yyval;
826 result.m_isFunc = false;
827 result.m_isThis = false;
828 /*result.Print();*/
829 }
830 break;
831 case 35:
832 {yyval = yyvsp[-1];}
833 break;
834 case 36:
835 {yyval = "";}
836 break;
837 case 37:
838 {yyval = yyvsp[-2] + yyvsp[-1] + yyvsp[0];}
839 break;
840 case 38:
841 {yyval = "";}
842 break;
843 case 39:
844 {
845 yyval = yyvsp[0];
846 expr_FuncArgList();
847 result.m_isFunc = true;
848 }
849 break;
850 case 40:
851 {yyval = yyvsp[0];}
852 break;
853 case 41:
854 {yyval = yyvsp[0];}
855 break;
856 case 42:
857 {yyval = yyvsp[0];}
858 break;
859 case 43:
860 {yyval = yyvsp[0];}
861 break;
862 case 44:
863 {yyval = ""; }
864 break;
865 case 45:
866 { yyval = yyvsp[0]; }
867 break;
868 case 46:
869 {yyval = ""; }
870 break;
871 case 47:
872 {yyval = yyvsp[-1] + yyvsp[0];}
873 break;
874 case 48:
875 { yyval = yyvsp[-1] + yyvsp[0]; }
876 break;
877 case 49:
878 {yyval = "";}
879 break;
880 case 50:
881 { yyval = ";";}
882 break;
883 case 51:
884 { yyval = ":";}
885 break;
886 case 52:
887 {
888 yyval = yyvsp[-5] + yyvsp[-4];
889 yyvsp[-5].erase(yyvsp[-5].find_last_not_of(":")+1);
890 result.m_scope = yyvsp[-5];
891 result.m_name = yyvsp[-4];
892 result.m_isPtr = (yyvsp[0].find("*") != (size_t)-1);;
893 result.m_isTemplate = true;
894 result.m_templateInitList = yyvsp[-3] + yyvsp[-2] + yyvsp[-1];
895 }
896 break;
897 case 53:
898 {
899 yyval = yyvsp[-2] + yyvsp[-1];
900 yyvsp[-2].erase(yyvsp[-2].find_last_not_of(":")+1);
901 result.m_scope = yyvsp[-2];
902 result.m_name = yyvsp[-1];
903 result.m_isPtr = (yyvsp[0].find("*") != (size_t)-1);;
904 }
905 break;
906 case 54:
907 {yyval = "";}
908 break;
909 case 55:
910 { yyval = yyvsp[-1] + yyvsp[0];}
911 break;
912 case 56:
913 {yyval = yyvsp[-1]+ yyvsp[0];}
914 break;
915 case 57:
916 { yyval = ""; }
917 break;
918 case 58:
919 { expr_consumBracketsContent('['); yyval = "[]";}
920 break;
921 }
922 yyssp -= yym;
923 yystate = *yyssp;
924 yyvsp -= yym;
925 yym = yylhs[yyn];
926 if (yystate == 0 && yym == 0)
927 {
928 #if YYDEBUG
929 if (yydebug)
930 printf("%sdebug: after reduction, shifting from state 0 to\
931 state %d\n", YYPREFIX, YYFINAL);
932 #endif
933 yystate = YYFINAL;
934 *++yyssp = YYFINAL;
935 *++yyvsp = yyval;
936 if (yychar < 0)
937 {
938 if ((yychar = yylex()) < 0) yychar = 0;
939 #if YYDEBUG
940 if (yydebug)
941 {
942 yys = 0;
943 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
944 if (!yys) yys = "illegal-symbol";
945 printf("%sdebug: state %d, reading %d (%s)\n",
946 YYPREFIX, YYFINAL, yychar, yys);
947 }
948 #endif
949 }
950 if (yychar == 0) goto yyaccept;
951 goto yyloop;
952 }
953 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
954 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
955 yystate = yytable[yyn];
956 else
957 yystate = yydgoto[yym];
958 #if YYDEBUG
959 if (yydebug)
960 printf("%sdebug: after reduction, shifting from state %d \
961 to state %d\n", YYPREFIX, *yyssp, yystate);
962 #endif
963 if (yyssp >= yyss + yystacksize - 1)
964 {
965 goto yyoverflow;
966 }
967 *++yyssp = yystate;
968 *++yyvsp = yyval;
969 goto yyloop;
970 yyoverflow:
971 yyerror("yacc stack overflow");
972 yyabort:
973 return (1);
974 yyaccept:
975 return (0);
976 }