Changeset 6
- Timestamp:
- 06/27/08 21:17:42 (6 months ago)
- Files:
-
- 1 modified
-
trunk/src/xtc/lang/C.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/xtc/lang/C.java
r1 r6 34 34 import xtc.tree.ParseTreePrinter; 35 35 import xtc.tree.ParseTreeStripper; 36 import xtc.tree.Pragma; 36 37 import xtc.tree.Printer; 37 38 import xtc.tree.Visitor; … … 105 106 "Include location information when printing the AST in " + 106 107 "generic form."). 108 bool("pragmaSymbol", "pragmaSymbol", false, 109 "Collect Pragma symbols information."). 107 110 bool("printSource", "printSource", false, 108 111 "Print the program's AST in C source form."). … … 167 170 runtime.error("printSymbolTable option requires analyze option"); 168 171 } 172 } 173 if (runtime.test("pragmaSymbol")) { 174 if (! runtime.test("optionAnalyze")) { 175 runtime.error("pragmaSymbol option requires analyze option"); 176 } 169 177 } 170 178 if (runtime.test("optionLocateAST")) { … … 371 379 if (runtime.test("optionAnalyze")) { 372 380 SymbolTable table; 373 381 PragmaSymbolTable pragmaTable = null; 374 382 if (runtime.test("optionTypical")) { 375 383 // Analyze and fill in the symbol table. … … 386 394 387 395 // Perform type checking. 388 new CAnalyzer(runtime).analyze(node, table); 396 if(!runtime.test("pragmaSymbol")) 397 new CAnalyzer(runtime).analyze(node, table); 398 else 399 { 400 pragmaTable = new PragmaSymbolTable(); 401 new CPragmaAnalyzer(runtime).analyze(node, pragmaTable); 402 } 389 403 } 390 404 … … 404 418 runtime.console().flush(); 405 419 } 406 } 420 // For pragma color analysis 421 // So far only print an enhanced version of the Symbol Table 422 if (runtime.test("pragmaSymbol")) { 423 // Save the registered visitor. 424 Visitor visitor = runtime.console().visitor(); 425 // Note that the type printer's constructor registers the just 426 // created printer with the console. 427 new TypePrinter(runtime.console()); 428 try { 429 if( pragmaTable != null ) 430 pragmaTable.root().dump(runtime.console()); 431 } finally { 432 // Restore the previously registered visitor. 433 runtime.console().register(visitor); 434 } 435 runtime.console().flush(); 436 } 437 } 407 438 408 439 // Print AST statistics. … … 437 468 runtime.console().flush(); 438 469 } 470 439 471 } 440 472
