Changes in src/SynTree/Statement.cc [de62360d:843054c2]
- File:
-
- 1 edited
-
src/SynTree/Statement.cc (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
rde62360d r843054c2 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 11:42:09 201513 // Update Count : 2 112 // Last Modified On : Mon May 18 10:55:19 2015 13 // Update Count : 2 14 14 // 15 15 … … 30 30 Statement::Statement( std::list<Label> _labels ) : labels(_labels ) {} 31 31 32 void Statement::print( std::ostream &, int indent ) const{}32 void Statement::print( std::ostream &, int indent ) {} 33 33 34 34 Statement::~Statement() {} … … 38 38 ExprStmt::~ExprStmt() {} 39 39 40 void ExprStmt::print( std::ostream &os, int indent ) const{41 os << string( indent, ' ') << "Expression Statement:" << endl;40 void ExprStmt::print( std::ostream &os, int indent ) { 41 os << "\r" << string(indent, ' ') << "Expression Statement:" << endl; 42 42 expr->print( os, indent + 2 ); 43 43 } … … 46 46 47 47 BranchStmt::BranchStmt( std::list<Label> labels, Label _target, Type _type ) throw ( SemanticError ) : 48 Statement( labels ), originalTarget(_target ),target(_target ), type(_type ) {48 Statement( labels ), target(_target ), type(_type ) { 49 49 //actually this is a syntactic error signaled by the parser 50 50 if ( type == BranchStmt::Goto && target.size() == 0 ) … … 58 58 } 59 59 60 void BranchStmt::print( std::ostream &os, int indent ) const{61 os << string( indent, ' ') << "Branch (" << brType[type] << ")" << endl ;60 void BranchStmt::print( std::ostream &os, int indent ) { 61 os << "\r" << string( indent, ' ') << "Branch (" << brType[type] << ")" << endl ; 62 62 } 63 63 … … 68 68 } 69 69 70 void ReturnStmt::print( std::ostream &os, int indent ) const{71 os << std::string( indent, ' ') << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";70 void ReturnStmt::print( std::ostream &os, int indent ) { 71 os << "\r" << std::string( indent, ' ') << string ( isThrow? "Throw":"Return" ) << " Statement, returning: "; 72 72 if ( expr != 0 ) expr->print( os ); 73 73 os << endl; … … 79 79 IfStmt::~IfStmt() {} 80 80 81 void IfStmt::print( std::ostream &os, int indent ) const{82 os << string( indent, ' ') << "If on condition: " << endl ;81 void IfStmt::print( std::ostream &os, int indent ) { 82 os << "\r" << string( indent, ' ') << "If on condition: " << endl ; 83 83 condition->print( os, indent + 4 ); 84 84 85 os << string( indent, ' ' ) << ".... and branches: " << endl;85 os << string( indent, ' ') << ".... and branches: " << endl; 86 86 87 87 thenPart->print( os, indent + 4 ); … … 103 103 void SwitchStmt::add_case( CaseStmt *c ) {} 104 104 105 void SwitchStmt::print( std::ostream &os, int indent ) const{106 os << string( indent, ' ') << "Switch on condition: ";105 void SwitchStmt::print( std::ostream &os, int indent ) { 106 os << "\r" << string( indent, ' ') << "Switch on condition: "; 107 107 condition->print( os ); 108 108 os << endl; 109 109 110 110 // branches 111 std::list<Statement *>:: const_iterator i;111 std::list<Statement *>::iterator i; 112 112 for ( i = branches.begin(); i != branches.end(); i++) 113 (*i )->print( os, indent + 4 );113 (*i )->print( os, indent + 4 ); 114 114 115 115 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os )); … … 126 126 } 127 127 128 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) { 129 return new CaseStmt( labels, 0, branches, true ); 130 } 131 132 void CaseStmt::print( std::ostream &os, int indent ) const { 133 os << string( indent, ' ' ); 134 135 if ( isDefault() ) 128 void CaseStmt::print( std::ostream &os, int indent ) { 129 os << "\r" << string( indent, ' '); 130 131 if ( isDefault()) 136 132 os << "Default "; 137 133 else { … … 142 138 os << endl; 143 139 144 std::list<Statement *>:: const_iterator i;140 std::list<Statement *>::iterator i; 145 141 for ( i = stmts.begin(); i != stmts.end(); i++) 146 142 (*i )->print( os, indent + 4 ); … … 158 154 void ChooseStmt::add_case( CaseStmt *c ) {} 159 155 160 void ChooseStmt::print( std::ostream &os, int indent ) const{161 os << string( indent, ' ') << "Choose on condition: ";156 void ChooseStmt::print( std::ostream &os, int indent ) { 157 os << "\r" << string( indent, ' ') << "Choose on condition: "; 162 158 condition->print( os ); 163 159 os << endl; 164 160 165 161 // branches 166 std::list<Statement *>:: const_iterator i;162 std::list<Statement *>::iterator i; 167 163 for ( i = branches.begin(); i != branches.end(); i++) 168 164 (*i )->print( os, indent + 4 ); … … 171 167 } 172 168 173 void FallthruStmt::print( std::ostream &os, int indent ) const{174 os << string( indent, ' ') << "Fall-through statement" << endl;169 void FallthruStmt::print( std::ostream &os, int indent ) { 170 os << "\r" << string( indent, ' ') << "Fall-through statement" << endl; 175 171 } 176 172 … … 183 179 } 184 180 185 void WhileStmt::print( std::ostream &os, int indent ) const{186 os << string( indent, ' ') << "While on condition: " << endl ;181 void WhileStmt::print( std::ostream &os, int indent ) { 182 os << "\r" << string( indent, ' ') << "While on condition: " << endl ; 187 183 condition->print( os, indent + 4 ); 188 184 189 os << string( indent, ' ' ) << ".... with body: " << endl;185 os << string( indent, ' ') << ".... with body: " << endl; 190 186 191 187 if ( body != 0 ) body->print( os, indent + 4 ); … … 203 199 } 204 200 205 void ForStmt::print( std::ostream &os, int indent ) const { 206 os << string( indent, ' ' ) << "Labels: {"; 207 for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) { 208 os << *it << ","; 209 } 210 os << "}" << endl; 211 212 os << string( indent, ' ' ) << "For Statement" << endl ; 213 214 os << string( indent + 2, ' ' ) << "initialization: \n"; 201 void ForStmt::print( std::ostream &os, int indent ) { 202 os << "\r" << string( indent, ' ') << "For Statement" << endl ; 203 204 os << "\r" << string( indent + 2, ' ') << "initialization: \n"; 215 205 if ( initialization != 0 ) 216 206 initialization->print( os, indent + 4 ); 217 207 218 os << "\n " << string( indent + 2, ' ') << "condition: \n";208 os << "\n\r" << string( indent + 2, ' ') << "condition: \n"; 219 209 if ( condition != 0 ) 220 210 condition->print( os, indent + 4 ); 221 211 222 os << "\n " << string( indent + 2, ' ') << "increment: \n";212 os << "\n\r" << string( indent + 2, ' ') << "increment: \n"; 223 213 if ( increment != 0 ) 224 214 increment->print( os, indent + 4 ); 225 215 226 os << "\n " << string( indent + 2, ' ') << "statement block: \n";216 os << "\n\r" << string( indent + 2, ' ') << "statement block: \n"; 227 217 if ( body != 0 ) 228 218 body->print( os, indent + 4 ); … … 245 235 } 246 236 247 void TryStmt::print( std::ostream &os, int indent ) const{248 os << string( indent, ' ') << "Try Statement" << endl;249 os << string( indent + 2, ' ' ) << "with block: " << endl;237 void TryStmt::print( std::ostream &os, int indent ) { 238 os << "\r" << string( indent, ' ') << "Try Statement" << endl; 239 os << string( indent + 2, ' ') << "with block: " << endl; 250 240 block->print( os, indent + 4 ); 251 241 252 242 // handlers 253 os << string( indent + 2, ' ' ) << "and handlers: " << endl; 254 for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++) 243 os << string( indent + 2, ' ') << "and handlers: " << endl; 244 std::list<Statement *>::iterator i; 245 for ( i = handlers.begin(); i != handlers.end(); i++) 255 246 (*i )->print( os, indent + 4 ); 256 247 257 248 // finally block 258 249 if ( finallyBlock != 0 ) { 259 os << string( indent + 2, ' ' ) << "Finally block: " << endl;250 os << string( indent + 2, ' ') << "Finally block: " << endl; 260 251 finallyBlock->print( os, indent + 4 ); 261 252 } // if … … 271 262 } 272 263 273 void CatchStmt::print( std::ostream &os, int indent ) const{274 os << string( indent, ' ') << "Catch Statement" << endl;275 276 os << string( indent, ' ') << "... catching" << endl;264 void CatchStmt::print( std::ostream &os, int indent ) { 265 os << "\r" << string( indent, ' ') << "Catch Statement" << endl; 266 267 os << "\r" << string( indent, ' ') << "... catching" << endl; 277 268 if ( decl ) { 278 269 decl->printShort( os, indent + 4 ); 279 270 os << endl; 280 271 } else if ( catchRest ) 281 os << string( indent + 4 , ' ') << "the rest" << endl;272 os << "\r" << string( indent + 4 , ' ') << "the rest" << endl; 282 273 else 283 os << string( indent + 4 , ' ') << ">>> Error: this catch clause must have a declaration <<<" << endl;274 os << "\r" << string( indent + 4 , ' ') << ">>> Error: this catch clause must have a declaration <<<" << endl; 284 275 } 285 276 … … 293 284 } 294 285 295 void FinallyStmt::print( std::ostream &os, int indent ) const{296 os << string( indent, ' ') << "Finally Statement" << endl;297 os << string( indent + 2, ' ' ) << "with block: " << endl;286 void FinallyStmt::print( std::ostream &os, int indent ) { 287 os << "\r" << string( indent, ' ') << "Finally Statement" << endl; 288 os << string( indent + 2, ' ') << "with block: " << endl; 298 289 block->print( os, indent + 4 ); 299 290 } … … 303 294 NullStmt::~NullStmt() {} 304 295 305 void NullStmt::print( std::ostream &os, int indent ) const{306 os << string( indent, ' ') << "Null Statement" << endl ;296 void NullStmt::print( std::ostream &os, int indent ) { 297 os << "\r" << string( indent, ' ') << "Null Statement" << endl ; 307 298 } 308 299
Note:
See TracChangeset
for help on using the changeset viewer.