Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rde62360d r843054c2  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 11:42:09 2015
    13 // Update Count     : 21
     12// Last Modified On : Mon May 18 10:55:19 2015
     13// Update Count     : 2
    1414//
    1515
     
    3030Statement::Statement( std::list<Label> _labels ) : labels(_labels ) {}
    3131
    32 void Statement::print( std::ostream &, int indent ) const {}
     32void Statement::print( std::ostream &, int indent ) {}
    3333
    3434Statement::~Statement() {}
     
    3838ExprStmt::~ExprStmt() {}
    3939
    40 void ExprStmt::print( std::ostream &os, int indent ) const {
    41         os << string( indent, ' ' ) << "Expression Statement:" << endl;
     40void ExprStmt::print( std::ostream &os, int indent ) {
     41        os << "\r" << string(indent, ' ') << "Expression Statement:" << endl;
    4242        expr->print( os, indent + 2 );
    4343}
     
    4646
    4747BranchStmt::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 ) {
    4949        //actually this is a syntactic error signaled by the parser
    5050        if ( type == BranchStmt::Goto && target.size() == 0 )
     
    5858}
    5959
    60 void BranchStmt::print( std::ostream &os, int indent ) const {
    61         os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ;
     60void BranchStmt::print( std::ostream &os, int indent ) {
     61        os << "\r" << string( indent, ' ') << "Branch (" << brType[type] << ")" << endl ;
    6262}
    6363
     
    6868}
    6969
    70 void ReturnStmt::print( std::ostream &os, int indent ) const {
    71         os << std::string( indent, ' ' ) << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
     70void ReturnStmt::print( std::ostream &os, int indent ) {
     71        os << "\r" << std::string( indent, ' ') << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
    7272        if ( expr != 0 ) expr->print( os );
    7373        os << endl;
     
    7979IfStmt::~IfStmt() {}
    8080
    81 void IfStmt::print( std::ostream &os, int indent ) const {
    82         os << string( indent, ' ' ) << "If on condition: " << endl ;
     81void IfStmt::print( std::ostream &os, int indent ) {
     82        os << "\r" << string( indent, ' ') << "If on condition: " << endl ;
    8383        condition->print( os, indent + 4 );
    8484
    85         os << string( indent, ' ' ) << ".... and branches: " << endl;
     85        os << string( indent, ' ') << ".... and branches: " << endl;
    8686
    8787        thenPart->print( os, indent + 4 );
     
    103103void SwitchStmt::add_case( CaseStmt *c ) {}
    104104
    105 void SwitchStmt::print( std::ostream &os, int indent ) const {
    106         os << string( indent, ' ' ) << "Switch on condition: ";
     105void SwitchStmt::print( std::ostream &os, int indent ) {
     106        os << "\r" << string( indent, ' ') << "Switch on condition: ";
    107107        condition->print( os );
    108108        os << endl;
    109109
    110110        // branches
    111         std::list<Statement *>::const_iterator i;
     111        std::list<Statement *>::iterator i;
    112112        for ( i = branches.begin(); i != branches.end(); i++)
    113                 (*i)->print( os, indent + 4 );
     113                (*i )->print( os, indent + 4 );
    114114
    115115        //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));
     
    126126}
    127127
    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() )
     128void CaseStmt::print( std::ostream &os, int indent ) {
     129        os << "\r" << string( indent, ' ');
     130
     131        if ( isDefault())
    136132                os << "Default ";
    137133        else {
     
    142138        os << endl;
    143139
    144         std::list<Statement *>::const_iterator i;
     140        std::list<Statement *>::iterator i;
    145141        for ( i = stmts.begin(); i != stmts.end(); i++)
    146142                (*i )->print( os, indent + 4 );
     
    158154void ChooseStmt::add_case( CaseStmt *c ) {}
    159155
    160 void ChooseStmt::print( std::ostream &os, int indent ) const {
    161         os << string( indent, ' ' ) << "Choose on condition: ";
     156void ChooseStmt::print( std::ostream &os, int indent ) {
     157        os << "\r" << string( indent, ' ') << "Choose on condition: ";
    162158        condition->print( os );
    163159        os << endl;
    164160
    165161        // branches
    166         std::list<Statement *>::const_iterator i;
     162        std::list<Statement *>::iterator i;
    167163        for ( i = branches.begin(); i != branches.end(); i++)
    168164                (*i )->print( os, indent + 4 );
     
    171167}
    172168
    173 void FallthruStmt::print( std::ostream &os, int indent ) const {
    174         os << string( indent, ' ' ) << "Fall-through statement" << endl;
     169void FallthruStmt::print( std::ostream &os, int indent ) {
     170        os << "\r" << string( indent, ' ') << "Fall-through statement" << endl;
    175171}
    176172
     
    183179}
    184180
    185 void WhileStmt::print( std::ostream &os, int indent ) const {
    186         os << string( indent, ' ' ) << "While on condition: " << endl ;
     181void WhileStmt::print( std::ostream &os, int indent ) {
     182        os << "\r" << string( indent, ' ') << "While on condition: " << endl ;
    187183        condition->print( os, indent + 4 );
    188184
    189         os << string( indent, ' ' ) << ".... with body: " << endl;
     185        os << string( indent, ' ') << ".... with body: " << endl;
    190186
    191187        if ( body != 0 ) body->print( os, indent + 4 );
     
    203199}
    204200
    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";
     201void ForStmt::print( std::ostream &os, int indent ) {
     202        os << "\r" << string( indent, ' ') << "For Statement" << endl ;
     203
     204        os << "\r" << string( indent + 2, ' ') << "initialization: \n";
    215205        if ( initialization != 0 )
    216206                initialization->print( os, indent + 4 );
    217207
    218         os << "\n" << string( indent + 2, ' ' ) << "condition: \n";
     208        os << "\n\r" << string( indent + 2, ' ') << "condition: \n";
    219209        if ( condition != 0 )
    220210                condition->print( os, indent + 4 );
    221211
    222         os << "\n" << string( indent + 2, ' ' ) << "increment: \n";
     212        os << "\n\r" << string( indent + 2, ' ') << "increment: \n";
    223213        if ( increment != 0 )
    224214                increment->print( os, indent + 4 );
    225215
    226         os << "\n" << string( indent + 2, ' ' ) << "statement block: \n";
     216        os << "\n\r" << string( indent + 2, ' ') << "statement block: \n";
    227217        if ( body != 0 )
    228218                body->print( os, indent + 4 );
     
    245235}
    246236
    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;
     237void TryStmt::print( std::ostream &os, int indent ) {
     238        os << "\r" << string( indent, ' ') << "Try Statement" << endl;
     239        os << string( indent + 2, ' ') << "with block: " << endl;
    250240        block->print( os, indent + 4 );
    251241
    252242        // 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++)
    255246                (*i )->print( os, indent + 4 );
    256247
    257248        // finally block
    258249        if ( finallyBlock != 0 ) {
    259                 os << string( indent + 2, ' ' ) << "Finally block: " << endl;
     250                os << string( indent + 2, ' ') << "Finally block: " << endl;
    260251                finallyBlock->print( os, indent + 4 );
    261252        } // if
     
    271262}
    272263
    273 void CatchStmt::print( std::ostream &os, int indent ) const {
    274         os << string( indent, ' ' ) << "Catch Statement" << endl;
    275 
    276         os << string( indent, ' ' ) << "... catching" << endl;
     264void CatchStmt::print( std::ostream &os, int indent ) {
     265        os << "\r" << string( indent, ' ') << "Catch Statement" << endl;
     266
     267        os << "\r" << string( indent, ' ') << "... catching" << endl;
    277268        if ( decl ) {
    278269                decl->printShort( os, indent + 4 );
    279270                os << endl;
    280271        } else if ( catchRest )
    281                 os << string( indent + 4 , ' ' ) << "the rest" << endl;
     272                os << "\r" << string( indent + 4 , ' ') << "the rest" << endl;
    282273        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;
    284275}
    285276
     
    293284}
    294285
    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;
     286void FinallyStmt::print( std::ostream &os, int indent ) {
     287        os << "\r" << string( indent, ' ') << "Finally Statement" << endl;
     288        os << string( indent + 2, ' ') << "with block: " << endl;
    298289        block->print( os, indent + 4 );
    299290}
     
    303294NullStmt::~NullStmt() {}
    304295
    305 void NullStmt::print( std::ostream &os, int indent ) const {
    306         os << string( indent, ' ' ) << "Null Statement" << endl ;
     296void NullStmt::print( std::ostream &os, int indent ) {
     297        os << "\r" << string( indent, ' ') << "Null Statement" << endl ;
    307298}
    308299
Note: See TracChangeset for help on using the changeset viewer.