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;
19 #define yyparse type_yyparse
20 #define yylval type_yylval
21 #define yychar type_yychar
22 #define yydebug type_yydebug
23 #define yynerrs type_yynerrs
24 #define yylloc type_yylloc
26 extern bool parseTypeError;
28 extern File fileInput;
42 SpecifierType specifierType;
47 Enumerator enumerator;
48 Declarator declarator;
50 Initializer initializer;
51 InitDeclarator initDeclarator;
53 Declaration declaration;
55 FunctionDefinition function;
62 Instantiation instance;
63 MembersInit membersInit;
64 MemberInit memberInit;
65 ClassFunction classFunction;
66 ClassDefinition _class;
71 TemplateParameter templateParameter;
72 TemplateArgument templateArgument;
73 TemplateDatatype templateDatatype;
78 %type <specifierType> struct_or_union
79 %type <i> unary_operator assignment_operator
81 %type <exp> primary_expression postfix_expression unary_expression cast_expression
82 multiplicative_expression additive_expression shift_expression
83 relational_expression relational_expression_smaller_than equality_expression and_expression
84 exclusive_or_expression inclusive_or_expression logical_and_expression
85 logical_or_expression conditional_expression assignment_expression
87 common_unary_expression simple_primary_expression
88 anon_instantiation_expression
90 //simple_postfix_expression simple_unary_expression
92 %type <list> argument_expression_list expression enumerator_list
93 struct_declarator_list struct_declaration_list
94 declaration_specifiers identifier_list initializer_list init_declarator_list
95 parameter_list parameter_type_list declaration_list statement_list
96 members_initialization_list members_initialization_list_coloned data_member_initialization_list data_member_initialization_list_coloned
97 guess_declaration_specifiers real_guess_declaration_specifiers
98 specifier_qualifier_list guess_specifier_qualifier_list
99 type_qualifier_list property_specifiers
101 default_property_list
102 template_arguments_list attribs_list
105 %type <specifier> storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier strict_type_specifier
106 struct_or_union_specifier_compound struct_or_union_specifier_nocompound guess_type type strict_type
107 real_guess_type ext_storage base_strict_type
108 %type <enumerator> enumerator
109 %type <declarator> declarator direct_declarator direct_abstract_declarator abstract_declarator
110 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
111 direct_abstract_declarator_noarray abstract_declarator_noarray declarator_nofunction
113 %type <pointer> pointer
114 %type <initializer> initializer initializer_condition
115 %type <initDeclarator> init_declarator
116 %type <typeName> type_name guess_type_name parameter_declaration
117 %type <stmt> statement labeled_statement compound_statement expression_statement
118 selection_statement iteration_statement jump_statement compound_inside
120 %type <declaration> declaration
121 %type <classDef> struct_declaration
122 %type <string> string_literal attribute_word
123 %type <extDecl> ext_decl
124 %type <attrib> attrib
125 %type <attribute> attribute
127 %type <instance> instantiation_named instantiation_unnamed guess_instantiation_named instantiation_anon
128 /* %type <membersInit> members_initialization */
129 %type <memberInit> data_member_initialization default_property
130 %type <classFunction> class_function_definition class_function_definition_start
131 virtual_class_function_definition_start
132 constructor_function_definition_start destructor_function_definition_start
133 %type <classFunction> instance_class_function_definition instance_class_function_definition_start
134 %type <prop> property
136 %type <templateArgument> template_argument template_type_argument template_expression_argument
137 %type <templateDatatype> template_datatype
139 %type <context> compound_start
141 %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
142 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
143 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
144 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
145 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
147 %token TYPEDEF EXTERN STATIC AUTO REGISTER
148 %token CHAR SHORT INT UINT INT64 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
149 %token STRUCT UNION ENUM ELLIPSIS
151 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
155 %token CLASS THISCLASS CLASS_NAME
156 %token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
157 %token PUBLIC PRIVATE
158 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
159 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
160 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
161 %token NEW0OP RENEW0 VAARG
162 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
163 %token ALIGNOF ATTRIB_DEP __ATTRIB
164 %token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
165 %token WIDE_STRING_LITERAL
166 %token BUILTIN_OFFSETOF
168 %destructor { FreeIdentifier($$); } identifier
169 %destructor { FreePointer($$); } pointer
170 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
171 multiplicative_expression additive_expression shift_expression
172 relational_expression equality_expression and_expression
173 exclusive_or_expression inclusive_or_expression logical_and_expression
174 logical_or_expression conditional_expression assignment_expression
176 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
177 struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type strict_type_specifier
179 %destructor { FreeEnumerator($$); } enumerator
180 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
181 direct_abstract_declarator_noarray abstract_declarator_noarray
182 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
183 declarator_nofunction
185 %destructor { FreeInitializer($$); } initializer initializer_condition
186 %destructor { FreeInitDeclarator($$); } init_declarator
187 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration
188 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
189 selection_statement iteration_statement jump_statement compound_inside
191 %destructor { FreeDeclaration($$); } declaration
193 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
195 %destructor { FreeMemberInit($$); } data_member_initialization default_property
197 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
198 virtual_class_function_definition_start
199 constructor_function_definition_start destructor_function_definition_start
200 instance_class_function_definition instance_class_function_definition_start
201 %destructor { FreeClassDef($$); } struct_declaration
202 %destructor { delete $$; } string_literal attribute_word
203 %destructor { FreeProperty($$); } property
205 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
206 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
207 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
208 guess_declaration_specifiers guess_specifier_qualifier_list
209 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
210 %destructor { FreeList($$, FreeDeclaration); } declaration_list
211 %destructor { FreeList($$, FreeInitializer); } initializer_list
212 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
213 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
214 %destructor { FreeList($$, FreeStatement); } statement_list
215 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
216 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
217 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
218 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
219 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_expression_argument
220 %destructor { FreeTemplateDataType($$); } template_datatype
221 %destructor { FreeAttrib($$); } attrib
222 %destructor { FreeExtDecl($$); } ext_decl
223 %destructor { FreeAttribute($$); } attribute
224 %destructor { FreeList($$, FreeAttribute); } attribs_list
234 DeclClass($1._class, $1.string);
235 fileInput.Seek(@1.start.pos, start);
236 resetScannerPos(&@1.start);
243 YY_STACK_PRINT (yyss, yyssp);
246 YY_STACK_PRINT (yyss, yyssp);
253 _DeclClass($1._class, $1.string);
257 fileInput.Seek(@1.start.pos, start);
258 resetScannerPos(&@1.start);
263 YY_STACK_PRINT (yyss, yyssp);
266 YY_STACK_PRINT (yyss, yyssp);
275 DeclClass($1._class, $1.string);
276 fileInput.Seek(@1.start.pos, start);
278 resetScannerPos(&@1.start);
284 YY_STACK_PRINT (yyss, yyssp);
287 YY_STACK_PRINT (yyss, yyssp);
293 _DeclClass($1._class, $1.string);
297 fileInput.Seek(@1.start.pos, start);
298 resetScannerPos(&@1.start);
303 YY_STACK_PRINT (yyss, yyssp);
306 YY_STACK_PRINT (yyss, yyssp);
313 strict_type { $$ = $1; }
314 | identifier identifier
317 DeclClass($1._class, $1.string);
318 fileInput.Seek(@1.start.pos, start);
319 resetScannerPos(&@1.start);
327 YY_STACK_PRINT (yyss, yyssp);
330 YY_STACK_PRINT (yyss, yyssp);
333 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
334 Compiler_Error($"Not a type: %s\n", $1.string);
335 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
341 TYPE_NAME { $$ = MkSpecifierName(yytext); }
346 | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
347 | base_strict_type '<' template_arguments_list RIGHT_OP
350 SetClassTemplateArgs($$, $3);
354 fileInput.Seek(@4.end.pos, start);
355 resetScannerPos(&@4.end);
359 /* | identifier '<' template_arguments_list '>'
360 { $$ = MkSpecifierNameArgs($1.string, $3); $$.loc = @$; FreeIdentifier($1); } */
363 class_function_definition_start:
364 guess_declaration_specifiers declarator_function
365 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
366 | declarator_function
367 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
370 constructor_function_definition_start:
371 guess_declaration_specifiers '(' ')'
372 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
375 destructor_function_definition_start:
376 '~' guess_declaration_specifiers '(' ')'
377 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
380 virtual_class_function_definition_start:
381 VIRTUAL guess_declaration_specifiers declarator_function
382 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
383 | VIRTUAL declarator_function
384 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
389 { $$ = MkIdentifier(yytext); $$.loc = @1; }
393 simple_primary_expression
395 { $$ = MkExpBrackets($2); $$.loc = @$; }
398 simple_primary_expression:
400 { $$ = MkExpIdentifier($1); $$.loc = @$; }
401 | instantiation_unnamed
402 { $$ = MkExpInstance($1); $$.loc = @$; }
404 { $$ = MkExpConstant(yytext); $$.loc = @$; }
405 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
407 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
408 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
409 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
411 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
413 | NEWOP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
414 | NEWOP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
415 | NEW0OP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
416 | NEW0OP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
417 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
418 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
419 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
420 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
421 | error { $$ = MkExpDummy(); }
426 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
427 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
428 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
429 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
430 | postfix_expression identifier
432 char * constant = $1.type == constantExp ? $1.constant : null;
433 int len = constant ? strlen(constant) : 0;
434 if(constant && constant[len-1] == '.')
437 $$ = MkExpMember($1, $2);
443 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
444 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
445 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
448 anon_instantiation_expression:
449 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
453 simple_postfix_expression:
454 simple_primary_expression
455 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
456 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
457 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
458 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
459 | simple_postfix_expression identifier
461 char * constant = $1.type == constantExp ? $1.constant : null;
462 int len = constant ? strlen(constant) : 0;
463 if(constant && constant[len-1] == '.')
466 $$ = MkExpMember($1, $2);
472 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
473 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
474 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
477 argument_expression_list:
478 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
479 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
480 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
481 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
484 common_unary_expression:
485 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
486 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
487 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
488 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
489 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
490 | SIZEOF '(' guess_type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
491 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
492 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
493 | ALIGNOF '(' guess_type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
497 common_unary_expression
501 simple_unary_expression:
502 common_unary_expression
503 | simple_postfix_expression
513 | DELETE { $$ = DELETE; }
518 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
521 multiplicative_expression:
523 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
524 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
525 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
529 multiplicative_expression
530 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
531 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
536 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
537 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
540 relational_expression_smaller_than:
541 relational_expression '<'
548 relational_expression:
550 | relational_expression_smaller_than /*relational_expression '<' */ shift_expression { skipErrors = false; $$ = MkExpOp($1, '<', $2/*$3*/); $$.loc = @$; }
551 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
552 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
553 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
557 relational_expression
558 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
559 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
564 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
567 exclusive_or_expression:
569 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
572 inclusive_or_expression:
573 exclusive_or_expression
574 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
577 logical_and_expression:
578 inclusive_or_expression
579 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
582 logical_or_expression:
583 logical_and_expression
584 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
587 conditional_expression:
588 logical_or_expression
589 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
592 assignment_expression:
593 conditional_expression
594 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
595 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
600 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
601 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
602 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
603 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
604 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
605 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
606 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
607 | AND_ASSIGN { $$ = AND_ASSIGN; }
608 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
609 | OR_ASSIGN { $$ = OR_ASSIGN; }
613 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
614 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
618 conditional_expression
622 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
623 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
624 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
625 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
628 specifier_qualifier_list:
629 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
630 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
631 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
632 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
633 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
634 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
635 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
636 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
639 guess_specifier_qualifier_list:
640 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
641 | guess_specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
642 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
643 | guess_specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
644 | guess_type { $$ = MkList(); ListAdd($$, $1); }
645 | guess_specifier_qualifier_list guess_type { $$ = $1; ListAdd($1, $2); }
646 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
647 | guess_specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
648 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
649 | guess_specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
652 declaration_specifiers:
653 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
654 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
655 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
656 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
657 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
658 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
659 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
660 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
661 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
662 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
665 guess_declaration_specifiers:
666 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
667 | guess_declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
668 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
669 | guess_declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
670 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
671 | guess_declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
672 | guess_type { $$ = MkList(); ListAdd($$, $1); }
673 | guess_declaration_specifiers guess_type { $$ = $1; ListAdd($1, $2); }
674 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
675 | guess_declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
676 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
677 | guess_declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
680 real_guess_declaration_specifiers:
681 guess_declaration_specifiers { $$ = $1; }
682 | real_guess_type { $$ = MkList(); ListAdd($$, $1); }
686 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
687 | property_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
688 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
689 | property_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
690 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
691 | property_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
692 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
693 | property_specifiers identifier { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
694 | identifier '<' template_arguments_list '>'
696 _DeclClass($1._class, $1.string);
699 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
702 | property_specifiers identifier '<' template_arguments_list '>'
704 _DeclClass($2._class, $2.string);
705 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
711 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
712 | renew_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
713 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
714 | renew_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
715 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
716 | renew_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
717 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
718 | renew_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
719 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
720 | renew_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
721 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
722 | renew_specifiers identifier { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
723 | identifier '<' template_arguments_list '>'
725 _DeclClass($1._class, $1.string);
728 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
731 | renew_specifiers identifier '<' template_arguments_list '>'
733 _DeclClass($2._class, $2.string);
734 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
739 init_declarator_list:
740 init_declarator { $$ = MkList(); ListAdd($$, $1); }
741 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
745 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
746 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
749 storage_class_specifier:
750 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
751 | EXTERN { $$ = MkSpecifier(EXTERN); }
752 | STATIC { $$ = MkSpecifier(STATIC); }
753 | AUTO { $$ = MkSpecifier(AUTO); }
754 | REGISTER { $$ = MkSpecifier(REGISTER); }
755 | THREAD { $$ = MkSpecifier(THREAD); }
759 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
760 | EXT_STORAGE { $$ = MkExtDeclString(CopyString(yytext)); }
761 | attrib { $$ = MkExtDeclAttrib($1); }
765 ATTRIB { $<i>$ = ATTRIB; }
766 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
767 | __ATTRIB { $<i>$ = __ATTRIB; }
772 IDENTIFIER { $$ = CopyString(yytext); }
773 | TYPE_NAME { $$ = CopyString(yytext); }
774 | EXT_STORAGE { $$ = CopyString(yytext); }
775 | EXT_DECL { $$ = CopyString(yytext); }
776 | CONST { $$ = CopyString(yytext); }
780 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
781 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
785 attribute { $$ = MkListOne($1); }
786 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
787 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
791 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
792 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
796 ext_decl { $$ = MkSpecifierExtended($1); }
800 CONST { $$ = MkSpecifier(CONST); }
801 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
802 | ext_storage { $$ = $1; }
807 VOID { $$ = MkSpecifier(VOID); }
808 | CHAR { $$ = MkSpecifier(CHAR); }
809 | SHORT { $$ = MkSpecifier(SHORT); }
810 | INT { $$ = MkSpecifier(INT); }
811 | UINT { $$ = MkSpecifier(UINT); }
812 | INT64 { $$ = MkSpecifier(INT64); }
813 | VALIST { $$ = MkSpecifier(VALIST); }
814 | LONG { $$ = MkSpecifier(LONG); }
815 | FLOAT { $$ = MkSpecifier(FLOAT); }
816 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
817 | SIGNED { $$ = MkSpecifier(SIGNED); }
818 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
819 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
820 | _BOOL { $$ = MkSpecifier(_BOOL); }
821 | BOOL { $$ = MkSpecifier(BOOL); }
822 | struct_or_union_specifier_nocompound
823 | enum_specifier_nocompound
825 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
826 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
827 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
828 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
829 | TYPED_OBJECT { $$ = MkSpecifier(TYPED_OBJECT); }
830 | ANY_OBJECT { $$ = MkSpecifier(ANY_OBJECT); }
833 strict_type_specifier:
834 VOID { $$ = MkSpecifier(VOID); }
835 | CHAR { $$ = MkSpecifier(CHAR); }
836 | SHORT { $$ = MkSpecifier(SHORT); }
837 | INT { $$ = MkSpecifier(INT); }
838 | UINT { $$ = MkSpecifier(UINT); }
839 | INT64 { $$ = MkSpecifier(INT64); }
840 | VALIST { $$ = MkSpecifier(VALIST); }
841 | LONG { $$ = MkSpecifier(LONG); }
842 | FLOAT { $$ = MkSpecifier(FLOAT); }
843 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
844 | SIGNED { $$ = MkSpecifier(SIGNED); }
845 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
846 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
847 | _BOOL { $$ = MkSpecifier(_BOOL); }
848 | BOOL { $$ = MkSpecifier(BOOL); }
849 | struct_or_union_specifier_nocompound
850 | enum_specifier_nocompound
852 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
853 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
854 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
855 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
859 struct_or_union_specifier_compound:
860 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2._class, $2.string); }
861 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
862 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
863 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
864 | struct_or_union base_strict_type '{' struct_declaration_list '}'
865 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
867 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
868 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
869 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
870 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
871 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
872 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
875 struct_or_union_specifier_nocompound:
876 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
877 | struct_or_union strict_type
878 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
880 | struct_or_union ext_decl identifier
881 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3._class, $3.string); }
882 | struct_or_union ext_decl strict_type
883 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
887 guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
888 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
889 /*| identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }*/
892 template_type_argument:
893 guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
894 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
895 //template_datatype { $$ = MkTemplateTypeArgument($1); }
899 template_identifier_argument:
900 identifier { $$ = MkTemplateIdentifierArgument($1); }
904 template_expression_argument:
905 shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
909 template_expression_argument
910 /*| template_identifier_argument*/
911 | template_type_argument
912 | identifier '=' template_expression_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
913 /*| identifier '=' template_identifier_argument { $$ = $3; $$.name = $1; $$.loc = @$; }*/
914 | identifier '=' template_type_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
915 | template_datatype '=' template_expression_argument
918 if($1.specifiers && $1.specifiers->first)
920 Specifier spec = $1.specifiers->first;
921 if(spec.type == nameSpecifier)
922 $$.name = MkIdentifier(spec.name);
924 FreeTemplateDataType($1);
927 /*| template_datatype '=' template_identifier_argument
930 if($1.specifiers && $1.specifiers->first)
932 Specifier spec = $1.specifiers->first;
933 if(spec.type == nameSpecifier)
934 $$.name = MkIdentifier(spec.name);
936 FreeTemplateDataType($1);
939 | template_datatype '=' template_type_argument
942 if($1.specifiers && $1.specifiers->first)
944 Specifier spec = $1.specifiers->first;
945 if(spec.type == nameSpecifier)
946 $$.name = MkIdentifier(spec.name);
948 FreeTemplateDataType($1);
953 template_arguments_list:
954 template_argument { $$ = MkList(); ListAdd($$, $1); }
955 | template_arguments_list ',' template_argument { ListAdd($1, $3); }
959 STRUCT { $$ = structSpecifier; }
960 | UNION { $$ = unionSpecifier; }
963 struct_declaration_list:
964 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
965 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
969 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; }
972 default_property_list:
973 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
974 | default_property_list ',' default_property { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
978 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
979 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
980 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
981 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
982 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
983 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
984 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
985 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
986 | PROPERTY property_specifiers identifier '{' '}'
987 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
989 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
990 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
991 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
992 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
993 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
994 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
995 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
996 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
997 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
998 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
1000 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
1001 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
1002 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
1003 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
1004 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
1005 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
1006 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
1007 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
1008 | PROPERTY property_specifiers '{' '}'
1009 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
1011 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
1012 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
1013 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
1014 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
1015 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
1016 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
1017 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
1018 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
1019 | PROPERTY property_specifiers abstract_declarator '{' '}'
1020 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
1024 guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
1025 | guess_declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
1026 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1027 | guess_instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1028 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
1029 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
1030 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
1031 | ';' { $$ = null; }
1034 struct_declarator_list:
1036 { $$ = MkList(); ListAdd($$, $1); }
1037 | struct_declarator_list ',' struct_declarator
1038 { $$ = $1; ListAdd($1, $3); }
1042 declarator_nofunction
1043 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
1044 | declarator_nofunction attrib
1045 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
1046 | ':' constant_expression
1047 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
1048 | declarator_nofunction ':' constant_expression
1049 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
1050 | declarator_nofunction ':' constant_expression ':' constant_expression
1051 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
1054 enum_specifier_nocompound:
1055 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2._class, $2.string); }
1056 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1059 enum_specifier_compound:
1060 ENUM '{' enumerator_list '}'
1061 { $$ = MkEnum(null, $3); }
1062 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2._class, $2.string); }
1063 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2._class, $2.string); }
1064 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1065 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1070 { $$ = MkList(); ListAdd($$, $1); }
1071 | enumerator_list ',' enumerator
1072 { $$ = $1; ListAdd($1, $3); }
1077 { $$ = MkEnumerator($1, null); }
1078 | identifier '=' constant_expression
1079 { $$ = MkEnumerator($1, $3); }
1083 direct_abstract_declarator:
1084 '(' abstract_declarator ')'
1085 { $$ = MkDeclaratorBrackets($2); }
1087 { $$ = MkDeclaratorArray(null, null); }
1088 | '[' constant_expression ']'
1089 { $$ = MkDeclaratorArray(null, $2); }
1091 { $$ = MkDeclaratorEnumArray(null, $2); }
1092 | direct_abstract_declarator '[' ']'
1093 { $$ = MkDeclaratorArray($1, null); }
1094 | direct_abstract_declarator '[' constant_expression ']'
1095 { $$ = MkDeclaratorArray($1, $3); }
1096 | direct_abstract_declarator '[' type']'
1097 { $$ = MkDeclaratorEnumArray($1, $3); }
1099 { $$ = MkDeclaratorFunction(null, null); }
1100 | '(' parameter_type_list ')'
1101 { $$ = MkDeclaratorFunction(null, $2); }
1102 | direct_abstract_declarator '(' ')'
1103 { $$ = MkDeclaratorFunction($1, null); }
1104 | direct_abstract_declarator '(' parameter_type_list ')'
1105 { $$ = MkDeclaratorFunction($1, $3); }
1108 direct_abstract_declarator_noarray:
1109 '(' abstract_declarator_noarray ')'
1110 { $$ = MkDeclaratorBrackets($2); }
1112 { $$ = MkDeclaratorFunction(null, null); }
1113 | '(' parameter_type_list ')'
1114 { $$ = MkDeclaratorFunction(null, $2); }
1115 | direct_abstract_declarator_noarray '(' ')'
1116 { $$ = MkDeclaratorFunction($1, null); }
1117 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
1118 { $$ = MkDeclaratorFunction($1, $3); }
1121 abstract_declarator:
1122 pointer { $$ = MkDeclaratorPointer($1, null); }
1123 | direct_abstract_declarator
1124 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
1125 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1126 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
1127 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1130 abstract_declarator_noarray:
1131 pointer { $$ = MkDeclaratorPointer($1, null); }
1132 | direct_abstract_declarator_noarray
1133 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
1134 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1135 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
1136 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1140 abstract_declarator:
1142 { $$ = MkDeclaratorPointer($1, null); }
1143 | direct_abstract_declarator
1144 | pointer direct_abstract_declarator
1145 { $$ = MkDeclaratorPointer($1, $2); }
1148 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1149 | ext_decl direct_abstract_declarator
1150 { $$ = MkDeclaratorExtended($1, $2); }
1151 | ext_decl pointer direct_abstract_declarator
1152 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1156 direct_abstract_declarator:
1157 '(' abstract_declarator ')'
1158 { $$ = MkDeclaratorBrackets($2); }
1160 { $$ = MkDeclaratorArray(null, null); }
1161 | '[' constant_expression ']'
1162 { $$ = MkDeclaratorArray(null, $2); }
1164 { $$ = MkDeclaratorEnumArray(null, $2); }
1165 | direct_abstract_declarator '[' ']'
1166 { $$ = MkDeclaratorArray($1, null); }
1167 | direct_abstract_declarator '[' constant_expression ']'
1168 { $$ = MkDeclaratorArray($1, $3); }
1169 | direct_abstract_declarator '[' type ']'
1170 { $$ = MkDeclaratorEnumArray($1, $3); }
1172 { $$ = MkDeclaratorFunction(null, null); }
1173 | '(' parameter_type_list ')'
1174 { $$ = MkDeclaratorFunction(null, $2); }
1175 | direct_abstract_declarator '(' ')'
1176 { $$ = MkDeclaratorFunction($1, null); }
1177 | direct_abstract_declarator '(' parameter_type_list ')'
1178 { $$ = MkDeclaratorFunction($1, $3); }
1183 | pointer direct_declarator
1184 { $$ = MkDeclaratorPointer($1, $2); }
1185 | ext_decl pointer direct_declarator
1186 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1187 | declarator ext_decl
1188 { $$ = MkDeclaratorExtendedEnd($2, $1); }
1191 direct_declarator_nofunction:
1193 { $$ = MkDeclaratorIdentifier($1); }
1194 | '(' declarator ')'
1195 { $$ = MkDeclaratorBrackets($2); }
1196 | direct_declarator_nofunction '[' constant_expression ']'
1197 { $$ = MkDeclaratorArray($1, $3); }
1198 | direct_declarator_nofunction '[' ']'
1199 { $$ = MkDeclaratorArray($1, null); }
1200 | direct_declarator_nofunction '[' type ']'
1201 { $$ = MkDeclaratorEnumArray($1, $3); }
1204 declarator_function:
1205 direct_declarator_function
1206 | pointer direct_declarator_function
1207 { $$ = MkDeclaratorPointer($1, $2); }
1209 | ext_decl direct_declarator_function
1210 { $$ = MkDeclaratorExtended($1, $2); }
1211 | ext_decl pointer direct_declarator_function
1212 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1213 | pointer ext_decl direct_declarator_function
1214 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1218 direct_declarator_function_start:
1219 direct_declarator_nofunction '('
1222 direct_declarator_function:
1223 direct_declarator_function_start parameter_type_list ')'
1224 { $$ = MkDeclaratorFunction($1, $2); }
1225 | direct_declarator_function_start identifier_list ')'
1226 { $$ = MkDeclaratorFunction($1, $2); }
1227 | direct_declarator_function_start ')'
1228 { $$ = MkDeclaratorFunction($1, null); }
1232 direct_declarator_function
1233 | direct_declarator_nofunction
1234 | ext_decl direct_declarator_function
1235 { $$ = MkDeclaratorExtended($1, $2); }
1236 | ext_decl direct_declarator_nofunction
1237 { $$ = MkDeclaratorExtended($1, $2); }
1240 declarator_nofunction:
1241 direct_declarator_nofunction
1242 | pointer direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, $2); }
1243 | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
1244 | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1245 | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1248 type_qualifier_list:
1249 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
1250 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
1254 '*' { $$ = MkPointer(null, null); }
1255 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
1256 | '*' pointer { $$ = MkPointer(null, $2); }
1257 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
1260 parameter_type_list:
1262 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
1266 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
1267 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
1270 parameter_declaration:
1271 guess_declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
1272 | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
1273 | guess_declaration_specifiers '&' { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
1274 | guess_declaration_specifiers '&' declarator { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
1275 | real_guess_declaration_specifiers { $$ = MkTypeName($1, null); }
1278 { $$ = MkTypeName(MkList(), null); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1280 { $$ = MkTypeName(null, null); $$.typedObject = true; $$.byReference = true; }
1282 { $$ = MkTypeName(MkList(), $2); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1283 | CLASS '&' declarator
1284 { $$ = MkTypeName(null, $3); $$.typedObject = true; $$.byReference = true; }
1287 { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
1290 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
1292 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
1293 | TYPED_OBJECT declarator
1294 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2); }
1295 | TYPED_OBJECT '&' declarator
1296 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
1298 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
1299 | ANY_OBJECT declarator
1300 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), $2); }
1303 { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), null); }
1304 | error declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1305 //| error struct_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1306 | error abstract_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1311 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
1312 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
1316 specifier_qualifier_list { $$ = MkTypeName($1, null); }
1317 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1321 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
1322 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1326 assignment_expression
1327 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1328 | '{' initializer_list '}'
1329 { $$ = MkInitializerList($2); $$.loc = @$; }
1330 | '{' initializer_list ',' '}'
1332 $$ = MkInitializerList($2);
1336 Expression exp = MkExpDummy();
1337 Initializer init = MkInitializerAssignment(exp);
1345 initializer_condition:
1346 conditional_expression
1347 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1348 | anon_instantiation_expression
1349 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1351 | '{' initializer_list '}'
1352 { $$ = MkInitializerList($2); $$.loc = @$; }
1353 | '{' initializer_list ',' '}'
1355 $$ = MkInitializerList($2);
1359 Expression exp = MkExpDummy();
1360 Initializer init = MkInitializerAssignment(exp);
1371 { $$ = MkList(); ListAdd($$, $1); }
1372 | initializer_list ',' initializer
1373 { $$ = $1; ListAdd($1, $3); }
1378 | compound_statement
1379 | expression_statement
1380 | selection_statement
1381 | iteration_statement
1386 identifier ':' statement
1387 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1388 | CASE constant_expression ':' statement
1389 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1390 | DEFAULT ':' statement
1391 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1395 declaration { $$ = MkList(); ListAdd($$, $1); }
1396 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1400 statement { $$ = MkList(); ListAdd($$, $1); }
1401 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1403 // declaration not allowed after statements
1404 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1408 statement_list { $$ = MkCompoundStmt(null, $1); }
1409 | declaration_list { $$ = MkCompoundStmt($1, null); }
1410 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1414 '{' { $<context>$ = PushContext(); }
1420 $$ = MkCompoundStmt(null, null);
1421 $$.compound.context = PushContext();
1422 PopContext($$.compound.context);
1426 | compound_start compound_inside '}'
1427 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1430 expression_statement:
1431 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1432 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1435 selection_statement:
1436 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1437 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1438 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1441 iteration_statement:
1442 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1443 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1444 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1445 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1447 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1448 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1449 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1453 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1454 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1455 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1456 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1457 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1461 STRING_LITERAL { $$ = CopyString(yytext); }
1464 instantiation_named:
1465 declaration_specifiers identifier '{' members_initialization_list '}'
1466 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1467 | declaration_specifiers identifier '{' '}'
1468 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1471 guess_instantiation_named:
1472 guess_declaration_specifiers identifier '{' members_initialization_list '}'
1473 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1474 | guess_declaration_specifiers identifier '{' '}'
1475 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1477 /*| guess_declaration_specifiers identifier '{' members_initialization_list error
1480 $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;
1486 else if(yychar == '{')
1498 instantiation_unnamed:
1499 type '{' members_initialization_list '}'
1500 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1502 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1503 | identifier '{' members_initialization_list '}'
1504 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1505 | identifier '{' '}'
1506 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1510 '{' members_initialization_list '}'
1511 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1513 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1515 class_function_definition:
1516 class_function_definition_start compound_statement
1517 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1518 | virtual_class_function_definition_start compound_statement
1519 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1520 | virtual_class_function_definition_start ';'
1521 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1522 | constructor_function_definition_start compound_statement
1523 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1524 | destructor_function_definition_start compound_statement
1525 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1528 instance_class_function_definition_start:
1529 // Guess here conflicts with an expression...
1530 declaration_specifiers declarator_function
1531 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1532 | declaration_specifiers declarator_nofunction
1533 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1536 instance_class_function_definition:
1537 instance_class_function_definition_start compound_statement
1538 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1541 data_member_initialization:
1542 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1543 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1546 data_member_initialization_list:
1547 data_member_initialization
1548 { $$ = MkList(); ListAdd($$, $1); }
1549 | data_member_initialization_list ',' data_member_initialization
1550 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1553 data_member_initialization_list_coloned:
1554 data_member_initialization_list ';'
1555 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1558 members_initialization_list_coloned:
1559 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1560 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1561 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1562 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2;$$ = $1; }
1563 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1564 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1567 members_initialization_list:
1568 members_initialization_list_coloned
1569 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1570 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1574 parameter_declaration { parsedType = $1; }
1575 | parameter_declaration ':' constant_expression { parsedType = $1; parsedType.bitCount = $3; }