Ignore:
Timestamp:
Apr 25, 2018, 4:55:53 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
42107b4
Parents:
2efe4b8 (diff), 9d5fb67 (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 remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 17:48:54 2018
    13 // Update Count     : 3028
     12// Last Modified On : Tue Apr 17 17:10:30 2018
     13// Update Count     : 3144
    1414//
    1515
     
    126126        } // if
    127127} // rebindForall
     128
     129NameExpr * build_postfix_name( const string * name ) {
     130        NameExpr * new_name = build_varref( new string( "?`" + *name ) );
     131        delete name;
     132        return new_name;
     133} // build_postfix_name
    128134
    129135bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    254260%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    255261%type<sn> selection_statement
    256 %type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
     262%type<sn> switch_clause_list_opt                switch_clause_list
    257263%type<en> case_value
    258264%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    259 %type<sn> fall_through                                  fall_through_opt
    260265%type<sn> iteration_statement                   jump_statement
    261266%type<sn> expression_statement                  asm_statement
     
    386391%precedence '('
    387392
    388 %locations                      // support location tracking for error messages
     393%locations                                                                                              // support location tracking for error messages
    389394
    390395%start translation_unit                                                                 // parse-tree root
     
    481486        | '(' compound_statement ')'                                            // GCC, lambda expression
    482487                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
     488        | constant '`' IDENTIFIER                                                       // CFA, postfix call
     489                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     490        | string_literal '`' IDENTIFIER                                         // CFA, postfix call
     491                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
     492        | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
     493                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
     494        | tuple '`' IDENTIFIER                                                          // CFA, postfix call
     495                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     496        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
     497                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    483498        | type_name '.' no_attr_identifier                                      // CFA, nested type
    484                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     499                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    485500        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    486                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     501                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    487502        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    488                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     503                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
    489504        ;
    490505
     
    535550        | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    536551                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     552        | '(' type_no_function ')' '@' '{' initializer_list comma_opt '}' // CFA, explicit C compound-literal
     553                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    537554        | '^' primary_expression '{' argument_expression_list '}' // CFA
    538555                {
     
    670687        | '(' type_no_function ')' cast_expression
    671688                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     689        | '(' COROUTINE '&' ')' cast_expression                         // CFA
     690                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
     691        | '(' THREAD '&' ')' cast_expression                            // CFA
     692                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
     693        | '(' MONITOR '&' ')' cast_expression                           // CFA
     694                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
    672695                // VIRTUAL cannot be opt because of look ahead issues
    673         | '(' VIRTUAL ')' cast_expression
     696        | '(' VIRTUAL ')' cast_expression                                       // CFA
    674697                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    675         | '(' VIRTUAL type_no_function ')' cast_expression
     698        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    676699                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    677700//      | '(' type_no_function ')' tuple
     
    765788        | logical_OR_expression '?' comma_expression ':' conditional_expression
    766789                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    767                 // FIX ME: this hack computes $1 twice
     790                // FIX ME: computes $1 twice
    768791        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    769792                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     
    780803                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    781804        | unary_expression '=' '{' initializer_list comma_opt '}'
    782                 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     805                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
    783806        ;
    784807
     
    850873        | exception_statement
    851874        | enable_disable_statement
    852                 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     875                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    853876        | asm_statement
    854877        ;
     
    917940                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    918941        | SWITCH '(' comma_expression ')' case_clause
    919                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     942                { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
    920943        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    921944                {
    922                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     945                        StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
    923946                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    924947                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    929952                }
    930953        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    931                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    932         | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    933                 {
    934                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     954                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
     955        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
     956                {
     957                        StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
    935958                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    936959                }
     
    970993        ;
    971994
     995//label_list_opt:
     996//      // empty
     997//      | identifier_or_type_name ':'
     998//      | label_list_opt identifier_or_type_name ':'
     999//      ;
     1000
    9721001case_label_list:                                                                                // CFA
    9731002        case_label
     
    9901019        | switch_clause_list case_label_list statement_list_nodecl
    9911020                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    992         ;
    993 
    994 choose_clause_list_opt:                                                                 // CFA
    995         // empty
    996                 { $$ = nullptr; }
    997         | choose_clause_list
    998         ;
    999 
    1000 choose_clause_list:                                                                             // CFA
    1001         case_label_list fall_through
    1002                 { $$ = $1->append_last_case( $2 ); }
    1003         | case_label_list statement_list_nodecl fall_through_opt
    1004                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
    1005         | choose_clause_list case_label_list fall_through
    1006                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    1007         | choose_clause_list case_label_list statement_list_nodecl fall_through_opt
    1008                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
    1009         ;
    1010 
    1011 fall_through_opt:                                                                               // CFA
    1012         // empty
    1013                 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break
    1014         | fall_through
    1015         ;
    1016 
    1017 fall_through_name:                                                                              // CFA
    1018         FALLTHRU
    1019         | FALLTHROUGH
    1020         ;
    1021 
    1022 fall_through:                                                                                   // CFA
    1023         fall_through_name
    1024                 { $$ = nullptr; }
    1025         | fall_through_name ';'
    1026                 { $$ = nullptr; }
    10271021        ;
    10281022
     
    10501044                // whereas normal operator precedence yields goto (*i)+3;
    10511045                { $$ = new StatementNode( build_computedgoto( $3 ) ); }
     1046                // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
     1047    | fall_through_name ';'                                                             // CFA
     1048                { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
     1049    | fall_through_name identifier_or_type_name ';'             // CFA
     1050                { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
     1051        | fall_through_name DEFAULT ';'                                         // CFA
     1052                { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }
    10521053        | CONTINUE ';'
    10531054                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     
    10671068                { $$ = new StatementNode( build_return( $2 ) ); }
    10681069        | RETURN '{' initializer_list comma_opt '}'
    1069                 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1070                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    10701071        | THROW assignment_expression_opt ';'                           // handles rethrow
    10711072                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10761077        ;
    10771078
     1079fall_through_name:                                                                              // CFA
     1080        FALLTHRU
     1081        | FALLTHROUGH
     1082        ;
     1083
    10781084with_statement:
    10791085        WITH '(' tuple_expression_list ')' statement
     
    10861092mutex_statement:
    10871093        MUTEX '(' argument_expression_list ')' statement
    1088                 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1094                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
    10891095        ;
    10901096
    10911097when_clause:
    1092         WHEN '(' comma_expression ')'
    1093                 { $$ = $3; }
     1098        WHEN '(' comma_expression ')'                           { $$ = $3; }
    10941099        ;
    10951100
     
    11151120
    11161121timeout:
    1117         TIMEOUT '(' comma_expression ')'
    1118                 { $$ = $3; }
     1122        TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
    11191123        ;
    11201124
     
    11591163        //empty
    11601164                { $$ = nullptr; }
    1161         | ';' conditional_expression
    1162                 { $$ = $2; }
     1165        | ';' conditional_expression                            { $$ = $2; }
    11631166        ;
    11641167
    11651168handler_key:
    1166         CATCH
    1167                 { $$ = CatchStmt::Terminate; }
    1168         | CATCHRESUME
    1169                 { $$ = CatchStmt::Resume; }
     1169        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1170        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
    11701171        ;
    11711172
    11721173finally_clause:
    1173         FINALLY compound_statement
    1174                 {
    1175                         $$ = new StatementNode( build_finally( $2 ) );
    1176                 }
     1174        FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
    11771175        ;
    11781176
     
    13161314static_assert:
    13171315        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1318                 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1316                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    13191317
    13201318// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    17101708        | LONG
    17111709                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    1712         | ZERO_T
    1713                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1714         | ONE_T
    1715                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17161710        | VALIST                                                                                        // GCC, __builtin_va_list
    17171711                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    17331727basic_type_specifier:
    17341728        direct_type
     1729                // Cannot have type modifiers, e.g., short, long, etc.
    17351730        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    17361731                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
     
    17381733
    17391734direct_type:
    1740                 // A semantic check is necessary for conflicting type qualifiers.
    17411735        basic_type_name
    17421736        | type_qualifier_list basic_type_name
     
    17571751        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    17581752                { $$ = DeclarationNode::newAttr( $1, $3 ); }
     1753        | ZERO_T                                                                                        // CFA
     1754                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     1755        | ONE_T                                                                                         // CFA
     1756                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17591757        ;
    17601758
     
    24132411                        $$ = $2;
    24142412                }
    2415         | forall '{' external_definition_list '}'                       // CFA, namespace
     2413        | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
    24162414        ;
    24172415
Note: See TracChangeset for help on using the changeset viewer.