Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    ree3c93d rba3706f  
    3434Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    36 void Statement::print( std::ostream & os, Indenter indent ) const {
     36void Statement::print( std::ostream & os, Indenter ) const {
    3737        if ( ! labels.empty() ) {
    38                 os << indent << "... Labels: {";
     38                os << "Labels: {";
    3939                for ( const Label & l : labels ) {
    4040                        os << l << ",";
     
    9494
    9595
    96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
    97 
    98 void DirectiveStmt::print( std::ostream &os, Indenter ) const {
    99         os << "GCC Directive:" << directive << endl;
    100 }
    101 
    102 
    10396const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    10497
    105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
     98BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) :
    10699        Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
    107100        //actually this is a syntactic error signaled by the parser
    108101        if ( type == BranchStmt::Goto && target.empty() ) {
    109                 SemanticError( target.get_statement()->location, "goto without target");
    110         }
    111 }
    112 
    113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) :
     102                throw SemanticError("goto without target");
     103        }
     104}
     105
     106BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) :
    114107        Statement(), computedTarget( computedTarget ), type( type ) {
    115108        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    116                 SemanticError( computedTarget->location, "Computed target not valid in branch statement");
     109                throw SemanticError("Computed target not valid in branch statement");
    117110        }
    118111}
     
    208201}
    209202
    210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :
     203CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    211204        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    212         if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " );
     205        if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
    213206}
    214207
     
    230223
    231224void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    232         if ( isDefault() ) os << indent << "Default ";
     225        if ( isDefault() ) os << "Default ";
    233226        else {
    234                 os << indent << "Case ";
     227                os << "Case ";
    235228                condition->print( os, indent );
    236229        } // if
     
    238231
    239232        for ( Statement * stmt : stmts ) {
    240                 os << indent+1;
    241233                stmt->print( os, indent+1 );
    242234        }
    243235}
    244236
    245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
    246         Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
     237WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):
     238        Statement(), condition( condition), body( body), isDoWhile( isDoWhile) {
    247239}
    248240
     
    460452void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    461453        os << "Waitfor Statement" << endl;
    462         indent += 1;
    463         for( auto & clause : clauses ) {
    464                 os << indent << "target function :";
    465                 if(clause.target.function) { clause.target.function->print(os, indent + 1); }
    466                 os << endl << indent << "with arguments :" << endl;
    467                 for( auto & thing : clause.target.arguments) {
    468                         if(thing) { thing->print(os, indent + 1); }
    469                 }
    470                 os << indent << " with statment :" << endl;
    471                 if(clause.statement) { clause.statement->print(os, indent + 1); }
    472 
    473                 os << indent << " with condition :" << endl;
    474                 if(clause.condition) { clause.condition->print(os, indent + 1); }
    475         }
    476 
    477         os << indent << " timeout of :" << endl;
    478         if(timeout.time) { timeout.time->print(os, indent + 1); }
    479 
    480         os << indent << " with statment :" << endl;
    481         if(timeout.statement) { timeout.statement->print(os, indent + 1); }
    482 
    483         os << indent << " with condition :" << endl;
    484         if(timeout.condition) { timeout.condition->print(os, indent + 1); }
    485 
    486 
    487         os << indent << " else :" << endl;
    488         if(orelse.statement) { orelse.statement->print(os, indent + 1); }
    489 
    490         os << indent << " with condition :" << endl;
    491         if(orelse.condition) { orelse.condition->print(os, indent + 1); }
    492 }
    493 
    494 
    495 WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Statement(), exprs( exprs ), stmt( stmt ) {}
    496 WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
    497         cloneAll( other.exprs, exprs );
    498 }
    499 WithStmt::~WithStmt() {
    500         deleteAll( exprs );
    501         delete stmt;
    502 }
    503 
    504 void WithStmt::print( std::ostream & os, Indenter indent ) const {
    505         os << "With statement" << endl;
    506         os << indent << "... with expressions: " << endl;
    507         printAll( exprs, os, indent+1 );
    508         os << indent << "... with statement:" << endl << indent+1;
    509         stmt->print( os, indent+1 );
    510 }
    511 
     454        os << indent << "... with block:" << endl << indent+1;
     455        // block->print( os, indent + 4 );
     456}
    512457
    513458NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) {
    514459}
    515460
    516 void NullStmt::print( std::ostream &os, Indenter indent ) const {
     461void NullStmt::print( std::ostream &os, Indenter ) const {
    517462        os << "Null Statement" << endl;
    518         Statement::print( os, indent );
    519463}
    520464
Note: See TracChangeset for help on using the changeset viewer.