Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r9a705dc8 ra16764a6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 17 17:10:30 2018
    13 // Update Count     : 3144
     12// Last Modified On : Thu Feb 22 17:48:54 2018
     13// Update Count     : 3028
    1414//
    1515
     
    126126        } // if
    127127} // rebindForall
    128 
    129 NameExpr * 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
    134128
    135129bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    260254%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    261255%type<sn> selection_statement
    262 %type<sn> switch_clause_list_opt                switch_clause_list
     256%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    263257%type<en> case_value
    264258%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
     259%type<sn> fall_through                                  fall_through_opt
    265260%type<sn> iteration_statement                   jump_statement
    266261%type<sn> expression_statement                  asm_statement
     
    391386%precedence '('
    392387
    393 %locations                                                                                              // support location tracking for error messages
     388%locations                      // support location tracking for error messages
    394389
    395390%start translation_unit                                                                 // parse-tree root
     
    486481        | '(' compound_statement ')'                                            // GCC, lambda expression
    487482                { $$ = 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 ) ); }
    498483        | type_name '.' no_attr_identifier                                      // CFA, nested type
    499                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
     484                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
    500485        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    501                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
     486                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
    502487        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    503                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
     488                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
    504489        ;
    505490
     
    550535        | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    551536                { $$ = 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 ) ) ); }
    554537        | '^' primary_expression '{' argument_expression_list '}' // CFA
    555538                {
     
    687670        | '(' type_no_function ')' cast_expression
    688671                { $$ = 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 ) ); }
    695672                // VIRTUAL cannot be opt because of look ahead issues
    696         | '(' VIRTUAL ')' cast_expression                                       // CFA
     673        | '(' VIRTUAL ')' cast_expression
    697674                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    698         | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
     675        | '(' VIRTUAL type_no_function ')' cast_expression
    699676                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    700677//      | '(' type_no_function ')' tuple
     
    788765        | logical_OR_expression '?' comma_expression ':' conditional_expression
    789766                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    790                 // FIX ME: computes $1 twice
     767                // FIX ME: this hack computes $1 twice
    791768        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    792769                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     
    803780                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    804781        | unary_expression '=' '{' initializer_list comma_opt '}'
    805                 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
     782                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
    806783        ;
    807784
     
    873850        | exception_statement
    874851        | enable_disable_statement
    875                 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
     852                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    876853        | asm_statement
    877854        ;
     
    940917                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    941918        | SWITCH '(' comma_expression ')' case_clause
    942                 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
     919                { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    943920        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    944921                {
    945                         StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
     922                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    946923                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    947924                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    952929                }
    953930        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    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 ) );
     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 ) );
    958935                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    959936                }
     
    993970        ;
    994971
    995 //label_list_opt:
    996 //      // empty
    997 //      | identifier_or_type_name ':'
    998 //      | label_list_opt identifier_or_type_name ':'
    999 //      ;
    1000 
    1001972case_label_list:                                                                                // CFA
    1002973        case_label
     
    1019990        | switch_clause_list case_label_list statement_list_nodecl
    1020991                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     992        ;
     993
     994choose_clause_list_opt:                                                                 // CFA
     995        // empty
     996                { $$ = nullptr; }
     997        | choose_clause_list
     998        ;
     999
     1000choose_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
     1011fall_through_opt:                                                                               // CFA
     1012        // empty
     1013                { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break
     1014        | fall_through
     1015        ;
     1016
     1017fall_through_name:                                                                              // CFA
     1018        FALLTHRU
     1019        | FALLTHROUGH
     1020        ;
     1021
     1022fall_through:                                                                                   // CFA
     1023        fall_through_name
     1024                { $$ = nullptr; }
     1025        | fall_through_name ';'
     1026                { $$ = nullptr; }
    10211027        ;
    10221028
     
    10441050                // whereas normal operator precedence yields goto (*i)+3;
    10451051                { $$ = 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 ) ); }
    10531052        | CONTINUE ';'
    10541053                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     
    10681067                { $$ = new StatementNode( build_return( $2 ) ); }
    10691068        | RETURN '{' initializer_list comma_opt '}'
    1070                 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
     1069                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10711070        | THROW assignment_expression_opt ';'                           // handles rethrow
    10721071                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10771076        ;
    10781077
    1079 fall_through_name:                                                                              // CFA
    1080         FALLTHRU
    1081         | FALLTHROUGH
    1082         ;
    1083 
    10841078with_statement:
    10851079        WITH '(' tuple_expression_list ')' statement
     
    10921086mutex_statement:
    10931087        MUTEX '(' argument_expression_list ')' statement
    1094                 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
     1088                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10951089        ;
    10961090
    10971091when_clause:
    1098         WHEN '(' comma_expression ')'                           { $$ = $3; }
     1092        WHEN '(' comma_expression ')'
     1093                { $$ = $3; }
    10991094        ;
    11001095
     
    11201115
    11211116timeout:
    1122         TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
     1117        TIMEOUT '(' comma_expression ')'
     1118                { $$ = $3; }
    11231119        ;
    11241120
     
    11631159        //empty
    11641160                { $$ = nullptr; }
    1165         | ';' conditional_expression                            { $$ = $2; }
     1161        | ';' conditional_expression
     1162                { $$ = $2; }
    11661163        ;
    11671164
    11681165handler_key:
    1169         CATCH                                                                           { $$ = CatchStmt::Terminate; }
    1170         | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
     1166        CATCH
     1167                { $$ = CatchStmt::Terminate; }
     1168        | CATCHRESUME
     1169                { $$ = CatchStmt::Resume; }
    11711170        ;
    11721171
    11731172finally_clause:
    1174         FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
     1173        FINALLY compound_statement
     1174                {
     1175                        $$ = new StatementNode( build_finally( $2 ) );
     1176                }
    11751177        ;
    11761178
     
    13141316static_assert:
    13151317        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1316                 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
     1318                { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
    13171319
    13181320// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    17081710        | LONG
    17091711                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
     1712        | ZERO_T
     1713                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     1714        | ONE_T
     1715                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17101716        | VALIST                                                                                        // GCC, __builtin_va_list
    17111717                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    17271733basic_type_specifier:
    17281734        direct_type
    1729                 // Cannot have type modifiers, e.g., short, long, etc.
    17301735        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    17311736                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
     
    17331738
    17341739direct_type:
     1740                // A semantic check is necessary for conflicting type qualifiers.
    17351741        basic_type_name
    17361742        | type_qualifier_list basic_type_name
     
    17511757        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    17521758                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    1753         | ZERO_T                                                                                        // CFA
    1754                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1755         | ONE_T                                                                                         // CFA
    1756                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17571759        ;
    17581760
     
    24112413                        $$ = $2;
    24122414                }
    2413         | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
     2415        | forall '{' external_definition_list '}'                       // CFA, namespace
    24142416        ;
    24152417
Note: See TracChangeset for help on using the changeset viewer.