Ignore:
Timestamp:
Jul 7, 2015, 1:49:58 PM (10 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
82dd287
Parents:
e0ff3e6 (diff), 8686f31 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    re0ff3e6 r413f7f8  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 22 15:19:44 2015
    13 // Update Count     : 1082
     12// Last Modified On : Fri Jul  3 13:53:45 2015
     13// Update Count     : 1220
    1414//
    1515
     
    118118
    119119%type<tok> zero_one  identifier  no_attr_identifier  no_01_identifier
    120 %type<tok> identifier_or_typedef_name  no_attr_identifier_or_typedef_name  no_01_identifier_or_typedef_name
     120%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  no_01_identifier_or_type_name
    121121%type<constant> string_literal_list
    122122
     
    204204%type<decl> parameter_type_list_opt
    205205
    206 %type<decl> paren_identifier paren_typedef
     206%type<decl> paren_identifier paren_type
    207207
    208208%type<decl> storage_class storage_class_name storage_class_list
     
    213213%type<decl> type_declarator type_declarator_name type_declaring_list
    214214
    215 %type<decl> typedef typedef_array typedef_declaration typedef_declaration_specifier typedef_expression
    216 %type<decl> typedef_function typedef_parameter_array typedef_parameter_function typedef_parameter_ptr
    217 %type<decl> typedef_parameter_redeclarator typedef_ptr typedef_redeclarator typedef_type_specifier
    218 %type<decl> typegen_declaration_specifier typegen_type_specifier
     215%type<decl> typedef type_array typedef_declaration typedef_declaration_specifier typedef_expression
     216%type<decl> type_function type_parameter_array type_parameter_function type_parameter_ptr
     217%type<decl> type_parameter_redeclarator type_ptr type_redeclarator typedef_type_specifier
     218%type<decl> typegen_declaration_specifier typegen_type_specifier typegen_name
    219219
    220220%type<decl> type_name type_name_no_function
     
    376376        | no_attr_identifier ':' assignment_expression
    377377                { $$ = $3->set_asArgName( $1 ); }
    378                 // Only a list of no_attr_identifier_or_typedef_name is allowed in this context. However, there is insufficient
     378                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    379379                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    380380                // with an appropriate semantic check.
     
    564564                // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with
    565565                // comma_expression in new_identifier_parameter_array and new_abstract_array
    566         '[' push pop ']'
     566        '[' ']'
    567567                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); }
    568568        | '[' push assignment_expression pop ']'
     
    924924
    925925label_list:                                                                                             // GCC, local label
    926         no_attr_identifier_or_typedef_name                      {}
    927         | label_list ',' no_attr_identifier_or_typedef_name {}
     926        no_attr_identifier_or_type_name                 {}
     927        | label_list ',' no_attr_identifier_or_type_name {}
    928928        ;
    929929
     
    965965                        $$ = $2->addQualifiers( $1 );
    966966                }
    967         | new_variable_declaration pop ',' push identifier_or_typedef_name initializer_opt
     967        | new_variable_declaration pop ',' push identifier_or_type_name initializer_opt
    968968                {
    969969                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
     
    975975                // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    976976                // storage-class
    977         new_abstract_declarator_no_tuple identifier_or_typedef_name asm_name_opt
     977        new_abstract_declarator_no_tuple identifier_or_type_name asm_name_opt
    978978                {
    979979                        typedefTable.setNextIdentifier( *$2 );
    980980                        $$ = $1->addName( $2 );
    981981                }
    982         | new_abstract_tuple identifier_or_typedef_name asm_name_opt
     982        | new_abstract_tuple identifier_or_type_name asm_name_opt
    983983                {
    984984                        typedefTable.setNextIdentifier( *$2 );
    985985                        $$ = $1->addName( $2 );
    986986                }
    987         | type_qualifier_list new_abstract_tuple identifier_or_typedef_name asm_name_opt
     987        | type_qualifier_list new_abstract_tuple identifier_or_type_name asm_name_opt
    988988                {
    989989                        typedefTable.setNextIdentifier( *$3 );
     
    10131013                        $$ = $3->addQualifiers( $1 )->addQualifiers( $2 );
    10141014                }
    1015         | new_function_declaration pop ',' push identifier_or_typedef_name
     1015        | new_function_declaration pop ',' push identifier_or_type_name
    10161016                {
    10171017                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
     
    10211021
    10221022new_function_specifier:                                                                 // CFA
    1023         '[' push pop ']' identifier '(' push new_parameter_type_list_opt pop ')'
    1024                 {
    1025                         typedefTable.setNextIdentifier( *( $5 ) );
    1026                         $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    1027                 }
    1028         | '[' push pop ']' TYPEDEFname '(' push new_parameter_type_list_opt pop ')'
    1029                 {
    1030                         typedefTable.setNextIdentifier( *( $5 ) );
    1031                         $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    1032                 }
    1033                 // identifier_or_typedef_name must be broken apart because of the sequence:
     1023        '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict
     1024                {
     1025                        $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
     1026                }
     1027//      '[' ']' identifier '(' push new_parameter_type_list_opt pop ')'
     1028//              {
     1029//                      typedefTable.setNextIdentifier( *$5 );
     1030//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1031//              }
     1032//      | '[' ']' TYPEDEFname '(' push new_parameter_type_list_opt pop ')'
     1033//              {
     1034//                      typedefTable.setNextIdentifier( *$5 );
     1035//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1036//              }
     1037//      | '[' ']' typegen_name
     1038                // identifier_or_type_name must be broken apart because of the sequence:
    10341039                //
    1035                 //   '[' ']' identifier_or_typedef_name '(' new_parameter_type_list_opt ')'
     1040                //   '[' ']' identifier_or_type_name '(' new_parameter_type_list_opt ')'
    10361041                //   '[' ']' type_specifier
    10371042                //
    1038                 // type_specifier can resolve to just TYPEDEFname (e.g. typedef int T; int f( T );). Therefore this must be
    1039                 // flattened to allow lookahead to the '(' without having to reduce identifier_or_typedef_name.
    1040         | new_abstract_tuple identifier_or_typedef_name '(' push new_parameter_type_list_opt pop ')'
     1043                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
     1044                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
     1045        | new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'
    10411046                // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator).
    10421047                {
    10431048                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
    10441049                }
    1045         | new_function_return identifier_or_typedef_name '(' push new_parameter_type_list_opt pop ')'
     1050        | new_function_return identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'
    10461051                {
    10471052                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
     
    11071112        ;
    11081113
    1109 typedef_expression:                                                                             // GCC, naming expression type
     1114typedef_expression:
     1115                // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    11101116        TYPEDEF no_attr_identifier '=' assignment_expression
    11111117                {
     
    13551361aggregate_name:
    13561362        aggregate_key '{' field_declaration_list '}'
    1357                 { $$ = DeclarationNode::newAggregate( $1, 0, 0, 0, $3 ); }
    1358         | aggregate_key no_attr_identifier_or_typedef_name
    1359                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, 0 ); }
    1360         | aggregate_key no_attr_identifier_or_typedef_name '{' field_declaration_list '}'
    1361                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, $4 ); }
    1362         | aggregate_key '(' push type_parameter_list pop ')' '{' field_declaration_list '}' // CFA
    1363                 { $$ = DeclarationNode::newAggregate( $1, 0, $4, 0, $8 ); }
    1364         | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name // CFA
    1365                 { $$ = DeclarationNode::newAggregate( $1, $7, $4, 0, 0 ); }
    1366         | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' // CFA
    1367                 { $$ = DeclarationNode::newAggregate( $1, $7, $4, 0, $9 ); }
    1368         | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1369                 { $$ = DeclarationNode::newAggregate( $1, 0, $4, $8, $11 ); }
    1370         | aggregate_key TYPEGENname '(' type_name_list ')' // CFA
    1371                 {}
    1372         | aggregate_key '(' push type_name_list pop ')' no_attr_identifier_or_typedef_name // CFA
    1373                 // push and pop are only to prevent S/R conflicts
    1374                 { $$ = DeclarationNode::newAggregate( $1, $7, 0, $4, 0 ); }
    1375         | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' // CFA
    1376                 { $$ = DeclarationNode::newAggregate( $1, $10, $4, $8, $12 ); }
     1363                { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3 ); }
     1364        | aggregate_key no_attr_identifier_or_type_name
     1365                { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0 ); }
     1366        | aggregate_key no_attr_identifier_or_type_name '{' field_declaration_list '}'
     1367                { $$ = DeclarationNode::newAggregate( $1, $2, 0, $4 ); }
     1368        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
     1369                { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }
     1370        | aggregate_key typegen_name                                            // CFA, S/R conflict
     1371                { $$ = $2; }
    13771372        ;
    13781373
     
    14021397new_field_declaring_list:                                                               // CFA, new style field declaration
    14031398        new_abstract_declarator_tuple                                           // CFA, no field name
    1404         | new_abstract_declarator_tuple no_attr_identifier_or_typedef_name
     1399        | new_abstract_declarator_tuple no_attr_identifier_or_type_name
    14051400                { $$ = $1->addName( $2 ); }
    1406         | new_field_declaring_list ',' no_attr_identifier_or_typedef_name
     1401        | new_field_declaring_list ',' no_attr_identifier_or_type_name
    14071402                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    14081403        | new_field_declaring_list ','                                          // CFA, no field name
     
    14251420                // A semantic check is required to ensure bit_subrange only appears on base type int.
    14261421                { $$ = $1->addBitfield( $2 ); }
    1427         | typedef_redeclarator bit_subrange_size_opt
     1422        | type_redeclarator bit_subrange_size_opt
    14281423                // A semantic check is required to ensure bit_subrange only appears on base type int.
    14291424                { $$ = $1->addBitfield( $2 ); }
     
    14501445        enum_key '{' enumerator_list comma_opt '}'
    14511446                { $$ = DeclarationNode::newEnum( 0, $3 ); }
    1452         | enum_key no_attr_identifier_or_typedef_name '{' enumerator_list comma_opt '}'
     1447        | enum_key no_attr_identifier_or_type_name '{' enumerator_list comma_opt '}'
    14531448                { $$ = DeclarationNode::newEnum( $2, $4 ); }
    1454         | enum_key no_attr_identifier_or_typedef_name
     1449        | enum_key no_attr_identifier_or_type_name
    14551450                { $$ = DeclarationNode::newEnum( $2, 0 ); }
    14561451        ;
    14571452
    14581453enumerator_list:
    1459         no_attr_identifier_or_typedef_name enumerator_value_opt
     1454        no_attr_identifier_or_type_name enumerator_value_opt
    14601455                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    1461         | enumerator_list ',' no_attr_identifier_or_typedef_name enumerator_value_opt
     1456        | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt
    14621457                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    14631458        ;
     
    15291524
    15301525// Provides optional identifier names (abstract_declarator/variable_declarator), no initialization, different semantics
    1531 // for typedef name by using typedef_parameter_redeclarator instead of typedef_redeclarator, and function prototypes.
     1526// for typedef name by using type_parameter_redeclarator instead of typedef_redeclarator, and function prototypes.
    15321527
    15331528new_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    15341529        parameter_declaration
    1535         | new_identifier_parameter_declarator_no_tuple identifier_or_typedef_name assignment_opt
     1530        | new_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
    15361531                { $$ = $1->addName( $2 ); }
    1537         | new_abstract_tuple identifier_or_typedef_name assignment_opt
     1532        | new_abstract_tuple identifier_or_type_name assignment_opt
    15381533                // To obtain LR(1), these rules must be duplicated here (see new_abstract_declarator).
    15391534                { $$ = $1->addName( $2 ); }
    1540         | type_qualifier_list new_abstract_tuple identifier_or_typedef_name assignment_opt
     1535        | type_qualifier_list new_abstract_tuple identifier_or_type_name assignment_opt
    15411536                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    15421537        | new_function_specifier
     
    15591554                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
    15601555                }
    1561         | declaration_specifier typedef_parameter_redeclarator assignment_opt
     1556        | declaration_specifier type_parameter_redeclarator assignment_opt
    15621557                {
    15631558                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    15831578        ;
    15841579
    1585 identifier_or_typedef_name:
     1580identifier_or_type_name:
    15861581        identifier
    15871582        | TYPEDEFname
     
    15891584        ;
    15901585
    1591 no_01_identifier_or_typedef_name:
     1586no_01_identifier_or_type_name:
    15921587        no_01_identifier
    15931588        | TYPEDEFname
     
    15951590        ;
    15961591
    1597 no_attr_identifier_or_typedef_name:
     1592no_attr_identifier_or_type_name:
    15981593        no_attr_identifier
    15991594        | TYPEDEFname
    1600         //      | TYPEGENname
     1595        | TYPEGENname
    16011596        ;
    16021597
     
    16191614        // empty
    16201615                { $$ = 0; }
    1621         | '=' initializer                                                       { $$ = $2; }
     1616        | '=' initializer
     1617                { $$ = $2; }
    16221618        ;
    16231619
     
    16471643designation:
    16481644        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    1649         | no_attr_identifier_or_typedef_name ':'                        // GCC, field name
    1650                                 { $$ = new VarRefNode( $1 ); }
     1645        | no_attr_identifier_or_type_name ':'                           // GCC, field name
     1646                { $$ = new VarRefNode( $1 ); }
    16511647        ;
    16521648
    16531649designator_list:                                                                                // C99
    16541650        designator
    1655         | designator_list designator                                    { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
     1651        | designator_list designator
     1652                { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
    16561653        //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
    16571654        ;
    16581655
    16591656designator:
    1660         '.' no_attr_identifier_or_typedef_name                          // C99, field name
     1657        '.' no_attr_identifier_or_type_name                                     // C99, field name
    16611658                { $$ = new VarRefNode( $2 ); }
    16621659        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    17001697
    17011698typegen_type_specifier:                                                                 // CFA
     1699        typegen_name
     1700        | type_qualifier_list typegen_name
     1701                { $$ = $2->addQualifiers( $1 ); }
     1702        | typegen_type_specifier type_qualifier
     1703                { $$ = $1->addQualifiers( $2 ); }
     1704        ;
     1705
     1706typegen_name:                                                                                   // CFA
    17021707        TYPEGENname '(' type_name_list ')'
    17031708                { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
    1704         | type_qualifier_list TYPEGENname '(' type_name_list ')'
    1705                 { $$ = DeclarationNode::newFromTypeGen( $2, $4 )->addQualifiers( $1 ); }
    1706         | typegen_type_specifier type_qualifier
    1707                 { $$ = $1->addQualifiers( $2 ); }
    17081709        ;
    17091710
     
    17151716
    17161717type_parameter:                                                                                 // CFA
    1717         type_class no_attr_identifier_or_typedef_name
    1718                 { typedefTable.addToEnclosingScope(*( $2 ), TypedefTable::TD ); }
     1718        type_class no_attr_identifier_or_type_name
     1719                { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); }
    17191720          assertion_list_opt
    17201721                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); }
     
    17391740
    17401741assertion:                                                                                              // CFA
    1741         '|' no_attr_identifier_or_typedef_name '(' type_name_list ')'
    1742                 {
    1743                         typedefTable.openContext( *( $2 ) );
     1742        '|' no_attr_identifier_or_type_name '(' type_name_list ')'
     1743                {
     1744                        typedefTable.openContext( *$2 );
    17441745                        $$ = DeclarationNode::newContextUse( $2, $4 );
    17451746                }
     
    17771778
    17781779type_declarator_name:                                                                   // CFA
    1779         no_attr_identifier_or_typedef_name
     1780        no_attr_identifier_or_type_name
    17801781                {
    17811782                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TD );
    17821783                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    17831784                }
    1784         | no_01_identifier_or_typedef_name '(' push type_parameter_list pop ')'
     1785        | no_01_identifier_or_type_name '(' push type_parameter_list pop ')'
    17851786                {
    17861787                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TG );
     
    17901791
    17911792context_specifier:                                                                              // CFA
    1792         CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{' '}'
     1793        CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
    17931794                {
    17941795                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    17951796                        $$ = DeclarationNode::newContext( $2, $5, 0 );
    17961797                }
    1797         | CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{'
     1798        | CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
    17981799                {
    17991800                        typedefTable.enterContext( *$2 );
     
    18301831                        $$ = $1;
    18311832                }
    1832         | new_context_declaring_list pop ',' push identifier_or_typedef_name
     1833        | new_context_declaring_list pop ',' push identifier_or_type_name
    18331834                {
    18341835                        typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
     
    18991900external_function_definition:
    19001901        function_definition
    1901 
    19021902                // These rules are a concession to the "implicit int" type_specifier because there is a significant amount of
    19031903                // code with functions missing a type-specifier on the return type.  Parsing is possible because
     
    19821982        variable_declarator
    19831983        | function_declarator
    1984         | typedef_redeclarator
     1984        | type_redeclarator
    19851985        ;
    19861986
     
    20212021
    20222022any_word:                                                                                               // GCC
    2023         identifier_or_typedef_name {}
     2023        identifier_or_type_name {}
    20242024        | storage_class_name {}
    20252025        | basic_type_name {}
     
    21032103// This pattern parses a function declarator that is not redefining a typedef name. Because functions cannot be nested,
    21042104// there is no context where a function definition can redefine a typedef name. To allow nested functions requires
    2105 // further separation of variable and function declarators in typedef_redeclarator.  The pattern precludes returning
     2105// further separation of variable and function declarators in type_redeclarator.  The pattern precludes returning
    21062106// arrays and functions versus pointers to arrays and functions.
    21072107
     
    21762176        ;
    21772177
    2178 // This pattern parses a declaration for a variable or function prototype that redefines a typedef name, e.g.:
     2178// This pattern parses a declaration for a variable or function prototype that redefines a type name, e.g.:
    21792179//
    21802180//              typedef int foo;
     
    21862186// and functions versus pointers to arrays and functions.
    21872187
    2188 typedef_redeclarator:
    2189         paren_typedef attribute_list_opt
    2190         | typedef_ptr
    2191         | typedef_array attribute_list_opt
    2192         | typedef_function attribute_list_opt
    2193         ;
    2194 
    2195 paren_typedef:
    2196         TYPEDEFname
    2197                 {
    2198                         typedefTable.setNextIdentifier( *( $1 ) );
    2199                         $$ = DeclarationNode::newName( $1 );
    2200                 }
    2201         | '(' paren_typedef ')'
    2202                 { $$ = $2; }
    2203         ;
    2204 
    2205 typedef_ptr:
    2206         '*' typedef_redeclarator
     2188type_redeclarator:
     2189        paren_type attribute_list_opt
     2190        | type_ptr
     2191        | type_array attribute_list_opt
     2192        | type_function attribute_list_opt
     2193        ;
     2194
     2195paren_type:
     2196        typedef
     2197        | '(' paren_type ')'
     2198                { $$ = $2; }
     2199        ;
     2200
     2201type_ptr:
     2202        '*' type_redeclarator
    22072203                { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
    2208         | '*' type_qualifier_list typedef_redeclarator
     2204        | '*' type_qualifier_list type_redeclarator
    22092205                { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
    2210         | '(' typedef_ptr ')'
    2211                 { $$ = $2; }
    2212         ;
    2213 
    2214 typedef_array:
    2215         paren_typedef array_dimension
     2206        | '(' type_ptr ')'
     2207                { $$ = $2; }
     2208        ;
     2209
     2210type_array:
     2211        paren_type array_dimension
    22162212                { $$ = $1->addArray( $2 ); }
    2217         | '(' typedef_ptr ')' array_dimension
     2213        | '(' type_ptr ')' array_dimension
    22182214                { $$ = $2->addArray( $4 ); }
    2219         | '(' typedef_array ')' multi_array_dimension           // redundant parenthesis
     2215        | '(' type_array ')' multi_array_dimension                      // redundant parenthesis
    22202216                { $$ = $2->addArray( $4 ); }
    2221         | '(' typedef_array ')'                                                         // redundant parenthesis
    2222                 { $$ = $2; }
    2223         ;
    2224 
    2225 typedef_function:
    2226         paren_typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2217        | '(' type_array ')'                                                            // redundant parenthesis
     2218                { $$ = $2; }
     2219        ;
     2220
     2221type_function:
     2222        paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    22272223                { $$ = $1->addParamList( $4 ); }
    2228         | '(' typedef_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2224        | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    22292225                { $$ = $2->addParamList( $6 ); }
    2230         | '(' typedef_function ')'                                                      // redundant parenthesis
     2226        | '(' type_function ')'                                                         // redundant parenthesis
    22312227                { $$ = $2; }
    22322228        ;
     
    22992295// functions.
    23002296
    2301 typedef_parameter_redeclarator:
     2297type_parameter_redeclarator:
    23022298        typedef attribute_list_opt
    2303         | typedef_parameter_ptr
    2304         | typedef_parameter_array attribute_list_opt
    2305         | typedef_parameter_function attribute_list_opt
     2299        | type_parameter_ptr
     2300        | type_parameter_array attribute_list_opt
     2301        | type_parameter_function attribute_list_opt
    23062302        ;
    23072303
     
    23122308                        $$ = DeclarationNode::newName( $1 );
    23132309                }
    2314         ;
    2315 
    2316 typedef_parameter_ptr:
    2317         '*' typedef_parameter_redeclarator
     2310        | TYPEGENname
     2311                {
     2312                        typedefTable.setNextIdentifier( *$1 );
     2313                        $$ = DeclarationNode::newName( $1 );
     2314                }
     2315        ;
     2316
     2317type_parameter_ptr:
     2318        '*' type_parameter_redeclarator
    23182319                { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
    2319         | '*' type_qualifier_list typedef_parameter_redeclarator
     2320        | '*' type_qualifier_list type_parameter_redeclarator
    23202321                { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
    2321         | '(' typedef_parameter_ptr ')'
    2322                 { $$ = $2; }
    2323         ;
    2324 
    2325 typedef_parameter_array:
     2322        | '(' type_parameter_ptr ')'
     2323                { $$ = $2; }
     2324        ;
     2325
     2326type_parameter_array:
    23262327        typedef array_parameter_dimension
    23272328                { $$ = $1->addArray( $2 ); }
    2328         | '(' typedef_parameter_ptr ')' array_parameter_dimension
     2329        | '(' type_parameter_ptr ')' array_parameter_dimension
    23292330                { $$ = $2->addArray( $4 ); }
    23302331        ;
    23312332
    2332 typedef_parameter_function:
     2333type_parameter_function:
    23332334        typedef '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
    23342335                { $$ = $1->addParamList( $4 ); }
    2335         | '(' typedef_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2336        | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    23362337                { $$ = $2->addParamList( $6 ); }
    23372338        ;
     
    23862387array_dimension:
    23872388                // Only the first dimension can be empty.
    2388         '[' push pop ']'
     2389        '[' ']'
    23892390                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    2390         | '[' push pop ']' multi_array_dimension
    2391                 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $5 ); }
     2391        | '[' ']' multi_array_dimension
     2392                { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
    23922393        | multi_array_dimension
    23932394        ;
     
    24652466
    24662467array_parameter_1st_dimension:
    2467         '[' push pop ']'
     2468        '[' ']'
    24682469                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    24692470        // multi_array_dimension handles the '[' '*' ']' case
     
    25582559                // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to
    25592560                // shift/reduce conflict with new-style empty (void) function return type.
    2560         '[' push pop ']' type_specifier
    2561                 { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2561        '[' ']' type_specifier
     2562                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    25622563        | new_array_parameter_1st_dimension type_specifier
    25632564                { $$ = $2->addNewArray( $1 ); }
    2564         | '[' push pop ']' multi_array_dimension type_specifier
    2565                 { $$ = $6->addNewArray( $5 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2565        | '[' ']' multi_array_dimension type_specifier
     2566                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    25662567        | new_array_parameter_1st_dimension multi_array_dimension type_specifier
    25672568                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
    25682569        | multi_array_dimension type_specifier
    25692570                { $$ = $2->addNewArray( $1 ); }
    2570         | '[' push pop ']' new_identifier_parameter_ptr
    2571                 { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2571        | '[' ']' new_identifier_parameter_ptr
     2572                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    25722573        | new_array_parameter_1st_dimension new_identifier_parameter_ptr
    25732574                { $$ = $2->addNewArray( $1 ); }
    2574         | '[' push pop ']' multi_array_dimension new_identifier_parameter_ptr
    2575                 { $$ = $6->addNewArray( $5 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2575        | '[' ']' multi_array_dimension new_identifier_parameter_ptr
     2576                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    25762577        | new_array_parameter_1st_dimension multi_array_dimension new_identifier_parameter_ptr
    25772578                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    26022603// These rules need LR(3):
    26032604//
    2604 //              new_abstract_tuple identifier_or_typedef_name
    2605 //              '[' new_parameter_list ']' identifier_or_typedef_name '(' new_parameter_type_list_opt ')'
     2605//              new_abstract_tuple identifier_or_type_name
     2606//              '[' new_parameter_list ']' identifier_or_type_name '(' new_parameter_type_list_opt ')'
    26062607//
    26072608// since a function return type can be syntactically identical to a tuple type:
     
    26102611//              [int, int] f( int );
    26112612//
    2612 // Therefore, it is necessary to look at the token after identifier_or_typedef_name to know when to reduce
     2613// Therefore, it is necessary to look at the token after identifier_or_type_name to know when to reduce
    26132614// new_abstract_tuple. To make this LR(1), several rules have to be flattened (lengthened) to allow the necessary
    26142615// lookahead. To accomplish this, new_abstract_declarator has an entry point without tuple, and tuple declarations are
     
    26452646                // Only the first dimension can be empty. Empty dimension must be factored out due to shift/reduce conflict with
    26462647                // empty (void) function return type.
    2647         '[' push pop ']' type_specifier
    2648                 { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    2649         | '[' push pop ']' multi_array_dimension type_specifier
    2650                 { $$ = $6->addNewArray( $5 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2648        '[' ']' type_specifier
     2649                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2650        | '[' ']' multi_array_dimension type_specifier
     2651                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    26512652        | multi_array_dimension type_specifier
    26522653                { $$ = $2->addNewArray( $1 ); }
    2653         | '[' push pop ']' new_abstract_ptr
    2654                 { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    2655         | '[' push pop ']' multi_array_dimension new_abstract_ptr
    2656                 { $$ = $6->addNewArray( $5 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2654        | '[' ']' new_abstract_ptr
     2655                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2656        | '[' ']' multi_array_dimension new_abstract_ptr
     2657                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    26572658        | multi_array_dimension new_abstract_ptr
    26582659                { $$ = $2->addNewArray( $1 ); }
     
    26652666
    26662667new_abstract_function:                                                                  // CFA
    2667         '[' push pop ']' '(' new_parameter_type_list_opt ')'
    2668                 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $6, 0 ); }
     2668        '[' ']' '(' new_parameter_type_list_opt ')'
     2669                { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
    26692670        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    26702671                { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
Note: See TracChangeset for help on using the changeset viewer.