Changeset 917f67dd


Ignore:
Timestamp:
Sep 30, 2024, 10:19:48 AM (6 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
e748094
Parents:
86841ee
Message:

remove what appear to be superfluous push/pop in grammar rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Parser/parser.yy

    r86841ee r917f67dd  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 23 22:47:42 2024
    13 // Update Count     : 6753
     12// Last Modified On : Mon Sep 30 09:40:28 2024
     13// Update Count     : 6776
    1414//
    1515
     
    11711171//      '[' ']'
    11721172//              { $$ = new ExpressionNode( build_tuple() ); }
    1173 //      | '[' push assignment_expression pop ']'
    1174 //              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
     1173//      '[' assignment_expression ']'
     1174//              { $$ = new ExpressionNode( build_tuple( $2 ) ); }
    11751175        '[' ',' tuple_expression_list ']'
    11761176                { $$ = new ExpressionNode( build_tuple( yylloc, (new ExpressionNode( nullptr ))->set_last( $3 ) ) ); }
    1177         | '[' push assignment_expression pop ',' tuple_expression_list ']'
    1178                 { $$ = new ExpressionNode( build_tuple( yylloc, $3->set_last( $6 ) ) ); }
     1177        | '[' assignment_expression ',' tuple_expression_list ']'
     1178                { $$ = new ExpressionNode( build_tuple( yylloc, $2->set_last( $4 ) ) ); }
    11791179        ;
    11801180
     
    21092109
    21102110cfa_function_return:                                                                    // CFA
    2111         '[' push cfa_parameter_list pop ']'
    2112                 { $$ = DeclarationNode::newTuple( $3 ); }
    2113         | '[' push cfa_parameter_list ',' cfa_abstract_parameter_list pop ']'
     2111        '[' cfa_parameter_list ']'
     2112                { $$ = DeclarationNode::newTuple( $2 ); }
     2113        | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']'
    21142114                // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'.
    2115                 { $$ = DeclarationNode::newTuple( $3->set_last( $5 ) ); }
     2115                { $$ = DeclarationNode::newTuple( $2->set_last( $4 ) ); }
    21162116        ;
    21172117
     
    30653065        '.' identifier_at                                                                       // C99, field name
    30663066                { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); }
    3067         | '[' push assignment_expression pop ']'                        // C99, single array element
     3067        | '[' assignment_expression ']'                                         // C99, single array element
    30683068                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     3069                { $$ = $2; }
     3070        | '[' subrange ']'                                                                      // CFA, multiple array elements
     3071                { $$ = $2; }
     3072        | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements
     3073                { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $2 ), maybeMoveBuild( $4 ) ) ); }
     3074        | '.' '[' field_name_list ']'                                           // CFA, tuple field selector
    30693075                { $$ = $3; }
    3070         | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    3071                 { $$ = $3; }
    3072         | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    3073                 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }
    3074         | '.' '[' push field_name_list pop ']'                          // CFA, tuple field selector
    3075                 { $$ = $4; }
    30763076        ;
    30773077
     
    40054005                { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); }
    40064006                // Cannot use constant_expression because of tuples => semantic check
    4007         | '[' push assignment_expression pop ',' comma_expression ']' // CFA
    4008                 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); }
     4007        | '[' assignment_expression ',' comma_expression ']' // CFA
     4008                { $$ = DeclarationNode::newArray( $2, nullptr, false )->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }
    40094009                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    40104010
     
    40124012        // | '[' push assignment_expression pop ',' push array_dimension_list pop ']' // CFA
    40134013
    4014         | '[' push array_type_list pop ']'                                      // CFA
    4015                 { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
     4014        | '[' array_type_list ']'                                                       // CFA
     4015                { $$ = DeclarationNode::newArray( $2, nullptr, false ); }
    40164016        | multi_array_dimension
    40174017        ;
     
    40434043
    40444044multi_array_dimension:
    4045         '[' push assignment_expression pop ']'
    4046                 { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
    4047         | '[' push '*' pop ']'                                                          // C99
     4045        '[' assignment_expression ']'
     4046                { $$ = DeclarationNode::newArray( $2, nullptr, false ); }
     4047        | '[' '*' ']'                                                                           // C99
    40484048                { $$ = DeclarationNode::newVarArray( 0 ); }
    4049         | multi_array_dimension '[' push assignment_expression pop ']'
    4050                 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }
    4051         | multi_array_dimension '[' push '*' pop ']'            // C99
     4049        | multi_array_dimension '[' assignment_expression ']'
     4050                { $$ = $1->addArray( DeclarationNode::newArray( $3, nullptr, false ) ); }
     4051        | multi_array_dimension '[' '*' ']'                                     // C99
    40524052                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
    40534053        ;
     
    42664266
    42674267cfa_array_parameter_1st_dimension:
    4268         '[' push type_qualifier_list '*' pop ']'                        // remaining C99
    4269                 { $$ = DeclarationNode::newVarArray( $3 ); }
    4270         | '[' push type_qualifier_list assignment_expression pop ']'
    4271                 { $$ = DeclarationNode::newArray( $4, $3, false ); }
    4272         | '[' push declaration_qualifier_list assignment_expression pop ']'
     4268        '[' type_qualifier_list '*' ']'                                         // remaining C99
     4269                { $$ = DeclarationNode::newVarArray( $2 ); }
     4270        | '[' type_qualifier_list assignment_expression ']'
     4271                { $$ = DeclarationNode::newArray( $3, $2, false ); }
     4272        | '[' declaration_qualifier_list assignment_expression ']'
    42734273                // declaration_qualifier_list must be used because of shift/reduce conflict with
    42744274                // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot
    42754275                // appear in this context.
    4276                 { $$ = DeclarationNode::newArray( $4, $3, true ); }
    4277         | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']'
    4278                 { $$ = DeclarationNode::newArray( $5, $4->addQualifiers( $3 ), true ); }
     4276                { $$ = DeclarationNode::newArray( $3, $2, true ); }
     4277        | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']'
     4278                { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $2 ), true ); }
    42794279        ;
    42804280
     
    43454345
    43464346cfa_abstract_tuple:                                                                             // CFA
    4347         '[' push cfa_abstract_parameter_list pop ']'
    4348                 { $$ = DeclarationNode::newTuple( $3 ); }
    4349         | '[' push type_specifier_nobody ELLIPSIS pop ']'
     4347        '[' cfa_abstract_parameter_list ']'
     4348                { $$ = DeclarationNode::newTuple( $2 ); }
     4349        | '[' type_specifier_nobody ELLIPSIS ']'
    43504350                { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
    4351         | '[' push type_specifier_nobody ELLIPSIS constant_expression pop ']'
     4351        | '[' type_specifier_nobody ELLIPSIS constant_expression ']'
    43524352                { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
    43534353        ;
Note: See TracChangeset for help on using the changeset viewer.