Changeset 6

Show
Ignore:
Timestamp:
06/27/08 21:17:42 (6 months ago)
Author:
lb
Message:

Pragma

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/xtc/lang/C.java

    r1 r6  
    3434import xtc.tree.ParseTreePrinter; 
    3535import xtc.tree.ParseTreeStripper; 
     36import xtc.tree.Pragma; 
    3637import xtc.tree.Printer; 
    3738import xtc.tree.Visitor; 
     
    105106           "Include location information when printing the AST in " +  
    106107           "generic form."). 
     108      bool("pragmaSymbol", "pragmaSymbol", false, 
     109           "Collect Pragma symbols information."). 
    107110      bool("printSource", "printSource", false, 
    108111           "Print the program's AST in C source form."). 
     
    167170        runtime.error("printSymbolTable option requires analyze option"); 
    168171      } 
     172    } 
     173    if (runtime.test("pragmaSymbol")) { 
     174        if (! runtime.test("optionAnalyze")) { 
     175          runtime.error("pragmaSymbol option requires analyze option"); 
     176        } 
    169177    } 
    170178    if (runtime.test("optionLocateAST")) { 
     
    371379    if (runtime.test("optionAnalyze")) { 
    372380      SymbolTable table; 
    373  
     381      PragmaSymbolTable pragmaTable = null; 
    374382      if (runtime.test("optionTypical")) { 
    375383        // Analyze and fill in the symbol table. 
     
    386394         
    387395        // 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        } 
    389403      } 
    390404 
     
    404418        runtime.console().flush(); 
    405419      } 
    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    }    
    407438 
    408439    // Print AST statistics. 
     
    437468      runtime.console().flush(); 
    438469    } 
     470         
    439471  } 
    440472