Ignore:
Timestamp:
Aug 10, 2016, 11:31:15 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
27fefeb6
Parents:
2f22cc4
Message:

more refactoring of parser code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r2f22cc4 r321f55d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 10 13:09:53 2016
    13 // Update Count     : 1844
     12// Last Modified On : Wed Aug 10 23:03:05 2016
     13// Update Count     : 1846
    1414//
    1515
     
    723723        IF '(' comma_expression ')' statement                           %prec THEN
    724724                // explicitly deal with the shift/reduce conflict on if/else
    725                 //{ $$ = new StatementNode( StatementNode::If, $3, $5 ); }
    726725                { $$ = new StatementNode2( build_if( $3, $5, nullptr ) ); }
    727726        | IF '(' comma_expression ')' statement ELSE statement
    728                 //{ $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
    729727                { $$ = new StatementNode2( build_if( $3, $5, $7 ) ); }
    730728        | SWITCH '(' comma_expression ')' case_clause           // CFA
    731                 //{ $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    732729                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    733730        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
     
    742739                }
    743740        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    744                 //{ $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    745741                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    746742        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    747743                {
    748                         //StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    749744                        StatementNode *sw = new StatementNode2( build_switch( $3, $8 ) );
    750745                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
     
    844839jump_statement:
    845840        GOTO IDENTIFIER ';'
    846                 { $$ = new StatementNode( StatementNode::Goto, $2 ); }
     841                //{ $$ = new StatementNode( StatementNode::Goto, $2 ); }
     842                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Goto ) ); }
    847843        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    848844                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
     
    851847        | CONTINUE ';'
    852848                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    853                 { $$ = new StatementNode( StatementNode::Continue ); }
     849                //{ $$ = new StatementNode( StatementNode::Continue ); }
     850                { $$ = new StatementNode2( build_branch( "", BranchStmt::Continue ) ); }
    854851        | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
    855852                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    856853                // the target of the transfer appears only at the start of an iteration statement.
    857                 { $$ = new StatementNode( StatementNode::Continue, $2 ); }
     854                //{ $$ = new StatementNode( StatementNode::Continue, $2 ); }
     855                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Continue ) ); delete $2; }
    858856        | BREAK ';'
    859857                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    860                 { $$ = new StatementNode( StatementNode::Break ); }
     858                //{ $$ = new StatementNode( StatementNode::Break ); }
     859                { $$ = new StatementNode2( build_branch( "", BranchStmt::Break ) ); }
    861860        | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
    862861                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    863862                // the target of the transfer appears only at the start of an iteration statement.
    864                 { $$ = new StatementNode( StatementNode::Break, $2 ); }
     863                //{ $$ = new StatementNode( StatementNode::Break, $2 ); }
     864                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Break ) ); delete $2; }
    865865        | RETURN comma_expression_opt ';'
    866866                { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
Note: See TracChangeset for help on using the changeset viewer.