Changes in / [a8541d9:bfbf97f]


Ignore:
Location:
src
Files:
121 added
404 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    ra8541d9 rbfbf97f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jun 11 13:22:39 2015
    13 // Update Count     : 137
     12// Last Modified On : Thu Jun 04 15:00:00 2015
     13// Update Count     : 125
    1414//
    1515
     
    4343        }
    4444
    45         ostream & CodeGenerator::Indenter::operator()( ostream & output ) {
    46           return output << string( cg.cur_indent, ' ' );
    47         }
    48 
    49         ostream & operator<<( ostream & output, CodeGenerator::Indenter &indent ) {
    50                 return indent( output );
    51         }
    52 
    53         CodeGenerator::CodeGenerator( std::ostream &os ) : indent(*this), cur_indent( 0 ), insideFunction( false ), output( os ) { }
    54 
    55         CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp )
    56                         : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {
     45        CodeGenerator::CodeGenerator( std::ostream &os ) : cur_indent( 0 ), insideFunction( false ), output( os ) { }
     46
     47        CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indent, bool infunp )
     48                        : cur_indent( indent ), insideFunction( infunp ), output( os ) {
    5749                //output << std::string( init );
    5850        }
    5951
    60         CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp )
    61                         : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {
     52        CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indent, bool infunp )
     53                        : cur_indent( indent ), insideFunction( infunp ), output( os ) {
    6254                //output << std::string( init );
    6355        }
     
    7062                } // if
    7163        }
    72  
     64  
    7365        //*** Declarations
    7466        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
     
    112104
    113105                if ( ! memb.empty() ) {
    114                         output << endl << indent << "{" << endl;
     106                        output << endl << string( cur_indent, ' ' ) << "{" << endl;
    115107
    116108                        cur_indent += CodeGenerator::tabsize;
    117109                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    118                                 output << indent;
     110                                output << string( cur_indent, ' ' );
    119111                                (*i)->accept(*this );
    120112                                output << ";" << endl;
     
    123115                        cur_indent -= CodeGenerator::tabsize;
    124116
    125                         output << indent << "}";
     117                        output << string( cur_indent, ' ' ) << "}";
    126118                } // if
    127119        }
     
    146138
    147139                if ( ! memb.empty() ) {
    148                         output << " {" << endl;
     140                        output << endl << "{" << endl;
    149141
    150142                        cur_indent += CodeGenerator::tabsize;
     
    152144                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    153145                                assert( obj );
    154                                 output << indent << mangleName( obj );
     146                                output << string( cur_indent, ' ' ) << mangleName( obj );
    155147                                if ( obj->get_init() ) {
    156148                                        output << " = ";
     
    162154                        cur_indent -= CodeGenerator::tabsize;
    163155
    164                         output << indent << "}";
     156                        output << "}" << endl;
    165157                } // if
    166158        }
     
    452444
    453445                for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end();  i++) {
    454                         output << indent << printLabels( (*i)->get_labels() );
     446                        output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() );
    455447                        (*i)->accept(*this );
    456448
     
    462454                cur_indent -= CodeGenerator::tabsize;
    463455
    464                 output << indent << "}";
     456                output << string( cur_indent, ' ' ) << "}";
    465457        }
    466458
     
    502494                cur_indent -= CodeGenerator::tabsize;
    503495
    504                 output << indent << "}";
     496                output << string( cur_indent, ' ' ) << "}";
    505497        }
    506498
    507499        void CodeGenerator::visit( CaseStmt *caseStmt ) {
    508                 output << indent;
     500                output << string( cur_indent, ' ' );
    509501                if ( caseStmt->isDefault()) {
    510502                        output << "default";
     
    519511                cur_indent += CodeGenerator::tabsize;
    520512                for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end();  i++) {
    521                         output << indent << printLabels( (*i)->get_labels() )  ;
     513                        output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() )  ;
    522514                        (*i)->accept(*this );
    523515                        output << endl;
     
    572564                whileStmt->get_body()->accept( *this );
    573565
    574                 output << indent;
     566                output << string( cur_indent, ' ' );
    575567
    576568                if ( whileStmt->get_isDoWhile() ) {
     
    604596
    605597        void CodeGenerator::visit( NullStmt *nullStmt ) {
    606                 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
     598                //output << string( cur_indent, ' ' ) << CodeGenerator::printLabels( nullStmt->get_labels() );
    607599                output << "/* null statement */ ;";
    608600        }
  • src/CodeGen/CodeGenerator.h

    ra8541d9 rbfbf97f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jun 11 13:24:23 2015
    13 // Update Count     : 23
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jun  8 14:34:43 2015
     13// Update Count     : 15
    1414//
    1515
     
    8080
    8181                template< class Iterator > void genCommaList( Iterator begin, Iterator end );
    82 
    83                 struct Indenter {
    84                         Indenter(CodeGenerator &cg) : cg(cg) {}
    85                         CodeGenerator & cg;
    86                         std::ostream& operator()(std::ostream & os);
    87                 };
    8882          private:
    89 
    90                 Indenter indent;
    9183                int cur_indent;
    9284                bool insideFunction;
  • src/Parser/parser.cc

    ra8541d9 rbfbf97f  
    92729272            std::cout << "in file " << yyfilename << " ";
    92739273        } // if
    9274         std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
     9274//      std::cout << "at line " << yylineno << " reading token \"" << *(yylval.tok.str) << "\"" << std::endl;
     9275        std::cout << "at line " << yylineno << " reading token \"" << yytext << "\"" << std::endl;
    92759276}
    92769277
  • src/Parser/parser.yy

    ra8541d9 rbfbf97f  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 10 20:31:54 2015
    13 // Update Count     : 1040
     12// Last Modified On : Wed Jun 10 14:22:15 2015
     13// Update Count     : 1039
    1414//
    1515
     
    27232723            std::cout << "in file " << yyfilename << " ";
    27242724        } // if
    2725         std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
     2725        std::cout << "at line " << yylineno << " reading token \"" << yytext << "\"" << std::endl;
    27262726}
    27272727
  • src/main.cc

    ra8541d9 rbfbf97f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 11 11:06:04 2015
    13 // Update Count     : 69
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Jun 09 15:10:05 2015
     13// Update Count     : 68
    1414//
    1515
     
    7171        errorp = false;
    7272
    73 enum { Ast, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Validate, };
     73enum { Ast, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Prototypes, Resolver, Symbol, Parse, };
    7474
    7575static struct option long_opts[] = {
     
    8080        { "libcfa", no_argument, 0, LibCFA },
    8181        { "nopreamble", no_argument, 0, Nopreamble },
    82         { "parse", no_argument, 0, Parse },
    8382        { "prototypes", no_argument, 0, Prototypes },
    8483        { "resolver", no_argument, 0, Resolver },
    8584        { "symbol", no_argument, 0, Symbol },
    86         { "validate", no_argument, 0, Validate },
     85        { "parse", no_argument, 0, Parse },
    8786        { 0, 0, 0, 0 }
    8887};
     
    9796       
    9897        int c;
    99         while ( (c = getopt_long( argc, argv, "aefglnpqrsvyzD:", long_opts, &long_index )) != -1 ) {
     98        while ( (c = getopt_long( argc, argv, "aefglnpqrsxyzD:", long_opts, &long_index )) != -1 ) {
    10099                switch ( c ) {
    101100                  case Ast:
     
    139138                        symtabp = true;
    140139                        break;
    141                   case 'v':                                                                             // dump AST after decl validation pass
     140                  case 'x':                                                                             // dump AST after decl validation pass
    142141                        validp = true;
    143142                        break;
Note: See TracChangeset for help on using the changeset viewer.