Changeset 65d6de4


Ignore:
Timestamp:
Nov 17, 2017, 2:41:46 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
9e1eabc
Parents:
34c6c767
Message:

add TYPEGENname to typegen_name, and fix shift/reduce in favour of shift

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r34c6c767 r65d6de4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Oct 25 12:28:54 2017
    13 // Update Count     : 2893
     12// Last Modified On : Fri Nov 17 11:38:57 2017
     13// Update Count     : 2914
    1414//
    1515
     
    348348
    349349
    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 */
     350// Handle shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string is ambiguous:
     351//   .---------.                                matches IF '(' comma_expression ')' statement . (reduce)
     352//   if ( C ) S1 else S2
     353//   `-----------------'                matches IF '(' comma_expression ')' statement . (shift) ELSE statement */
    355354// Similar issues exit with the waitfor statement.
    356355
     
    361360%precedence TIMEOUT     // token precedence for start of TIMEOUT in WAITFOR statement
    362361%precedence ELSE        // token precedence for start of else clause in IF/WAITFOR statement
     362
     363// Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous:
     364//   forall( otype T ) struct Foo { T v; };
     365//       .-----.                                matches pointer to function returning a generic (which is impossible without a type)
     366//   Foo ( *fp )( int );
     367//   `---'                                              matches start of TYPEGENname '('
     368// Must be:
     369// Foo( int ) ( *fp )( int );
     370
     371// Order of these lines matters (low-to-high precedence).
     372%precedence TYPEGENname
     373%precedence '('
    363374
    364375%locations                      // support location tracking for error messages
     
    17651776
    17661777typegen_name:                                                                                   // CFA
    1767         TYPEGENname '(' ')'
     1778        TYPEGENname
     1779                { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
     1780        | TYPEGENname '(' ')'
    17681781                { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
    17691782        | TYPEGENname '(' type_list ')'
     
    18091822                }
    18101823        | aggregate_key attribute_list_opt typegen_name         // CFA
    1811                 { $$ = $3->addQualifiers( $2 ); }
     1824                {
     1825                        // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is
     1826                        // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and
     1827                        // delete newFromTypeGen.
     1828                        $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 );
     1829                        $3->type->symbolic.name = nullptr;
     1830                        $3->type->symbolic.actuals = nullptr;
     1831                        delete $3;
     1832                }
    18121833        ;
    18131834
Note: See TracChangeset for help on using the changeset viewer.