Ignore:
Timestamp:
Aug 14, 2024, 11:55:20 AM (17 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
960665c
Parents:
26d40a1 (diff), 2870cb6 (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

    r26d40a1 rd1f5054  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 26 14:09:30 2024
    13 // Update Count     : 6733
     12// Last Modified On : Tue Aug 13 11:25:16 2024
     13// Update Count     : 6740
    1414//
    1515
     
    952952                }
    953953        | COUNTOF unary_expression
    954                 {  $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
     954                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
    955955        | COUNTOF '(' type_no_function ')'
    956956                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     
    16261626enum_key:
    16271627        type_name
    1628                 {       typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
    1629                         $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false ); }
     1628                {
     1629                        typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
     1630                        $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false );
     1631                }
    16301632        | ENUM identifier
    1631                 {       typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
    1632                         $$ = DeclarationNode::newEnum( $2, nullptr, false, false ); }
     1633                {
     1634                        typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
     1635                        $$ = DeclarationNode::newEnum( $2, nullptr, false, false );
     1636                }
    16331637        | ENUM type_name
    1634                 {       typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
    1635                         $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false ); }
     1638                {
     1639                        typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
     1640                        $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false );
     1641                }
    16361642        ;
    16371643
     
    18491855
    18501856handler_clause:
    1851         handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1852                 { $$ = new ClauseNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
    1853         | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1854                 { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
     1857        handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
     1858                { $$ = new ClauseNode( build_catch( yylloc, $1, $3, $4, $6 ) ); }
     1859        | handler_clause handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
     1860                { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $4, $5, $7 ) ) ); }
    18551861        ;
    18561862
     
    28502856
    28512857enumerator_list:
    2852         visible_hide_opt identifier_or_type_name enumerator_value_opt
     2858        // empty
     2859                { SemanticError( yylloc, "enumeration must have a minimum of one enumerator, empty enumerator list is meaningless." );  $$ = nullptr; }
     2860        | visible_hide_opt identifier_or_type_name enumerator_value_opt
    28532861                { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); }
    28542862        | INLINE type_name
     
    31553163        '|' identifier_or_type_name '(' type_list ')'
    31563164                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    3157         | '|' '{' push trait_declaration_list pop '}'
    3158                 { $$ = $4; }
     3165        | '|' '{' trait_declaration_list '}'
     3166                { $$ = $3; }
    31593167        // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
    31603168        //      { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
     
    32083216        | forall TRAIT identifier_or_type_name '{' '}'          // alternate
    32093217                { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); }
    3210         | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
     3218        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' trait_declaration_list '}'
    32113219                {
    32123220                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax );
    3213                         $$ = DeclarationNode::newTrait( $2, $4, $8 );
    3214                 }
    3215         | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
    3216                 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); }
     3221                        $$ = DeclarationNode::newTrait( $2, $4, $7 );
     3222                }
     3223        | forall TRAIT identifier_or_type_name '{' trait_declaration_list '}' // alternate
     3224                { $$ = DeclarationNode::newTrait( $3, $1, $5 ); }
    32173225        ;
    32183226
    32193227trait_declaration_list:                                                                 // CFA
    32203228        trait_declaration
    3221         | trait_declaration_list pop push trait_declaration
    3222                 { $$ = $1->set_last( $4 ); }
     3229        | trait_declaration_list trait_declaration
     3230                { $$ = $1->set_last( $2 ); }
    32233231        ;
    32243232
     
    32313239        cfa_variable_specifier
    32323240        | cfa_function_specifier
    3233         | cfa_trait_declaring_list pop ',' push identifier_or_type_name
    3234                 { $$ = $1->set_last( $1->cloneType( $5 ) ); }
     3241        | cfa_trait_declaring_list ',' identifier_or_type_name
     3242                { $$ = $1->set_last( $1->cloneType( $3 ) ); }
    32353243        ;
    32363244
    32373245trait_declaring_list:                                                                   // CFA
    3238         type_specifier declarator
     3246                // Cannot declare an aggregate or enumeration in a trait.
     3247        type_specifier_nobody declarator
    32393248                { $$ = $2->addType( $1 ); }
    3240         | trait_declaring_list pop ',' push declarator
    3241                 { $$ = $1->set_last( $1->cloneBaseType( $5 ) ); }
     3249        | trait_declaring_list ',' declarator
     3250                { $$ = $1->set_last( $1->cloneBaseType( $3 ) ); }
     3251        | error
     3252                { SemanticError( yylloc, "Possible cause is declaring an aggregate or enumeration type in a trait." ); $$ = nullptr; }
    32423253        ;
    32433254
Note: See TracChangeset for help on using the changeset viewer.