Changes in src/Parser/parser.yy [1b29996:9059213]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r1b29996 r9059213 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 26 17:35:53 201613 // Update Count : 20 6612 // Last Modified On : Wed Oct 19 22:19:33 2016 13 // Update Count : 2003 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 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 96 %token<tok> INTEGERconstant FLOATINGconstant CHARACTERconstant STRINGliteral 101 97 %token<tok> ZERO ONE // CFA 102 98 … … 316 312 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 317 313 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 318 | REALDECIMALconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }319 | REALFRACTIONconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }320 314 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 321 315 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1 ) ); } … … 364 358 | zero_one 365 359 { $$ = new ExpressionNode( build_varref( $1 ) ); } 366 | tuple367 360 | '(' comma_expression ')' 368 361 { $$ = $2; } … … 381 374 | postfix_expression '(' argument_expression_list ')' 382 375 { $$ = 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; 383 378 | postfix_expression '.' no_attr_identifier 384 379 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 385 380 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 386 | postfix_expression REALFRACTIONconstant // CFA, tuple index381 | postfix_expression '.' INTEGERconstant 387 382 | postfix_expression ARROW no_attr_identifier 388 383 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 421 416 field: // CFA, tuple field selector 422 417 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; 423 420 { $$ = new ExpressionNode( build_varref( $1 ) ); } 424 | REALDECIMALconstant field425 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); }426 | REALDECIMALconstant '[' push field_list pop ']'427 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); }428 421 | field_name '.' field 429 422 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); } … … 437 430 438 431 field_name: 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 432 no_attr_identifier 433 // x.1, x.[0, 0.0] 434 | INTEGERconstant 450 435 ; 451 436 … … 520 505 | '(' type_name_no_function ')' cast_expression 521 506 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 522 //| '(' type_name_no_function ')' tuple523 //{ $$ = new ExpressionNode( build_cast( $2, $4 ) ); }507 | '(' type_name_no_function ')' tuple 508 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 524 509 ; 525 510 … … 607 592 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 608 593 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 609 //| logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression610 //{ $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }594 | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 595 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 611 596 ; 612 597 … … 620 605 | unary_expression assignment_operator assignment_expression 621 606 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 622 //| tuple assignment_opt // CFA, tuple expression623 //{ $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }607 | tuple assignment_opt // CFA, tuple expression 608 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); } 624 609 ; 625 610 … … 648 633 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with 649 634 // comma_expression in new_identifier_parameter_array and new_abstract_array 650 //'[' ']'651 //{ $$ = new ExpressionNode( build_tuple() ); }652 //'[' push assignment_expression pop ']'653 //{ $$ = new ExpressionNode( build_tuple( $3 ) ); }654 '[' push ',' tuple_expression_list pop ']'635 '[' ']' 636 { $$ = new ExpressionNode( build_tuple() ); } 637 | '[' push assignment_expression pop ']' 638 { $$ = new ExpressionNode( build_tuple( $3 ) ); } 639 | '[' push ',' tuple_expression_list pop ']' 655 640 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 656 641 | '[' push assignment_expression ',' tuple_expression_list pop ']' … … 1151 1136 1152 1137 new_function_specifier: // CFA 1153 //'[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict1154 //{1155 //$$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );1156 //}1138 '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict 1139 { 1140 $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1141 } 1157 1142 // '[' ']' identifier '(' push new_parameter_type_list_opt pop ')' 1158 1143 // { … … 1173 1158 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1174 1159 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1175 new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'1160 | new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' 1176 1161 // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator). 1177 1162 { … … 2837 2822 2838 2823 new_abstract_function: // CFA 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 ')'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 ')' 2842 2827 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 2843 2828 | new_function_return '(' push new_parameter_type_list_opt pop ')'
Note:
See TracChangeset
for help on using the changeset viewer.