Changeset 25f49f4 for src/Parser/parser.yy
- Timestamp:
- Oct 27, 2016, 9:37:58 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- d93d980
- Parents:
- efe4d730 (diff), 6d7c3df (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
refe4d730 r25f49f4 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Oct 19 22:19:33 201613 // Update Count : 20 0312 // Last Modified On : Wed Oct 26 17:35:53 2016 13 // Update Count : 2066 14 14 // 15 15 … … 94 94 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 95 95 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname 96 %token<tok> INTEGERconstant FLOATINGconstant CHARACTERconstant STRINGliteral 96 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 97 // Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and 98 // overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically 99 // converted into the tuple index (.)(1). e.g., 3.x 100 %token<tok> REALDECIMALconstant REALFRACTIONconstant FLOATINGconstant 97 101 %token<tok> ZERO ONE // CFA 98 102 … … 312 316 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 313 317 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 318 | REALDECIMALconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 319 | REALFRACTIONconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 314 320 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 315 321 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1 ) ); } … … 358 364 | zero_one 359 365 { $$ = new ExpressionNode( build_varref( $1 ) ); } 366 | tuple 360 367 | '(' comma_expression ')' 361 368 { $$ = $2; } … … 374 381 | postfix_expression '(' argument_expression_list ')' 375 382 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 376 // ambiguity with .0 so space required after field-selection, e.g.377 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;378 383 | postfix_expression '.' no_attr_identifier 379 384 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 380 385 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 381 | postfix_expression '.' INTEGERconstant386 | postfix_expression REALFRACTIONconstant // CFA, tuple index 382 387 | postfix_expression ARROW no_attr_identifier 383 388 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 416 421 field: // CFA, tuple field selector 417 422 field_name 418 // ambiguity with .0 so space required after field-selection, e.g.419 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;420 423 { $$ = new ExpressionNode( build_varref( $1 ) ); } 424 | REALDECIMALconstant field 425 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); } 426 | REALDECIMALconstant '[' push field_list pop ']' 427 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); } 421 428 | field_name '.' field 422 429 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); } … … 430 437 431 438 field_name: 432 no_attr_identifier 433 // x.1, x.[0, 0.0] 434 | INTEGERconstant 439 INTEGERconstant fraction_constants 440 { $$ = $1; } 441 | FLOATINGconstant fraction_constants 442 { $$ = $1; } 443 | no_attr_identifier fraction_constants 444 { $$ = $1; } 445 ; 446 447 fraction_constants: 448 // empty 449 | fraction_constants REALFRACTIONconstant 435 450 ; 436 451 … … 505 520 | '(' type_name_no_function ')' cast_expression 506 521 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 507 | '(' type_name_no_function ')' tuple508 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }522 // | '(' type_name_no_function ')' tuple 523 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 509 524 ; 510 525 … … 592 607 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 593 608 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 594 | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression595 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }609 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 610 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 596 611 ; 597 612 … … 605 620 | unary_expression assignment_operator assignment_expression 606 621 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 607 | tuple assignment_opt // CFA, tuple expression608 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }622 // | tuple assignment_opt // CFA, tuple expression 623 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); } 609 624 ; 610 625 … … 633 648 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with 634 649 // comma_expression in new_identifier_parameter_array and new_abstract_array 635 '[' ']'636 { $$ = new ExpressionNode( build_tuple() ); }637 |'[' push assignment_expression pop ']'638 { $$ = new ExpressionNode( build_tuple( $3 ) ); }639 |'[' push ',' tuple_expression_list pop ']'650 // '[' ']' 651 // { $$ = new ExpressionNode( build_tuple() ); } 652 // '[' push assignment_expression pop ']' 653 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 654 '[' push ',' tuple_expression_list pop ']' 640 655 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 641 656 | '[' push assignment_expression ',' tuple_expression_list pop ']' … … 1136 1151 1137 1152 new_function_specifier: // CFA 1138 '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict1139 {1140 $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );1141 }1153 // '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict 1154 // { 1155 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1156 // } 1142 1157 // '[' ']' identifier '(' push new_parameter_type_list_opt pop ')' 1143 1158 // { … … 1158 1173 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1159 1174 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1160 |new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'1175 new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' 1161 1176 // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator). 1162 1177 { … … 2822 2837 2823 2838 new_abstract_function: // CFA 2824 '[' ']' '(' new_parameter_type_list_opt ')'2825 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }2826 |new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'2839 // '[' ']' '(' new_parameter_type_list_opt ')' 2840 // { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); } 2841 new_abstract_tuple '(' push new_parameter_type_list_opt pop ')' 2827 2842 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 2828 2843 | new_function_return '(' push new_parameter_type_list_opt pop ')'
Note:
See TracChangeset
for help on using the changeset viewer.