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
167 %destructor { FreeIdentifier($$); } identifier
168 %destructor { FreePointer($$); } pointer
169 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
170 multiplicative_expression additive_expression shift_expression
171 relational_expression equality_expression and_expression
172 exclusive_or_expression inclusive_or_expression logical_and_expression
173 logical_or_expression conditional_expression assignment_expression
175 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
176 struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type strict_type_specifier
178 %destructor { FreeEnumerator($$); } enumerator
179 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
180 direct_abstract_declarator_noarray abstract_declarator_noarray
181 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
182 declarator_nofunction
184 %destructor { FreeInitializer($$); } initializer initializer_condition
185 %destructor { FreeInitDeclarator($$); } init_declarator
186 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration
187 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
188 selection_statement iteration_statement jump_statement compound_inside
190 %destructor { FreeDeclaration($$); } declaration
192 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
194 %destructor { FreeMemberInit($$); } data_member_initialization default_property
196 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
197 virtual_class_function_definition_start
198 constructor_function_definition_start destructor_function_definition_start
199 instance_class_function_definition instance_class_function_definition_start
200 %destructor { FreeClassDef($$); } struct_declaration
201 %destructor { delete $$; } string_literal attribute_word
202 %destructor { FreeProperty($$); } property
204 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
205 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
206 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
207 guess_declaration_specifiers guess_specifier_qualifier_list
208 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
209 %destructor { FreeList($$, FreeDeclaration); } declaration_list
210 %destructor { FreeList($$, FreeInitializer); } initializer_list
211 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
212 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
213 %destructor { FreeList($$, FreeStatement); } statement_list
214 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
215 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
216 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
217 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
218 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_expression_argument
219 %destructor { FreeTemplateDataType($$); } template_datatype
220 %destructor { FreeAttrib($$); } attrib
221 %destructor { FreeExtDecl($$); } ext_decl
222 %destructor { FreeAttribute($$); } attribute
223 %destructor { FreeList($$, FreeAttribute); } attribs_list
233 DeclClass($1._class, $1.string);
234 fileInput.Seek(@1.start.pos, start);
235 resetScannerPos(&@1.start);
242 YY_STACK_PRINT (yyss, yyssp);
245 YY_STACK_PRINT (yyss, yyssp);
252 _DeclClass($1._class, $1.string);
256 fileInput.Seek(@1.start.pos, start);
257 resetScannerPos(&@1.start);
262 YY_STACK_PRINT (yyss, yyssp);
265 YY_STACK_PRINT (yyss, yyssp);
274 DeclClass($1._class, $1.string);
275 fileInput.Seek(@1.start.pos, start);
277 resetScannerPos(&@1.start);
283 YY_STACK_PRINT (yyss, yyssp);
286 YY_STACK_PRINT (yyss, yyssp);
292 _DeclClass($1._class, $1.string);
296 fileInput.Seek(@1.start.pos, start);
297 resetScannerPos(&@1.start);
302 YY_STACK_PRINT (yyss, yyssp);
305 YY_STACK_PRINT (yyss, yyssp);
312 strict_type { $$ = $1; }
313 | identifier identifier
316 DeclClass($1._class, $1.string);
317 fileInput.Seek(@1.start.pos, start);
318 resetScannerPos(&@1.start);
326 YY_STACK_PRINT (yyss, yyssp);
329 YY_STACK_PRINT (yyss, yyssp);
332 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
333 Compiler_Error($"Not a type: %s\n", $1.string);
334 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
340 TYPE_NAME { $$ = MkSpecifierName(yytext); }
345 | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
346 | base_strict_type '<' template_arguments_list RIGHT_OP
349 SetClassTemplateArgs($$, $3);
353 fileInput.Seek(@4.end.pos, start);
354 resetScannerPos(&@4.end);
358 /* | identifier '<' template_arguments_list '>'
359 { $$ = MkSpecifierNameArgs($1.string, $3); $$.loc = @$; FreeIdentifier($1); } */
362 class_function_definition_start:
363 guess_declaration_specifiers declarator_function
364 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
365 | declarator_function
366 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
369 constructor_function_definition_start:
370 guess_declaration_specifiers '(' ')'
371 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
374 destructor_function_definition_start:
375 '~' guess_declaration_specifiers '(' ')'
376 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
379 virtual_class_function_definition_start:
380 VIRTUAL guess_declaration_specifiers declarator_function
381 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
382 | VIRTUAL declarator_function
383 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
388 { $$ = MkIdentifier(yytext); $$.loc = @1; }
392 simple_primary_expression
394 { $$ = MkExpBrackets($2); $$.loc = @$; }
397 simple_primary_expression:
399 { $$ = MkExpIdentifier($1); $$.loc = @$; }
400 | instantiation_unnamed
401 { $$ = MkExpInstance($1); $$.loc = @$; }
403 { $$ = MkExpConstant(yytext); $$.loc = @$; }
404 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
406 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
407 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
408 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
410 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
412 | NEWOP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
413 | NEWOP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
414 | NEW0OP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
415 | NEW0OP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
416 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
417 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
418 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
419 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
420 | error { $$ = MkExpDummy(); }
425 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
426 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
427 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
428 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
429 | postfix_expression identifier
431 char * constant = $1.type == constantExp ? $1.constant : null;
432 int len = constant ? strlen(constant) : 0;
433 if(constant && constant[len-1] == '.')
436 $$ = MkExpMember($1, $2);
442 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
443 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
444 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
447 anon_instantiation_expression:
448 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
452 simple_postfix_expression:
453 simple_primary_expression
454 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
455 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
456 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
457 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
458 | simple_postfix_expression identifier
460 char * constant = $1.type == constantExp ? $1.constant : null;
461 int len = constant ? strlen(constant) : 0;
462 if(constant && constant[len-1] == '.')
465 $$ = MkExpMember($1, $2);
471 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
472 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
473 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
476 argument_expression_list:
477 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
478 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
479 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
480 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
483 common_unary_expression:
484 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
485 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
486 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
487 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
488 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
489 | SIZEOF '(' guess_type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
490 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
491 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
492 | ALIGNOF '(' guess_type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
496 common_unary_expression
500 simple_unary_expression:
501 common_unary_expression
502 | simple_postfix_expression
512 | DELETE { $$ = DELETE; }
517 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
520 multiplicative_expression:
522 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
523 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
524 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
528 multiplicative_expression
529 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
530 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
535 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
536 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
539 relational_expression_smaller_than:
540 relational_expression '<'
547 relational_expression:
549 | relational_expression_smaller_than /*relational_expression '<' */ shift_expression { skipErrors = false; $$ = MkExpOp($1, '<', $2/*$3*/); $$.loc = @$; }
550 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
551 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
552 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
556 relational_expression
557 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
558 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
563 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
566 exclusive_or_expression:
568 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
571 inclusive_or_expression:
572 exclusive_or_expression
573 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
576 logical_and_expression:
577 inclusive_or_expression
578 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
581 logical_or_expression:
582 logical_and_expression
583 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
586 conditional_expression:
587 logical_or_expression
588 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
591 assignment_expression:
592 conditional_expression
593 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
594 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
599 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
600 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
601 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
602 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
603 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
604 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
605 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
606 | AND_ASSIGN { $$ = AND_ASSIGN; }
607 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
608 | OR_ASSIGN { $$ = OR_ASSIGN; }
612 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
613 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
617 conditional_expression
621 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
622 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
623 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
624 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
627 specifier_qualifier_list:
628 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
629 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
630 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
631 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
632 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
633 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
634 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
635 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
638 guess_specifier_qualifier_list:
639 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
640 | guess_specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
641 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
642 | guess_specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
643 | guess_type { $$ = MkList(); ListAdd($$, $1); }
644 | guess_specifier_qualifier_list guess_type { $$ = $1; ListAdd($1, $2); }
645 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
646 | guess_specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
647 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
648 | guess_specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
651 declaration_specifiers:
652 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
653 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
654 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
655 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
656 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
657 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
658 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
659 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
660 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
661 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
664 guess_declaration_specifiers:
665 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
666 | guess_declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
667 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
668 | guess_declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
669 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
670 | guess_declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
671 | guess_type { $$ = MkList(); ListAdd($$, $1); }
672 | guess_declaration_specifiers guess_type { $$ = $1; ListAdd($1, $2); }
673 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
674 | guess_declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
675 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
676 | guess_declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
679 real_guess_declaration_specifiers:
680 guess_declaration_specifiers { $$ = $1; }
681 | real_guess_type { $$ = MkList(); ListAdd($$, $1); }
685 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
686 | property_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
687 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
688 | property_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
689 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
690 | property_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
691 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
692 | property_specifiers identifier { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
693 | identifier '<' template_arguments_list '>'
695 _DeclClass($1._class, $1.string);
698 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
701 | property_specifiers identifier '<' template_arguments_list '>'
703 _DeclClass($2._class, $2.string);
704 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
710 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
711 | renew_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
712 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
713 | renew_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
714 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
715 | renew_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
716 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
717 | renew_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
718 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
719 | renew_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
720 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
721 | renew_specifiers identifier { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
722 | identifier '<' template_arguments_list '>'
724 _DeclClass($1._class, $1.string);
727 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
730 | renew_specifiers identifier '<' template_arguments_list '>'
732 _DeclClass($2._class, $2.string);
733 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
738 init_declarator_list:
739 init_declarator { $$ = MkList(); ListAdd($$, $1); }
740 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
744 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
745 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
748 storage_class_specifier:
749 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
750 | EXTERN { $$ = MkSpecifier(EXTERN); }
751 | STATIC { $$ = MkSpecifier(STATIC); }
752 | AUTO { $$ = MkSpecifier(AUTO); }
753 | REGISTER { $$ = MkSpecifier(REGISTER); }
754 | THREAD { $$ = MkSpecifier(THREAD); }
758 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
759 | EXT_STORAGE { $$ = MkExtDeclString(CopyString(yytext)); }
760 | attrib { $$ = MkExtDeclAttrib($1); }
764 ATTRIB { $<i>$ = ATTRIB; }
765 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
766 | __ATTRIB { $<i>$ = __ATTRIB; }
771 IDENTIFIER { $$ = CopyString(yytext); }
772 | TYPE_NAME { $$ = CopyString(yytext); }
773 | EXT_STORAGE { $$ = CopyString(yytext); }
774 | EXT_DECL { $$ = CopyString(yytext); }
775 | CONST { $$ = CopyString(yytext); }
779 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
780 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
784 attribute { $$ = MkListOne($1); }
785 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
786 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
790 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
791 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
795 ext_decl { $$ = MkSpecifierExtended($1); }
799 CONST { $$ = MkSpecifier(CONST); }
800 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
801 | ext_storage { $$ = $1; }
806 VOID { $$ = MkSpecifier(VOID); }
807 | CHAR { $$ = MkSpecifier(CHAR); }
808 | SHORT { $$ = MkSpecifier(SHORT); }
809 | INT { $$ = MkSpecifier(INT); }
810 | UINT { $$ = MkSpecifier(UINT); }
811 | INT64 { $$ = MkSpecifier(INT64); }
812 | VALIST { $$ = MkSpecifier(VALIST); }
813 | LONG { $$ = MkSpecifier(LONG); }
814 | FLOAT { $$ = MkSpecifier(FLOAT); }
815 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
816 | SIGNED { $$ = MkSpecifier(SIGNED); }
817 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
818 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
819 | _BOOL { $$ = MkSpecifier(_BOOL); }
820 | BOOL { $$ = MkSpecifier(BOOL); }
821 | struct_or_union_specifier_nocompound
822 | enum_specifier_nocompound
824 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
825 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
826 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
827 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
828 | TYPED_OBJECT { $$ = MkSpecifier(TYPED_OBJECT); }
829 | ANY_OBJECT { $$ = MkSpecifier(ANY_OBJECT); }
832 strict_type_specifier:
833 VOID { $$ = MkSpecifier(VOID); }
834 | CHAR { $$ = MkSpecifier(CHAR); }
835 | SHORT { $$ = MkSpecifier(SHORT); }
836 | INT { $$ = MkSpecifier(INT); }
837 | UINT { $$ = MkSpecifier(UINT); }
838 | INT64 { $$ = MkSpecifier(INT64); }
839 | VALIST { $$ = MkSpecifier(VALIST); }
840 | LONG { $$ = MkSpecifier(LONG); }
841 | FLOAT { $$ = MkSpecifier(FLOAT); }
842 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
843 | SIGNED { $$ = MkSpecifier(SIGNED); }
844 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
845 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
846 | _BOOL { $$ = MkSpecifier(_BOOL); }
847 | BOOL { $$ = MkSpecifier(BOOL); }
848 | struct_or_union_specifier_nocompound
849 | enum_specifier_nocompound
851 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
852 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
853 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
854 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
858 struct_or_union_specifier_compound:
859 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2._class, $2.string); }
860 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
861 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
862 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
863 | struct_or_union base_strict_type '{' struct_declaration_list '}'
864 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
866 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
867 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
868 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
869 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
870 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
871 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
874 struct_or_union_specifier_nocompound:
875 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
876 | struct_or_union strict_type
877 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
879 | struct_or_union ext_decl identifier
880 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3._class, $3.string); }
881 | struct_or_union ext_decl strict_type
882 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
886 guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
887 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
888 /*| identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }*/
891 template_type_argument:
892 guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
893 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
894 //template_datatype { $$ = MkTemplateTypeArgument($1); }
898 template_identifier_argument:
899 identifier { $$ = MkTemplateIdentifierArgument($1); }
903 template_expression_argument:
904 shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
908 template_expression_argument
909 /*| template_identifier_argument*/
910 | template_type_argument
911 | identifier '=' template_expression_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
912 /*| identifier '=' template_identifier_argument { $$ = $3; $$.name = $1; $$.loc = @$; }*/
913 | identifier '=' template_type_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
914 | template_datatype '=' template_expression_argument
917 if($1.specifiers && $1.specifiers->first)
919 Specifier spec = $1.specifiers->first;
920 if(spec.type == nameSpecifier)
921 $$.name = MkIdentifier(spec.name);
923 FreeTemplateDataType($1);
926 /*| template_datatype '=' template_identifier_argument
929 if($1.specifiers && $1.specifiers->first)
931 Specifier spec = $1.specifiers->first;
932 if(spec.type == nameSpecifier)
933 $$.name = MkIdentifier(spec.name);
935 FreeTemplateDataType($1);
938 | template_datatype '=' template_type_argument
941 if($1.specifiers && $1.specifiers->first)
943 Specifier spec = $1.specifiers->first;
944 if(spec.type == nameSpecifier)
945 $$.name = MkIdentifier(spec.name);
947 FreeTemplateDataType($1);
952 template_arguments_list:
953 template_argument { $$ = MkList(); ListAdd($$, $1); }
954 | template_arguments_list ',' template_argument { ListAdd($1, $3); }
958 STRUCT { $$ = structSpecifier; }
959 | UNION { $$ = unionSpecifier; }
962 struct_declaration_list:
963 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
964 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
968 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; }
971 default_property_list:
972 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
973 | default_property_list ',' default_property { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
977 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
978 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
979 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
980 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
981 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
982 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
983 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
984 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
985 | PROPERTY property_specifiers identifier '{' '}'
986 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
988 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
989 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
990 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
991 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
992 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
993 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
994 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
995 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
996 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
997 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
999 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
1000 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
1001 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
1002 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
1003 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
1004 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
1005 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
1006 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
1007 | PROPERTY property_specifiers '{' '}'
1008 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
1010 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
1011 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
1012 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
1013 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
1014 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
1015 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
1016 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
1017 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
1018 | PROPERTY property_specifiers abstract_declarator '{' '}'
1019 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
1023 guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
1024 | guess_declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
1025 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1026 | guess_instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1027 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
1028 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
1029 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
1030 | ';' { $$ = null; }
1033 struct_declarator_list:
1035 { $$ = MkList(); ListAdd($$, $1); }
1036 | struct_declarator_list ',' struct_declarator
1037 { $$ = $1; ListAdd($1, $3); }
1041 declarator_nofunction
1042 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
1043 | declarator_nofunction attrib
1044 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
1045 | ':' constant_expression
1046 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
1047 | declarator_nofunction ':' constant_expression
1048 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
1049 | declarator_nofunction ':' constant_expression ':' constant_expression
1050 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
1053 enum_specifier_nocompound:
1054 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2._class, $2.string); }
1055 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1058 enum_specifier_compound:
1059 ENUM '{' enumerator_list '}'
1060 { $$ = MkEnum(null, $3); }
1061 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2._class, $2.string); }
1062 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2._class, $2.string); }
1063 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1064 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1069 { $$ = MkList(); ListAdd($$, $1); }
1070 | enumerator_list ',' enumerator
1071 { $$ = $1; ListAdd($1, $3); }
1076 { $$ = MkEnumerator($1, null); }
1077 | identifier '=' constant_expression
1078 { $$ = MkEnumerator($1, $3); }
1082 direct_abstract_declarator:
1083 '(' abstract_declarator ')'
1084 { $$ = MkDeclaratorBrackets($2); }
1086 { $$ = MkDeclaratorArray(null, null); }
1087 | '[' constant_expression ']'
1088 { $$ = MkDeclaratorArray(null, $2); }
1090 { $$ = MkDeclaratorEnumArray(null, $2); }
1091 | direct_abstract_declarator '[' ']'
1092 { $$ = MkDeclaratorArray($1, null); }
1093 | direct_abstract_declarator '[' constant_expression ']'
1094 { $$ = MkDeclaratorArray($1, $3); }
1095 | direct_abstract_declarator '[' type']'
1096 { $$ = MkDeclaratorEnumArray($1, $3); }
1098 { $$ = MkDeclaratorFunction(null, null); }
1099 | '(' parameter_type_list ')'
1100 { $$ = MkDeclaratorFunction(null, $2); }
1101 | direct_abstract_declarator '(' ')'
1102 { $$ = MkDeclaratorFunction($1, null); }
1103 | direct_abstract_declarator '(' parameter_type_list ')'
1104 { $$ = MkDeclaratorFunction($1, $3); }
1107 direct_abstract_declarator_noarray:
1108 '(' abstract_declarator_noarray ')'
1109 { $$ = MkDeclaratorBrackets($2); }
1111 { $$ = MkDeclaratorFunction(null, null); }
1112 | '(' parameter_type_list ')'
1113 { $$ = MkDeclaratorFunction(null, $2); }
1114 | direct_abstract_declarator_noarray '(' ')'
1115 { $$ = MkDeclaratorFunction($1, null); }
1116 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
1117 { $$ = MkDeclaratorFunction($1, $3); }
1120 abstract_declarator:
1121 pointer { $$ = MkDeclaratorPointer($1, null); }
1122 | direct_abstract_declarator
1123 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
1124 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1125 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
1126 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1129 abstract_declarator_noarray:
1130 pointer { $$ = MkDeclaratorPointer($1, null); }
1131 | direct_abstract_declarator_noarray
1132 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
1133 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1134 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
1135 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1139 abstract_declarator:
1141 { $$ = MkDeclaratorPointer($1, null); }
1142 | direct_abstract_declarator
1143 | pointer direct_abstract_declarator
1144 { $$ = MkDeclaratorPointer($1, $2); }
1147 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1148 | ext_decl direct_abstract_declarator
1149 { $$ = MkDeclaratorExtended($1, $2); }
1150 | ext_decl pointer direct_abstract_declarator
1151 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1155 direct_abstract_declarator:
1156 '(' abstract_declarator ')'
1157 { $$ = MkDeclaratorBrackets($2); }
1159 { $$ = MkDeclaratorArray(null, null); }
1160 | '[' constant_expression ']'
1161 { $$ = MkDeclaratorArray(null, $2); }
1163 { $$ = MkDeclaratorEnumArray(null, $2); }
1164 | direct_abstract_declarator '[' ']'
1165 { $$ = MkDeclaratorArray($1, null); }
1166 | direct_abstract_declarator '[' constant_expression ']'
1167 { $$ = MkDeclaratorArray($1, $3); }
1168 | direct_abstract_declarator '[' type ']'
1169 { $$ = MkDeclaratorEnumArray($1, $3); }
1171 { $$ = MkDeclaratorFunction(null, null); }
1172 | '(' parameter_type_list ')'
1173 { $$ = MkDeclaratorFunction(null, $2); }
1174 | direct_abstract_declarator '(' ')'
1175 { $$ = MkDeclaratorFunction($1, null); }
1176 | direct_abstract_declarator '(' parameter_type_list ')'
1177 { $$ = MkDeclaratorFunction($1, $3); }
1182 | pointer direct_declarator
1183 { $$ = MkDeclaratorPointer($1, $2); }
1184 | ext_decl pointer direct_declarator
1185 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1186 | declarator ext_decl
1187 { $$ = MkDeclaratorExtendedEnd($2, $1); }
1190 direct_declarator_nofunction:
1192 { $$ = MkDeclaratorIdentifier($1); }
1193 | '(' declarator ')'
1194 { $$ = MkDeclaratorBrackets($2); }
1195 | direct_declarator_nofunction '[' constant_expression ']'
1196 { $$ = MkDeclaratorArray($1, $3); }
1197 | direct_declarator_nofunction '[' ']'
1198 { $$ = MkDeclaratorArray($1, null); }
1199 | direct_declarator_nofunction '[' type ']'
1200 { $$ = MkDeclaratorEnumArray($1, $3); }
1203 declarator_function:
1204 direct_declarator_function
1205 | pointer direct_declarator_function
1206 { $$ = MkDeclaratorPointer($1, $2); }
1208 | ext_decl direct_declarator_function
1209 { $$ = MkDeclaratorExtended($1, $2); }
1210 | ext_decl pointer direct_declarator_function
1211 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1212 | pointer ext_decl direct_declarator_function
1213 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1217 direct_declarator_function_start:
1218 direct_declarator_nofunction '('
1221 direct_declarator_function:
1222 direct_declarator_function_start parameter_type_list ')'
1223 { $$ = MkDeclaratorFunction($1, $2); }
1224 | direct_declarator_function_start identifier_list ')'
1225 { $$ = MkDeclaratorFunction($1, $2); }
1226 | direct_declarator_function_start ')'
1227 { $$ = MkDeclaratorFunction($1, null); }
1231 direct_declarator_function
1232 | direct_declarator_nofunction
1233 | ext_decl direct_declarator_function
1234 { $$ = MkDeclaratorExtended($1, $2); }
1235 | ext_decl direct_declarator_nofunction
1236 { $$ = MkDeclaratorExtended($1, $2); }
1239 declarator_nofunction:
1240 direct_declarator_nofunction
1241 | pointer direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, $2); }
1242 | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
1243 | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1244 | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1247 type_qualifier_list:
1248 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
1249 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
1253 '*' { $$ = MkPointer(null, null); }
1254 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
1255 | '*' pointer { $$ = MkPointer(null, $2); }
1256 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
1259 parameter_type_list:
1261 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
1265 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
1266 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
1269 parameter_declaration:
1270 guess_declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
1271 | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
1272 | guess_declaration_specifiers '&' { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
1273 | guess_declaration_specifiers '&' declarator { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
1274 | real_guess_declaration_specifiers { $$ = MkTypeName($1, null); }
1277 { $$ = MkTypeName(MkList(), null); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1279 { $$ = MkTypeName(null, null); $$.typedObject = true; $$.byReference = true; }
1281 { $$ = MkTypeName(MkList(), $2); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1282 | CLASS '&' declarator
1283 { $$ = MkTypeName(null, $3); $$.typedObject = true; $$.byReference = true; }
1286 { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
1289 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
1291 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
1292 | TYPED_OBJECT declarator
1293 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2); }
1294 | TYPED_OBJECT '&' declarator
1295 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
1297 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
1298 | ANY_OBJECT declarator
1299 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), $2); }
1302 { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), null); }
1303 | error declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1304 //| error struct_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1305 | error abstract_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1310 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
1311 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
1315 specifier_qualifier_list { $$ = MkTypeName($1, null); }
1316 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1320 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
1321 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1325 assignment_expression
1326 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1327 | '{' initializer_list '}'
1328 { $$ = MkInitializerList($2); $$.loc = @$; }
1329 | '{' initializer_list ',' '}'
1331 $$ = MkInitializerList($2);
1335 Expression exp = MkExpDummy();
1336 Initializer init = MkInitializerAssignment(exp);
1344 initializer_condition:
1345 conditional_expression
1346 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1347 | anon_instantiation_expression
1348 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1350 | '{' initializer_list '}'
1351 { $$ = MkInitializerList($2); $$.loc = @$; }
1352 | '{' initializer_list ',' '}'
1354 $$ = MkInitializerList($2);
1358 Expression exp = MkExpDummy();
1359 Initializer init = MkInitializerAssignment(exp);
1370 { $$ = MkList(); ListAdd($$, $1); }
1371 | initializer_list ',' initializer
1372 { $$ = $1; ListAdd($1, $3); }
1377 | compound_statement
1378 | expression_statement
1379 | selection_statement
1380 | iteration_statement
1385 identifier ':' statement
1386 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1387 | CASE constant_expression ':' statement
1388 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1389 | DEFAULT ':' statement
1390 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1394 declaration { $$ = MkList(); ListAdd($$, $1); }
1395 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1399 statement { $$ = MkList(); ListAdd($$, $1); }
1400 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1402 // declaration not allowed after statements
1403 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1407 statement_list { $$ = MkCompoundStmt(null, $1); }
1408 | declaration_list { $$ = MkCompoundStmt($1, null); }
1409 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1413 '{' { $<context>$ = PushContext(); }
1419 $$ = MkCompoundStmt(null, null);
1420 $$.compound.context = PushContext();
1421 PopContext($$.compound.context);
1425 | compound_start compound_inside '}'
1426 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1429 expression_statement:
1430 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1431 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1434 selection_statement:
1435 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1436 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1437 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1440 iteration_statement:
1441 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1442 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1443 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1444 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1446 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1447 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1448 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1452 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1453 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1454 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1455 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1456 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1460 STRING_LITERAL { $$ = CopyString(yytext); }
1463 instantiation_named:
1464 declaration_specifiers identifier '{' members_initialization_list '}'
1465 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1466 | declaration_specifiers identifier '{' '}'
1467 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1470 guess_instantiation_named:
1471 guess_declaration_specifiers identifier '{' members_initialization_list '}'
1472 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1473 | guess_declaration_specifiers identifier '{' '}'
1474 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1476 /*| guess_declaration_specifiers identifier '{' members_initialization_list error
1479 $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;
1485 else if(yychar == '{')
1497 instantiation_unnamed:
1498 type '{' members_initialization_list '}'
1499 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1501 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1502 | identifier '{' members_initialization_list '}'
1503 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1504 | identifier '{' '}'
1505 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1509 '{' members_initialization_list '}'
1510 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1512 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1514 class_function_definition:
1515 class_function_definition_start compound_statement
1516 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1517 | virtual_class_function_definition_start compound_statement
1518 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1519 | virtual_class_function_definition_start ';'
1520 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1521 | constructor_function_definition_start compound_statement
1522 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1523 | destructor_function_definition_start compound_statement
1524 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1527 instance_class_function_definition_start:
1528 // Guess here conflicts with an expression...
1529 declaration_specifiers declarator_function
1530 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1531 | declaration_specifiers declarator_nofunction
1532 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1535 instance_class_function_definition:
1536 instance_class_function_definition_start compound_statement
1537 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1540 data_member_initialization:
1541 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1542 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1545 data_member_initialization_list:
1546 data_member_initialization
1547 { $$ = MkList(); ListAdd($$, $1); }
1548 | data_member_initialization_list ',' data_member_initialization
1549 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1552 data_member_initialization_list_coloned:
1553 data_member_initialization_list ';'
1554 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1557 members_initialization_list_coloned:
1558 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1559 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1560 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1561 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2;$$ = $1; }
1562 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1563 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1566 members_initialization_list:
1567 members_initialization_list_coloned
1568 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1569 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1573 parameter_declaration { parsedType = $1; }
1574 | parameter_declaration ':' constant_expression { parsedType = $1; parsedType.bitCount = $3; }