Changes in translator/main.cc [42e2ad7:b1a6d6b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/main.cc
r42e2ad7 rb1a6d6b 49 49 bool debugp = false, treep = false, astp = false, manglep = false, symtabp = false, validp = false; 50 50 bool preludep = true, protop = false, libp = false; 51 bool exprp = false, codegenp = false ;51 bool exprp = false, codegenp = false, errorp = false; 52 52 int c; 53 53 FILE *input, *prelude, *builtins; … … 56 56 opterr = 0; 57 57 58 while ( (c = getopt( argc, argv, "dtsgmvxcenprlDz:" )) != -1 ) { 58 std::list< Declaration* > translationUnit; 59 60 while ( (c = getopt( argc, argv, "dtsgmvxcenprlDyz:" )) != -1 ) { 59 61 switch (c) { 60 62 case 'd': 61 / * bison debugging info */63 // bison debugging info 62 64 debugp = true; 63 65 break; 64 66 case 't': 65 / * dump parse tree */67 // dump parse tree 66 68 treep = true; 67 69 break; 68 70 case 's': 69 / * dump AST */71 // dump AST 70 72 astp = true; 71 73 break; 72 74 case 'g': 73 / * print alternatives for expressions */75 // print alternatives for expressions 74 76 manglep = true; 75 77 break; 76 78 case 'm': 77 / * print symbol table events */79 // print symbol table events 78 80 symtabp = true; 79 81 break; 80 82 case 'r': 81 / * print resolver steps */83 // print resolver steps 82 84 resolveVerbose = true; 83 85 break; 84 86 case 'x': 85 / * dump AST after decl validation pass */87 // dump AST after decl validation pass 86 88 validp = true; 87 89 break; 88 90 case 'e': 89 / * dump AST after expression analysis */91 // dump AST after expression analysis 90 92 exprp = true; 91 93 break; … … 93 95 codegenp = true; 94 96 break; 97 case 'y': 98 errorp = true; 99 break; 95 100 case 'n': 96 / * don't read preamble */101 // don't read preamble 97 102 preludep = false; 98 103 break; 99 104 case 'p': 100 / * generate prototypes for preamble functions */105 // generate prototypes for preamble functions 101 106 protop = true; 102 107 break; 103 108 case 'l': 104 / * generate libcfa.c */109 // generate libcfa.c 105 110 libp = true; 106 111 break; 107 112 case 'v': 108 / * verbose */113 // verbose 109 114 beVerbose = true; 110 115 break; 111 116 case 'D': 112 / * ignore -Dxxx */117 // ignore -Dxxx 113 118 break; 114 119 case '?': … … 205 210 } // if 206 211 207 std::list< Declaration* > translationUnit;208 212 buildList( Parser::get_parser().get_parseTree(), translationUnit ); 209 213 … … 233 237 234 238 if ( exprp ) { 239 InitTweak::tweak( translationUnit ); 235 240 SymTab::validate( translationUnit, false ); 236 ResolvExpr::resolve( translationUnit );237 printAll( translationUnit, std::cout );238 return 0;239 } // if240 241 if ( codegenp ) {242 // print the tree right before code generation...243 // InitTweak::mutate( translationUnit );244 // InitTweak::tweak( translationUnit );245 //printAll( translationUnit, std::cout );246 247 // std::cerr << "finished tweaking" << std::endl;248 SymTab::validate( translationUnit, false );249 241 ControlStruct::mutate( translationUnit ); 250 242 CodeGen::fixNames( translationUnit ); 243 ResolvExpr::resolve( translationUnit ); 244 printAll( translationUnit, std::cout ); 245 return 0; 246 } // if 247 248 if ( codegenp ) { 249 // print the tree right before code generation 250 cerr << "tweak" << endl; 251 InitTweak::tweak( translationUnit ); 252 cerr << "validate" << endl; 253 SymTab::validate( translationUnit, false ); 254 cerr << "mutate" << endl; 255 ControlStruct::mutate( translationUnit ); 256 cerr << "fixNames" << endl; 257 CodeGen::fixNames( translationUnit ); 258 cerr << "resolve" << endl; 251 259 ResolvExpr::resolve( translationUnit ); 260 cerr << "copyParams" << endl; 252 261 GenPoly::copyParams( translationUnit ); 262 cerr << "convertSpecializations" << endl; 253 263 GenPoly::convertSpecializations( translationUnit ); 264 cerr << "convertLvalue" << endl; 254 265 GenPoly::convertLvalue( translationUnit ); 266 cerr << "box" << endl; 255 267 GenPoly::box( translationUnit ); 256 printAll( translationUnit, std::cout ); 268 if ( errorp ) { 269 printAll( translationUnit, std::cout ); 270 } 257 271 return 0; 258 272 } // if … … 293 307 294 308 } catch ( SemanticError &e ) { 309 if ( errorp ) { 310 printAll( translationUnit, std::cout ); 311 } 295 312 e.print( cout ); 296 313 if ( output != &std::cout ) {
Note: See TracChangeset
for help on using the changeset viewer.