Changeset f51aefb for src/Parser/parser.yy
- Timestamp:
- Nov 1, 2016, 3:18:59 PM (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:
- 84118d8
- Parents:
- 40744af8 (diff), 0afffee (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
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r40744af8 rf51aefb 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 24 12:16:53 201613 // Update Count : 199212 // 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 … … 196 200 %type<decl> field_declaration field_declaration_list field_declarator field_declaring_list 197 201 %type<en> field field_list 202 %type<tok> field_name 198 203 199 204 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 277 282 // 278 283 // Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those 279 // introduced through "forall" qualifiers), and by introducing "type generators" -- paramet rized types. This latter284 // introduced through "forall" qualifiers), and by introducing "type generators" -- parameterized types. This latter 280 285 // type name creates a third class of identifiers that must be distinguished by the scanner. 281 286 // 282 287 // Since the scanner cannot distinguish among the different classes of identifiers without some context information, it 283 // accesses a data structure ( the TypedefTable) to allow classification of an identifier that it has just read.284 // Semanticactions during the parser update this data structure when the class of identifiers change.288 // accesses a data structure (TypedefTable) to allow classification of an identifier that it has just read. Semantic 289 // actions during the parser update this data structure when the class of identifiers change. 285 290 // 286 291 // Because the Cforall language is block-scoped, there is the possibility that an identifier can change its class in a … … 288 293 // particular declaration, each declaration is itself a scope. This requires distinguishing between type names that are 289 294 // local to the current declaration scope and those that persist past the end of the declaration (i.e., names defined in 290 // "typedef" or " type" declarations).295 // "typedef" or "otype" declarations). 291 296 // 292 297 // The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and closing of … … 311 316 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 312 317 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 318 | REALDECIMALconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 319 | REALFRACTIONconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 313 320 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 314 321 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1 ) ); } … … 357 364 | zero_one 358 365 { $$ = new ExpressionNode( build_varref( $1 ) ); } 366 | tuple 359 367 | '(' comma_expression ')' 360 368 { $$ = $2; } … … 373 381 | postfix_expression '(' argument_expression_list ')' 374 382 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 375 // ambiguity with .0 so space required after field-selection, e.g.376 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;377 383 | postfix_expression '.' no_attr_identifier 378 384 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 379 385 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 386 | postfix_expression REALFRACTIONconstant // CFA, tuple index 380 387 | postfix_expression ARROW no_attr_identifier 381 388 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 413 420 414 421 field: // CFA, tuple field selector 415 no_attr_identifier422 field_name 416 423 { $$ = new ExpressionNode( build_varref( $1 ) ); } 417 // ambiguity with .0 so space required after field-selection, e.g. 418 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 419 | no_attr_identifier '.' field 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 ) ) ); } 428 | field_name '.' field 420 429 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); } 421 | no_attr_identifier'.' '[' push field_list pop ']'430 | field_name '.' '[' push field_list pop ']' 422 431 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); } 423 | no_attr_identifierARROW field432 | field_name ARROW field 424 433 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); } 425 | no_attr_identifierARROW '[' push field_list pop ']'434 | field_name ARROW '[' push field_list pop ']' 426 435 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); } 436 ; 437 438 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 427 450 ; 428 451 … … 497 520 | '(' type_name_no_function ')' cast_expression 498 521 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 499 | '(' type_name_no_function ')' tuple500 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }522 // | '(' type_name_no_function ')' tuple 523 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 501 524 ; 502 525 … … 584 607 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 585 608 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 586 | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression587 { $$ = 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 ) ); } 588 611 ; 589 612 … … 597 620 | unary_expression assignment_operator assignment_expression 598 621 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 599 | tuple assignment_opt // CFA, tuple expression600 { $$ = ( $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 ) ); } 601 624 ; 602 625 … … 625 648 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with 626 649 // comma_expression in new_identifier_parameter_array and new_abstract_array 627 '[' ']'628 { $$ = new ExpressionNode( build_tuple() ); }629 |'[' push assignment_expression pop ']'630 { $$ = new ExpressionNode( build_tuple( $3 ) ); }631 |'[' 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 ']' 632 655 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 633 656 | '[' push assignment_expression ',' tuple_expression_list pop ']' … … 1128 1151 1129 1152 new_function_specifier: // CFA 1130 '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict1131 {1132 $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );1133 }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 // } 1134 1157 // '[' ']' identifier '(' push new_parameter_type_list_opt pop ')' 1135 1158 // { … … 1150 1173 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1151 1174 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1152 |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 ')' 1153 1176 // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator). 1154 1177 { … … 2005 2028 { 2006 2029 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2007 linkage = LinkageSpec:: fromString( *$2 );2030 linkage = LinkageSpec::linkageCheck( $2 ); 2008 2031 } 2009 2032 '{' external_definition_list_opt '}' // C++-style linkage specifier … … 2716 2739 | multi_array_dimension type_specifier 2717 2740 { $$ = $2->addNewArray( $1 ); } 2741 2718 2742 | '[' ']' new_identifier_parameter_ptr 2719 2743 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } … … 2813 2837 2814 2838 new_abstract_function: // CFA 2815 '[' ']' '(' new_parameter_type_list_opt ')'2816 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }2817 |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 ')' 2818 2842 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 2819 2843 | new_function_return '(' push new_parameter_type_list_opt pop ')'
Note:
See TracChangeset
for help on using the changeset viewer.