~quadrispro/codelite/trunk

1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
1
 %{
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
2
// Copyright Eran Ifrah(c)
3
%}
4
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
5
%{
6
/*************** Includes and Defines *****************************/
7
#include "string"
8
#include "vector"
9
#include "stdio.h"
10
#include "map"
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
11
12
#define YYDEBUG_LEXER_TEXT (cl_scope_lval)
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
13
#define YYSTYPE std::string
14
#define YYDEBUG 0        /* get the pretty debugging code to compile*/
15
16
int cl_scope_parse();
17
void cl_scope_error(char *string);
18
void syncParser();
19
20
static std::vector<std::string> gs_additionlNS;
21
22
//---------------------------------------------
23
// externs defined in the lexer
24
//---------------------------------------------
25
extern char *cl_scope_text;
26
extern int cl_scope_lex();
846 by eranif
- 'resolve ambiguity' dialog now properly dismissed with ESC key
27
extern bool setLexerInput(const std::string &in, const std::map<std::string, std::string> &ignoreTokens);
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
28
extern int cl_scope_lineno;
29
extern std::vector<std::string> currentScope;
30
extern void printScopeName();	//print the current scope name
31
extern void increaseScope();	//increase scope with anonymouse value
32
extern std::string getCurrentScope();
33
extern void cl_scope_lex_clean();
34
extern void cl_scope_less(int count);
35
36
/*************** Standard ytab.c continues here *********************/
37
%}
38
39
/*************************************************************************/
40
41
/* This group is used by the C/C++ language parser */
42
%token  LE_AUTO            LE_DOUBLE          LE_INT             LE_STRUCT
43
%token  LE_BREAK           LE_ELSE            LE_LONG            LE_SWITCH
44
%token  LE_CASE            LE_ENUM            LE_REGISTER        LE_TYPEDEF
45
%token  LE_CHAR            LE_EXTERN          LE_RETURN          LE_UNION
46
%token  LE_CONST           LE_FLOAT           LE_SHORT           LE_UNSIGNED
47
%token  LE_CONTINUE        LE_FOR             LE_SIGNED          LE_VOID
48
%token  LE_DEFAULT         LE_GOTO            LE_SIZEOF          LE_VOLATILE
49
%token  LE_DO              LE_IF              LE_STATIC          LE_WHILE
50
51
/* The following are used in C++ only.  ANSI C would call these IDENTIFIERs */
52
%token  LE_NEW             LE_DELETE
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
53
%token  LE_THIS
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
54
%token  LE_OPERATOR
55
%token  LE_CLASS
56
%token  LE_PUBLIC          LE_PROTECTED       LE_PRIVATE
57
%token  LE_VIRTUAL         LE_FRIEND
58
%token  LE_INLINE          LE_OVERLOAD
59
%token  LE_TEMPLATE		   LE_TYPENAME
43 by eranif
- Added supprort for 'throw' keyword in function declaration
60
%token  LE_THROW		  	LE_CATCH
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
61
/* ANSI C Grammar suggestions */
62
%token  LE_IDENTIFIER              LE_STRINGliteral
63
%token  LE_FLOATINGconstant        LE_INTEGERconstant        LE_CHARACTERconstant
64
%token  LE_OCTALconstant           LE_HEXconstant
65
%token  LE_POUNDPOUND LE_CComment LE_CPPComment LE_NAMESPACE LE_USING
66
67
/* New Lexical element, whereas ANSI C suggested non-terminal */
68
%token  LE_TYPEDEFname
69
70
/* Multi-Character operators */
71
%token   LE_ARROW            											/*    ->                              */
72
%token   LE_ICR LE_DECR         										/*    ++      --                      */
73
%token   LE_LS LE_RS            										/*    <<      >>                      */
74
%token   LE_LE LE_GE LE_EQ LE_NE      								/*    <=      >=      ==      !=      */
75
%token   LE_ANDAND LE_OROR      										/*    &&      ||                      */
76
%token   LE_ELLIPSIS         											/*    ...                             */
77
			/* Following are used in C++, not ANSI C        */
78
%token   LE_CLCL             											/*    ::                              */
79
%token   LE_DOTstar LE_ARROWstar										/*    .*       ->*                    */
80
81
/* modifying assignment operators */
82
%token  LE_MULTassign  LE_DIVassign    LE_MODassign   	/*   *=      /=      %=      */
83
%token  LE_PLUSassign  LE_MINUSassign              		/*   +=      -=              */
84
%token  LE_LSassign    LE_RSassign                 		/*   <<=     >>=             */
85
%token  LE_ANDassign   LE_ERassign     LE_ORassign    	/*   &=      ^=      |=      */
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
86
%token  LE_MACRO
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
87
%token  LE_DYNAMIC_CAST
88
%token  LE_STATIC_CAST
89
%token  LE_CONST_CAST
90
%token  LE_REINTERPRET_CAST
91
92
%start   translation_unit
93
94
%%
95
/* Costants */
96
basic_type_name:
97
        LE_INT			{ $$ = $1; }
98
        | LE_CHAR		{ $$ = $1; }
99
        | LE_SHORT		{ $$ = $1; }
100
        | LE_LONG		{ $$ = $1; }
101
        | LE_FLOAT		{ $$ = $1; }
102
        | LE_DOUBLE		{ $$ = $1; }
103
        | LE_SIGNED		{ $$ = $1; }
104
        | LE_UNSIGNED	{ $$ = $1; }
105
        | LE_VOID		{ $$ = $1; }
106
        ;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
107
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
108
109
/* ========================================================================*/
110
/* find declarations																   */
111
/* ========================================================================*/
112
113
translation_unit	:		/*empty*/
114
						| translation_unit external_decl
115
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
116
117
external_decl			:	class_decl
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
118
						|	enum_decl
119
						|	union_decl
120
						| 	function_decl
121
						|	namespace_decl
122
						|	using_namespace
123
						| 	scope_reducer
124
						| 	scope_increaer
1430 by eranif
- Fixed: code completion was broken after expressions of type something = cond ? do1: do2;
125
						|  	question_expression
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
126
						| 	error {
960 by eranif
- Fixed: CC now properly recognizes scope of functions of similar prototypes:
127
//								printf("CodeLite: syntax error, unexpected token '%s' found at line %d \n", cl_scope_text, cl_scope_lineno);
128
//								syncParser();
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
129
							}
130
						;
960 by eranif
- Fixed: CC now properly recognizes scope of functions of similar prototypes:
131
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
132
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
133
/*templates*/
134
template_arg		:	/* empty */	{ $$ = "";}
135
						| template_specifiter LE_IDENTIFIER {$$ = $1 + " " + $2;}
136
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
137
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
138
template_arg_list	:	template_arg	{ $$ = $1; }
139
						| 	template_arg_list ',' template_arg	{ $$ = $1 + " " + $2 + " " + $3; }
140
						;
141
142
template_specifiter	:	LE_CLASS	{ $$ = $1; }
143
							|	LE_TYPENAME	{ $$ = $1; }
144
							;
145
146
opt_template_qualifier	: /*empty*/
147
							| LE_TEMPLATE '<' template_arg_list '>'	{ $$ = $1 + $2 + $3 + $4;}
148
							;
149
/*inheritance*/
150
derivation_list			:	/*empty*/ {$$ = "";}
151
							|	parent_class {$$ = $1;}
152
							| 	derivation_list ',' parent_class {$$ = $1 + $2 + $3;}
153
							;
154
155
parent_class				: 	access_specifier LE_IDENTIFIER	opt_template_specifier {$$ = $1 + " " + $2 + $3;}
156
							;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
157
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
158
opt_template_specifier	: /*empty*/	{$$ = "";}
159
							| '<' template_parameter_list '>' {$$ = $1 + $2 + $3;}
160
							;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
161
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
162
access_specifier			:	/*empty*/	{$$ = "";}
163
							|	LE_PUBLIC {$$ = $1;}
164
							| 	LE_PRIVATE {$$ = $1;}
165
							| 	LE_PROTECTED {$$ = $1;}
166
							;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
167
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
168
/* the following rules are for template parameters no declarations! */
169
template_parameter_list	: /* empty */		{$$ = "";}
170
							| template_parameter	{$$ = $1;}
171
							| template_parameter_list ',' template_parameter {$$ = $1 + $2 + $3;}
172
							;
173
960 by eranif
- Fixed: CC now properly recognizes scope of functions of similar prototypes:
174
/*template_parameter		:	const_spec nested_scope_specifier LE_IDENTIFIER special_star_amp {$$ = $1 + $2 + $3 +$4;}
175
							;*/
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
176
template_parameter	:	const_spec nested_scope_specifier LE_IDENTIFIER special_star_amp
960 by eranif
- Fixed: CC now properly recognizes scope of functions of similar prototypes:
177
						{
178
							$$ = $1 +  $2 + $3 +$4;
179
						}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
180
					|  	const_spec nested_scope_specifier basic_type_name special_star_amp
960 by eranif
- Fixed: CC now properly recognizes scope of functions of similar prototypes:
181
						{
182
							$$ = $1 +  $2 + $3 +$4;
183
						}
184
					|  	const_spec nested_scope_specifier LE_IDENTIFIER '<' template_parameter_list '>' special_star_amp
185
						{
186
							$$ = $1 + $2 + $3 +$4 + $5 + $6 + $7 + " " ;
187
						}
188
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
189
1725 by eranif
- Fixed: 'using namespace ' is now better understood by codelite
190
using_namespace:	LE_USING LE_NAMESPACE nested_scope_specifier LE_IDENTIFIER ';'
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
191
					{
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
192
						//printf("Found using namespace %s\n", $3.c_str());
1725 by eranif
- Fixed: 'using namespace ' is now better understood by codelite
193
						gs_additionlNS.push_back($3+$4);
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
194
					}
195
				;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
196
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
197
/* namespace */
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
198
namespace_decl	:	stmnt_starter LE_NAMESPACE LE_IDENTIFIER '{'
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
199
						{
200
							currentScope.push_back($3);
201
							printScopeName();
202
						}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
203
					|	stmnt_starter LE_NAMESPACE '{'
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
204
						{
205
							//anonymouse namespace
206
							increaseScope();
207
							printScopeName();
208
						}
209
					;
210
opt_class_qualifier 	: /*empty*/{$$ = "";}
211
							| LE_MACRO {$$ = $1;}
212
							;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
213
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
214
/* the class rule itself */
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
215
class_decl	:	stmnt_starter opt_template_qualifier class_keyword opt_class_qualifier LE_IDENTIFIER '{'
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
216
				{
217
					//increase the scope level
218
					currentScope.push_back($5);
219
					printScopeName();
220
				}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
221
222
				| 	stmnt_starter opt_template_qualifier class_keyword opt_class_qualifier LE_IDENTIFIER ':' derivation_list '{'
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
223
				{
224
					//increase the scope level
225
					currentScope.push_back($5);
226
					printScopeName();
227
				}
228
				;
229
230
scope_reducer		:	'}'	{
231
								if(currentScope.empty())
232
								{
233
									//fatal error!
234
									//printf("CodeLite: fatal error - cant go beyond global scope!\n");
235
								}
236
								else
237
								{
238
									currentScope.pop_back();
239
									printScopeName();
240
								}
241
							}
242
					;
243
scope_increaer	:	'{' {
244
								//increase random scope
245
								increaseScope();
246
								printScopeName();
247
							 }
248
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
249
question_expression : '?'
1430 by eranif
- Fixed: code completion was broken after expressions of type something = cond ? do1: do2;
250
						{
251
							consumeNotIncluding(';');
252
						}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
253
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
254
class_keyword: 	LE_CLASS		{$$ = $1;}
255
					|	LE_STRUCT	{$$ = $1;}
256
					;
257
258
func_name: LE_IDENTIFIER {$$ = $1;}
259
		 | LE_OPERATOR any_operator {$$ = $1;}
260
		 ;
261
262
any_operator:
263
        '+'
264
		| '='
265
        | '*'
266
        | '/'
267
        | '%'
268
        | '^'
269
        | '&'
270
        | '|'
271
        | '~'
272
        | '!'
273
        | '<'
274
        | '>'
275
        | LE_LS
276
        | LE_RS
277
        | LE_ANDAND
278
        | LE_OROR
279
        | LE_ARROW
280
        | LE_ARROWstar
281
        | '.'
282
        | LE_DOTstar
283
        | LE_ICR
284
        | LE_DECR
285
        | LE_LE
286
        | LE_GE
287
        | LE_EQ
288
        | LE_NE
289
        | '(' ')'
290
        | '[' ']'
291
        | LE_NEW
292
        | LE_DELETE
293
        | ','
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
294
		| LE_MULTassign
295
		| LE_DIVassign
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
296
		| LE_MODassign
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
297
		| LE_PLUSassign
298
		| LE_MINUSassign
299
		| LE_LSassign
300
		| LE_RSassign
301
		| LE_ANDassign
302
		| LE_ERassign
303
		| LE_ORassign
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
304
        ;
305
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
306
optional_initialization_list: '{' {$$ = '{';}/* empty */
307
		| ':' {consumeInitializationList() /*eat everything including the open brace*/;}
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
308
		;
309
884 by eranif
- fixed parsing of functions with complex throw(TTT) arguments
310
declare_throw: 	/*empty*/ {$$ = "";}
311
			|	LE_THROW '(' template_parameter_list ')' {$$ = $3;}
312
			;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
313
314
/* functions */
884 by eranif
- fixed parsing of functions with complex throw(TTT) arguments
315
function_decl	: 	stmnt_starter opt_template_qualifier virtual_spec const_spec variable_decl nested_scope_specifier func_name '(' {consumeFuncArgList();} const_spec declare_throw '{'
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
316
					{
317
						//trim down trailing '::' from scope name
318
						if($6.find_last_not_of(":") != std::string::npos){
319
							$6.erase($6.find_last_not_of(":")+1);
320
						}
321
						currentScope.push_back($6);
322
						printScopeName();
323
					}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
324
				|	stmnt_starter opt_template_qualifier virtual_spec const_spec nested_scope_specifier func_name '(' {consumeFuncArgList();}  optional_initialization_list
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
325
					{
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
326
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
327
						//trim down trailing '::' from scope name
328
						if($5.find_last_not_of(":") != std::string::npos){
329
							$5.erase($5.find_last_not_of(":")+1);
330
						}
331
						currentScope.push_back($5);
332
						printScopeName();
333
					}
334
				|	stmnt_starter opt_template_qualifier virtual_spec const_spec nested_scope_specifier '~' func_name '(' {consumeFuncArgList();} const_spec  '{'
335
					{
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
336
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
337
						//trim down trailing '::' from scope name
338
						if($5.find_last_not_of(":") != std::string::npos){
339
							$5.erase($5.find_last_not_of(":")+1);
340
						}
341
						currentScope.push_back($5);
342
						printScopeName();
343
					}
344
				;
345
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
346
/*
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
347
applicable for C++, for cases where a function is declared as
348
void scope::foo(){ ... }
349
*/
350
nested_scope_specifier		: /*empty*/ {$$ = "";}
351
							| nested_scope_specifier scope_specifier {	$$ = $1 + $2;}
352
							;
353
354
scope_specifier		:	LE_IDENTIFIER LE_CLCL {$$ = $1+ $2;}
355
						|	LE_IDENTIFIER  '<' {consumeTemplateDecl();} LE_CLCL {$$ = $1 + $4;}
356
						;
357
358
virtual_spec		:	/* empty */	{$$ = ""; }
359
						| 	LE_VIRTUAL 	{ $$ = $1; }
360
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
361
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
362
const_spec			:	/* empty */	{$$ = ""; }
363
						| 	LE_CONST 	{ $$ = $1; }
364
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
365
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
366
amp_item				:	/*empty*/	{$$ = ""; }
367
						|   '&' 			{ $$ = $1; }
368
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
369
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
370
star_list			: 	/*empty*/		{$$ = ""; }
371
						|	star_list '*'	{$$ = $1 + $2;}
372
						;
373
374
special_star_amp		:	star_list amp_item { $$ = $1 + $2; }
375
						;
376
377
stmnt_starter		:	/*empty*/ {$$ = "";}
378
						| ';' { $$ = ";";}
379
						| ':' { $$ = ":";}	//e.g. private: std::string m_name;
380
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
381
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
382
/** Variables **/
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
383
variable_decl			:	nested_scope_specifier basic_type_name special_star_amp
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
384
							{$$ = $1 + $2 + $3  ;}
385
						|	nested_scope_specifier LE_IDENTIFIER special_star_amp
386
							{$$ = $1 + $2 + $3  ;}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
387
						| 	nested_scope_specifier LE_IDENTIFIER '<' template_parameter_list '>' special_star_amp
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
388
							{$$ = $1 + $2 + $3  + $4 + $5 + $6 ;}
389
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
390
391
enum_decl				:	stmnt_starter LE_ENUM LE_IDENTIFIER '{' {currentScope.push_back($3); printScopeName();} enum_arg_list '}'
392
						{
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
393
							currentScope.pop_back();//reduce the scope
394
							printScopeName();
395
							//printf("found enum: %s, args are: %s\n", $2.c_str(), $5.c_str());
396
						}
397
						;
398
399
enum_optional_assign	:	/*empty*/ {$$ = "";}
400
						|	'=' LE_HEXconstant	{$$ = $1 + $2;}
401
						|	'='	 LE_OCTALconstant {$$ = $1 + $2;}
402
						|	'='	 LE_INTEGERconstant {$$ = $1 + $2;}
403
						;
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
404
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
405
enum_argument			:	LE_IDENTIFIER	enum_optional_assign {$$ = $1 + $2;}
406
						;
407
enum_arg_list			:	/*empty*/ {$$ = "";}
408
						|	enum_argument	{$$ = $1;}
409
						|	enum_arg_list ',' enum_argument {$$ = $1 + $2 + $3;}
410
						;
411
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
412
union_decl			:	stmnt_starter LE_UNION LE_IDENTIFIER '{'
413
							{
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
414
								currentScope.push_back($3);
415
								printScopeName();
416
								consumeDecl();
417
								printScopeName();
418
							}
419
						;
420
%%
421
void yyerror(char *s) {}
422
423
void syncParser(){
424
	//move lexer to the next ';' line or scope opening '{'
425
	//int ch = cl_scope_lex();
426
}
427
428
//swallow all tokens up to the first '{'
429
void consumeInitializationList(){
430
	while( true ){
431
		int ch = cl_scope_lex();
432
		if(ch == 0){
433
			break;
434
		}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
435
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
436
		if(ch == '{'){
437
			break;
438
		}
439
	}
440
}
441
442
//swallow all tokens up to the first '{'
443
void consumeBody (){
444
	std::string cs = "{";
445
	int depth = 1;
446
	while( true ) {
447
		int ch = cl_scope_lex();
448
		if(ch == 0){
449
			break;
450
		}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
451
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
452
		cs += cl_scope_text;
453
		cs += " ";
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
454
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
455
		if(ch == '{'){
456
			depth++;
457
		}else if(ch == '}'){
458
			depth--;
459
			if(depth == 0){
460
				cl_scope_less(0);
461
				break;
462
			}
463
		}
464
	}
465
	printf("Consumed body: [%s]\n", cs.c_str());
466
}
467
468
void consumeFuncArgList(){
469
	int depth = 1;
470
	while(depth > 0){
471
		int ch = cl_scope_lex();
472
		if(ch == 0){
473
			break;
474
		}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
475
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
476
		if(ch == ')'){
477
			depth--;
478
			continue;
479
		}
480
		else if(ch == '('){
481
			depth ++ ;
482
			continue;
483
		}
484
	}
485
}
486
487
/**
488
 * consume all token until matching closing brace is found
489
 */
490
void consumeDecl()
491
{
492
	int depth = 1;
493
	while(depth > 0)
494
	{
495
		int ch = cl_scope_lex();
496
		if(ch ==0)
497
		{
498
			break;
499
		}
500
		if(ch == '}')
501
		{
502
			depth--;
503
			if(depth == 0) currentScope.pop_back();//reduce the scope
504
			continue;
505
		}
506
		else if(ch == '{')
507
		{
508
			depth ++ ;
509
			continue;
510
		}
511
	}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
512
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
513
}
514
515
void consumeTemplateDecl()
516
{
517
	int depth = 1;
518
	while(depth > 0)
519
	{
520
		int ch = cl_scope_lex();
521
		//printf("ch=%d\n", ch);
522
		fflush(stdout);
523
		if(ch ==0){
524
			break;
525
		}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
526
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
527
		if(ch == '>')
528
		{
529
			depth--;
530
			continue;
531
		}
532
		else if(ch == '<')
533
		{
534
			depth ++ ;
535
			continue;
536
		}
537
	}
538
}
539
1430 by eranif
- Fixed: code completion was broken after expressions of type something = cond ? do1: do2;
540
//swallow all tokens up to the first '{'
541
void consumeNotIncluding(int ch){
542
	while( true ){
543
		int c = cl_scope_lex();
544
		if(c == 0){ // EOF?
545
			break;
546
		}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
547
1430 by eranif
- Fixed: code completion was broken after expressions of type something = cond ? do1: do2;
548
		//keep the function signature
549
		if(c == ch){
550
			cl_scope_less(0);
551
			break;
552
		}
553
	}
554
}
555
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
556
// return the scope name at the end of the input string
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
557
std::string get_scope_name(	const std::string &in,
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
558
							std::vector<std::string> &additionalNS,
846 by eranif
- 'resolve ambiguity' dialog now properly dismissed with ESC key
559
							const std::map<std::string, std::string> &ignoreTokens)
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
560
{
561
	if( !setLexerInput(in, ignoreTokens) ){
562
		return "";
563
	}
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
564
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
565
	//call tghe main parsing routine
566
	cl_scope_parse();
567
	std::string scope = getCurrentScope();
568
	//do the lexer cleanup
569
	cl_scope_lex_clean();
1629 by eranif
- Fixed: bug#[ 2342339 ] no code completion in constructor init line
570
1 by eranif
modified the directory structure to fit to standard SVN structure (tags, branches, trunk)
571
	for(size_t i=0; i<gs_additionlNS.size(); i++){
572
		additionalNS.push_back(gs_additionlNS.at(i));
573
	}
574
	gs_additionlNS.clear();
575
	return scope;
576
}