Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rc38ae92 rf9941ff  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 20 09:45:36 2017
    13 // Update Count     : 2945
     12// Last Modified On : Wed Oct 25 12:28:54 2017
     13// Update Count     : 2893
    1414//
    1515
     
    114114        } // for
    115115} // 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
    128116
    129117bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    360348
    361349
    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 */
    366355// Similar issues exit with the waitfor statement.
    367356
     
    372361%precedence TIMEOUT     // token precedence for start of TIMEOUT in WAITFOR statement
    373362%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 '('
    386363
    387364%locations                      // support location tracking for error messages
     
    17881765
    17891766typegen_name:                                                                                   // CFA
    1790         TYPEGENname
    1791                 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
    1792         | TYPEGENname '(' ')'
     1767        TYPEGENname '(' ')'
    17931768                { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
    17941769        | TYPEGENname '(' type_list ')'
     
    18341809                }
    18351810        | 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 ); }
    18451812        ;
    18461813
     
    24132380        | declaration_specifier function_declarator with_clause_opt compound_statement
    24142381                {
    2415                         rebindForall( $1, $2 );
    24162382                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    24172383                        typedefTable.leaveScope();
     
    24402406        | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24412407                {
    2442                         rebindForall( $1, $2 );
    24432408                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    24442409                        typedefTable.leaveScope();
Note: See TracChangeset for help on using the changeset viewer.