Changeset 88ef2af for src/Parser/parser.yy
- Timestamp:
- Nov 23, 2017, 1:31:49 PM (6 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:
- f7a4f89
- Parents:
- 9f10d1f2 (diff), a8b27c6 (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
r9f10d1f2 r88ef2af 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 25 12:28:54201713 // Update Count : 2 89312 // Last Modified On : Mon Nov 20 09:45:36 2017 13 // Update Count : 2945 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 definition 124 funcDecl->type->forall = declSpec->type->aggregate.params; // move forall from aggregate to function type 125 declSpec->type->aggregate.params = nullptr; 126 } // if 127 } // rebindForall 116 128 117 129 bool forall = false; // aggregate have one or more forall qualifiers ? … … 348 360 349 361 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 */ 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 */ 355 366 // Similar issues exit with the waitfor statement. 356 367 … … 361 372 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement 362 373 %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 TYPEGENname 385 %precedence '(' 363 386 364 387 %locations // support location tracking for error messages … … 1765 1788 1766 1789 typegen_name: // CFA 1767 TYPEGENname '(' ')' 1790 TYPEGENname 1791 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1792 | TYPEGENname '(' ')' 1768 1793 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1769 1794 | TYPEGENname '(' type_list ')' … … 1809 1834 } 1810 1835 | aggregate_key attribute_list_opt typegen_name // CFA 1811 { $$ = $3->addQualifiers( $2 ); } 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 } 1812 1845 ; 1813 1846 … … 2380 2413 | declaration_specifier function_declarator with_clause_opt compound_statement 2381 2414 { 2415 rebindForall( $1, $2 ); 2382 2416 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2383 2417 typedefTable.leaveScope(); … … 2406 2440 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2407 2441 { 2442 rebindForall( $1, $2 ); 2408 2443 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2409 2444 typedefTable.leaveScope();
Note: See TracChangeset
for help on using the changeset viewer.