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/StatementNode.cc

    r2f22cc4 r321f55d  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 10 13:54:21 2016
    13 // Update Count     : 170
     12// Last Modified On : Wed Aug 10 22:08:38 2016
     13// Update Count     : 173
    1414//
    1515
     
    224224          case Case:
    225225                return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches );
     226                assert( false );
    226227          case Default:
    227228                return new CaseStmt( labs, 0, branches, true );
     229                assert( false );
    228230          case While:
    229231                // assert( branches.size() == 1 );
     
    268270          case Break:
    269271                return new BranchStmt( labs, get_target(), BranchStmt::Break );
     272                assert( false );
    270273          case Continue:
    271274                return new BranchStmt( labs, get_target(), BranchStmt::Continue );
     275                assert( false );
    272276          case Return:
    273277          case Throw :
     
    314318        std::list<Statement *> branches;
    315319        buildList<Statement, StatementNode>( then_stmt, branches );
    316         assert( branches.size() >= 1 );
     320        assert( branches.size() == 1 );
    317321        thenb = branches.front();
    318322
     
    320324                std::list<Statement *> branches;
    321325                buildList<Statement, StatementNode>( else_stmt, branches );
    322                 assert( branches.size() >= 1 );
     326                assert( branches.size() == 1 );
    323327                elseb = branches.front();
    324328        } // if
     
    329333        std::list<Statement *> branches;
    330334        buildList<Statement, StatementNode>( stmt, branches );
    331         assert( branches.size() >= 1 );
     335        assert( branches.size() >= 0 );                                         // size == 0 for switch (...) {}, i.e., no declaration or statements
    332336        return new SwitchStmt( noLabels, maybeBuild<Expression>(ctl), branches );
     337}
     338Statement *build_case( ExpressionNode *ctl ) {
     339        std::list<Statement *> branches;
     340        buildList<Statement, StatementNode>( nullptr, branches );
     341        return new CaseStmt( noLabels, maybeBuild<Expression>(ctl), branches );
     342}
     343Statement *build_default() {
     344        std::list<Statement *> branches;
     345        return new CaseStmt( noLabels, nullptr, branches, true );
    333346}
    334347
     
    360373        delete forctl;
    361374        return new ForStmt( noLabels, init, cond, incr, branches.front() );
     375}
     376
     377Statement *build_branch( std::string identifier, BranchStmt::Type kind ) {
     378        return new BranchStmt( noLabels, identifier, kind );
    362379}
    363380
Note: See TracChangeset for help on using the changeset viewer.