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 INT128 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
149 %token STRUCT UNION ENUM ELLIPSIS
151 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
155 %token CLASS THISCLASS CLASS_NAME
156 %token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
157 %token PUBLIC PRIVATE
158 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
159 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
160 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
161 %token NEW0OP RENEW0 VAARG
162 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
163 %token ALIGNOF ATTRIB_DEP __ATTRIB
164 %token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
165 %token WIDE_STRING_LITERAL
166 %token BUILTIN_OFFSETOF
168 %destructor { FreeIdentifier($$); } identifier
169 %destructor { FreePointer($$); } pointer
170 %destructor { FreeExpression($$); } primary_expression postfix_expression unary_expression cast_expression
171 multiplicative_expression additive_expression shift_expression
172 relational_expression equality_expression and_expression
173 exclusive_or_expression inclusive_or_expression logical_and_expression
174 logical_or_expression conditional_expression assignment_expression
176 %destructor { FreeSpecifier($$); } storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier
177 struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type strict_type_specifier
179 %destructor { FreeEnumerator($$); } enumerator
180 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
181 direct_abstract_declarator_noarray abstract_declarator_noarray
182 struct_declarator direct_declarator_function direct_declarator_function_start declarator_function direct_declarator_nofunction
183 declarator_nofunction
185 %destructor { FreeInitializer($$); } initializer initializer_condition
186 %destructor { FreeInitDeclarator($$); } init_declarator
187 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration
188 %destructor { FreeStatement($$); } statement labeled_statement compound_statement expression_statement
189 selection_statement iteration_statement jump_statement compound_inside
191 %destructor { FreeDeclaration($$); } declaration
193 %destructor { FreeInstance($$); } instantiation_named instantiation_unnamed
195 %destructor { FreeMemberInit($$); } data_member_initialization default_property
197 %destructor { FreeClassFunction($$); } class_function_definition class_function_definition_start
198 virtual_class_function_definition_start
199 constructor_function_definition_start destructor_function_definition_start
200 instance_class_function_definition instance_class_function_definition_start
201 %destructor { FreeClassDef($$); } struct_declaration
202 %destructor { delete $$; } string_literal attribute_word
203 %destructor { FreeProperty($$); } property
205 %destructor { FreeList($$, FreeExpression); } argument_expression_list expression
206 %destructor { FreeList($$, FreeEnumerator); } enumerator_list
207 %destructor { FreeList($$, FreeSpecifier); } type_qualifier_list specifier_qualifier_list declaration_specifiers
208 guess_declaration_specifiers guess_specifier_qualifier_list
209 %destructor { FreeList($$, FreeDeclarator); } struct_declarator_list
210 %destructor { FreeList($$, FreeDeclaration); } declaration_list
211 %destructor { FreeList($$, FreeInitializer); } initializer_list
212 %destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list
213 %destructor { FreeList($$, FreeTypeName); } parameter_list parameter_type_list identifier_list
214 %destructor { FreeList($$, FreeStatement); } statement_list
215 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list
216 %destructor { FreeList($$, FreeMemberInit); } default_property_list data_member_initialization_list data_member_initialization_list_coloned
217 %destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned
218 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
219 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_expression_argument
220 %destructor { FreeTemplateDataType($$); } template_datatype
221 %destructor { FreeAttrib($$); } attrib
222 %destructor { FreeExtDecl($$); } ext_decl
223 %destructor { FreeAttribute($$); } attribute
224 %destructor { FreeList($$, FreeAttribute); } attribs_list
234 DeclClass($1._class, $1.string);
235 fileInput.Seek(@1.start.pos, start);
236 resetScannerPos(&@1.start);
243 YY_STACK_PRINT (yyss, yyssp);
246 YY_STACK_PRINT (yyss, yyssp);
253 _DeclClass($1._class, $1.string);
257 fileInput.Seek(@1.start.pos, start);
258 resetScannerPos(&@1.start);
263 YY_STACK_PRINT (yyss, yyssp);
266 YY_STACK_PRINT (yyss, yyssp);
275 DeclClass($1._class, $1.string);
276 fileInput.Seek(@1.start.pos, start);
278 resetScannerPos(&@1.start);
284 YY_STACK_PRINT (yyss, yyssp);
287 YY_STACK_PRINT (yyss, yyssp);
293 _DeclClass($1._class, $1.string);
297 fileInput.Seek(@1.start.pos, start);
298 resetScannerPos(&@1.start);
303 YY_STACK_PRINT (yyss, yyssp);
306 YY_STACK_PRINT (yyss, yyssp);
313 strict_type { $$ = $1; }
314 | identifier identifier
317 DeclClass($1._class, $1.string);
318 fileInput.Seek(@1.start.pos, start);
319 resetScannerPos(&@1.start);
327 YY_STACK_PRINT (yyss, yyssp);
330 YY_STACK_PRINT (yyss, yyssp);
333 Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
334 Compiler_Error($"Not a type: %s\n", $1.string);
335 yylloc = tmpLoc; $2.badID = $1; // FreeIdentifier($1);
341 TYPE_NAME { $$ = MkSpecifierName(yytext); }
346 | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
347 | base_strict_type '<' template_arguments_list RIGHT_OP
350 SetClassTemplateArgs($$, $3);
354 fileInput.Seek(@4.end.pos, start);
355 resetScannerPos(&@4.end);
359 /* | identifier '<' template_arguments_list '>'
360 { $$ = MkSpecifierNameArgs($1.string, $3); $$.loc = @$; FreeIdentifier($1); } */
363 class_function_definition_start:
364 guess_declaration_specifiers declarator_function
365 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
366 | declarator_function
367 { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
370 constructor_function_definition_start:
371 guess_declaration_specifiers '(' ')'
372 { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($1, FreeSpecifier); }
375 destructor_function_definition_start:
376 '~' guess_declaration_specifiers '(' ')'
377 { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; FreeList /*FreeSpecifier*/($2, FreeSpecifier); }
380 virtual_class_function_definition_start:
381 VIRTUAL guess_declaration_specifiers declarator_function
382 { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
383 | VIRTUAL declarator_function
384 { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
389 { $$ = MkIdentifier(yytext); $$.loc = @1; }
393 simple_primary_expression
395 { $$ = MkExpBrackets($2); $$.loc = @$; }
398 simple_primary_expression:
400 { $$ = MkExpIdentifier($1); $$.loc = @$; }
401 | instantiation_unnamed
402 { $$ = MkExpInstance($1); $$.loc = @$; }
404 { $$ = MkExpConstant(yytext); $$.loc = @$; }
405 | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
407 { $$ = MkExpString($1); delete $1; $$.loc = @$; }
408 | '$' string_literal { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
409 | '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
411 { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
413 | NEWOP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
414 | NEWOP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,null), $4); $$.loc = @$; }
415 | NEW0OP guess_declaration_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,$3), $5); $$.loc = @$; }
416 | NEW0OP guess_declaration_specifiers '[' constant_expression ']' { $$ = MkExpNew0(MkTypeName($2,null), $4); $$.loc = @$; }
417 | RENEW constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,$4), $6); $$.loc = @$; }
418 | RENEW constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew($2, MkTypeName($3,null), $5); $$.loc = @$; }
419 | RENEW0 constant_expression renew_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,$4), $6); $$.loc = @$; }
420 | RENEW0 constant_expression renew_specifiers '[' constant_expression ']' { $$ = MkExpRenew0($2, MkTypeName($3,null), $5); $$.loc = @$; }
421 | error { $$ = MkExpDummy(); }
426 | postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
427 | postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
428 | postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
429 | postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
430 | postfix_expression identifier
432 char * constant = $1.type == constantExp ? $1.constant : null;
433 int len = constant ? strlen(constant) : 0;
434 if(constant && constant[len-1] == '.')
437 $$ = MkExpMember($1, $2);
443 | postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
444 | postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
445 | postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
448 anon_instantiation_expression:
449 instantiation_anon { $$ = MkExpInstance($1); $$.loc = @$; }
453 simple_postfix_expression:
454 simple_primary_expression
455 | simple_postfix_expression '[' expression ']' { $$ = MkExpIndex($1, $3); $$.loc = @$; }
456 | simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
457 | simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
458 | simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
459 | simple_postfix_expression identifier
461 char * constant = $1.type == constantExp ? $1.constant : null;
462 int len = constant ? strlen(constant) : 0;
463 if(constant && constant[len-1] == '.')
466 $$ = MkExpMember($1, $2);
472 | simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
473 | simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
474 | simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
477 argument_expression_list:
478 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
479 | anon_instantiation_expression { $$ = MkList(); ListAdd($$, $1); }
480 | argument_expression_list ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
481 | argument_expression_list ',' anon_instantiation_expression { $$ = $1; ListAdd($1, $3); }
484 common_unary_expression:
485 INC_OP unary_expression { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
486 | DEC_OP unary_expression { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
487 | unary_operator cast_expression { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
488 //| SIZEOF '(' unary_expression ')' { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
489 | SIZEOF unary_expression { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
490 | SIZEOF '(' guess_type_name ')' { $$ = MkExpTypeSize($3); $$.loc = @$; }
491 //| ALIGNOF '(' unary_expression ')' { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
492 | ALIGNOF unary_expression { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
493 | ALIGNOF '(' guess_type_name ')' { $$ = MkExpTypeAlign($3); $$.loc = @$; }
497 common_unary_expression
501 simple_unary_expression:
502 common_unary_expression
503 | simple_postfix_expression
513 | DELETE { $$ = DELETE; }
518 | '(' type_name ')' cast_expression { $$ = MkExpCast($2, $4); $$.loc = @$; }
521 multiplicative_expression:
523 | multiplicative_expression '*' cast_expression { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
524 | multiplicative_expression '/' cast_expression { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
525 | multiplicative_expression '%' cast_expression { $$ = MkExpOp($1, '%', $3); $$.loc = @$; }
529 multiplicative_expression
530 | additive_expression '+' multiplicative_expression { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
531 | additive_expression '-' multiplicative_expression { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
536 | shift_expression LEFT_OP additive_expression { $$ = MkExpOp($1, LEFT_OP, $3); $$.loc = @$; }
537 | shift_expression RIGHT_OP additive_expression { $$ = MkExpOp($1, RIGHT_OP, $3); $$.loc = @$; }
540 relational_expression_smaller_than:
541 relational_expression '<'
548 relational_expression:
550 | relational_expression_smaller_than /*relational_expression '<' */ shift_expression { skipErrors = false; $$ = MkExpOp($1, '<', $2/*$3*/); $$.loc = @$; }
551 | relational_expression '>' shift_expression { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
552 | relational_expression LE_OP shift_expression { $$ = MkExpOp($1, LE_OP, $3); $$.loc = @$; }
553 | relational_expression GE_OP shift_expression { $$ = MkExpOp($1, GE_OP, $3); $$.loc = @$; }
557 relational_expression
558 | equality_expression EQ_OP relational_expression { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
559 | equality_expression NE_OP relational_expression { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
564 | and_expression '&' equality_expression { $$ = MkExpOp($1, '&', $3); $$.loc = @$; }
567 exclusive_or_expression:
569 | exclusive_or_expression '^' and_expression { $$ = MkExpOp($1, '^', $3); $$.loc = @$; }
572 inclusive_or_expression:
573 exclusive_or_expression
574 | inclusive_or_expression '|' exclusive_or_expression { $$ = MkExpOp($1, '|', $3); $$.loc = @$; }
577 logical_and_expression:
578 inclusive_or_expression
579 | logical_and_expression AND_OP inclusive_or_expression { $$ = MkExpOp($1, AND_OP, $3); $$.loc = @$; }
582 logical_or_expression:
583 logical_and_expression
584 | logical_or_expression OR_OP logical_and_expression { $$ = MkExpOp($1, OR_OP, $3); $$.loc = @$; }
587 conditional_expression:
588 logical_or_expression
589 | logical_or_expression '?' expression ':' conditional_expression { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
592 assignment_expression:
593 conditional_expression
594 | unary_expression assignment_operator assignment_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
595 | unary_expression assignment_operator anon_instantiation_expression { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
600 | MUL_ASSIGN { $$ = MUL_ASSIGN; }
601 | DIV_ASSIGN { $$ = DIV_ASSIGN; }
602 | MOD_ASSIGN { $$ = MOD_ASSIGN; }
603 | ADD_ASSIGN { $$ = ADD_ASSIGN; }
604 | SUB_ASSIGN { $$ = SUB_ASSIGN; }
605 | LEFT_ASSIGN { $$ = LEFT_ASSIGN; }
606 | RIGHT_ASSIGN { $$ = RIGHT_ASSIGN; }
607 | AND_ASSIGN { $$ = AND_ASSIGN; }
608 | XOR_ASSIGN { $$ = XOR_ASSIGN; }
609 | OR_ASSIGN { $$ = OR_ASSIGN; }
613 assignment_expression { $$ = MkList(); ListAdd($$, $1); }
614 | expression ',' assignment_expression { $$ = $1; ListAdd($1, $3); }
618 conditional_expression
622 declaration_specifiers ';' { $$ = MkDeclaration($1, null); $$.loc = @$; }
623 | declaration_specifiers init_declarator_list ';' { $$ = MkDeclaration($1, $2); $$.loc = @$; }
624 | instantiation_named ';' { $$ = MkDeclarationInst($1); $$.loc = @$; }
625 | DEFINE identifier '=' constant_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
628 specifier_qualifier_list:
629 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
630 | specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
631 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
632 | specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
633 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
634 | specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
635 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
636 | specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
639 guess_specifier_qualifier_list:
640 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
641 | guess_specifier_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
642 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
643 | guess_specifier_qualifier_list type_specifier { $$ = $1; ListAdd($1, $2); }
644 | guess_type { $$ = MkList(); ListAdd($$, $1); }
645 | guess_specifier_qualifier_list guess_type { $$ = $1; ListAdd($1, $2); }
646 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
647 | guess_specifier_qualifier_list enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
648 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
649 | guess_specifier_qualifier_list struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
652 declaration_specifiers:
653 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
654 | declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
655 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
656 | declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
657 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
658 | declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
659 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
660 | declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
661 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
662 | declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
665 guess_declaration_specifiers:
666 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
667 | guess_declaration_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
668 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
669 | guess_declaration_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
670 | type_specifier { $$ = MkList(); ListAdd($$, $1); }
671 | guess_declaration_specifiers type_specifier { $$ = $1; ListAdd($1, $2); }
672 | guess_type { $$ = MkList(); ListAdd($$, $1); }
673 | guess_declaration_specifiers guess_type { $$ = $1; ListAdd($1, $2); }
674 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
675 | guess_declaration_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
676 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
677 | guess_declaration_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
680 real_guess_declaration_specifiers:
681 guess_declaration_specifiers { $$ = $1; }
682 | real_guess_type { $$ = MkList(); ListAdd($$, $1); }
686 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
687 | property_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
688 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
689 | property_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
690 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
691 | property_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
692 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
693 | property_specifiers identifier { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
694 | identifier '<' template_arguments_list '>'
696 _DeclClass($1._class, $1.string);
699 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
702 | property_specifiers identifier '<' template_arguments_list '>'
704 _DeclClass($2._class, $2.string);
705 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
711 storage_class_specifier { $$ = MkList(); ListAdd($$, $1); }
712 | renew_specifiers storage_class_specifier { $$ = $1; ListAdd($1, $2); }
713 | type_qualifier { $$ = MkList(); ListAdd($$, $1); }
714 | renew_specifiers type_qualifier { $$ = $1; ListAdd($1, $2); }
715 | strict_type_specifier { $$ = MkList(); ListAdd($$, $1); }
716 | renew_specifiers strict_type_specifier { $$ = $1; ListAdd($1, $2); }
717 | struct_or_union_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
718 | renew_specifiers struct_or_union_specifier_compound { $$ = $1; ListAdd($1, $2); }
719 | enum_specifier_compound { $$ = MkList(); ListAdd($$, $1); }
720 | renew_specifiers enum_specifier_compound { $$ = $1; ListAdd($1, $2); }
721 | identifier { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1); }
722 | renew_specifiers identifier { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
723 | identifier '<' template_arguments_list '>'
725 _DeclClass($1._class, $1.string);
728 ListAdd($$, MkSpecifierNameArgs($1.string, $3));
731 | renew_specifiers identifier '<' template_arguments_list '>'
733 _DeclClass($2._class, $2.string);
734 ListAdd($1, MkSpecifierNameArgs($2.string, $4));
739 init_declarator_list:
740 init_declarator { $$ = MkList(); ListAdd($$, $1); }
741 | init_declarator_list ',' init_declarator { $$ = $1; ListAdd($1, $3); }
745 declarator { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
746 | declarator '=' initializer { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
749 storage_class_specifier:
750 TYPEDEF { $$ = MkSpecifier(TYPEDEF); }
751 | EXTERN { $$ = MkSpecifier(EXTERN); }
752 | STATIC { $$ = MkSpecifier(STATIC); }
753 | AUTO { $$ = MkSpecifier(AUTO); }
754 | REGISTER { $$ = MkSpecifier(REGISTER); }
755 | THREAD { $$ = MkSpecifier(THREAD); }
759 EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
760 | EXT_STORAGE { $$ = MkExtDeclString(CopyString(yytext)); }
761 | attrib { $$ = MkExtDeclAttrib($1); }
765 ATTRIB { $<i>$ = ATTRIB; }
766 | ATTRIB_DEP { $<i>$ = ATTRIB_DEP; }
767 | __ATTRIB { $<i>$ = __ATTRIB; }
772 IDENTIFIER { $$ = CopyString(yytext); }
773 | TYPE_NAME { $$ = CopyString(yytext); }
774 | EXT_STORAGE { $$ = CopyString(yytext); }
775 | EXT_DECL { $$ = CopyString(yytext); }
776 | CONST { $$ = CopyString(yytext); }
780 attribute_word { $$ = MkAttribute($1, null); $$.loc = @$; }
781 | attribute_word '(' expression ')' { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
785 attribute { $$ = MkListOne($1); }
786 | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
787 | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
791 _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
792 | _attrib '(' '(' ')' ')' { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
796 ext_decl { $$ = MkSpecifierExtended($1); }
800 CONST { $$ = MkSpecifier(CONST); }
801 | VOLATILE { $$ = MkSpecifier(VOLATILE); }
802 | ext_storage { $$ = $1; }
807 VOID { $$ = MkSpecifier(VOID); }
808 | CHAR { $$ = MkSpecifier(CHAR); }
809 | SHORT { $$ = MkSpecifier(SHORT); }
810 | INT { $$ = MkSpecifier(INT); }
811 | UINT { $$ = MkSpecifier(UINT); }
812 | INT64 { $$ = MkSpecifier(INT64); }
813 | INT128 { $$ = MkSpecifier(INT128); }
814 | VALIST { $$ = MkSpecifier(VALIST); }
815 | LONG { $$ = MkSpecifier(LONG); }
816 | FLOAT { $$ = MkSpecifier(FLOAT); }
817 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
818 | SIGNED { $$ = MkSpecifier(SIGNED); }
819 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
820 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
821 | _BOOL { $$ = MkSpecifier(_BOOL); }
822 | BOOL { $$ = MkSpecifier(BOOL); }
823 | struct_or_union_specifier_nocompound
824 | enum_specifier_nocompound
826 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
827 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
828 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
829 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
830 | TYPED_OBJECT { $$ = MkSpecifier(TYPED_OBJECT); }
831 | ANY_OBJECT { $$ = MkSpecifier(ANY_OBJECT); }
834 strict_type_specifier:
835 VOID { $$ = MkSpecifier(VOID); }
836 | CHAR { $$ = MkSpecifier(CHAR); }
837 | SHORT { $$ = MkSpecifier(SHORT); }
838 | INT { $$ = MkSpecifier(INT); }
839 | UINT { $$ = MkSpecifier(UINT); }
840 | INT64 { $$ = MkSpecifier(INT64); }
841 | INT128 { $$ = MkSpecifier(INT128); }
842 | VALIST { $$ = MkSpecifier(VALIST); }
843 | LONG { $$ = MkSpecifier(LONG); }
844 | FLOAT { $$ = MkSpecifier(FLOAT); }
845 | DOUBLE { $$ = MkSpecifier(DOUBLE); }
846 | SIGNED { $$ = MkSpecifier(SIGNED); }
847 | UNSIGNED { $$ = MkSpecifier(UNSIGNED); }
848 | EXTENSION { $$ = MkSpecifier(EXTENSION); }
849 | _BOOL { $$ = MkSpecifier(_BOOL); }
850 | BOOL { $$ = MkSpecifier(BOOL); }
851 | struct_or_union_specifier_nocompound
852 | enum_specifier_nocompound
854 | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
855 | SUBCLASS '(' type ')' { $$ = MkSpecifierSubClass($3); }
856 | SUBCLASS '(' identifier ')' { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
857 | THISCLASS { $$ = MkSpecifier(THISCLASS); }
861 struct_or_union_specifier_compound:
862 struct_or_union identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $2, $4); if(declMode) DeclClass($2._class, $2.string); }
863 | struct_or_union '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $3); }
864 | struct_or_union identifier '{' '}' { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
865 | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); }
866 | struct_or_union base_strict_type '{' struct_declaration_list '}'
867 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
869 | struct_or_union ext_decl identifier '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, $3, $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
870 | struct_or_union ext_decl '{' struct_declaration_list '}' { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; }
871 | struct_or_union ext_decl identifier '{' '}' { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2; if(declMode) DeclClass($3._class, $3.string); }
872 | struct_or_union ext_decl '{' '}' { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; }
873 | struct_or_union ext_decl strict_type '{' struct_declaration_list '}'
874 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), $5); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
877 struct_or_union_specifier_nocompound:
878 struct_or_union identifier { $$ = MkStructOrUnion($1, $2, null); if(declMode) DeclClass($2._class, $2.string); }
879 | struct_or_union strict_type
880 { $$ = MkStructOrUnion($1, MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
882 | struct_or_union ext_decl identifier
883 { $$ = MkStructOrUnion($1, $3, null); $$.extDeclStruct = $2;if(declMode) DeclClass($3._class, $3.string); }
884 | struct_or_union ext_decl strict_type
885 { $$ = MkStructOrUnion($1, MkIdentifier($3.name), null); $$.extDeclStruct = $2; if(declMode) DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); }
889 guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
890 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
891 /*| identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }*/
894 template_type_argument:
895 guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
896 | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
897 //template_datatype { $$ = MkTemplateTypeArgument($1); }
901 template_identifier_argument:
902 identifier { $$ = MkTemplateIdentifierArgument($1); }
906 template_expression_argument:
907 shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
911 template_expression_argument
912 /*| template_identifier_argument*/
913 | template_type_argument
914 | identifier '=' template_expression_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
915 /*| identifier '=' template_identifier_argument { $$ = $3; $$.name = $1; $$.loc = @$; }*/
916 | identifier '=' template_type_argument { $$ = $3; $$.name = $1; $$.loc = @$; }
917 | template_datatype '=' template_expression_argument
920 if($1.specifiers && $1.specifiers->first)
922 Specifier spec = $1.specifiers->first;
923 if(spec.type == nameSpecifier)
924 $$.name = MkIdentifier(spec.name);
926 FreeTemplateDataType($1);
929 /*| template_datatype '=' template_identifier_argument
932 if($1.specifiers && $1.specifiers->first)
934 Specifier spec = $1.specifiers->first;
935 if(spec.type == nameSpecifier)
936 $$.name = MkIdentifier(spec.name);
938 FreeTemplateDataType($1);
941 | template_datatype '=' template_type_argument
944 if($1.specifiers && $1.specifiers->first)
946 Specifier spec = $1.specifiers->first;
947 if(spec.type == nameSpecifier)
948 $$.name = MkIdentifier(spec.name);
950 FreeTemplateDataType($1);
955 template_arguments_list:
956 template_argument { $$ = MkList(); ListAdd($$, $1); }
957 | template_arguments_list ',' template_argument { ListAdd($1, $3); }
961 STRUCT { $$ = structSpecifier; }
962 | UNION { $$ = unionSpecifier; }
965 struct_declaration_list:
966 struct_declaration { $$ = MkList(); ListAdd($$, $1); }
967 | struct_declaration_list struct_declaration { $$ = $1; ListAdd($1, $2); }
971 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; }
974 default_property_list:
975 default_property { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
976 | default_property_list ',' default_property { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
980 PROPERTY property_specifiers identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
981 { $$ = MkProperty($2, null, $3, $6, $8); $$.loc = @$; }
982 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
983 { $$ = MkProperty($2, null, $3, $8, $6); $$.loc = @$; }
984 | PROPERTY property_specifiers identifier '{' SETPROP compound_statement '}'
985 { $$ = MkProperty($2, null, $3, $6, null); $$.loc = @$; }
986 | PROPERTY property_specifiers identifier '{' GETPROP compound_statement '}'
987 { $$ = MkProperty($2, null, $3, null, $6); $$.loc = @$; }
988 | PROPERTY property_specifiers identifier '{' '}'
989 { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
991 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement GETPROP compound_statement '}'
992 { $$ = MkProperty($2, $3, $4, $7, $9); $$.loc = @$; }
993 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement SETPROP compound_statement '}'
994 { $$ = MkProperty($2, $3, $4, $9, $7); $$.loc = @$; }
995 | PROPERTY property_specifiers abstract_declarator identifier '{' SETPROP compound_statement '}'
996 { $$ = MkProperty($2, $3, $4, $7, null); $$.loc = @$; }
997 | PROPERTY property_specifiers abstract_declarator identifier '{' GETPROP compound_statement '}'
998 { $$ = MkProperty($2, $3, $4, null, $7); $$.loc = @$; }
999 | PROPERTY property_specifiers abstract_declarator identifier '{' '}'
1000 { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
1002 | PROPERTY property_specifiers '{' SETPROP compound_statement GETPROP compound_statement '}'
1003 { $$ = MkProperty($2, null, null, $5, $7); $$.loc = @$; }
1004 | PROPERTY property_specifiers '{' GETPROP compound_statement SETPROP compound_statement '}'
1005 { $$ = MkProperty($2, null, null, $7, $5); $$.loc = @$; }
1006 | PROPERTY property_specifiers '{' SETPROP compound_statement '}'
1007 { $$ = MkProperty($2, null, null, $5, null); $$.loc = @$; }
1008 | PROPERTY property_specifiers '{' GETPROP compound_statement '}'
1009 { $$ = MkProperty($2, null, null, null, $5); $$.loc = @$; }
1010 | PROPERTY property_specifiers '{' '}'
1011 { $$ = MkProperty($2, null, null, null, null); $$.loc = @$; }
1013 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement GETPROP compound_statement '}'
1014 { $$ = MkProperty($2, $3, null, $6, $8); $$.loc = @$; }
1015 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement SETPROP compound_statement '}'
1016 { $$ = MkProperty($2, $3, null, $8, $6); $$.loc = @$; }
1017 | PROPERTY property_specifiers abstract_declarator '{' SETPROP compound_statement '}'
1018 { $$ = MkProperty($2, $3, null, $6, null); $$.loc = @$; }
1019 | PROPERTY property_specifiers abstract_declarator '{' GETPROP compound_statement '}'
1020 { $$ = MkProperty($2, $3, null, null, $6); $$.loc = @$; }
1021 | PROPERTY property_specifiers abstract_declarator '{' '}'
1022 { $$ = MkProperty($2, $3, null, null, null); $$.loc = @$; }
1026 guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; }
1027 | guess_declaration_specifiers ';' { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; }
1028 | instantiation_unnamed ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1029 | guess_instantiation_named ';' { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; }
1030 | class_function_definition { $$ = MkClassDefFunction($1); $$.loc = @$; }
1031 | default_property_list ';' { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
1032 | property { $$ = MkClassDefProperty($1); $$.loc = @$; }
1033 | ';' { $$ = null; }
1036 struct_declarator_list:
1038 { $$ = MkList(); ListAdd($$, $1); }
1039 | struct_declarator_list ',' struct_declarator
1040 { $$ = $1; ListAdd($1, $3); }
1044 declarator_nofunction
1045 { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
1046 | declarator_nofunction attrib
1047 { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
1048 | ':' constant_expression
1049 { $$ = MkStructDeclarator(null, $2); $$.loc = @$; }
1050 | declarator_nofunction ':' constant_expression
1051 { $$ = MkStructDeclarator($1, $3); $$.loc = @$; }
1052 | declarator_nofunction ':' constant_expression ':' constant_expression
1053 { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
1056 enum_specifier_nocompound:
1057 ENUM identifier { $$ = MkEnum($2, null); if(declMode) DeclClass($2._class, $2.string); }
1058 | ENUM strict_type { $$ = MkEnum(MkIdentifier($2.name), null); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1061 enum_specifier_compound:
1062 ENUM '{' enumerator_list '}'
1063 { $$ = MkEnum(null, $3); }
1064 | ENUM identifier '{' enumerator_list '}' { $$ = MkEnum($2, $4); if(declMode) DeclClass($2._class, $2.string); }
1065 | ENUM identifier '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum($2, $4); $$.definitions = $6; if(declMode) DeclClass($2._class, $2.string); }
1066 | ENUM strict_type '{' enumerator_list ';' struct_declaration_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); $$.definitions = $6; if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1067 | ENUM strict_type '{' enumerator_list '}' { $$ = MkEnum(MkIdentifier($2.name), $4); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
1072 { $$ = MkList(); ListAdd($$, $1); }
1073 | enumerator_list ',' enumerator
1074 { $$ = $1; ListAdd($1, $3); }
1079 { $$ = MkEnumerator($1, null); }
1080 | identifier '=' constant_expression
1081 { $$ = MkEnumerator($1, $3); }
1085 direct_abstract_declarator:
1086 '(' abstract_declarator ')'
1087 { $$ = MkDeclaratorBrackets($2); }
1089 { $$ = MkDeclaratorArray(null, null); }
1090 | '[' constant_expression ']'
1091 { $$ = MkDeclaratorArray(null, $2); }
1093 { $$ = MkDeclaratorEnumArray(null, $2); }
1094 | direct_abstract_declarator '[' ']'
1095 { $$ = MkDeclaratorArray($1, null); }
1096 | direct_abstract_declarator '[' constant_expression ']'
1097 { $$ = MkDeclaratorArray($1, $3); }
1098 | direct_abstract_declarator '[' type']'
1099 { $$ = MkDeclaratorEnumArray($1, $3); }
1101 { $$ = MkDeclaratorFunction(null, null); }
1102 | '(' parameter_type_list ')'
1103 { $$ = MkDeclaratorFunction(null, $2); }
1104 | direct_abstract_declarator '(' ')'
1105 { $$ = MkDeclaratorFunction($1, null); }
1106 | direct_abstract_declarator '(' parameter_type_list ')'
1107 { $$ = MkDeclaratorFunction($1, $3); }
1110 direct_abstract_declarator_noarray:
1111 '(' abstract_declarator_noarray ')'
1112 { $$ = MkDeclaratorBrackets($2); }
1114 { $$ = MkDeclaratorFunction(null, null); }
1115 | '(' parameter_type_list ')'
1116 { $$ = MkDeclaratorFunction(null, $2); }
1117 | direct_abstract_declarator_noarray '(' ')'
1118 { $$ = MkDeclaratorFunction($1, null); }
1119 | direct_abstract_declarator_noarray '(' parameter_type_list ')'
1120 { $$ = MkDeclaratorFunction($1, $3); }
1123 abstract_declarator:
1124 pointer { $$ = MkDeclaratorPointer($1, null); }
1125 | direct_abstract_declarator
1126 | pointer direct_abstract_declarator { $$ = MkDeclaratorPointer($1, $2); }
1127 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1128 | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
1129 | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1132 abstract_declarator_noarray:
1133 pointer { $$ = MkDeclaratorPointer($1, null); }
1134 | direct_abstract_declarator_noarray
1135 | pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorPointer($1, $2); }
1136 | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1137 | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
1138 | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1142 abstract_declarator:
1144 { $$ = MkDeclaratorPointer($1, null); }
1145 | direct_abstract_declarator
1146 | pointer direct_abstract_declarator
1147 { $$ = MkDeclaratorPointer($1, $2); }
1150 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
1151 | ext_decl direct_abstract_declarator
1152 { $$ = MkDeclaratorExtended($1, $2); }
1153 | ext_decl pointer direct_abstract_declarator
1154 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1158 direct_abstract_declarator:
1159 '(' abstract_declarator ')'
1160 { $$ = MkDeclaratorBrackets($2); }
1162 { $$ = MkDeclaratorArray(null, null); }
1163 | '[' constant_expression ']'
1164 { $$ = MkDeclaratorArray(null, $2); }
1166 { $$ = MkDeclaratorEnumArray(null, $2); }
1167 | direct_abstract_declarator '[' ']'
1168 { $$ = MkDeclaratorArray($1, null); }
1169 | direct_abstract_declarator '[' constant_expression ']'
1170 { $$ = MkDeclaratorArray($1, $3); }
1171 | direct_abstract_declarator '[' type ']'
1172 { $$ = MkDeclaratorEnumArray($1, $3); }
1174 { $$ = MkDeclaratorFunction(null, null); }
1175 | '(' parameter_type_list ')'
1176 { $$ = MkDeclaratorFunction(null, $2); }
1177 | direct_abstract_declarator '(' ')'
1178 { $$ = MkDeclaratorFunction($1, null); }
1179 | direct_abstract_declarator '(' parameter_type_list ')'
1180 { $$ = MkDeclaratorFunction($1, $3); }
1185 | pointer direct_declarator
1186 { $$ = MkDeclaratorPointer($1, $2); }
1187 | ext_decl pointer direct_declarator
1188 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1189 | declarator ext_decl
1190 { $$ = MkDeclaratorExtendedEnd($2, $1); }
1193 direct_declarator_nofunction:
1195 { $$ = MkDeclaratorIdentifier($1); }
1196 | '(' declarator ')'
1197 { $$ = MkDeclaratorBrackets($2); }
1198 | direct_declarator_nofunction '[' constant_expression ']'
1199 { $$ = MkDeclaratorArray($1, $3); }
1200 | direct_declarator_nofunction '[' ']'
1201 { $$ = MkDeclaratorArray($1, null); }
1202 | direct_declarator_nofunction '[' type ']'
1203 { $$ = MkDeclaratorEnumArray($1, $3); }
1206 declarator_function:
1207 direct_declarator_function
1208 | pointer direct_declarator_function
1209 { $$ = MkDeclaratorPointer($1, $2); }
1211 | ext_decl direct_declarator_function
1212 { $$ = MkDeclaratorExtended($1, $2); }
1213 | ext_decl pointer direct_declarator_function
1214 { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1215 | pointer ext_decl direct_declarator_function
1216 { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1220 direct_declarator_function_start:
1221 direct_declarator_nofunction '('
1224 direct_declarator_function:
1225 direct_declarator_function_start parameter_type_list ')'
1226 { $$ = MkDeclaratorFunction($1, $2); }
1227 | direct_declarator_function_start identifier_list ')'
1228 { $$ = MkDeclaratorFunction($1, $2); }
1229 | direct_declarator_function_start ')'
1230 { $$ = MkDeclaratorFunction($1, null); }
1234 direct_declarator_function
1235 | direct_declarator_nofunction
1236 | ext_decl direct_declarator_function
1237 { $$ = MkDeclaratorExtended($1, $2); }
1238 | ext_decl direct_declarator_nofunction
1239 { $$ = MkDeclaratorExtended($1, $2); }
1242 declarator_nofunction:
1243 direct_declarator_nofunction
1244 | pointer direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, $2); }
1245 | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
1246 | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
1247 | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
1250 type_qualifier_list:
1251 type_qualifier { $$ = MkList(); ListAdd($$, $1); }
1252 | type_qualifier_list type_qualifier { $$ = $1; ListAdd($1, $2); }
1256 '*' { $$ = MkPointer(null, null); }
1257 | '*' type_qualifier_list { $$ = MkPointer($2, null); }
1258 | '*' pointer { $$ = MkPointer(null, $2); }
1259 | '*' type_qualifier_list pointer { $$ = MkPointer($2, $3); }
1262 parameter_type_list:
1264 | parameter_list ',' ELLIPSIS { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
1268 parameter_declaration { $$ = MkList(); ListAdd($$, $1); }
1269 | parameter_list ',' parameter_declaration { $$ = $1; ListAdd($1, $3); }
1272 parameter_declaration:
1273 guess_declaration_specifiers declarator { $$ = MkTypeName($1, $2); }
1274 | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
1275 | guess_declaration_specifiers '&' { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
1276 | guess_declaration_specifiers '&' declarator { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
1277 | real_guess_declaration_specifiers { $$ = MkTypeName($1, null); }
1280 { $$ = MkTypeName(MkList(), null); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1282 { $$ = MkTypeName(null, null); $$.typedObject = true; $$.byReference = true; }
1284 { $$ = MkTypeName(MkList(), $2); $$.typedObject = true; } // Confusion with ellipsis? MkList()?
1285 | CLASS '&' declarator
1286 { $$ = MkTypeName(null, $3); $$.typedObject = true; $$.byReference = true; }
1289 { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
1292 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
1294 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
1295 | TYPED_OBJECT declarator
1296 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2); }
1297 | TYPED_OBJECT '&' declarator
1298 { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
1300 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
1301 | ANY_OBJECT declarator
1302 { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), $2); }
1305 { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), null); }
1306 | error declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1307 //| error struct_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1308 | error abstract_declarator { $$ = MkTypeName(MkListOne(MkSpecifier(INT)), $2); }
1313 identifier { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
1314 | identifier_list ',' identifier { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
1318 specifier_qualifier_list { $$ = MkTypeName($1, null); }
1319 | specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1323 guess_specifier_qualifier_list { $$ = MkTypeName($1, null); }
1324 | guess_specifier_qualifier_list abstract_declarator { $$ = MkTypeName($1, $2); }
1328 assignment_expression
1329 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1330 | '{' initializer_list '}'
1331 { $$ = MkInitializerList($2); $$.loc = @$; }
1332 | '{' initializer_list ',' '}'
1334 $$ = MkInitializerList($2);
1338 Expression exp = MkExpDummy();
1339 Initializer init = MkInitializerAssignment(exp);
1347 initializer_condition:
1348 conditional_expression
1349 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1350 | anon_instantiation_expression
1351 { $$ = MkInitializerAssignment($1); $$.loc = @$; }
1353 | '{' initializer_list '}'
1354 { $$ = MkInitializerList($2); $$.loc = @$; }
1355 | '{' initializer_list ',' '}'
1357 $$ = MkInitializerList($2);
1361 Expression exp = MkExpDummy();
1362 Initializer init = MkInitializerAssignment(exp);
1373 { $$ = MkList(); ListAdd($$, $1); }
1374 | initializer_list ',' initializer
1375 { $$ = $1; ListAdd($1, $3); }
1380 | compound_statement
1381 | expression_statement
1382 | selection_statement
1383 | iteration_statement
1388 identifier ':' statement
1389 { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
1390 | CASE constant_expression ':' statement
1391 { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
1392 | DEFAULT ':' statement
1393 { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
1397 declaration { $$ = MkList(); ListAdd($$, $1); }
1398 | declaration_list declaration { $$ = $1; ListAdd($1, $2); }
1402 statement { $$ = MkList(); ListAdd($$, $1); }
1403 | statement_list statement { $$ = $1; ListAdd($1, $2); }
1405 // declaration not allowed after statements
1406 | statement_list declaration { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; /*yyerror(); */ ListAdd($1, stmt); $$ = $1; }
1410 statement_list { $$ = MkCompoundStmt(null, $1); }
1411 | declaration_list { $$ = MkCompoundStmt($1, null); }
1412 | declaration_list statement_list { $$ = MkCompoundStmt($1, $2); }
1416 '{' { $<context>$ = PushContext(); }
1422 $$ = MkCompoundStmt(null, null);
1423 $$.compound.context = PushContext();
1424 PopContext($$.compound.context);
1428 | compound_start compound_inside '}'
1429 { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; }
1432 expression_statement:
1433 ';' { $$ = MkExpressionStmt(null); $$.loc = @$; }
1434 | expression ';' { $$ = MkExpressionStmt($1); $$.loc = @$; }
1437 selection_statement:
1438 IF '(' expression ')' statement %prec IFX { $$ = MkIfStmt($3, $5, null); $$.loc = @$; }
1439 | IF '(' expression ')' statement ELSE statement { $$ = MkIfStmt($3, $5, $7); $$.loc = @$; }
1440 | SWITCH '(' expression ')' statement { $$ = MkSwitchStmt($3, $5); $$.loc = @$; }
1443 iteration_statement:
1444 WHILE '(' expression ')' statement { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
1445 | DO statement WHILE '(' expression ')' ';' { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
1446 | FOR '(' expression_statement expression_statement ')' statement { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
1447 | FOR '(' expression_statement expression_statement expression ')' statement { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
1449 | WHILE '(' ')' statement { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
1450 | FOR '(' expression_statement ')' statement { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
1451 | FOR '(' ')' statement { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
1455 GOTO identifier ';' { $$ = MkGotoStmt($2); $$.loc = @$; }
1456 | CONTINUE ';' { $$ = MkContinueStmt(); $$.loc = @$; }
1457 | BREAK ';' { $$ = MkBreakStmt(); $$.loc = @$; }
1458 | RETURN ';' { Expression exp = MkExpDummy(); $$ = MkReturnStmt(MkListOne(exp)); $$.loc = @$; exp.loc = @2; }
1459 | RETURN expression ';' { $$ = MkReturnStmt($2); $$.loc = @$; }
1463 STRING_LITERAL { $$ = CopyString(yytext); }
1466 instantiation_named:
1467 declaration_specifiers identifier '{' members_initialization_list '}'
1468 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1469 | declaration_specifiers identifier '{' '}'
1470 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1473 guess_instantiation_named:
1474 guess_declaration_specifiers identifier '{' members_initialization_list '}'
1475 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;}
1476 | guess_declaration_specifiers identifier '{' '}'
1477 { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), MkList()); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.start;}
1479 /*| guess_declaration_specifiers identifier '{' members_initialization_list error
1482 $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @5.start;
1488 else if(yychar == '{')
1500 instantiation_unnamed:
1501 type '{' members_initialization_list '}'
1502 { $$ = MkInstantiation($1, null, $3); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
1504 { $$ = MkInstantiation($1, null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
1505 | identifier '{' members_initialization_list '}'
1506 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);$$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
1507 | identifier '{' '}'
1508 { Location tmpLoc = yylloc; yylloc = @1; yylloc = tmpLoc; $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList()); $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1); }
1512 '{' members_initialization_list '}'
1513 { $$ = MkInstantiation(null, null, $2); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
1515 { $$ = MkInstantiation(null, null, MkList()); $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
1517 class_function_definition:
1518 class_function_definition_start compound_statement
1519 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1520 | virtual_class_function_definition_start compound_statement
1521 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1522 | virtual_class_function_definition_start ';'
1523 { ProcessClassFunctionBody($1, null); $$.loc = @$; }
1524 | constructor_function_definition_start compound_statement
1525 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1526 | destructor_function_definition_start compound_statement
1527 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1530 instance_class_function_definition_start:
1531 // Guess here conflicts with an expression...
1532 declaration_specifiers declarator_function
1533 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1534 | declaration_specifiers declarator_nofunction
1535 { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
1538 instance_class_function_definition:
1539 instance_class_function_definition_start compound_statement
1540 { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
1543 data_member_initialization:
1544 postfix_expression '=' initializer_condition { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
1545 | initializer_condition { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
1548 data_member_initialization_list:
1549 data_member_initialization
1550 { $$ = MkList(); ListAdd($$, $1); }
1551 | data_member_initialization_list ',' data_member_initialization
1552 { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
1555 data_member_initialization_list_coloned:
1556 data_member_initialization_list ';'
1557 { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
1560 members_initialization_list_coloned:
1561 data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1562 | instance_class_function_definition { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
1563 | members_initialization_list_coloned data_member_initialization_list_coloned { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
1564 | members_initialization_list_coloned instance_class_function_definition { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2;$$ = $1; }
1565 | ';' { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
1566 | members_initialization_list_coloned ';' { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2; $$ = $1; }
1569 members_initialization_list:
1570 members_initialization_list_coloned
1571 | data_member_initialization_list { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
1572 | members_initialization_list_coloned data_member_initialization_list { ListAdd($1, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
1576 parameter_declaration { parsedType = $1; }
1577 | parameter_declaration ':' constant_expression { parsedType = $1; parsedType.bitCount = $3; }