5 #define YYLTYPE Location
9 # define YYLLOC_DEFAULT(Current, Rhs, N) \
10 (Current).start = (Rhs)[1].start; \
11 (Current).end = (Rhs)[N].end;
18 #define yyparse type_yyparse
19 #define yylval type_yylval
20 #define yychar type_yychar
21 #define yydebug type_yydebug
22 #define yynerrs type_yynerrs
23 #define yylloc type_yylloc
25 extern bool parseTypeError;
27 extern File fileInput;
41 SpecifierType specifierType;
46 Enumerator enumerator;
47 Declarator declarator;
49 Initializer initializer;
50 InitDeclarator initDeclarator;
52 Declaration declaration;
54 FunctionDefinition function;
61 Instantiation instance;
62 MembersInit membersInit;
63 MemberInit memberInit;
64 ClassFunction classFunction;
65 ClassDefinition _class;
70 TemplateParameter templateParameter;
71 TemplateArgument templateArgument;
72 TemplateDatatype templateDatatype;
77 %type <specifierType> struct_or_union
78 %type <i> unary_operator assignment_operator
80 %type <exp> primary_expression postfix_expression unary_expression cast_expression
81 multiplicative_expression additive_expression shift_expression
82 relational_expression relational_expression_smaller_than equality_expression and_expression
83 exclusive_or_expression inclusive_or_expression logical_and_expression
84 logical_or_expression conditional_expression assignment_expression
86 common_unary_expression simple_primary_expression
87 anon_instantiation_expression
89 //simple_postfix_expression simple_unary_expression
91 %type <list> argument_expression_list expression enumerator_list
92 struct_declarator_list struct_declaration_list
93 declaration_specifiers identifier_list initializer_list init_declarator_list
94 parameter_list parameter_type_list declaration_list statement_list
95 members_initialization_list members_initialization_list_coloned data_member_initialization_list data_member_initialization_list_coloned
96 guess_declaration_specifiers real_guess_declaration_specifiers
97 specifier_qualifier_list guess_specifier_qualifier_list
98 type_qualifier_list property_specifiers
100 default_property_list
101 template_arguments_list attribs_list
104 %type <specifier> storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier strict_type_specifier
105 struct_or_union_specifier_compound struct_or_union_specifier_nocompound guess_type type strict_type
106 real_guess_type ext_storage base_strict_type
107 %type <enumerator> enumerator
108 %type <declarator> declarator direct_declarator direct_abstract_declarator abstract_declarator
109 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
110 direct_abstract_declarator_noarray abstract_declarator_noarray declarator_nofunction
112 %type <pointer> pointer
113 %type <initializer> initializer initializer_condition
114 %type <initDeclarator> init_declarator
115 %type <typeName> type_name guess_type_name parameter_declaration
116 %type <stmt> statement labeled_statement compound_statement expression_statement
117 selection_statement iteration_statement jump_statement compound_inside
119 %type <declaration> declaration
120 %type <classDef> struct_declaration
121 %type <string> string_literal attribute_word
122 %type <extDecl> ext_decl
123 %type <attrib> attrib
124 %type <attribute> attribute
126 %type <instance> instantiation_named instantiation_unnamed guess_instantiation_named instantiation_anon
127 /* %type <membersInit> members_initialization */
128 %type <memberInit> data_member_initialization default_property
129 %type <classFunction> class_function_definition class_function_definition_start
130 virtual_class_function_definition_start
131 constructor_function_definition_start destructor_function_definition_start
132 %type <classFunction> instance_class_function_definition instance_class_function_definition_start
133 %type <prop> property
135 %type <templateArgument> template_argument template_type_argument template_expression_argument
136 %type <templateDatatype> template_datatype
138 %type <context> compound_start
140 %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
141 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
142 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
143 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
144 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
146 %token TYPEDEF EXTERN STATIC AUTO REGISTER
147 %token CHAR SHORT INT UINT INT64 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
148 %token STRUCT UNION ENUM ELLIPSIS
150 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
154 %token CLASS THISCLASS CLASS_NAME
155 %token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
156 %token PUBLIC PRIVATE
157 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
158 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
159 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
160 %token NEW0OP RENEW0 VAARG
161 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
162 %token ALIGNOF ATTRIB_DEP __ATTRIB
163 %token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
164 %token WIDE_STRING_LITERAL
166 %destructor { FreeIdentifier($$); } identifier
167 %destructor { FreePointer($$); } pointer
168 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
169 multiplicative_expression additive_expression shift_expression
170 relational_expression equality_expression and_expression
171 exclusive_or_expression inclusive_or_expression logical_and_expression
172 logical_or_expression conditional_expression assignment_expression
174 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
175 struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type strict_type_specifier
177 %destructor { FreeEnumerator($$); } enumerator
178 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
179 direct_abstract_declarator_noarray abstract_declarator_noarray
180 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
181 declarator_nofunction
183 %destructor { FreeInitializer($$); } initializer initializer_condition
184 %destructor { FreeInitDeclarator($$); } init_declarator
185 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration
186 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
187 selection_statement iteration_statement jump_statement compound_inside
189 %destructor { FreeDeclaration($$); } declaration
191 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
193 %destructor { FreeMemberInit($$); } data_member_initialization default_property
195 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
196 virtual_class_function_definition_start
197 constructor_function_definition_start destructor_function_definition_start
198 instance_class_function_definition instance_class_function_definition_start
199 %destructor { FreeClassDef($$); } struct_declaration
200 %destructor { delete $$; } string_literal attribute_word
201 %destructor { FreeProperty($$); } property
203 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
204 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
205 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
206 guess_declaration_specifiers guess_specifier_qualifier_list
207 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
208 %destructor { FreeList($$, FreeDeclaration); } declaration_list
209 %destructor { FreeList($$, FreeInitializer); } initializer_list
210 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
211 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
212 %destructor { FreeList($$, FreeStatement); } statement_list
213 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
214 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
215 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
216 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
217 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_expression_argument
218 %destructor { FreeTemplateDataType($$); } template_datatype
219 %destructor { FreeAttrib($$); } attrib
220 %destructor { FreeExtDecl($$); } ext_decl
221 %destructor { FreeAttribute($$); } attribute
222 %destructor { FreeList($$, FreeAttribute); } attribs_list
232 DeclClass($1.string);
233 fileInput.Seek(@1.start.pos, start);
234 resetScannerPos(&@1.start);
241 YY_STACK_PRINT (yyss, yyssp);
244 YY_STACK_PRINT (yyss, yyssp);
251 // if($1._class && !$1._class.name)
255 strcpy(name, $1._class.name ? $1._class.name : "");
257 strcat(name, $1.string);
261 _DeclClass($1.string);
265 fileInput.Seek(@1.start.pos, start);
266 resetScannerPos(&@1.start);
271 YY_STACK_PRINT (yyss, yyssp);
274 YY_STACK_PRINT (yyss, yyssp);
283 DeclClass($1.string);
284 fileInput.Seek(@1.start.pos, start);
286 resetScannerPos(&@1.start);
292 YY_STACK_PRINT (yyss, yyssp);
295 YY_STACK_PRINT (yyss, yyssp);
301 // if($1._class && !$1._class.name)
305 strcpy(name, $1._class.name ? $1._class.name : "");
307 strcat(name, $1.string);
311 _DeclClass($1.string);
315 fileInput.Seek(@1.start.pos, start);
316 resetScannerPos(&@1.start);
321 YY_STACK_PRINT (yyss, yyssp);
324 YY_STACK_PRINT (yyss, yyssp);
331 strict_type { $$ = $1; }
332 | identifier identifier
335 DeclClass($1.string);
336 fileInput.Seek(@1.start.pos, start);
337 resetScannerPos(&@1.start);
345 YY_STACK_PRINT (yyss, yyssp);
348 YY_STACK_PRINT (yyss, yyssp);
351 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
352 Compiler_Error($"Not a type: %s\n", $1.string);
353 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
359 TYPE_NAME { $$ = MkSpecifierName(yytext); }
364 | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
365 | base_strict_type '<' template_arguments_list RIGHT_OP
368 SetClassTemplateArgs($$, $3);
372 fileInput.Seek(@4.end.pos, start);
373 resetScannerPos(&@4.end);
377 /* | identifier '<' template_arguments_list '>'
378 { $$ = MkSpecifierNameArgs($1.string, $3); $$.loc = @$; FreeIdentifier($1); } */
381 class_function_definition_start:
382 guess_declaration_specifiers declarator_function
383 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
384 | declarator_function
385 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
388 constructor_function_definition_start:
389 guess_declaration_specifiers '(' ')'
390 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
393 destructor_function_definition_start:
394 '~' guess_declaration_specifiers '(' ')'
395 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
398 virtual_class_function_definition_start:
399 VIRTUAL guess_declaration_specifiers declarator_function
400 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
401 | VIRTUAL declarator_function
402 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
407 { $$ = MkIdentifier(yytext); $$.loc = @1; }
411 simple_primary_expression
413 { $$ = MkExpBrackets($2); $$.loc = @$; }
416 simple_primary_expression:
418 { $$ = MkExpIdentifier($1); $$.loc = @$; }
419 | instantiation_unnamed
420 { $$ = MkExpInstance($1); $$.loc = @$; }
422 { $$ = MkExpConstant(yytext); $$.loc = @$; }
423 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
425 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
426 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
427 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
429 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
431 | NEWOP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
432 | NEWOP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
433 | NEW0OP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
434 | NEW0OP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
435 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
436 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
437 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
438 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
439 | error { $$ = MkExpDummy(); }
444 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
445 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
446 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
447 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
448 | postfix_expression identifier
450 char * constant = $1.type == constantExp ? $1.constant : null;
451 int len = constant ? strlen(constant) : 0;
452 if(constant && constant[len-1] == '.')
455 $$ = MkExpMember($1, $2);
461 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
462 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
463 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
466 anon_instantiation_expression:
467 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
471 simple_postfix_expression:
472 simple_primary_expression
473 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
474 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
475 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
476 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
477 | simple_postfix_expression identifier
479 char * constant = $1.type == constantExp ? $1.constant : null;
480 int len = constant ? strlen(constant) : 0;
481 if(constant && constant[len-1] == '.')
484 $$ = MkExpMember($1, $2);
490 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
491 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
492 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
495 argument_expression_list:
496 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
497 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
498 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
499 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
502 common_unary_expression:
503 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
504 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
505 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
506 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
507 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
508 | SIZEOF '(' guess_type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
509 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
510 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
511 | ALIGNOF '(' guess_type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
515 common_unary_expression
519 simple_unary_expression:
520 common_unary_expression
521 | simple_postfix_expression
531 | DELETE { $$ = DELETE; }
536 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
539 multiplicative_expression:
541 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
542 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
543 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
547 multiplicative_expression
548 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
549 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
554 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
555 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
558 relational_expression_smaller_than:
559 relational_expression '<'
566 relational_expression:
568 | relational_expression_smaller_than /*relational_expression '<' */ shift_expression { skipErrors = false; $$ = MkExpOp($1, '<', $2/*$3*/); $$.loc = @$; }
569 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
570 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
571 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
575 relational_expression
576 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
577 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
582 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
585 exclusive_or_expression:
587 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
590 inclusive_or_expression:
591 exclusive_or_expression
592 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
595 logical_and_expression:
596 inclusive_or_expression
597 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
600 logical_or_expression:
601 logical_and_expression
602 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
605 conditional_expression:
606 logical_or_expression
607 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
610 assignment_expression:
611 conditional_expression
612 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
613 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
618 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
619 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
620 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
621 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
622 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
623 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
624 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
625 | AND_ASSIGN { $$ = AND_ASSIGN; }
626 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
627 | OR_ASSIGN { $$ = OR_ASSIGN; }
631 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
632 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
636 conditional_expression
640 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
641 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
642 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
643 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
646 specifier_qualifier_list:
647 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
648 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
649 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
650 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
651 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
652 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
653 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
654 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
657 guess_specifier_qualifier_list:
658 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
659 | guess_specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
660 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
661 | guess_specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
662 | guess_type { $$ = MkList(); ListAdd($$, $1); }
663 | guess_specifier_qualifier_list guess_type { $$ = $1; ListAdd($1, $2); }
664 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
665 | guess_specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
666 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
667 | guess_specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
670 declaration_specifiers:
671 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
672 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
673 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
674 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
675 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
676 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
677 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
678 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
679 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
680 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
683 guess_declaration_specifiers:
684 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
685 | guess_declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
686 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
687 | guess_declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
688 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
689 | guess_declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
690 | guess_type { $$ = MkList(); ListAdd($$, $1); }
691 | guess_declaration_specifiers guess_type { $$ = $1; ListAdd($1, $2); }
692 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
693 | guess_declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
694 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
695 | guess_declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
698 real_guess_declaration_specifiers:
699 guess_declaration_specifiers { $$ = $1; }
700 | real_guess_type { $$ = MkList(); ListAdd($$, $1); }
704 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
705 | property_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
706 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
707 | property_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
708 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
709 | property_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
710 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
711 | property_specifiers identifier { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
712 | identifier '<' template_arguments_list '>'
714 // if($1._class && !$1._class.name)
718 strcpy(name, $1._class.name ? $1._class.name : "");
720 strcat(name, $1.string);
724 _DeclClass($1.string);
727 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
730 | property_specifiers identifier '<' template_arguments_list '>'
732 if($2._class && !$2._class.name)
736 strcat(name, $2.string);
740 _DeclClass($2.string);
741 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
747 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
748 | renew_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
749 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
750 | renew_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
751 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
752 | renew_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
753 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
754 | renew_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
755 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
756 | renew_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
757 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
758 | renew_specifiers identifier { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
759 | identifier '<' template_arguments_list '>'
761 // if($1._class && !$1._class.name)
765 strcpy(name, $1._class.name ? $1._class.name : "");
767 strcat(name, $1.string);
771 _DeclClass($1.string);
774 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
777 | renew_specifiers identifier '<' template_arguments_list '>'
779 if($2._class && !$2._class.name)
783 strcat(name, $2.string);
787 _DeclClass($2.string);
788 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
793 init_declarator_list:
794 init_declarator { $$ = MkList(); ListAdd($$, $1); }
795 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
799 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
800 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
803 storage_class_specifier:
804 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
805 | EXTERN { $$ = MkSpecifier(EXTERN); }
806 | STATIC { $$ = MkSpecifier(STATIC); }
807 | AUTO { $$ = MkSpecifier(AUTO); }
808 | REGISTER { $$ = MkSpecifier(REGISTER); }
809 | THREAD { $$ = MkSpecifier(THREAD); }
813 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
814 | EXT_STORAGE { $$ = MkExtDeclString(CopyString(yytext)); }
815 | attrib { $$ = MkExtDeclAttrib($1); }
819 ATTRIB { $<i>$ = ATTRIB; }
820 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
821 | __ATTRIB { $<i>$ = __ATTRIB; }
826 IDENTIFIER { $$ = CopyString(yytext); }
827 | TYPE_NAME { $$ = CopyString(yytext); }
828 | EXT_STORAGE { $$ = CopyString(yytext); }
829 | EXT_DECL { $$ = CopyString(yytext); }
830 | CONST { $$ = CopyString(yytext); }
834 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
835 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
839 attribute { $$ = MkListOne($1); }
840 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
841 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
845 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
846 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
850 ext_decl { $$ = MkSpecifierExtended($1); }
854 CONST { $$ = MkSpecifier(CONST); }
855 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
856 | ext_storage { $$ = $1; }
861 VOID { $$ = MkSpecifier(VOID); }
862 | CHAR { $$ = MkSpecifier(CHAR); }
863 | SHORT { $$ = MkSpecifier(SHORT); }
864 | INT { $$ = MkSpecifier(INT); }
865 | UINT { $$ = MkSpecifier(UINT); }
866 | INT64 { $$ = MkSpecifier(INT64); }
867 | VALIST { $$ = MkSpecifier(VALIST); }
868 | LONG { $$ = MkSpecifier(LONG); }
869 | FLOAT { $$ = MkSpecifier(FLOAT); }
870 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
871 | SIGNED { $$ = MkSpecifier(SIGNED); }
872 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
873 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
874 | _BOOL { $$ = MkSpecifier(_BOOL); }
875 | BOOL { $$ = MkSpecifier(BOOL); }
876 | struct_or_union_specifier_nocompound
877 | enum_specifier_nocompound
879 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
880 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
881 | SUBCLASS '(' identifier ')' { _DeclClass($3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
882 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
883 | TYPED_OBJECT { $$ = MkSpecifier(TYPED_OBJECT); }
884 | ANY_OBJECT { $$ = MkSpecifier(ANY_OBJECT); }
887 strict_type_specifier:
888 VOID { $$ = MkSpecifier(VOID); }
889 | CHAR { $$ = MkSpecifier(CHAR); }
890 | SHORT { $$ = MkSpecifier(SHORT); }
891 | INT { $$ = MkSpecifier(INT); }
892 | UINT { $$ = MkSpecifier(UINT); }
893 | INT64 { $$ = MkSpecifier(INT64); }
894 | VALIST { $$ = MkSpecifier(VALIST); }
895 | LONG { $$ = MkSpecifier(LONG); }
896 | FLOAT { $$ = MkSpecifier(FLOAT); }
897 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
898 | SIGNED { $$ = MkSpecifier(SIGNED); }
899 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
900 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
901 | _BOOL { $$ = MkSpecifier(_BOOL); }
902 | BOOL { $$ = MkSpecifier(BOOL); }
903 | struct_or_union_specifier_nocompound
904 | enum_specifier_nocompound
906 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
907 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
908 | SUBCLASS '(' identifier ')' { _DeclClass($3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
909 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
913 struct_or_union_specifier_compound:
914 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2.string); }
915 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
916 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2.string); }
917 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
918 | struct_or_union base_strict_type '{' struct_declaration_list '}'
919 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.name); FreeSpecifier($2); }
921 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.string); }
922 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
923 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.string); }
924 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
925 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
926 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.name); FreeSpecifier($3); }
929 struct_or_union_specifier_nocompound:
930 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2.string); }
931 | struct_or_union strict_type
932 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.name); FreeSpecifier($2); }
934 | struct_or_union ext_decl identifier
935 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3.string); }
936 | struct_or_union ext_decl strict_type
937 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.name); FreeSpecifier($3); }
941 guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
942 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
943 /*| identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }*/
946 template_type_argument:
947 guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
948 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
949 //template_datatype { $$ = MkTemplateTypeArgument($1); }
953 template_identifier_argument:
954 identifier { $$ = MkTemplateIdentifierArgument($1); }
958 template_expression_argument:
959 shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
963 template_expression_argument
964 /*| template_identifier_argument*/
965 | template_type_argument
966 | identifier '=' template_expression_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
967 /*| identifier '=' template_identifier_argument { $$ = $3; $$.name = $1; $$.loc = @$; }*/
968 | identifier '=' template_type_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
969 | template_datatype '=' template_expression_argument
972 if($1.specifiers && $1.specifiers->first)
974 Specifier spec = $1.specifiers->first;
975 if(spec.type == nameSpecifier)
976 $$.name = MkIdentifier(spec.name);
978 FreeTemplateDataType($1);
981 /*| template_datatype '=' template_identifier_argument
984 if($1.specifiers && $1.specifiers->first)
986 Specifier spec = $1.specifiers->first;
987 if(spec.type == nameSpecifier)
988 $$.name = MkIdentifier(spec.name);
990 FreeTemplateDataType($1);
993 | template_datatype '=' template_type_argument
996 if($1.specifiers && $1.specifiers->first)
998 Specifier spec = $1.specifiers->first;
999 if(spec.type == nameSpecifier)
1000 $$.name = MkIdentifier(spec.name);
1002 FreeTemplateDataType($1);
1007 template_arguments_list:
1008 template_argument { $$ = MkList(); ListAdd($$, $1); }
1009 | template_arguments_list ',' template_argument { ListAdd($1, $3); }
1013 STRUCT { $$ = structSpecifier; }
1014 | UNION { $$ = unionSpecifier; }
1017 struct_declaration_list:
1018 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
1019 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
1023 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; }
1026 default_property_list:
1027 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
1028 | default_property_list ',' default_property { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1032 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
1033 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
1034 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
1035 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
1036 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
1037 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
1038 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
1039 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
1040 | PROPERTY property_specifiers identifier '{' '}'
1041 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
1043 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
1044 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
1045 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
1046 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
1047 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
1048 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
1049 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
1050 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
1051 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
1052 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
1054 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
1055 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
1056 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
1057 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
1058 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
1059 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
1060 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
1061 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
1062 | PROPERTY property_specifiers '{' '}'
1063 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
1065 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
1066 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
1067 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
1068 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
1069 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
1070 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
1071 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
1072 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
1073 | PROPERTY property_specifiers abstract_declarator '{' '}'
1074 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
1078 guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
1079 | guess_declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
1080 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1081 | guess_instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1082 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
1083 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
1084 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
1085 | ';' { $$ = null; }
1088 struct_declarator_list:
1090 { $$ = MkList(); ListAdd($$, $1); }
1091 | struct_declarator_list ',' struct_declarator
1092 { $$ = $1; ListAdd($1, $3); }
1096 declarator_nofunction
1097 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
1098 | declarator_nofunction attrib
1099 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
1100 | ':' constant_expression
1101 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
1102 | declarator_nofunction ':' constant_expression
1103 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
1104 | declarator_nofunction ':' constant_expression ':' constant_expression
1105 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
1108 enum_specifier_nocompound:
1109 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2.string); }
1110 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.name); FreeSpecifier($2); }
1113 enum_specifier_compound:
1114 ENUM '{' enumerator_list '}'
1115 { $$ = MkEnum(null, $3); }
1116 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2.string); }
1117 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2.string); }
1118 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.name); FreeSpecifier($2); }
1119 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.name); FreeSpecifier($2); }
1124 { $$ = MkList(); ListAdd($$, $1); }
1125 | enumerator_list ',' enumerator
1126 { $$ = $1; ListAdd($1, $3); }
1131 { $$ = MkEnumerator($1, null); }
1132 | identifier '=' constant_expression
1133 { $$ = MkEnumerator($1, $3); }
1137 direct_abstract_declarator:
1138 '(' abstract_declarator ')'
1139 { $$ = MkDeclaratorBrackets($2); }
1141 { $$ = MkDeclaratorArray(null, null); }
1142 | '[' constant_expression ']'
1143 { $$ = MkDeclaratorArray(null, $2); }
1145 { $$ = MkDeclaratorEnumArray(null, $2); }
1146 | direct_abstract_declarator '[' ']'
1147 { $$ = MkDeclaratorArray($1, null); }
1148 | direct_abstract_declarator '[' constant_expression ']'
1149 { $$ = MkDeclaratorArray($1, $3); }
1150 | direct_abstract_declarator '[' type']'
1151 { $$ = MkDeclaratorEnumArray($1, $3); }
1153 { $$ = MkDeclaratorFunction(null, null); }
1154 | '(' parameter_type_list ')'
1155 { $$ = MkDeclaratorFunction(null, $2); }
1156 | direct_abstract_declarator '(' ')'
1157 { $$ = MkDeclaratorFunction($1, null); }
1158 | direct_abstract_declarator '(' parameter_type_list ')'
1159 { $$ = MkDeclaratorFunction($1, $3); }
1162 direct_abstract_declarator_noarray:
1163 '(' abstract_declarator_noarray ')'
1164 { $$ = MkDeclaratorBrackets($2); }
1166 { $$ = MkDeclaratorFunction(null, null); }
1167 | '(' parameter_type_list ')'
1168 { $$ = MkDeclaratorFunction(null, $2); }
1169 | direct_abstract_declarator_noarray '(' ')'
1170 { $$ = MkDeclaratorFunction($1, null); }
1171 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
1172 { $$ = MkDeclaratorFunction($1, $3); }
1175 abstract_declarator:
1176 pointer { $$ = MkDeclaratorPointer($1, null); }
1177 | direct_abstract_declarator
1178 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
1179 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1180 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
1181 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1184 abstract_declarator_noarray:
1185 pointer { $$ = MkDeclaratorPointer($1, null); }
1186 | direct_abstract_declarator_noarray
1187 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
1188 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1189 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
1190 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1194 abstract_declarator:
1196 { $$ = MkDeclaratorPointer($1, null); }
1197 | direct_abstract_declarator
1198 | pointer direct_abstract_declarator
1199 { $$ = MkDeclaratorPointer($1, $2); }
1202 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1203 | ext_decl direct_abstract_declarator
1204 { $$ = MkDeclaratorExtended($1, $2); }
1205 | ext_decl pointer direct_abstract_declarator
1206 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1210 direct_abstract_declarator:
1211 '(' abstract_declarator ')'
1212 { $$ = MkDeclaratorBrackets($2); }
1214 { $$ = MkDeclaratorArray(null, null); }
1215 | '[' constant_expression ']'
1216 { $$ = MkDeclaratorArray(null, $2); }
1218 { $$ = MkDeclaratorEnumArray(null, $2); }
1219 | direct_abstract_declarator '[' ']'
1220 { $$ = MkDeclaratorArray($1, null); }
1221 | direct_abstract_declarator '[' constant_expression ']'
1222 { $$ = MkDeclaratorArray($1, $3); }
1223 | direct_abstract_declarator '[' type ']'
1224 { $$ = MkDeclaratorEnumArray($1, $3); }
1226 { $$ = MkDeclaratorFunction(null, null); }
1227 | '(' parameter_type_list ')'
1228 { $$ = MkDeclaratorFunction(null, $2); }
1229 | direct_abstract_declarator '(' ')'
1230 { $$ = MkDeclaratorFunction($1, null); }
1231 | direct_abstract_declarator '(' parameter_type_list ')'
1232 { $$ = MkDeclaratorFunction($1, $3); }
1237 | pointer direct_declarator
1238 { $$ = MkDeclaratorPointer($1, $2); }
1239 | ext_decl pointer direct_declarator
1240 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1241 | declarator ext_decl
1242 { $$ = MkDeclaratorExtendedEnd($2, $1); }
1245 direct_declarator_nofunction:
1247 { $$ = MkDeclaratorIdentifier($1); }
1248 | '(' declarator ')'
1249 { $$ = MkDeclaratorBrackets($2); }
1250 | direct_declarator_nofunction '[' constant_expression ']'
1251 { $$ = MkDeclaratorArray($1, $3); }
1252 | direct_declarator_nofunction '[' ']'
1253 { $$ = MkDeclaratorArray($1, null); }
1254 | direct_declarator_nofunction '[' type ']'
1255 { $$ = MkDeclaratorEnumArray($1, $3); }
1258 declarator_function:
1259 direct_declarator_function
1260 | pointer direct_declarator_function
1261 { $$ = MkDeclaratorPointer($1, $2); }
1263 | ext_decl direct_declarator_function
1264 { $$ = MkDeclaratorExtended($1, $2); }
1265 | ext_decl pointer direct_declarator_function
1266 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1267 | pointer ext_decl direct_declarator_function
1268 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1272 direct_declarator_function_start:
1273 direct_declarator_nofunction '('
1276 direct_declarator_function:
1277 direct_declarator_function_start parameter_type_list ')'
1278 { $$ = MkDeclaratorFunction($1, $2); }
1279 | direct_declarator_function_start identifier_list ')'
1280 { $$ = MkDeclaratorFunction($1, $2); }
1281 | direct_declarator_function_start ')'
1282 { $$ = MkDeclaratorFunction($1, null); }
1286 direct_declarator_function
1287 | direct_declarator_nofunction
1288 | ext_decl direct_declarator_function
1289 { $$ = MkDeclaratorExtended($1, $2); }
1290 | ext_decl direct_declarator_nofunction
1291 { $$ = MkDeclaratorExtended($1, $2); }
1294 declarator_nofunction:
1295 direct_declarator_nofunction
1296 | pointer direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, $2); }
1297 | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
1298 | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1299 | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1302 type_qualifier_list:
1303 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
1304 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
1308 '*' { $$ = MkPointer(null, null); }
1309 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
1310 | '*' pointer { $$ = MkPointer(null, $2); }
1311 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
1314 parameter_type_list:
1316 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
1320 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
1321 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
1324 parameter_declaration:
1325 guess_declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
1326 | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
1327 | guess_declaration_specifiers '&' { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
1328 | guess_declaration_specifiers '&' declarator { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
1329 | real_guess_declaration_specifiers { $$ = MkTypeName($1, null); }
1332 { $$ = MkTypeName(MkList(), null); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1334 { $$ = MkTypeName(null, null); $$.typedObject = true; $$.byReference = true; }
1336 { $$ = MkTypeName(MkList(), $2); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1337 | CLASS '&' declarator
1338 { $$ = MkTypeName(null, $3); $$.typedObject = true; $$.byReference = true; }
1341 { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
1344 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
1346 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
1347 | TYPED_OBJECT declarator
1348 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2); }
1349 | TYPED_OBJECT '&' declarator
1350 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
1352 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
1353 | ANY_OBJECT declarator
1354 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), $2); }
1357 { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), null); }
1358 | error declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1359 //| error struct_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1360 | error abstract_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1365 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
1366 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
1370 specifier_qualifier_list { $$ = MkTypeName($1, null); }
1371 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1375 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
1376 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1380 assignment_expression
1381 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1382 | '{' initializer_list '}'
1383 { $$ = MkInitializerList($2); $$.loc = @$; }
1384 | '{' initializer_list ',' '}'
1386 $$ = MkInitializerList($2);
1390 Expression exp = MkExpDummy();
1391 Initializer init = MkInitializerAssignment(exp);
1399 initializer_condition:
1400 conditional_expression
1401 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1402 | anon_instantiation_expression
1403 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1405 | '{' initializer_list '}'
1406 { $$ = MkInitializerList($2); $$.loc = @$; }
1407 | '{' initializer_list ',' '}'
1409 $$ = MkInitializerList($2);
1413 Expression exp = MkExpDummy();
1414 Initializer init = MkInitializerAssignment(exp);
1425 { $$ = MkList(); ListAdd($$, $1); }
1426 | initializer_list ',' initializer
1427 { $$ = $1; ListAdd($1, $3); }
1432 | compound_statement
1433 | expression_statement
1434 | selection_statement
1435 | iteration_statement
1440 identifier ':' statement
1441 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1442 | CASE constant_expression ':' statement
1443 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1444 | DEFAULT ':' statement
1445 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1449 declaration { $$ = MkList(); ListAdd($$, $1); }
1450 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1454 statement { $$ = MkList(); ListAdd($$, $1); }
1455 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1457 // declaration not allowed after statements
1458 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1462 statement_list { $$ = MkCompoundStmt(null, $1); }
1463 | declaration_list { $$ = MkCompoundStmt($1, null); }
1464 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1468 '{' { $<context>$ = PushContext(); }
1474 $$ = MkCompoundStmt(null, null);
1475 $$.compound.context = PushContext();
1476 PopContext($$.compound.context);
1480 | compound_start compound_inside '}'
1481 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1484 expression_statement:
1485 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1486 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1489 selection_statement:
1490 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1491 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1492 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1495 iteration_statement:
1496 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1497 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1498 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1499 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1501 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1502 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1503 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1507 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1508 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1509 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1510 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1511 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1515 STRING_LITERAL { $$ = CopyString(yytext); }
1518 instantiation_named:
1519 declaration_specifiers identifier '{' members_initialization_list '}'
1520 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1521 | declaration_specifiers identifier '{' '}'
1522 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1525 guess_instantiation_named:
1526 guess_declaration_specifiers identifier '{' members_initialization_list '}'
1527 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1528 | guess_declaration_specifiers identifier '{' '}'
1529 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1531 /*| guess_declaration_specifiers identifier '{' members_initialization_list error
1534 $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;
1540 else if(yychar == '{')
1552 instantiation_unnamed:
1553 type '{' members_initialization_list '}'
1554 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1556 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1557 | identifier '{' members_initialization_list '}'
1558 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1559 | identifier '{' '}'
1560 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1564 '{' members_initialization_list '}'
1565 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1567 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1569 class_function_definition:
1570 class_function_definition_start compound_statement
1571 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1572 | virtual_class_function_definition_start compound_statement
1573 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1574 | virtual_class_function_definition_start ';'
1575 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1576 | constructor_function_definition_start compound_statement
1577 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1578 | destructor_function_definition_start compound_statement
1579 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1582 instance_class_function_definition_start:
1583 // Guess here conflicts with an expression...
1584 declaration_specifiers declarator_function
1585 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1586 | declaration_specifiers declarator_nofunction
1587 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1590 instance_class_function_definition:
1591 instance_class_function_definition_start compound_statement
1592 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1595 data_member_initialization:
1596 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1597 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1600 data_member_initialization_list:
1601 data_member_initialization
1602 { $$ = MkList(); ListAdd($$, $1); }
1603 | data_member_initialization_list ',' data_member_initialization
1604 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1607 data_member_initialization_list_coloned:
1608 data_member_initialization_list ';'
1609 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1612 members_initialization_list_coloned:
1613 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1614 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1615 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1616 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2;$$ = $1; }
1617 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1618 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1621 members_initialization_list:
1622 members_initialization_list_coloned
1623 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1624 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1628 parameter_declaration { parsedType = $1; }
1629 | parameter_declaration ':' constant_expression { parsedType = $1; parsedType.bitCount = $3; }