Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r4e06c1e r8e9cbb2  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:26:32 2016
    13 // Update Count     : 1659
     12// Last Modified On : Thu Jun 30 21:15:54 2016
     13// Update Count     : 1657
    1414//
    1515
     
    712712                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    713713        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    714                 {
    715                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    716                         // The semantics of the declaration list is changed to include associated initialization, which is performed
    717                         // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    718                         // statement around the switch.  Statements after the initial declaration list can never be executed, and
    719                         // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
    720                         $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    721                 }
     714                { $$ = new StatementNode( StatementNode::Switch, $3, $8 ); /* xxx */ }
     715                // The semantics of the declaration list is changed to include any associated initialization, which is performed
     716                // *before* the transfer to the appropriate case clause.  Statements after the initial declaration list can
     717                // never be executed, and therefore, are removed from the grammar even though C allows it.
    722718        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    723                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     719                { $$ = new StatementNode( StatementNode::Choose, $3, $5 ); }
    724720        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    725                 {
    726                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    727                         $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    728                 }
     721                { $$ = new StatementNode( StatementNode::Choose, $3, $8 ); }
    729722        ;
    730723
     
    757750
    758751case_clause:                                                                                    // CFA
    759         case_label_list statement                                       { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
     752        case_label_list statement                                       { $$ = $1->append_last_case( $2 ); }
    760753        ;
    761754
     
    768761switch_clause_list:                                                                             // CFA
    769762        case_label_list statement_list
    770                 { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
     763                { $$ = $1->append_last_case( $2 ); }
    771764        | switch_clause_list case_label_list statement_list
    772                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); }
     765                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    773766        ;
    774767
     
    783776                { $$ = $1->append_last_case( $2 ); }
    784777        | case_label_list statement_list fall_through_opt
    785                 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }
     778                { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3 ))); }
    786779        | choose_clause_list case_label_list fall_through
    787780                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    788781        | choose_clause_list case_label_list statement_list fall_through_opt
    789                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }
     782                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case((StatementNode *)mkList((*$3,*$4 ))))); }
    790783        ;
    791784
    792785fall_through_opt:                                                                               // CFA
    793786        // empty
    794                 { $$ = new StatementNode( StatementNode::Break ); }     // insert implicit break
     787                { $$ = 0; }
    795788        | fall_through
    796789        ;
    797790
    798791fall_through:                                                                                   // CFA
    799         FALLTHRU
    800                 { $$ = 0; }
    801         | FALLTHRU ';'
    802                 { $$ = 0; }
     792        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru ); }
     793        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru ); }
    803794        ;
    804795
     
    823814                { $$ = new StatementNode( StatementNode::Goto, $2 ); }
    824815        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    825                 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
     816                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3 );
    826817                // whereas normal operator precedence yields goto (*i)+3;
    827818                { $$ = new StatementNode( StatementNode::Goto, $3 ); }
     
    829820                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    830821                { $$ = new StatementNode( StatementNode::Continue ); }
    831         | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
     822        | CONTINUE IDENTIFIER ';'                                       // CFA, multi-level continue
    832823                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    833824                // the target of the transfer appears only at the start of an iteration statement.
     
    836827                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    837828                { $$ = new StatementNode( StatementNode::Break ); }
    838         | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
     829        | BREAK IDENTIFIER ';'                                          // CFA, multi-level exit
    839830                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    840831                // the target of the transfer appears only at the start of an iteration statement.
     
    960951        ;
    961952
    962 asm_clobbers_list_opt:                                                                  // GCC
     953asm_clobbers_list_opt:                                                                          // GCC
    963954        // empty
    964955                { $$ = 0; }                                                                             // use default argument
     
    14611452                { typedefTable.makeTypedef( *$2 ); }
    14621453                '{' field_declaration_list '}'
    1463                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5 ); }
     1454                { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5); }
    14641455        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    14651456                { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }
     
    18491840                { $$ = 0; }
    18501841        | assertion_list_opt assertion
    1851                 { $$ = $1 != 0 ? $1->appendList( $2 ) : $2; }
     1842                { $$ = $1 == 0 ? $2 : $1->appendList( $2 ); }
    18521843        ;
    18531844
Note: See TracChangeset for help on using the changeset viewer.