Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r13e8427 r3ed994e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 28 17:01:36 2018
    13 // Update Count     : 3383
     12// Last Modified On : Tue May 22 08:41:57 2018
     13// Update Count     : 3353
    1414//
    1515
     
    175175        bool flag;
    176176        CatchStmt::Kind catch_kind;
     177        GenericExpr * genexpr;
    177178}
    178179
     
    259260%type<flag> asm_volatile_opt
    260261%type<en> handler_predicate_opt
     262%type<genexpr> generic_association generic_assoc_list
    261263
    262264// statements
     
    324326%type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr
    325327
    326 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ellipsis_list_opt
     328%type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt
    327329
    328330%type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier
     
    501503                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    502504        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    503                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
     505                {
     506                        // add the missing control expression to the GenericExpr and return it
     507                        $5->control = maybeMoveBuild<Expression>( $3 );
     508                        $$ = new ExpressionNode( $5 );
     509                }
    504510        ;
    505511
    506512generic_assoc_list:                                                                             // C11
    507         | generic_association
     513        generic_association
    508514        | generic_assoc_list ',' generic_association
     515                {
     516                        // steal the association node from the singleton and delete the wrapper
     517                        $1->associations.splice($1->associations.end(), $3->associations);
     518                        delete $3;
     519                        $$ = $1;
     520                }
    509521        ;
    510522
    511523generic_association:                                                                    // C11
    512524        type_no_function ':' assignment_expression
     525                {
     526                        // create a GenericExpr wrapper with one association pair
     527                        $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild<Expression>($3) } } );
     528                }
    513529        | DEFAULT ':' assignment_expression
     530                { $$ = new GenericExpr( nullptr, { { maybeMoveBuild<Expression>($3) } } ); }
    514531        ;
    515532
     
    835852//      '[' ']'
    836853//              { $$ = new ExpressionNode( build_tuple() ); }
    837 //      | '[' push assignment_expression pop ']'
     854//      '[' push assignment_expression pop ']'
    838855//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    839         '[' push ',' tuple_expression_list pop ']'
    840                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
    841         | '[' push assignment_expression ',' tuple_expression_list pop ']'
    842                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); }
     856        '[' ',' tuple_expression_list ']'
     857                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
     858        | '[' assignment_expression ',' tuple_expression_list ']'
     859                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$2->set_last( $4 ) ) ); }
    843860        ;
    844861
     
    866883        labeled_statement
    867884        | compound_statement
    868         | expression_statement
     885        | expression_statement                                          { $$ = $1; }
    869886        | selection_statement
    870887        | iteration_statement
     
    11831200        type_specifier_nobody
    11841201        | type_specifier_nobody declarator
    1185                 { $$ = $2->addType( $1 ); }
     1202                {
     1203                        $$ = $2->addType( $1 );
     1204                }
    11861205        | type_specifier_nobody variable_abstract_declarator
    11871206                { $$ = $2->addType( $1 ); }
    11881207        | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
    1189                 { $$ = $1->addName( $2 ); }
     1208                {
     1209                        $$ = $1->addName( $2 );
     1210                }
    11901211        | cfa_abstract_declarator_tuple                                         // CFA
    11911212        ;
     
    12651286
    12661287declaration_list_opt:                                                                   // used at beginning of switch statement
    1267         pop     // empty
     1288        pop
    12681289                { $$ = nullptr; }
    12691290        | declaration_list
     
    13001321
    13011322local_label_list:                                                                               // GCC, local label
    1302         no_attr_identifier_or_type_name
    1303         | local_label_list ',' no_attr_identifier_or_type_name
     1323        no_attr_identifier_or_type_name                         {}
     1324        | local_label_list ',' no_attr_identifier_or_type_name {}
    13041325        ;
    13051326
     
    13641385        | declaration_qualifier_list type_qualifier_list cfa_function_specifier
    13651386                { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); }
    1366         | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1387        | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    13671388                {
    13681389                        // Append the return type at the start (left-hand-side) to each identifier in the list.
    13691390                        DeclarationNode * ret = new DeclarationNode;
    13701391                        ret->type = maybeClone( $1->type->base );
    1371                         $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $6, nullptr ) );
     1392                        $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $5, nullptr ) );
    13721393                }
    13731394        ;
    13741395
    13751396cfa_function_specifier:                                                                 // CFA
    1376 //      '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict
     1397//      '[' ']' identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' // S/R conflict
    13771398//              {
    13781399//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    13791400//              }
    1380 //      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1401//      '[' ']' identifier '(' push cfa_parameter_type_list_opt pop ')'
    13811402//              {
    13821403//                      typedefTable.setNextIdentifier( *$5 );
    13831404//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    13841405//              }
    1385 //      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1406//      | '[' ']' TYPEDEFname '(' push cfa_parameter_type_list_opt pop ')'
    13861407//              {
    13871408//                      typedefTable.setNextIdentifier( *$5 );
     
    13911412                // identifier_or_type_name must be broken apart because of the sequence:
    13921413                //
    1393                 //   '[' ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
     1414                //   '[' ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    13941415                //   '[' ']' type_specifier
    13951416                //
    13961417                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    13971418                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1398         cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1419        cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    13991420                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    1400                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
    1401         | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
    1402                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
     1421                { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); }
     1422        | cfa_function_return identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     1423                { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); }
    14031424        ;
    14041425
    14051426cfa_function_return:                                                                    // CFA
    1406         '[' push cfa_parameter_list pop ']'
    1407                 { $$ = DeclarationNode::newTuple( $3 ); }
    1408         | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']'
    1409                 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'.
    1410                 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); }
     1427        '[' cfa_parameter_list ']'
     1428                { $$ = DeclarationNode::newTuple( $2 ); }
     1429        | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']'
     1430                // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the
     1431                // ']'.
     1432                { $$ = DeclarationNode::newTuple( $2->appendList( $4 ) ); }
    14111433        ;
    14121434
     
    15821604
    15831605forall:
    1584         FORALL '(' push type_parameter_list pop ')'                                     // CFA
    1585                 { $$ = DeclarationNode::newForall( $4 ); }
     1606        FORALL '('
     1607                {
     1608                        typedefTable.enterScope();
     1609                }
     1610          type_parameter_list ')'                                                       // CFA
     1611                {
     1612                        typedefTable.leaveScope();
     1613                        $$ = DeclarationNode::newForall( $4 );
     1614                }
    15861615        ;
    15871616
     
    19511980        ;
    19521981
    1953 cfa_parameter_ellipsis_list_opt:                                                        // CFA, abstract + real
     1982cfa_parameter_type_list_opt:                                                    // CFA, abstract + real
    19541983        // empty
    19551984                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     
    19581987        | cfa_abstract_parameter_list
    19591988        | cfa_parameter_list
    1960         | cfa_parameter_list pop ',' push cfa_abstract_parameter_list
    1961                 { $$ = $1->appendList( $5 ); }
    1962         | cfa_abstract_parameter_list pop ',' push ELLIPSIS
     1989        | cfa_parameter_list ',' cfa_abstract_parameter_list
     1990                { $$ = $1->appendList( $3 ); }
     1991        | cfa_abstract_parameter_list ',' ELLIPSIS
    19631992                { $$ = $1->addVarArgs(); }
    1964         | cfa_parameter_list pop ',' push ELLIPSIS
     1993        | cfa_parameter_list ',' ELLIPSIS
    19651994                { $$ = $1->addVarArgs(); }
    19661995        ;
     
    19701999                // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'.
    19712000        cfa_parameter_declaration
    1972         | cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration
    1973                 { $$ = $1->appendList( $5 ); }
    1974         | cfa_parameter_list pop ',' push cfa_parameter_declaration
    1975                 { $$ = $1->appendList( $5 ); }
    1976         | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration
    1977                 { $$ = $1->appendList( $5 )->appendList( $9 ); }
     2001        | cfa_abstract_parameter_list ',' cfa_parameter_declaration
     2002                { $$ = $1->appendList( $3 ); }
     2003        | cfa_parameter_list ',' cfa_parameter_declaration
     2004                { $$ = $1->appendList( $3 ); }
     2005        | cfa_parameter_list ',' cfa_abstract_parameter_list ',' cfa_parameter_declaration
     2006                { $$ = $1->appendList( $3 )->appendList( $5 ); }
    19782007        ;
    19792008
    19802009cfa_abstract_parameter_list:                                                    // CFA, new & old style abstract
    19812010        cfa_abstract_parameter_declaration
    1982         | cfa_abstract_parameter_list pop ',' push cfa_abstract_parameter_declaration
    1983                 { $$ = $1->appendList( $5 ); }
     2011        | cfa_abstract_parameter_list ',' cfa_abstract_parameter_declaration
     2012                { $$ = $1->appendList( $3 ); }
    19842013        ;
    19852014
     
    20842113                { $$ = $2; }
    20852114        | '=' VOID
    2086                 { $$ = nullptr; }
     2115                { $$ = new InitializerNode( true ); }
    20872116        | ATassign initializer
    20882117                { $$ = $2->set_maybeConstructed( false ); }
     
    21302159        '.' no_attr_identifier                                                          // C99, field name
    21312160                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    2132         | '[' push assignment_expression pop ']'                        // C99, single array element
     2161        | '[' assignment_expression ']'                                         // C99, single array element
    21332162                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     2163                { $$ = $2; }
     2164        | '[' subrange ']'                                                                      // CFA, multiple array elements
     2165                { $$ = $2; }
     2166        | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements
     2167                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $2 ), maybeMoveBuild< Expression >( $4 ) ) ); }
     2168        | '.' '[' field_list ']'                                                        // CFA, tuple field selector
    21342169                { $$ = $3; }
    2135         | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    2136                 { $$ = $3; }
    2137         | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    2138                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); }
    2139         | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    2140                 { $$ = $4; }
    21412170        ;
    21422171
     
    22092238        '|' no_attr_identifier_or_type_name '(' type_list ')'
    22102239                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    2211         | '|' '{' push trait_declaration_list pop '}'
     2240        | '|' '{' push trait_declaration_list '}'
    22122241                { $$ = $4; }
    2213         | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
     2242        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'
    22142243                { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
    22152244        ;
     
    22572286        TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
    22582287                { $$ = DeclarationNode::newTrait( $2, $5, 0 ); }
    2259         | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}'
     2288        | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
     2289                { typedefTable.enterScope(); }
     2290          trait_declaration_list '}'
    22602291                { $$ = DeclarationNode::newTrait( $2, $5, $10 ); }
    22612292        ;
     
    22632294trait_declaration_list:                                                                 // CFA
    22642295        trait_declaration
    2265         | trait_declaration_list pop push trait_declaration
    2266                 { $$ = $1->appendList( $4 ); }
     2296        | trait_declaration_list push trait_declaration
     2297                { $$ = $1->appendList( $3 ); }
    22672298        ;
    22682299
    22692300trait_declaration:                                                                              // CFA
    2270         cfa_trait_declaring_list ';'
    2271         | trait_declaring_list ';'
     2301        cfa_trait_declaring_list pop ';'
     2302        | trait_declaring_list pop ';'
    22722303        ;
    22732304
    22742305cfa_trait_declaring_list:                                                               // CFA
    22752306        cfa_variable_specifier
     2307                { $$ = $1; }
    22762308        | cfa_function_specifier
     2309                { $$ = $1; }
    22772310        | cfa_trait_declaring_list pop ',' push identifier_or_type_name
    22782311                { $$ = $1->appendList( $1->cloneType( $5 ) ); }
     
    23332366                }
    23342367        | type_qualifier_list
    2335                 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
     2368                {
     2369                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2370                }
    23362371          push '{' external_definition_list '}'                         // CFA, namespace
    23372372                {
     
    23462381                }
    23472382        | declaration_qualifier_list
    2348                 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
     2383                {
     2384                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2385                }
    23492386          push '{' external_definition_list '}'                         // CFA, namespace
    23502387                {
     
    23862423                // declaration must still have a type_specifier.  OBSOLESCENT (see 1)
    23872424        | function_declarator compound_statement
    2388                 { $$ = $1->addFunctionBody( $2 ); }
     2425                {
     2426                        typedefTable.leaveScope();
     2427                        $$ = $1->addFunctionBody( $2 );
     2428                }
    23892429        | KR_function_declarator KR_declaration_list_opt compound_statement
    2390                 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); }
     2430                {
     2431                        typedefTable.leaveScope();
     2432                        $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 );
     2433                }
    23912434        ;
    23922435
     
    24012444        cfa_function_declaration with_clause_opt compound_statement     // CFA
    24022445                {
     2446                        typedefTable.leaveScope();
    24032447                        // Add the function body to the last identifier in the function definition list, i.e., foo3:
    24042448                        //   [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; }
     
    24092453                {
    24102454                        rebindForall( $1, $2 );
     2455                        typedefTable.leaveScope();
    24112456                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24122457                }
     
    24142459                {
    24152460                        rebindForall( $1, $2 );
     2461                        typedefTable.leaveScope();
    24162462                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24172463                }
    24182464                // handles default int return type, OBSOLESCENT (see 1)
    24192465        | type_qualifier_list function_declarator with_clause_opt compound_statement
    2420                 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
     2466                {
     2467                        typedefTable.leaveScope();
     2468                        $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
     2469                }
    24212470                // handles default int return type, OBSOLESCENT (see 1)
    24222471        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    2423                 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
     2472                {
     2473                        typedefTable.leaveScope();
     2474                        $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
     2475                }
    24242476                // handles default int return type, OBSOLESCENT (see 1)
    24252477        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    2426                 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); }
     2478                {
     2479                        typedefTable.leaveScope();
     2480                        $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2481                }
    24272482
    24282483                // Old-style K&R function definition, OBSOLESCENT (see 4)
     
    24302485                {
    24312486                        rebindForall( $1, $2 );
     2487                        typedefTable.leaveScope();
    24322488                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 );
    24332489                }
    24342490                // handles default int return type, OBSOLESCENT (see 1)
    24352491        | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    2436                 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); }
     2492                {
     2493                        typedefTable.leaveScope();
     2494                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 );
     2495                }
    24372496                // handles default int return type, OBSOLESCENT (see 1)
    24382497        | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    2439                 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); }
     2498                {
     2499                        typedefTable.leaveScope();
     2500                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 );
     2501                }
    24402502                // handles default int return type, OBSOLESCENT (see 1)
    24412503        | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    2442                 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); }
     2504                {
     2505                        typedefTable.leaveScope();
     2506                        $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 );
     2507                }
    24432508        ;
    24442509
     
    26372702        paren_identifier '(' identifier_list ')'                        // function_declarator handles empty parameter
    26382703                { $$ = $1->addIdList( $3 ); }
    2639         | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    2640                 { $$ = $2->addParamList( $6 ); }
     2704        | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')'
     2705                { $$ = $2->addParamList( $5 ); }
    26412706        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    26422707                { $$ = $2; }
     
    27562821
    27572822identifier_parameter_function:
    2758         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2759                 { $$ = $1->addParamList( $4 ); }
    2760         | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2761                 { $$ = $2->addParamList( $6 ); }
     2823        paren_identifier '(' parameter_type_list_opt ')'        // empty parameter list OBSOLESCENT (see 3)
     2824                { $$ = $1->addParamList( $3 ); }
     2825        | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2826                { $$ = $2->addParamList( $5 ); }
    27622827        | '(' identifier_parameter_function ')'                         // redundant parenthesis
    27632828                { $$ = $2; }
     
    28092874
    28102875type_parameter_function:
    2811         typedef '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
    2812                 { $$ = $1->addParamList( $4 ); }
    2813         | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2814                 { $$ = $2->addParamList( $6 ); }
     2876        typedef '(' parameter_type_list_opt ')'                         // empty parameter list OBSOLESCENT (see 3)
     2877                { $$ = $1->addParamList( $3 ); }
     2878        | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2879                { $$ = $2->addParamList( $5 ); }
    28152880        ;
    28162881
     
    28592924
    28602925abstract_function:
    2861         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2862                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    2863         | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2864                 { $$ = $2->addParamList( $6 ); }
     2926        '(' parameter_type_list_opt ')'                                         // empty parameter list OBSOLESCENT (see 3)
     2927                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     2928        | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2929                { $$ = $2->addParamList( $5 ); }
    28652930        | '(' abstract_function ')'                                                     // redundant parenthesis
    28662931                { $$ = $2; }
     
    28772942
    28782943multi_array_dimension:
    2879         '[' push assignment_expression pop ']'
    2880                 { $$ = DeclarationNode::newArray( $3, 0, false ); }
    2881         | '[' push '*' pop ']'                                                          // C99
     2944        '[' assignment_expression ']'
     2945                { $$ = DeclarationNode::newArray( $2, 0, false ); }
     2946        | '[' '*' ']'                                                                           // C99
    28822947                { $$ = DeclarationNode::newVarArray( 0 ); }
    2883         | multi_array_dimension '[' push assignment_expression pop ']'
    2884                 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
    2885         | multi_array_dimension '[' push '*' pop ']'            // C99
     2948        | multi_array_dimension '[' assignment_expression ']'
     2949                { $$ = $1->addArray( DeclarationNode::newArray( $3, 0, false ) ); }
     2950        | multi_array_dimension '[' '*' ']'                                     // C99
    28862951                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
    28872952        ;
     
    29503015
    29513016abstract_parameter_function:
    2952         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2953                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    2954         | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2955                 { $$ = $2->addParamList( $6 ); }
     3017        '(' parameter_type_list_opt ')'                                         // empty parameter list OBSOLESCENT (see 3)
     3018                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     3019        | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3020                { $$ = $2->addParamList( $5 ); }
    29563021        | '(' abstract_parameter_function ')'                           // redundant parenthesis
    29573022                { $$ = $2; }
     
    29743039        '[' ']'
    29753040                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    2976                 // multi_array_dimension handles the '[' '*' ']' case
    2977         | '[' push type_qualifier_list '*' pop ']'                      // remaining C99
    2978                 { $$ = DeclarationNode::newVarArray( $3 ); }
    2979         | '[' push type_qualifier_list pop ']'
    2980                 { $$ = DeclarationNode::newArray( 0, $3, false ); }
    2981                 // multi_array_dimension handles the '[' assignment_expression ']' case
    2982         | '[' push type_qualifier_list assignment_expression pop ']'
    2983                 { $$ = DeclarationNode::newArray( $4, $3, false ); }
    2984         | '[' push STATIC type_qualifier_list_opt assignment_expression pop ']'
    2985                 { $$ = DeclarationNode::newArray( $5, $4, true ); }
    2986         | '[' push type_qualifier_list STATIC assignment_expression pop ']'
    2987                 { $$ = DeclarationNode::newArray( $5, $3, true ); }
     3041        // multi_array_dimension handles the '[' '*' ']' case
     3042        | '[' type_qualifier_list '*' ']'                                       // remaining C99
     3043                { $$ = DeclarationNode::newVarArray( $2 ); }
     3044        | '[' type_qualifier_list ']'
     3045                { $$ = DeclarationNode::newArray( 0, $2, false ); }
     3046        // multi_array_dimension handles the '[' assignment_expression ']' case
     3047        | '[' type_qualifier_list assignment_expression ']'
     3048                { $$ = DeclarationNode::newArray( $3, $2, false ); }
     3049        | '[' STATIC type_qualifier_list_opt assignment_expression ']'
     3050                { $$ = DeclarationNode::newArray( $4, $3, true ); }
     3051        | '[' type_qualifier_list STATIC assignment_expression ']'
     3052                { $$ = DeclarationNode::newArray( $4, $2, true ); }
    29883053        ;
    29893054
     
    30293094
    30303095variable_abstract_function:
    3031         '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3032                 { $$ = $2->addParamList( $6 ); }
     3096        '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3097                { $$ = $2->addParamList( $5 ); }
    30333098        | '(' variable_abstract_function ')'                            // redundant parenthesis
    30343099                { $$ = $2; }
     
    30933158
    30943159cfa_array_parameter_1st_dimension:
    3095         '[' push type_qualifier_list '*' pop ']'                        // remaining C99
    3096                 { $$ = DeclarationNode::newVarArray( $3 ); }
    3097         | '[' push type_qualifier_list assignment_expression pop ']'
    3098                 { $$ = DeclarationNode::newArray( $4, $3, false ); }
    3099         | '[' push declaration_qualifier_list assignment_expression pop ']'
     3160        '[' type_qualifier_list '*' ']'                                         // remaining C99
     3161                { $$ = DeclarationNode::newVarArray( $2 ); }
     3162        | '[' type_qualifier_list assignment_expression ']'
     3163                { $$ = DeclarationNode::newArray( $3, $2, false ); }
     3164        | '[' declaration_qualifier_list assignment_expression ']'
    31003165                // declaration_qualifier_list must be used because of shift/reduce conflict with
    31013166                // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot
    31023167                // appear in this context.
    3103                 { $$ = DeclarationNode::newArray( $4, $3, true ); }
    3104         | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']'
    3105                 { $$ = DeclarationNode::newArray( $5, $4->addQualifiers( $3 ), true ); }
     3168                { $$ = DeclarationNode::newArray( $3, $2, true ); }
     3169        | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']'
     3170                { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $3 ), true ); }
    31063171        ;
    31073172
     
    31153180//
    31163181//              cfa_abstract_tuple identifier_or_type_name
    3117 //              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
     3182//              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    31183183//
    31193184// since a function return type can be syntactically identical to a tuple type:
     
    31723237
    31733238cfa_abstract_tuple:                                                                             // CFA
    3174         '[' push cfa_abstract_parameter_list pop ']'
    3175                 { $$ = DeclarationNode::newTuple( $3 ); }
    3176         | '[' push type_specifier_nobody ELLIPSIS ']'
    3177                 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
    3178         | '[' push type_specifier_nobody ELLIPSIS constant_expression ']'
    3179                 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
     3239        '[' cfa_abstract_parameter_list ']'
     3240                { $$ = DeclarationNode::newTuple( $2 ); }
    31803241        ;
    31813242
    31823243cfa_abstract_function:                                                                  // CFA
    3183 //      '[' ']' '(' cfa_parameter_ellipsis_list_opt ')'
     3244//      '[' ']' '(' cfa_parameter_type_list_opt ')'
    31843245//              { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    3185         cfa_abstract_tuple '(' push cfa_parameter_ellipsis_list_opt pop ')'
    3186                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    3187         | cfa_function_return '(' push cfa_parameter_ellipsis_list_opt pop ')'
    3188                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     3246        cfa_abstract_tuple '(' cfa_parameter_type_list_opt ')'
     3247                { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); }
     3248        | cfa_function_return '(' cfa_parameter_type_list_opt ')'
     3249                { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); }
    31893250        ;
    31903251
Note: See TracChangeset for help on using the changeset viewer.