Changeset 9f4af04


Ignore:
Timestamp:
Mar 6, 2024, 1:59:33 PM (2 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
169496e1
Parents:
e72fc60 (diff), b93c544 (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

    re72fc60 r9f4af04  
    763763                // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
    764764                // Current: Commas in subscripts make tuples.
    765                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
     765                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, $3->set_last( $5 ) ) ) ) ); }
    766766        | postfix_expression '[' assignment_expression ']'
    767767                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
     
    778778                        Token fn;
    779779                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    780                         $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
     780                        $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), $1->set_last( $3 ) ) ) );
    781781                }
    782782        | postfix_expression '(' argument_expression_list_opt ')'
     
    784784        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
    785785                // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
    786                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg") ) ),
    787                                                                                            (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }
     786                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg" ) ) ),
     787                                                                                           $3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) ) ) ); }
    788788        | postfix_expression '`' identifier                                     // CFA, postfix call
    789789                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
     
    843843                        Token fn;
    844844                        fn.str = new string( "^?{}" );                          // location undefined
    845                         $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );
     845                        $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), $2->set_last( $4 ) ) );
    846846                }
    847847        ;
     
    856856        argument_expression
    857857        | argument_expression_list_opt ',' argument_expression
    858                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     858                { $$ = $1->set_last( $3 ); }
    859859        ;
    860860
     
    868868field_name_list:                                                                                // CFA, tuple field selector
    869869        field
    870         | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     870        | field_name_list ',' field                                     { $$ = $1->set_last( $3 ); }
    871871        ;
    872872
     
    11621162//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    11631163        '[' ',' tuple_expression_list ']'
    1164                 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
     1164                { $$ = new ExpressionNode( build_tuple( yylloc, (new ExpressionNode( nullptr ))->set_last( $3 ) ) ); }
    11651165        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    1166                 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $6 ) ) )); }
     1166                { $$ = new ExpressionNode( build_tuple( yylloc, $3->set_last( $6 ) ) ); }
    11671167        ;
    11681168
     
    11721172                { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; }
    11731173        | tuple_expression_list ',' assignment_expression
    1174                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1174                { $$ = $1->set_last( $3 ); }
    11751175        | tuple_expression_list ',' '@'
    11761176                { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; }
     
    13071307                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    13081308                        // statement.
    1309                         $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     1309                        $$ = $7 ? new StatementNode( build_compound( yylloc, (new StatementNode( $7 ))->set_last( sw ) ) ) : sw;
    13101310                }
    13111311        | SWITCH '(' comma_expression ')' '{' error '}'         // CFA, invalid syntax rule error
     
    13161316                {
    13171317                        StatementNode *sw = new StatementNode( build_switch( yylloc, false, $3, $8 ) );
    1318                         $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     1318                        $$ = $7 ? new StatementNode( build_compound( yylloc, (new StatementNode( $7 ))->set_last( sw ) ) ) : sw;
    13191319                }
    13201320        | CHOOSE '(' comma_expression ')' '{' error '}'         // CFA, invalid syntax rule
     
    17181718        cast_expression
    17191719        | cast_expression_list ',' cast_expression
    1720                 // { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    17211720                { SemanticError( yylloc, "List of mutex member is currently unimplemented." ); $$ = nullptr; }
    17221721        ;
     
    17341733                { $$ = $3; }
    17351734        | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')'
    1736                 { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1735                { $$ = $3->set_last( $5 ); }
    17371736        ;
    17381737
     
    18901889        asm_operand
    18911890        | asm_operands_list ',' asm_operand
    1892                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1891                { $$ = $1->set_last( $3 ); }
    18931892        ;
    18941893
     
    19091908                { $$ = $1; }
    19101909        | asm_clobbers_list_opt ',' string_literal
    1911                 { $$ = (ExpressionNode *)( $1->set_last( $3 ) ); }
     1910                { $$ = $1->set_last( $3 ); }
    19121911        ;
    19131912
     
    29752974        | initializer
    29762975        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    2977         | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    2978         | initializer_list_opt ',' designation initializer { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
     2976        | initializer_list_opt ',' initializer          { $$ = $1->set_last( $3 ); }
     2977        | initializer_list_opt ',' designation initializer { $$ = $1->set_last( $4->set_designators( $3 ) ); }
    29792978        ;
    29802979
     
    29982997        designator
    29992998        | designator_list designator
    3000                 { $$ = (ExpressionNode *)($1->set_last( $2 )); }
     2999                { $$ = $1->set_last( $2 ); }
    30013000        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    30023001        ;
     
    31273126        | assignment_expression
    31283127        | type_list ',' type
    3129                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
     3128                { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); }
    31303129        | type_list ',' assignment_expression
    3131                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     3130                { $$ = $1->set_last( $3 ); }
    31323131        ;
    31333132
     
    39663965        | assignment_expression upupeq assignment_expression
    39673966        | array_type_list ',' basic_type_name
    3968                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
     3967                { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); }
    39693968        | array_type_list ',' type_name
    3970                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
     3969                { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); }
    39713970        | array_type_list ',' assignment_expression upupeq assignment_expression
    39723971        ;
Note: See TracChangeset for help on using the changeset viewer.