5 #define YYLTYPE Location
9 # define YYLLOC_DEFAULT(Current, Rhs, N) \
10 (Current).start = (Rhs)[1].start; \
11 (Current).end = (Rhs)[N].end;
18 #define yyparse type_yyparse
19 #define yylval type_yylval
20 #define yychar type_yychar
21 #define yydebug type_yydebug
22 #define yynerrs type_yynerrs
23 #define yylloc type_yylloc
25 extern bool parseTypeError;
27 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;
70 TemplateParameter templateParameter;
71 TemplateArgument templateArgument;
72 TemplateDatatype templateDatatype;
77 %type <specifierType> struct_or_union
78 %type <i> unary_operator assignment_operator
80 %type <exp> primary_expression postfix_expression unary_expression cast_expression
81 multiplicative_expression additive_expression shift_expression
82 relational_expression relational_expression_smaller_than equality_expression and_expression
83 exclusive_or_expression inclusive_or_expression logical_and_expression
84 logical_or_expression conditional_expression assignment_expression
86 common_unary_expression simple_primary_expression
87 anon_instantiation_expression
89 //simple_postfix_expression simple_unary_expression
91 %type <list> argument_expression_list expression enumerator_list
92 struct_declarator_list struct_declaration_list
93 declaration_specifiers identifier_list initializer_list init_declarator_list
94 parameter_list parameter_type_list declaration_list statement_list
95 members_initialization_list members_initialization_list_coloned data_member_initialization_list data_member_initialization_list_coloned
96 guess_declaration_specifiers real_guess_declaration_specifiers
97 specifier_qualifier_list guess_specifier_qualifier_list
98 type_qualifier_list property_specifiers
100 default_property_list
101 template_arguments_list attribs_list
104 %type <specifier> storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier strict_type_specifier
105 struct_or_union_specifier_compound struct_or_union_specifier_nocompound guess_type type strict_type
106 real_guess_type ext_storage base_strict_type
107 %type <enumerator> enumerator
108 %type <declarator> declarator direct_declarator direct_abstract_declarator abstract_declarator
109 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
110 direct_abstract_declarator_noarray abstract_declarator_noarray declarator_nofunction
112 %type <pointer> pointer
113 %type <initializer> initializer initializer_condition
114 %type <initDeclarator> init_declarator
115 %type <typeName> type_name guess_type_name parameter_declaration
116 %type <stmt> statement labeled_statement compound_statement expression_statement
117 selection_statement iteration_statement jump_statement compound_inside
119 %type <declaration> declaration
120 %type <classDef> struct_declaration
121 %type <string> string_literal attribute_word
122 %type <extDecl> ext_decl
123 %type <attrib> attrib
124 %type <attribute> attribute
126 %type <instance> instantiation_named instantiation_unnamed guess_instantiation_named instantiation_anon
127 /* %type <membersInit> members_initialization */
128 %type <memberInit> data_member_initialization default_property
129 %type <classFunction> class_function_definition class_function_definition_start
130 virtual_class_function_definition_start
131 constructor_function_definition_start destructor_function_definition_start
132 %type <classFunction> instance_class_function_definition instance_class_function_definition_start
133 %type <prop> property
135 %type <templateArgument> template_argument template_type_argument template_expression_argument
136 %type <templateDatatype> template_datatype
138 %type <context> compound_start
140 %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
141 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
142 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
143 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
144 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
146 %token TYPEDEF EXTERN STATIC AUTO REGISTER
147 %token CHAR SHORT INT UINT INT64 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
148 %token STRUCT UNION ENUM ELLIPSIS
150 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
154 %token CLASS THISCLASS CLASS_NAME
155 %token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
156 %token PUBLIC PRIVATE
157 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
158 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
159 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
160 %token NEW0OP RENEW0 VAARG
161 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
162 %token ALIGNOF ATTRIB_DEP __ATTRIB
163 %token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
164 %token WIDE_STRING_LITERAL
166 %destructor { FreeIdentifier($$); } identifier
167 %destructor { FreePointer($$); } pointer
168 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
169 multiplicative_expression additive_expression shift_expression
170 relational_expression equality_expression and_expression
171 exclusive_or_expression inclusive_or_expression logical_and_expression
172 logical_or_expression conditional_expression assignment_expression
174 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
175 struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type strict_type_specifier
177 %destructor { FreeEnumerator($$); } enumerator
178 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
179 direct_abstract_declarator_noarray abstract_declarator_noarray
180 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
181 declarator_nofunction
183 %destructor { FreeInitializer($$); } initializer initializer_condition
184 %destructor { FreeInitDeclarator($$); } init_declarator
185 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration
186 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
187 selection_statement iteration_statement jump_statement compound_inside
189 %destructor { FreeDeclaration($$); } declaration
191 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
193 %destructor { FreeMemberInit($$); } data_member_initialization default_property
195 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
196 virtual_class_function_definition_start
197 constructor_function_definition_start destructor_function_definition_start
198 instance_class_function_definition instance_class_function_definition_start
199 %destructor { FreeClassDef($$); } struct_declaration
200 %destructor { delete $$; } string_literal attribute_word
201 %destructor { FreeProperty($$); } property
203 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
204 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
205 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
206 guess_declaration_specifiers guess_specifier_qualifier_list
207 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
208 %destructor { FreeList($$, FreeDeclaration); } declaration_list
209 %destructor { FreeList($$, FreeInitializer); } initializer_list
210 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
211 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
212 %destructor { FreeList($$, FreeStatement); } statement_list
213 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
214 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
215 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
216 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
217 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_expression_argument
218 %destructor { FreeTemplateDataType($$); } template_datatype
219 %destructor { FreeAttrib($$); } attrib
220 %destructor { FreeExtDecl($$); } ext_decl
221 %destructor { FreeAttribute($$); } attribute
222 %destructor { FreeList($$, FreeAttribute); } attribs_list
232 DeclClass($1._class, $1.string);
233 fileInput.Seek(@1.start.pos, start);
234 resetScannerPos(&@1.start);
241 YY_STACK_PRINT (yyss, yyssp);
244 YY_STACK_PRINT (yyss, yyssp);
251 _DeclClass($1._class, $1.string);
255 fileInput.Seek(@1.start.pos, start);
256 resetScannerPos(&@1.start);
261 YY_STACK_PRINT (yyss, yyssp);
264 YY_STACK_PRINT (yyss, yyssp);
273 DeclClass($1._class, $1.string);
274 fileInput.Seek(@1.start.pos, start);
276 resetScannerPos(&@1.start);
282 YY_STACK_PRINT (yyss, yyssp);
285 YY_STACK_PRINT (yyss, yyssp);
291 _DeclClass($1._class, $1.string);
295 fileInput.Seek(@1.start.pos, start);
296 resetScannerPos(&@1.start);
301 YY_STACK_PRINT (yyss, yyssp);
304 YY_STACK_PRINT (yyss, yyssp);
311 strict_type { $$ = $1; }
312 | identifier identifier
315 DeclClass($1._class, $1.string);
316 fileInput.Seek(@1.start.pos, start);
317 resetScannerPos(&@1.start);
325 YY_STACK_PRINT (yyss, yyssp);
328 YY_STACK_PRINT (yyss, yyssp);
331 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
332 Compiler_Error($"Not a type: %s\n", $1.string);
333 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
339 TYPE_NAME { $$ = MkSpecifierName(yytext); }
344 | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
345 | base_strict_type '<' template_arguments_list RIGHT_OP
348 SetClassTemplateArgs($$, $3);
352 fileInput.Seek(@4.end.pos, start);
353 resetScannerPos(&@4.end);
357 /* | identifier '<' template_arguments_list '>'
358 { $$ = MkSpecifierNameArgs($1.string, $3); $$.loc = @$; FreeIdentifier($1); } */
361 class_function_definition_start:
362 guess_declaration_specifiers declarator_function
363 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
364 | declarator_function
365 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
368 constructor_function_definition_start:
369 guess_declaration_specifiers '(' ')'
370 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
373 destructor_function_definition_start:
374 '~' guess_declaration_specifiers '(' ')'
375 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
378 virtual_class_function_definition_start:
379 VIRTUAL guess_declaration_specifiers declarator_function
380 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
381 | VIRTUAL declarator_function
382 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
387 { $$ = MkIdentifier(yytext); $$.loc = @1; }
391 simple_primary_expression
393 { $$ = MkExpBrackets($2); $$.loc = @$; }
396 simple_primary_expression:
398 { $$ = MkExpIdentifier($1); $$.loc = @$; }
399 | instantiation_unnamed
400 { $$ = MkExpInstance($1); $$.loc = @$; }
402 { $$ = MkExpConstant(yytext); $$.loc = @$; }
403 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
405 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
406 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
407 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
409 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
411 | NEWOP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
412 | NEWOP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
413 | NEW0OP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
414 | NEW0OP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
415 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
416 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
417 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
418 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
419 | error { $$ = MkExpDummy(); }
424 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
425 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
426 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
427 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
428 | postfix_expression identifier
430 char * constant = $1.type == constantExp ? $1.constant : null;
431 int len = constant ? strlen(constant) : 0;
432 if(constant && constant[len-1] == '.')
435 $$ = MkExpMember($1, $2);
441 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
442 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
443 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
446 anon_instantiation_expression:
447 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
451 simple_postfix_expression:
452 simple_primary_expression
453 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
454 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
455 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
456 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
457 | simple_postfix_expression identifier
459 char * constant = $1.type == constantExp ? $1.constant : null;
460 int len = constant ? strlen(constant) : 0;
461 if(constant && constant[len-1] == '.')
464 $$ = MkExpMember($1, $2);
470 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
471 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
472 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
475 argument_expression_list:
476 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
477 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
478 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
479 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
482 common_unary_expression:
483 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
484 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
485 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
486 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
487 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
488 | SIZEOF '(' guess_type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
489 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
490 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
491 | ALIGNOF '(' guess_type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
495 common_unary_expression
499 simple_unary_expression:
500 common_unary_expression
501 | simple_postfix_expression
511 | DELETE { $$ = DELETE; }
516 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
519 multiplicative_expression:
521 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
522 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
523 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
527 multiplicative_expression
528 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
529 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
534 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
535 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
538 relational_expression_smaller_than:
539 relational_expression '<'
546 relational_expression:
548 | relational_expression_smaller_than /*relational_expression '<' */ shift_expression { skipErrors = false; $$ = MkExpOp($1, '<', $2/*$3*/); $$.loc = @$; }
549 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
550 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
551 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
555 relational_expression
556 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
557 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
562 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
565 exclusive_or_expression:
567 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
570 inclusive_or_expression:
571 exclusive_or_expression
572 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
575 logical_and_expression:
576 inclusive_or_expression
577 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
580 logical_or_expression:
581 logical_and_expression
582 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
585 conditional_expression:
586 logical_or_expression
587 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
590 assignment_expression:
591 conditional_expression
592 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
593 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
598 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
599 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
600 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
601 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
602 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
603 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
604 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
605 | AND_ASSIGN { $$ = AND_ASSIGN; }
606 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
607 | OR_ASSIGN { $$ = OR_ASSIGN; }
611 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
612 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
616 conditional_expression
620 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
621 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
622 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
623 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
626 specifier_qualifier_list:
627 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
628 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
629 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
630 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
631 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
632 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
633 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
634 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
637 guess_specifier_qualifier_list:
638 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
639 | guess_specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
640 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
641 | guess_specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
642 | guess_type { $$ = MkList(); ListAdd($$, $1); }
643 | guess_specifier_qualifier_list guess_type { $$ = $1; ListAdd($1, $2); }
644 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
645 | guess_specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
646 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
647 | guess_specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
650 declaration_specifiers:
651 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
652 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
653 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
654 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
655 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
656 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
657 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
658 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
659 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
660 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
663 guess_declaration_specifiers:
664 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
665 | guess_declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
666 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
667 | guess_declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
668 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
669 | guess_declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
670 | guess_type { $$ = MkList(); ListAdd($$, $1); }
671 | guess_declaration_specifiers guess_type { $$ = $1; ListAdd($1, $2); }
672 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
673 | guess_declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
674 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
675 | guess_declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
678 real_guess_declaration_specifiers:
679 guess_declaration_specifiers { $$ = $1; }
680 | real_guess_type { $$ = MkList(); ListAdd($$, $1); }
684 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
685 | property_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
686 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
687 | property_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
688 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
689 | property_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
690 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
691 | property_specifiers identifier { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
692 | identifier '<' template_arguments_list '>'
694 _DeclClass($1._class, $1.string);
697 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
700 | property_specifiers identifier '<' template_arguments_list '>'
702 _DeclClass($2._class, $2.string);
703 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
709 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
710 | renew_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
711 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
712 | renew_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
713 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
714 | renew_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
715 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
716 | renew_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
717 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
718 | renew_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
719 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
720 | renew_specifiers identifier { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
721 | identifier '<' template_arguments_list '>'
723 _DeclClass($1._class, $1.string);
726 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
729 | renew_specifiers identifier '<' template_arguments_list '>'
731 _DeclClass($2._class, $2.string);
732 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
737 init_declarator_list:
738 init_declarator { $$ = MkList(); ListAdd($$, $1); }
739 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
743 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
744 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
747 storage_class_specifier:
748 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
749 | EXTERN { $$ = MkSpecifier(EXTERN); }
750 | STATIC { $$ = MkSpecifier(STATIC); }
751 | AUTO { $$ = MkSpecifier(AUTO); }
752 | REGISTER { $$ = MkSpecifier(REGISTER); }
753 | THREAD { $$ = MkSpecifier(THREAD); }
757 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
758 | EXT_STORAGE { $$ = MkExtDeclString(CopyString(yytext)); }
759 | attrib { $$ = MkExtDeclAttrib($1); }
763 ATTRIB { $<i>$ = ATTRIB; }
764 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
765 | __ATTRIB { $<i>$ = __ATTRIB; }
770 IDENTIFIER { $$ = CopyString(yytext); }
771 | TYPE_NAME { $$ = CopyString(yytext); }
772 | EXT_STORAGE { $$ = CopyString(yytext); }
773 | EXT_DECL { $$ = CopyString(yytext); }
774 | CONST { $$ = CopyString(yytext); }
778 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
779 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
783 attribute { $$ = MkListOne($1); }
784 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
785 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
789 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
790 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
794 ext_decl { $$ = MkSpecifierExtended($1); }
798 CONST { $$ = MkSpecifier(CONST); }
799 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
800 | ext_storage { $$ = $1; }
805 VOID { $$ = MkSpecifier(VOID); }
806 | CHAR { $$ = MkSpecifier(CHAR); }
807 | SHORT { $$ = MkSpecifier(SHORT); }
808 | INT { $$ = MkSpecifier(INT); }
809 | UINT { $$ = MkSpecifier(UINT); }
810 | INT64 { $$ = MkSpecifier(INT64); }
811 | VALIST { $$ = MkSpecifier(VALIST); }
812 | LONG { $$ = MkSpecifier(LONG); }
813 | FLOAT { $$ = MkSpecifier(FLOAT); }
814 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
815 | SIGNED { $$ = MkSpecifier(SIGNED); }
816 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
817 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
818 | _BOOL { $$ = MkSpecifier(_BOOL); }
819 | BOOL { $$ = MkSpecifier(BOOL); }
820 | struct_or_union_specifier_nocompound
821 | enum_specifier_nocompound
823 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
824 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
825 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
826 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
827 | TYPED_OBJECT { $$ = MkSpecifier(TYPED_OBJECT); }
828 | ANY_OBJECT { $$ = MkSpecifier(ANY_OBJECT); }
831 strict_type_specifier:
832 VOID { $$ = MkSpecifier(VOID); }
833 | CHAR { $$ = MkSpecifier(CHAR); }
834 | SHORT { $$ = MkSpecifier(SHORT); }
835 | INT { $$ = MkSpecifier(INT); }
836 | UINT { $$ = MkSpecifier(UINT); }
837 | INT64 { $$ = MkSpecifier(INT64); }
838 | VALIST { $$ = MkSpecifier(VALIST); }
839 | LONG { $$ = MkSpecifier(LONG); }
840 | FLOAT { $$ = MkSpecifier(FLOAT); }
841 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
842 | SIGNED { $$ = MkSpecifier(SIGNED); }
843 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
844 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
845 | _BOOL { $$ = MkSpecifier(_BOOL); }
846 | BOOL { $$ = MkSpecifier(BOOL); }
847 | struct_or_union_specifier_nocompound
848 | enum_specifier_nocompound
850 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
851 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
852 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
853 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
857 struct_or_union_specifier_compound:
858 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2._class, $2.string); }
859 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
860 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
861 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
862 | struct_or_union base_strict_type '{' struct_declaration_list '}'
863 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
865 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
866 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
867 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
868 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
869 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
870 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
873 struct_or_union_specifier_nocompound:
874 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
875 | struct_or_union strict_type
876 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
878 | struct_or_union ext_decl identifier
879 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3._class, $3.string); }
880 | struct_or_union ext_decl strict_type
881 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
885 guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
886 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
887 /*| identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }*/
890 template_type_argument:
891 guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
892 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
893 //template_datatype { $$ = MkTemplateTypeArgument($1); }
897 template_identifier_argument:
898 identifier { $$ = MkTemplateIdentifierArgument($1); }
902 template_expression_argument:
903 shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
907 template_expression_argument
908 /*| template_identifier_argument*/
909 | template_type_argument
910 | identifier '=' template_expression_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
911 /*| identifier '=' template_identifier_argument { $$ = $3; $$.name = $1; $$.loc = @$; }*/
912 | identifier '=' template_type_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
913 | template_datatype '=' template_expression_argument
916 if($1.specifiers && $1.specifiers->first)
918 Specifier spec = $1.specifiers->first;
919 if(spec.type == nameSpecifier)
920 $$.name = MkIdentifier(spec.name);
922 FreeTemplateDataType($1);
925 /*| template_datatype '=' template_identifier_argument
928 if($1.specifiers && $1.specifiers->first)
930 Specifier spec = $1.specifiers->first;
931 if(spec.type == nameSpecifier)
932 $$.name = MkIdentifier(spec.name);
934 FreeTemplateDataType($1);
937 | template_datatype '=' template_type_argument
940 if($1.specifiers && $1.specifiers->first)
942 Specifier spec = $1.specifiers->first;
943 if(spec.type == nameSpecifier)
944 $$.name = MkIdentifier(spec.name);
946 FreeTemplateDataType($1);
951 template_arguments_list:
952 template_argument { $$ = MkList(); ListAdd($$, $1); }
953 | template_arguments_list ',' template_argument { ListAdd($1, $3); }
957 STRUCT { $$ = structSpecifier; }
958 | UNION { $$ = unionSpecifier; }
961 struct_declaration_list:
962 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
963 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
967 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; }
970 default_property_list:
971 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
972 | default_property_list ',' default_property { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
976 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
977 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
978 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
979 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
980 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
981 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
982 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
983 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
984 | PROPERTY property_specifiers identifier '{' '}'
985 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
987 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
988 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
989 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
990 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
991 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
992 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
993 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
994 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
995 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
996 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
998 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
999 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
1000 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
1001 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
1002 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
1003 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
1004 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
1005 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
1006 | PROPERTY property_specifiers '{' '}'
1007 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
1009 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
1010 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
1011 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
1012 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
1013 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
1014 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
1015 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
1016 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
1017 | PROPERTY property_specifiers abstract_declarator '{' '}'
1018 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
1022 guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
1023 | guess_declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
1024 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1025 | guess_instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1026 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
1027 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
1028 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
1029 | ';' { $$ = null; }
1032 struct_declarator_list:
1034 { $$ = MkList(); ListAdd($$, $1); }
1035 | struct_declarator_list ',' struct_declarator
1036 { $$ = $1; ListAdd($1, $3); }
1040 declarator_nofunction
1041 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
1042 | declarator_nofunction attrib
1043 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
1044 | ':' constant_expression
1045 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
1046 | declarator_nofunction ':' constant_expression
1047 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
1048 | declarator_nofunction ':' constant_expression ':' constant_expression
1049 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
1052 enum_specifier_nocompound:
1053 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2._class, $2.string); }
1054 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1057 enum_specifier_compound:
1058 ENUM '{' enumerator_list '}'
1059 { $$ = MkEnum(null, $3); }
1060 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2._class, $2.string); }
1061 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2._class, $2.string); }
1062 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1063 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1068 { $$ = MkList(); ListAdd($$, $1); }
1069 | enumerator_list ',' enumerator
1070 { $$ = $1; ListAdd($1, $3); }
1075 { $$ = MkEnumerator($1, null); }
1076 | identifier '=' constant_expression
1077 { $$ = MkEnumerator($1, $3); }
1081 direct_abstract_declarator:
1082 '(' abstract_declarator ')'
1083 { $$ = MkDeclaratorBrackets($2); }
1085 { $$ = MkDeclaratorArray(null, null); }
1086 | '[' constant_expression ']'
1087 { $$ = MkDeclaratorArray(null, $2); }
1089 { $$ = MkDeclaratorEnumArray(null, $2); }
1090 | direct_abstract_declarator '[' ']'
1091 { $$ = MkDeclaratorArray($1, null); }
1092 | direct_abstract_declarator '[' constant_expression ']'
1093 { $$ = MkDeclaratorArray($1, $3); }
1094 | direct_abstract_declarator '[' type']'
1095 { $$ = MkDeclaratorEnumArray($1, $3); }
1097 { $$ = MkDeclaratorFunction(null, null); }
1098 | '(' parameter_type_list ')'
1099 { $$ = MkDeclaratorFunction(null, $2); }
1100 | direct_abstract_declarator '(' ')'
1101 { $$ = MkDeclaratorFunction($1, null); }
1102 | direct_abstract_declarator '(' parameter_type_list ')'
1103 { $$ = MkDeclaratorFunction($1, $3); }
1106 direct_abstract_declarator_noarray:
1107 '(' abstract_declarator_noarray ')'
1108 { $$ = MkDeclaratorBrackets($2); }
1110 { $$ = MkDeclaratorFunction(null, null); }
1111 | '(' parameter_type_list ')'
1112 { $$ = MkDeclaratorFunction(null, $2); }
1113 | direct_abstract_declarator_noarray '(' ')'
1114 { $$ = MkDeclaratorFunction($1, null); }
1115 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
1116 { $$ = MkDeclaratorFunction($1, $3); }
1119 abstract_declarator:
1120 pointer { $$ = MkDeclaratorPointer($1, null); }
1121 | direct_abstract_declarator
1122 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
1123 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1124 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
1125 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1128 abstract_declarator_noarray:
1129 pointer { $$ = MkDeclaratorPointer($1, null); }
1130 | direct_abstract_declarator_noarray
1131 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
1132 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1133 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
1134 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1138 abstract_declarator:
1140 { $$ = MkDeclaratorPointer($1, null); }
1141 | direct_abstract_declarator
1142 | pointer direct_abstract_declarator
1143 { $$ = MkDeclaratorPointer($1, $2); }
1146 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1147 | ext_decl direct_abstract_declarator
1148 { $$ = MkDeclaratorExtended($1, $2); }
1149 | ext_decl pointer direct_abstract_declarator
1150 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1154 direct_abstract_declarator:
1155 '(' abstract_declarator ')'
1156 { $$ = MkDeclaratorBrackets($2); }
1158 { $$ = MkDeclaratorArray(null, null); }
1159 | '[' constant_expression ']'
1160 { $$ = MkDeclaratorArray(null, $2); }
1162 { $$ = MkDeclaratorEnumArray(null, $2); }
1163 | direct_abstract_declarator '[' ']'
1164 { $$ = MkDeclaratorArray($1, null); }
1165 | direct_abstract_declarator '[' constant_expression ']'
1166 { $$ = MkDeclaratorArray($1, $3); }
1167 | direct_abstract_declarator '[' type ']'
1168 { $$ = MkDeclaratorEnumArray($1, $3); }
1170 { $$ = MkDeclaratorFunction(null, null); }
1171 | '(' parameter_type_list ')'
1172 { $$ = MkDeclaratorFunction(null, $2); }
1173 | direct_abstract_declarator '(' ')'
1174 { $$ = MkDeclaratorFunction($1, null); }
1175 | direct_abstract_declarator '(' parameter_type_list ')'
1176 { $$ = MkDeclaratorFunction($1, $3); }
1181 | pointer direct_declarator
1182 { $$ = MkDeclaratorPointer($1, $2); }
1183 | ext_decl pointer direct_declarator
1184 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1185 | declarator ext_decl
1186 { $$ = MkDeclaratorExtendedEnd($2, $1); }
1189 direct_declarator_nofunction:
1191 { $$ = MkDeclaratorIdentifier($1); }
1192 | '(' declarator ')'
1193 { $$ = MkDeclaratorBrackets($2); }
1194 | direct_declarator_nofunction '[' constant_expression ']'
1195 { $$ = MkDeclaratorArray($1, $3); }
1196 | direct_declarator_nofunction '[' ']'
1197 { $$ = MkDeclaratorArray($1, null); }
1198 | direct_declarator_nofunction '[' type ']'
1199 { $$ = MkDeclaratorEnumArray($1, $3); }
1202 declarator_function:
1203 direct_declarator_function
1204 | pointer direct_declarator_function
1205 { $$ = MkDeclaratorPointer($1, $2); }
1207 | ext_decl direct_declarator_function
1208 { $$ = MkDeclaratorExtended($1, $2); }
1209 | ext_decl pointer direct_declarator_function
1210 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1211 | pointer ext_decl direct_declarator_function
1212 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1216 direct_declarator_function_start:
1217 direct_declarator_nofunction '('
1220 direct_declarator_function:
1221 direct_declarator_function_start parameter_type_list ')'
1222 { $$ = MkDeclaratorFunction($1, $2); }
1223 | direct_declarator_function_start identifier_list ')'
1224 { $$ = MkDeclaratorFunction($1, $2); }
1225 | direct_declarator_function_start ')'
1226 { $$ = MkDeclaratorFunction($1, null); }
1230 direct_declarator_function
1231 | direct_declarator_nofunction
1232 | ext_decl direct_declarator_function
1233 { $$ = MkDeclaratorExtended($1, $2); }
1234 | ext_decl direct_declarator_nofunction
1235 { $$ = MkDeclaratorExtended($1, $2); }
1238 declarator_nofunction:
1239 direct_declarator_nofunction
1240 | pointer direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, $2); }
1241 | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
1242 | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1243 | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1246 type_qualifier_list:
1247 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
1248 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
1252 '*' { $$ = MkPointer(null, null); }
1253 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
1254 | '*' pointer { $$ = MkPointer(null, $2); }
1255 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
1258 parameter_type_list:
1260 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
1264 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
1265 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
1268 parameter_declaration:
1269 guess_declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
1270 | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
1271 | guess_declaration_specifiers '&' { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
1272 | guess_declaration_specifiers '&' declarator { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
1273 | real_guess_declaration_specifiers { $$ = MkTypeName($1, null); }
1276 { $$ = MkTypeName(MkList(), null); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1278 { $$ = MkTypeName(null, null); $$.typedObject = true; $$.byReference = true; }
1280 { $$ = MkTypeName(MkList(), $2); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1281 | CLASS '&' declarator
1282 { $$ = MkTypeName(null, $3); $$.typedObject = true; $$.byReference = true; }
1285 { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
1288 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
1290 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
1291 | TYPED_OBJECT declarator
1292 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2); }
1293 | TYPED_OBJECT '&' declarator
1294 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
1296 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
1297 | ANY_OBJECT declarator
1298 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), $2); }
1301 { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), null); }
1302 | error declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1303 //| error struct_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1304 | error abstract_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1309 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
1310 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
1314 specifier_qualifier_list { $$ = MkTypeName($1, null); }
1315 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1319 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
1320 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1324 assignment_expression
1325 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1326 | '{' initializer_list '}'
1327 { $$ = MkInitializerList($2); $$.loc = @$; }
1328 | '{' initializer_list ',' '}'
1330 $$ = MkInitializerList($2);
1334 Expression exp = MkExpDummy();
1335 Initializer init = MkInitializerAssignment(exp);
1343 initializer_condition:
1344 conditional_expression
1345 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1346 | anon_instantiation_expression
1347 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1349 | '{' initializer_list '}'
1350 { $$ = MkInitializerList($2); $$.loc = @$; }
1351 | '{' initializer_list ',' '}'
1353 $$ = MkInitializerList($2);
1357 Expression exp = MkExpDummy();
1358 Initializer init = MkInitializerAssignment(exp);
1369 { $$ = MkList(); ListAdd($$, $1); }
1370 | initializer_list ',' initializer
1371 { $$ = $1; ListAdd($1, $3); }
1376 | compound_statement
1377 | expression_statement
1378 | selection_statement
1379 | iteration_statement
1384 identifier ':' statement
1385 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1386 | CASE constant_expression ':' statement
1387 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1388 | DEFAULT ':' statement
1389 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1393 declaration { $$ = MkList(); ListAdd($$, $1); }
1394 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1398 statement { $$ = MkList(); ListAdd($$, $1); }
1399 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1401 // declaration not allowed after statements
1402 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1406 statement_list { $$ = MkCompoundStmt(null, $1); }
1407 | declaration_list { $$ = MkCompoundStmt($1, null); }
1408 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1412 '{' { $<context>$ = PushContext(); }
1418 $$ = MkCompoundStmt(null, null);
1419 $$.compound.context = PushContext();
1420 PopContext($$.compound.context);
1424 | compound_start compound_inside '}'
1425 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1428 expression_statement:
1429 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1430 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1433 selection_statement:
1434 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1435 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1436 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1439 iteration_statement:
1440 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1441 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1442 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1443 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1445 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1446 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1447 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1451 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1452 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1453 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1454 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1455 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1459 STRING_LITERAL { $$ = CopyString(yytext); }
1462 instantiation_named:
1463 declaration_specifiers identifier '{' members_initialization_list '}'
1464 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1465 | declaration_specifiers identifier '{' '}'
1466 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1469 guess_instantiation_named:
1470 guess_declaration_specifiers identifier '{' members_initialization_list '}'
1471 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1472 | guess_declaration_specifiers identifier '{' '}'
1473 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1475 /*| guess_declaration_specifiers identifier '{' members_initialization_list error
1478 $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;
1484 else if(yychar == '{')
1496 instantiation_unnamed:
1497 type '{' members_initialization_list '}'
1498 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1500 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1501 | identifier '{' members_initialization_list '}'
1502 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1503 | identifier '{' '}'
1504 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1508 '{' members_initialization_list '}'
1509 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1511 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1513 class_function_definition:
1514 class_function_definition_start compound_statement
1515 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1516 | virtual_class_function_definition_start compound_statement
1517 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1518 | virtual_class_function_definition_start ';'
1519 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1520 | constructor_function_definition_start compound_statement
1521 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1522 | destructor_function_definition_start compound_statement
1523 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1526 instance_class_function_definition_start:
1527 // Guess here conflicts with an expression...
1528 declaration_specifiers declarator_function
1529 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1530 | declaration_specifiers declarator_nofunction
1531 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1534 instance_class_function_definition:
1535 instance_class_function_definition_start compound_statement
1536 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1539 data_member_initialization:
1540 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1541 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1544 data_member_initialization_list:
1545 data_member_initialization
1546 { $$ = MkList(); ListAdd($$, $1); }
1547 | data_member_initialization_list ',' data_member_initialization
1548 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1551 data_member_initialization_list_coloned:
1552 data_member_initialization_list ';'
1553 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1556 members_initialization_list_coloned:
1557 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1558 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1559 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1560 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2;$$ = $1; }
1561 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1562 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1565 members_initialization_list:
1566 members_initialization_list_coloned
1567 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1568 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1572 parameter_declaration { parsedType = $1; }
1573 | parameter_declaration ':' constant_expression { parsedType = $1; parsedType.bitCount = $3; }