5 #define YYSIZE_T size_t
6 #define YYLTYPE Location
10 # define YYLLOC_DEFAULT(Current, Rhs, N) \
11 (Current).start = (Rhs)[1].start; \
12 (Current).end = (Rhs)[N].end;
15 Expression parsedExpression;
17 #define yyparse expression_yyparse
18 #define yylval expression_yylval
19 #define yychar expression_yychar
20 #define yydebug expression_yydebug
21 #define yynerrs expression_yynerrs
22 #define yylloc expression_yylloc
24 // #define PRECOMPILER
25 extern File fileInput;
41 SpecifierType specifierType;
46 Enumerator enumerator;
47 Declarator declarator;
49 Initializer initializer;
50 InitDeclarator initDeclarator;
52 Declaration declaration;
54 FunctionDefinition function;
61 Instantiation instance;
62 MembersInit membersInit;
63 MemberInit memberInit;
64 ClassFunction classFunction;
65 ClassDefinition _class;
74 %type <specifierType> struct_or_union
75 %type <i> unary_operator assignment_operator
77 %type <exp> primary_expression postfix_expression unary_expression cast_expression
78 multiplicative_expression additive_expression shift_expression
79 relational_expression equality_expression and_expression
80 exclusive_or_expression inclusive_or_expression logical_and_expression
81 logical_or_expression conditional_expression assignment_expression
83 common_unary_expression simple_primary_expression
84 anon_instantiation_expression
86 // simple_postfix_expression simple_unary_expression
88 %type <list> argument_expression_list expression enumerator_list
89 struct_declarator_list struct_declaration_list
90 declaration_specifiers identifier_list initializer_list init_declarator_list
91 parameter_list parameter_type_list declaration_list statement_list
92 members_initialization_list members_initialization_list_coloned data_member_initialization_list data_member_initialization_list_coloned
93 specifier_qualifier_list
94 type_qualifier_list property_specifiers
96 default_property_list attribs_list
99 %type <specifier> storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier strict_type_specifier
100 struct_or_union_specifier_compound struct_or_union_specifier_nocompound type strict_type
101 %type <enumerator> enumerator
102 %type <declarator> declarator direct_declarator direct_abstract_declarator abstract_declarator
103 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
104 direct_abstract_declarator_noarray abstract_declarator_noarray
106 %type <pointer> pointer
107 %type <initializer> initializer initializer_condition
108 %type <initDeclarator> init_declarator
109 %type <typeName> type_name parameter_declaration
110 %type <stmt> statement labeled_statement compound_statement expression_statement
111 selection_statement iteration_statement jump_statement compound_inside
113 %type <declaration> declaration
114 %type <classDef> struct_declaration
115 %type <string> string_literal attribute_word
116 %type <extDecl> ext_decl
117 %type <attrib> attrib
118 %type <attribute> attribute
120 %type <instance> instantiation_named instantiation_unnamed instantiation_anon
121 /* %type <membersInit> members_initialization */
122 %type <memberInit> data_member_initialization default_property
123 %type <classFunction> class_function_definition class_function_definition_start
124 virtual_class_function_definition_start
125 constructor_function_definition_start destructor_function_definition_start
126 %type <classFunction> instance_class_function_definition instance_class_function_definition_start
127 %type <prop> property
129 %type <context> compound_start
131 %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
132 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
133 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
134 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
135 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
137 %token TYPEDEF EXTERN STATIC AUTO REGISTER
138 %token CHAR SHORT INT UINT INT64 INT128 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
139 %token STRUCT UNION ENUM ELLIPSIS
141 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
145 %token CLASS THISCLASS CLASS_NAME
146 %token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
147 %token PUBLIC PRIVATE
148 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
149 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
150 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
151 %token NEW0OP RENEW0 VAARG
152 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
153 %token ALIGNOF ATTRIB_DEP __ATTRIB
154 %token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
155 %token WIDE_STRING_LITERAL
156 %token BUILTIN_OFFSETOF
158 %destructor { FreeIdentifier($$); } identifier
159 %destructor { FreePointer($$); } pointer
160 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
161 multiplicative_expression additive_expression shift_expression
162 relational_expression equality_expression and_expression
163 exclusive_or_expression inclusive_or_expression logical_and_expression
164 logical_or_expression conditional_expression assignment_expression
166 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
167 struct_or_union_specifier_compound struct_or_union_specifier_nocompound type strict_type strict_type_specifier
168 %destructor { FreeEnumerator($$); } enumerator
169 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
170 direct_abstract_declarator_noarray abstract_declarator_noarray
171 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
173 %destructor { FreeInitializer($$); } initializer initializer_condition
174 %destructor { FreeInitDeclarator($$); } init_declarator
175 %destructor { FreeTypeName($$); } type_name parameter_declaration
176 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
177 selection_statement iteration_statement jump_statement compound_inside
179 %destructor { FreeDeclaration($$); } declaration
181 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
183 %destructor { FreeMemberInit($$); } data_member_initialization default_property
185 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
186 virtual_class_function_definition_start
187 constructor_function_definition_start destructor_function_definition_start
188 instance_class_function_definition instance_class_function_definition_start
189 %destructor { FreeClassDef($$); } struct_declaration
190 %destructor { delete $$; } string_literal attribute_word
191 %destructor { FreeProperty($$); } property
193 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
194 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
195 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
196 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
197 %destructor { FreeList($$, FreeDeclaration); } declaration_list
198 %destructor { FreeList($$, FreeInitializer); } initializer_list
199 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
200 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
201 %destructor { FreeList($$, FreeStatement); } statement_list
202 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
203 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
204 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
205 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
206 %destructor { FreeAttrib($$); } attrib
207 %destructor { FreeExtDecl($$); } ext_decl
208 %destructor { FreeAttribute($$); } attribute
209 %destructor { FreeList($$, FreeAttribute); } attribs_list
211 %start expression_unit
217 { $$ = MkIdentifier(yytext); $$.loc = @1; }
221 simple_primary_expression
223 { $$ = MkExpBrackets($2); $$.loc = @$; }
226 simple_primary_expression:
228 { $$ = MkExpIdentifier($1); $$.loc = @$; }
229 | instantiation_unnamed
230 { $$ = MkExpInstance($1); $$.loc = @$; }
232 { $$ = MkExpConstant(yytext); $$.loc = @$; }
233 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
235 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
236 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
237 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
239 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
241 | NEWOP declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
242 | NEWOP declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
243 | NEW0OP declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
244 | NEW0OP declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
245 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
246 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
247 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
248 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
249 | error { $$ = MkExpDummy(); yyerror(); }
252 anon_instantiation_expression:
253 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
258 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
259 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
260 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
261 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
262 | postfix_expression identifier
264 char * constant = $1.type == constantExp ? $1.constant : null;
265 int len = constant ? strlen(constant) : 0;
266 if(constant && constant[len-1] == '.')
269 $$ = MkExpMember($1, $2);
275 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
276 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
277 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
281 simple_postfix_expression:
282 simple_primary_expression
283 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
284 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
285 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
286 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
287 | simple_postfix_expression identifier
289 char * constant = $1.type == constantExp ? $1.constant : null;
290 int len = constant ? strlen(constant) : 0;
291 if(constant && constant[len-1] == '.')
294 $$ = MkExpMember($1, $2);
300 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
301 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
302 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
306 argument_expression_list:
307 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
308 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
309 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
310 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
313 common_unary_expression:
314 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
315 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
316 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
317 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
318 //| SIZEOF simple_unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
319 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
320 | SIZEOF '(' type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
321 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
322 //| ALIGNOF simple_unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
323 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
324 | ALIGNOF '(' type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
328 common_unary_expression
332 /*simple_unary_expression:
333 common_unary_expression
334 | simple_postfix_expression
344 | DELETE { $$ = DELETE; }
349 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
352 multiplicative_expression:
354 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
355 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
356 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
360 multiplicative_expression
361 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
362 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
367 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
368 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
371 relational_expression:
373 | relational_expression '<' shift_expression { $$ = MkExpOp($1, '<', $3); $$.loc = @$; }
374 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
375 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
376 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
380 relational_expression
381 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
382 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
387 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
390 exclusive_or_expression:
392 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
395 inclusive_or_expression:
396 exclusive_or_expression
397 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
400 logical_and_expression:
401 inclusive_or_expression
402 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
405 logical_or_expression:
406 logical_and_expression
407 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
410 conditional_expression:
411 logical_or_expression
412 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
415 assignment_expression:
416 conditional_expression
417 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
418 | conditional_expression assignment_operator assignment_expression { yyerror(); $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
420 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
421 | conditional_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
426 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
427 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
428 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
429 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
430 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
431 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
432 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
433 | AND_ASSIGN { $$ = AND_ASSIGN; }
434 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
435 | OR_ASSIGN { $$ = OR_ASSIGN; }
439 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
440 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
444 conditional_expression
448 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
449 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
450 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
451 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
454 specifier_qualifier_list:
455 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
456 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
457 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
458 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
459 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
460 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
461 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
462 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
465 declaration_specifiers:
466 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
467 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
468 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
469 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
470 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
471 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
472 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
473 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
474 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
475 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
480 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
481 | property_specifiers storage_class_specifier { ListAdd($1, $2); }
482 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
483 | property_specifiers type_qualifier { ListAdd($1, $2); }
484 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
485 | property_specifiers type_specifier { ListAdd($1, $2); }
486 | type { $$ = MkList(); ListAdd($$, $1); }
487 | property_specifiers type { ListAdd($1, $2); }
491 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
492 | renew_specifiers storage_class_specifier { ListAdd($1, $2); }
493 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
494 | renew_specifiers type_qualifier { ListAdd($1, $2); }
495 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
496 | renew_specifiers strict_type_specifier { ListAdd($1, $2); }
497 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
498 | renew_specifiers struct_or_union_specifier_compound { ListAdd($1, $2); }
499 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
500 | renew_specifiers enum_specifier_compound { ListAdd($1, $2); }
503 init_declarator_list:
504 init_declarator { $$ = MkList(); ListAdd($$, $1); }
505 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
509 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
510 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
513 storage_class_specifier:
514 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
515 | EXTERN { $$ = MkSpecifier(EXTERN); }
516 | STATIC { $$ = MkSpecifier(STATIC); }
517 | AUTO { $$ = MkSpecifier(AUTO); }
518 | REGISTER { $$ = MkSpecifier(REGISTER); }
519 | THREAD { $$ = MkSpecifier(THREAD); }
523 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
524 | attrib { $$ = MkExtDeclAttrib($1); }
528 ATTRIB { $<i>$ = ATTRIB; }
529 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
530 | __ATTRIB { $<i>$ = __ATTRIB; }
535 IDENTIFIER { $$ = CopyString(yytext); }
536 | TYPE_NAME { $$ = CopyString(yytext); }
537 | EXT_STORAGE { $$ = CopyString(yytext); }
538 | EXT_DECL { $$ = CopyString(yytext); }
539 | CONST { $$ = CopyString(yytext); }
543 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
544 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
548 attribute { $$ = MkListOne($1); }
549 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
550 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
554 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
555 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
559 CONST { $$ = MkSpecifier(CONST); }
560 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
561 | EXT_STORAGE { $$ = MkSpecifierExtended(MkExtDeclString(CopyString(yytext))); }
565 strict_type { $$ = $1; }
566 /* | identifier identifier
569 DeclClass($1._class, $1.string);
570 fileInput.Seek(@1.start.pos, start);
571 resetScannerPos(&@1.start);
576 YY_STACK_PRINT (yyss, yyssp);
579 YY_STACK_PRINT (yyss, yyssp);
582 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
583 Compiler_Error($"Not a type: %s\n", $1.string);
584 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
590 TYPE_NAME { $$ = MkSpecifierName(yytext); }
594 VOID { $$ = MkSpecifier(VOID); }
595 | CHAR { $$ = MkSpecifier(CHAR); }
596 | SHORT { $$ = MkSpecifier(SHORT); }
597 | INT { $$ = MkSpecifier(INT); }
598 | UINT { $$ = MkSpecifier(UINT); }
599 | INT64 { $$ = MkSpecifier(INT64); }
600 | INT128 { $$ = MkSpecifier(INT128); }
601 | VALIST { $$ = MkSpecifier(VALIST); }
602 | LONG { $$ = MkSpecifier(LONG); }
603 | FLOAT { $$ = MkSpecifier(FLOAT); }
604 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
605 | SIGNED { $$ = MkSpecifier(SIGNED); }
606 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
607 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
608 | _BOOL { $$ = MkSpecifier(_BOOL); }
609 | BOOL { $$ = MkSpecifier(BOOL); }
610 | struct_or_union_specifier_nocompound
611 | enum_specifier_nocompound
613 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
614 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
617 strict_type_specifier:
618 VOID { $$ = MkSpecifier(VOID); }
619 | CHAR { $$ = MkSpecifier(CHAR); }
620 | SHORT { $$ = MkSpecifier(SHORT); }
621 | INT { $$ = MkSpecifier(INT); }
622 | UINT { $$ = MkSpecifier(UINT); }
623 | INT64 { $$ = MkSpecifier(INT64); }
624 | INT128 { $$ = MkSpecifier(INT128); }
625 | VALIST { $$ = MkSpecifier(VALIST); }
626 | LONG { $$ = MkSpecifier(LONG); }
627 | FLOAT { $$ = MkSpecifier(FLOAT); }
628 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
629 | SIGNED { $$ = MkSpecifier(SIGNED); }
630 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
631 | _BOOL { $$ = MkSpecifier(_BOOL); }
632 | BOOL { $$ = MkSpecifier(BOOL); }
633 | struct_or_union_specifier_nocompound
634 | enum_specifier_nocompound
636 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
637 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
641 struct_or_union_specifier_compound:
642 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2._class, $2.string); }
643 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
644 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
645 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
646 | struct_or_union strict_type '{' struct_declaration_list '}'
647 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
649 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
650 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
651 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
652 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
653 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
654 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
657 struct_or_union_specifier_nocompound:
658 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
659 | struct_or_union strict_type
660 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
662 | struct_or_union ext_decl identifier
663 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3._class, $3.string); }
664 | struct_or_union ext_decl strict_type
665 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
669 STRUCT { $$ = structSpecifier; }
670 | UNION { $$ = unionSpecifier; }
673 struct_declaration_list:
674 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
675 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
679 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end; }
682 default_property_list:
683 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
684 | default_property_list ',' default_property { $$ = $1; ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
688 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
689 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
690 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
691 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
692 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
693 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
694 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
695 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
696 | PROPERTY property_specifiers identifier '{' '}'
697 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
699 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
700 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
701 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
702 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
703 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
704 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
705 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
706 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
707 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
708 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
710 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
711 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
712 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
713 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
714 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
715 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
716 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
717 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
718 | PROPERTY property_specifiers '{' '}'
719 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
721 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
722 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
723 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
724 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
725 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
726 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
727 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
728 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
729 | PROPERTY property_specifiers abstract_declarator '{' '}'
730 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
734 declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
735 | declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
736 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
737 | instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
738 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
739 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
740 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
744 struct_declarator_list:
746 { $$ = MkList(); ListAdd($$, $1); }
747 | struct_declarator_list ',' struct_declarator
748 { $$ = $1; ListAdd($1, $3); }
753 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
755 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
756 | ':' constant_expression
757 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
758 | declarator ':' constant_expression
759 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
760 | declarator ':' constant_expression ':' constant_expression
761 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
764 enum_specifier_nocompound:
765 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2._class, $2.string); }
766 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
769 enum_specifier_compound:
770 ENUM '{' enumerator_list '}'
771 { $$ = MkEnum(null, $3); }
772 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2._class, $2.string); }
773 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2._class, $2.string); }
774 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
775 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
780 { $$ = MkList(); ListAdd($$, $1); }
781 | enumerator_list ',' enumerator
782 { $$ = $1; ListAdd($1, $3); }
787 { $$ = MkEnumerator($1, null); }
788 | identifier '=' constant_expression
789 { $$ = MkEnumerator($1, $3); }
793 direct_abstract_declarator:
794 '(' abstract_declarator ')'
795 { $$ = MkDeclaratorBrackets($2); }
797 { $$ = MkDeclaratorArray(null, null); }
798 | '[' constant_expression ']'
799 { $$ = MkDeclaratorArray(null, $2); }
801 { $$ = MkDeclaratorEnumArray(null, $2); }
802 | direct_abstract_declarator '[' ']'
803 { $$ = MkDeclaratorArray($1, null); }
804 | direct_abstract_declarator '[' constant_expression ']'
805 { $$ = MkDeclaratorArray($1, $3); }
806 | direct_abstract_declarator '[' type']'
807 { $$ = MkDeclaratorEnumArray($1, $3); }
809 { $$ = MkDeclaratorFunction(null, null); }
810 | '(' parameter_type_list ')'
811 { $$ = MkDeclaratorFunction(null, $2); }
812 | direct_abstract_declarator '(' ')'
813 { $$ = MkDeclaratorFunction($1, null); }
814 | direct_abstract_declarator '(' parameter_type_list ')'
815 { $$ = MkDeclaratorFunction($1, $3); }
818 direct_abstract_declarator_noarray:
819 '(' abstract_declarator_noarray ')'
820 { $$ = MkDeclaratorBrackets($2); }
822 { $$ = MkDeclaratorFunction(null, null); }
823 | '(' parameter_type_list ')'
824 { $$ = MkDeclaratorFunction(null, $2); }
825 | direct_abstract_declarator_noarray '(' ')'
826 { $$ = MkDeclaratorFunction($1, null); }
827 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
828 { $$ = MkDeclaratorFunction($1, $3); }
832 pointer { $$ = MkDeclaratorPointer($1, null); }
833 | direct_abstract_declarator
834 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
835 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
836 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
837 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
840 abstract_declarator_noarray:
841 pointer { $$ = MkDeclaratorPointer($1, null); }
842 | direct_abstract_declarator_noarray
843 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
844 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
845 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
846 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
852 { $$ = MkDeclaratorPointer($1, null); }
853 | direct_abstract_declarator
854 | pointer direct_abstract_declarator
855 { $$ = MkDeclaratorPointer($1, $2); }
858 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
859 | ext_decl direct_abstract_declarator
860 { $$ = MkDeclaratorExtended($1, $2); }
861 | ext_decl pointer direct_abstract_declarator
862 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
866 direct_abstract_declarator:
867 '(' abstract_declarator ')'
868 { $$ = MkDeclaratorBrackets($2); }
870 { $$ = MkDeclaratorArray(null, null); }
871 | '[' constant_expression ']'
872 { $$ = MkDeclaratorArray(null, $2); }
874 { $$ = MkDeclaratorEnumArray(null, $2); }
875 | direct_abstract_declarator '[' ']'
876 { $$ = MkDeclaratorArray($1, null); }
877 | direct_abstract_declarator '[' constant_expression ']'
878 { $$ = MkDeclaratorArray($1, $3); }
879 | direct_abstract_declarator '[' type ']'
880 { $$ = MkDeclaratorEnumArray($1, $3); }
882 { $$ = MkDeclaratorFunction(null, null); }
883 | '(' parameter_type_list ')'
884 { $$ = MkDeclaratorFunction(null, $2); }
885 | direct_abstract_declarator '(' ')'
886 { $$ = MkDeclaratorFunction($1, null); }
887 | direct_abstract_declarator '(' parameter_type_list ')'
888 { $$ = MkDeclaratorFunction($1, $3); }
893 | pointer direct_declarator
894 { $$ = MkDeclaratorPointer($1, $2); }
895 | ext_decl pointer direct_declarator
896 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
900 direct_declarator_nofunction:
902 { $$ = MkDeclaratorIdentifier($1); }
904 { $$ = MkDeclaratorBrackets($2); }
905 | direct_declarator_nofunction '[' constant_expression ']'
906 { $$ = MkDeclaratorArray($1, $3); }
907 | direct_declarator_nofunction '[' ']'
908 { $$ = MkDeclaratorArray($1, null); }
909 | direct_declarator_nofunction '[' type ']'
910 { $$ = MkDeclaratorEnumArray($1, $3); }
914 direct_declarator_function
915 | pointer direct_declarator_function
916 { $$ = MkDeclaratorPointer($1, $2); }
918 | ext_decl direct_declarator_function
919 { $$ = MkDeclaratorExtended($1, $2); }
920 | ext_decl pointer direct_declarator_function
921 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
922 | pointer ext_decl direct_declarator_function
923 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
928 direct_declarator_function
929 | direct_declarator_nofunction
930 | ext_decl direct_declarator_function
931 { $$ = MkDeclaratorExtended($1, $2); }
932 | ext_decl direct_declarator_nofunction
933 { $$ = MkDeclaratorExtended($1, $2); }
936 direct_declarator_function_start:
937 direct_declarator_nofunction '('
940 direct_declarator_function:
941 direct_declarator_function_start parameter_type_list ')'
942 { $$ = MkDeclaratorFunction($1, $2); }
943 | direct_declarator_function_start identifier_list ')'
944 { $$ = MkDeclaratorFunction($1, $2); }
945 | direct_declarator_function_start ')'
946 { $$ = MkDeclaratorFunction($1, null); }
950 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
951 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
955 '*' { $$ = MkPointer(null, null); }
956 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
957 | '*' pointer { $$ = MkPointer(null, $2); }
958 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
963 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
967 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
968 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
971 parameter_declaration:
972 declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
973 | declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
974 | declaration_specifiers { $$ = MkTypeName($1, null); }
978 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
979 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
983 specifier_qualifier_list { $$ = MkTypeName($1, null); }
984 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
988 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
989 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
993 assignment_expression
994 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
995 | '{' initializer_list '}'
996 { $$ = MkInitializerList($2); $$.loc = @$; }
997 | '{' initializer_list ',' '}'
999 $$ = MkInitializerList($2);
1003 Expression exp = MkExpDummy();
1004 Initializer init = MkInitializerAssignment(exp);
1012 initializer_condition:
1013 conditional_expression { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1014 | anon_instantiation_expression
1015 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1017 | '{' initializer_list '}' { $$ = MkInitializerList($2); $$.loc = @$; }
1018 | '{' initializer_list ',' '}'
1020 $$ = MkInitializerList($2);
1024 Expression exp = MkExpDummy();
1025 Initializer init = MkInitializerAssignment(exp);
1036 { $$ = MkList(); ListAdd($$, $1); }
1037 | initializer_list ',' initializer
1038 { $$ = $1; ListAdd($1, $3); }
1043 | compound_statement
1044 | expression_statement
1045 | selection_statement
1046 | iteration_statement
1051 identifier ':' statement
1052 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1053 | CASE constant_expression ':' statement
1054 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1055 | DEFAULT ':' statement
1056 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1060 declaration { $$ = MkList(); ListAdd($$, $1); }
1061 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1065 statement { $$ = MkList(); ListAdd($$, $1); }
1066 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1068 // declaration not allowed after statements
1069 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1073 statement_list { $$ = MkCompoundStmt(null, $1); }
1074 | declaration_list { $$ = MkCompoundStmt($1, null); }
1075 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1079 '{' { $<context>$ = PushContext(); }
1085 $$ = MkCompoundStmt(null, null);
1086 $$.compound.context = PushContext();
1087 PopContext($$.compound.context);
1091 | compound_start compound_inside '}'
1092 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1095 expression_statement:
1096 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1097 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1100 selection_statement:
1101 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1102 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1103 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1106 iteration_statement:
1107 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1108 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1109 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1110 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1112 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1113 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1114 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1118 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1119 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1120 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1121 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1122 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1126 STRING_LITERAL { $$ = CopyString(yytext); }
1129 instantiation_named:
1130 declaration_specifiers identifier '{' members_initialization_list '}'
1131 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1132 | declaration_specifiers identifier '{' '}'
1133 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1136 instantiation_unnamed:
1137 type '{' members_initialization_list '}'
1138 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1140 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1141 | identifier '{' members_initialization_list '}'
1142 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1143 | identifier '{' '}'
1144 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1148 '{' members_initialization_list '}'
1149 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1151 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1154 class_function_definition_start:
1155 declaration_specifiers declarator_function
1156 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1157 | declarator_function
1158 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
1161 constructor_function_definition_start:
1162 declaration_specifiers '(' ')'
1163 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
1166 destructor_function_definition_start:
1167 '~' declaration_specifiers '(' ')'
1168 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
1171 virtual_class_function_definition_start:
1172 VIRTUAL declaration_specifiers declarator_function
1173 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
1174 | VIRTUAL declarator_function
1175 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
1178 class_function_definition:
1179 class_function_definition_start compound_statement
1180 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1181 | virtual_class_function_definition_start compound_statement
1182 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1183 | virtual_class_function_definition_start ';'
1184 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1185 | constructor_function_definition_start compound_statement
1186 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1187 | destructor_function_definition_start compound_statement
1188 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1191 instance_class_function_definition_start:
1192 // Guess here conflicts with an expression...
1193 declaration_specifiers declarator_function
1194 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1197 instance_class_function_definition:
1198 instance_class_function_definition_start compound_statement
1199 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1202 data_member_initialization:
1203 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1204 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1207 data_member_initialization_list:
1208 data_member_initialization
1209 { $$ = MkList(); ListAdd($$, $1); }
1210 | data_member_initialization_list ',' data_member_initialization
1211 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1214 data_member_initialization_list_coloned:
1215 data_member_initialization_list ';'
1216 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1219 members_initialization_list_coloned:
1220 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1221 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1222 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1223 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
1224 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1225 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1228 members_initialization_list:
1229 members_initialization_list_coloned
1230 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1231 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1235 assignment_expression { parsedExpression = $1; }