Changes in src/SynTree/Statement.cc [ee3c93d:ba3706f]
- File:
-
- 1 edited
-
src/SynTree/Statement.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
ree3c93d rba3706f 34 34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} 35 35 36 void Statement::print( std::ostream & os, Indenter indent) const {36 void Statement::print( std::ostream & os, Indenter ) const { 37 37 if ( ! labels.empty() ) { 38 os << indent << "...Labels: {";38 os << "Labels: {"; 39 39 for ( const Label & l : labels ) { 40 40 os << l << ","; … … 94 94 95 95 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 103 96 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 104 97 105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError Exception) :98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) : 106 99 Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 107 100 //actually this is a syntactic error signaled by the parser 108 101 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 ( SemanticError Exception) :102 throw SemanticError("goto without target"); 103 } 104 } 105 106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) : 114 107 Statement(), computedTarget( computedTarget ), type( type ) { 115 108 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"); 117 110 } 118 111 } … … 208 201 } 209 202 210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError Exception) :203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) : 211 204 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); 213 206 } 214 207 … … 230 223 231 224 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 232 if ( isDefault() ) os << indent <<"Default ";225 if ( isDefault() ) os << "Default "; 233 226 else { 234 os << indent <<"Case ";227 os << "Case "; 235 228 condition->print( os, indent ); 236 229 } // if … … 238 231 239 232 for ( Statement * stmt : stmts ) { 240 os << indent+1;241 233 stmt->print( os, indent+1 ); 242 234 } 243 235 } 244 236 245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization,bool isDoWhile ):246 Statement(), condition( condition), body( body), i nitialization( initialization ), isDoWhile( isDoWhile) {237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ): 238 Statement(), condition( condition), body( body), isDoWhile( isDoWhile) { 247 239 } 248 240 … … 460 452 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 461 453 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 } 512 457 513 458 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { 514 459 } 515 460 516 void NullStmt::print( std::ostream &os, Indenter indent) const {461 void NullStmt::print( std::ostream &os, Indenter ) const { 517 462 os << "Null Statement" << endl; 518 Statement::print( os, indent );519 463 } 520 464
Note:
See TracChangeset
for help on using the changeset viewer.