~ubuntu-branches/ubuntu/trusty/anjuta/trusty

« back to all changes in this revision

Viewing changes to plugins/parser-cxx/cxxparser/expression-parser.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-08-17 23:48:26 UTC
  • mfrom: (1.1.50)
  • Revision ID: package-import@ubuntu.com-20120817234826-fvk3rfp6nmfaqi9p
Tags: 2:3.5.5-0ubuntu1
* New upstream release.
* debian/control.in:
  - Bump vala dependency to 0.18 series
  - Drop graphviz from build-depends
* debian/watch: Watch for unstable releases

Show diffs side-by-side

added added

removed removed

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