Changes in src/Parser/parser.yy [c38ae92:f9941ff]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rc38ae92 rf9941ff 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 20 09:45:36201713 // Update Count : 2 94512 // Last Modified On : Wed Oct 25 12:28:54 2017 13 // Update Count : 2893 14 14 // 15 15 … … 114 114 } // for 115 115 } // distExt 116 117 // There is an ambiguity for inline generic-routine return-types and generic routines.118 // forall( otype T ) struct S { int i; } bar( T ) {}119 // Does the forall bind to the struct or the routine, and how would it be possible to explicitly specify the binding.120 // forall( otype T ) struct S { int T; } forall( otype W ) bar( W ) {}121 122 void rebindForall( DeclarationNode * declSpec, DeclarationNode * funcDecl ) {123 if ( declSpec->type->kind == TypeData::Aggregate ) { // return is aggregate definition124 funcDecl->type->forall = declSpec->type->aggregate.params; // move forall from aggregate to function type125 declSpec->type->aggregate.params = nullptr;126 } // if127 } // rebindForall128 116 129 117 bool forall = false; // aggregate have one or more forall qualifiers ? … … 360 348 361 349 362 // Handle shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string is ambiguous: 363 // .---------. matches IF '(' comma_expression ')' statement . (reduce) 364 // if ( C ) S1 else S2 365 // `-----------------' matches IF '(' comma_expression ')' statement . (shift) ELSE statement */ 350 // Handle single shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string 351 // is ambiguous: 352 // .---------. matches IF '(' comma_expression ')' statement . (reduce) 353 // if ( C ) S1 else S2 354 // `-----------------' matches IF '(' comma_expression ')' statement . (shift) ELSE statement */ 366 355 // Similar issues exit with the waitfor statement. 367 356 … … 372 361 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement 373 362 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 374 375 // Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous:376 // forall( otype T ) struct Foo { T v; };377 // .-----. matches pointer to function returning a generic (which is impossible without a type)378 // Foo ( *fp )( int );379 // `---' matches start of TYPEGENname '('380 // Must be:381 // Foo( int ) ( *fp )( int );382 383 // Order of these lines matters (low-to-high precedence).384 %precedence TYPEGENname385 %precedence '('386 363 387 364 %locations // support location tracking for error messages … … 1788 1765 1789 1766 typegen_name: // CFA 1790 TYPEGENname 1791 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1792 | TYPEGENname '(' ')' 1767 TYPEGENname '(' ')' 1793 1768 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1794 1769 | TYPEGENname '(' type_list ')' … … 1834 1809 } 1835 1810 | aggregate_key attribute_list_opt typegen_name // CFA 1836 { 1837 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is 1838 // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and 1839 // delete newFromTypeGen. 1840 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 1841 $3->type->symbolic.name = nullptr; 1842 $3->type->symbolic.actuals = nullptr; 1843 delete $3; 1844 } 1811 { $$ = $3->addQualifiers( $2 ); } 1845 1812 ; 1846 1813 … … 2413 2380 | declaration_specifier function_declarator with_clause_opt compound_statement 2414 2381 { 2415 rebindForall( $1, $2 );2416 2382 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2417 2383 typedefTable.leaveScope(); … … 2440 2406 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2441 2407 { 2442 rebindForall( $1, $2 );2443 2408 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2444 2409 typedefTable.leaveScope();
Note:
See TracChangeset
for help on using the changeset viewer.