Changeset 622

Show
Ignore:
Timestamp:
08/05/08 08:42:35 (4 months ago)
Author:
weyrick
Message:

more skeleton code in the driver

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/compiler/CMakeLists.txt

    r621 r622  
    22MESSAGE( STATUS "compiler check" ) 
    33 
    4 EXECUTE_PROCESS(COMMAND llvm-config --libs core jit native OUTPUT_VARIABLE LLVM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) 
     4# TODO: move this to a FindLLVM in cmake/modules 
     5EXECUTE_PROCESS(COMMAND llvm-config --libs core jit bitreader bitwriter OUTPUT_VARIABLE LLVM_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) 
    56EXECUTE_PROCESS(COMMAND llvm-config --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) 
    67EXECUTE_PROCESS(COMMAND llvm-config --cppflags OUTPUT_VARIABLE LLVM_CPP_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) 
  • trunk/rphp/compiler/pDriver.cpp

    r621 r622  
    2525#include <unicode/ustream.h> 
    2626 
     27#include <boost/algorithm/string.hpp> 
     28 
     29#include "llvm/Bitcode/ReaderWriter.h" 
    2730#include "llvm/ModuleProvider.h" 
    2831#include "llvm/Analysis/Verifier.h" 
     
    4245namespace rphp { 
    4346 
    44     // dump LLVM IR 
    45     void pDriver::dumpIR(string fileName) { 
    46  
    47         // Create the "module" or "program" or "translation unit" to hold the 
    48         // function 
    49         llvm::Module *M = new llvm::Module("test"); 
    50  
    51         // Create the main function: first create the type 'int ()' 
    52         llvm::FunctionType *FT = llvm::FunctionType::get(llvm::Type::Int32Ty, std::vector<const llvm::Type*>(), 
    53                                             /*not vararg*/false); 
    54  
    55         // By passing a module as the last parameter to the Function constructor, 
    56         // it automatically gets appended to the Module. 
    57         llvm::Function *F = llvm::Function::Create(FT, llvm::Function::ExternalLinkage, "main", M); 
    58  
    59         // Add a basic block to the function... again, it automatically inserts 
    60         // because of the last argument. 
    61         llvm::BasicBlock *BB = llvm::BasicBlock::Create("EntryBlock", F); 
    62  
    63         // Get pointers to the constant integers... 
    64         llvm::Value *Two = llvm::ConstantInt::get(llvm::Type::Int32Ty, 2); 
    65         llvm::Value *Three = llvm::ConstantInt::get(llvm::Type::Int32Ty, 3); 
    66  
    67         // Create the add instruction... does not insert... 
    68         llvm::Instruction *Add = llvm::BinaryOperator::create(llvm::Instruction::Add, Two, Three, 
    69                                                     "addresult"); 
    70  
    71         // explicitly insert it into the basic block... 
    72         BB->getInstList().push_back(Add); 
    73  
    74         // Create the return instruction and add it to the basic block 
    75         BB->getInstList().push_back(llvm::ReturnInst::Create(Add)); 
    76  
    77          
    78         M->dump(); 
    79  
    80         delete M; 
    81  
    82     } 
    83  
    84  
    85     /** 
    86     * print the token with the same text as php tokens - so they can be compared with 
    87     * the result of get_token_all (see test-tokenize.php) 
    88     **/ 
    89     template <class LexerType, class StringType> 
    90     void printToken(int token, const LexerType& lexer, const StringType& content) 
     47 
     48/** 
     49 * execute given file -- php source or bytecode 
     50 */ 
     51void pDriver::execute(string fileName) { 
     52    cout << "executing file: " << fileName << endl; 
     53    // TODO: determine file type, then run executeBC or executePHP 
     54 
     55
     56 
     57/** 
     58 * execute precompiled bytecode 
     59 */ 
     60void pDriver::executeBC(string fileName) { 
     61    cout << "executing compiled bytecode: " << fileName << endl; 
     62
     63 
     64/** 
     65 * compile, then execute PHP source 
     66 */ 
     67void pDriver::executePHP(string fileName) { 
     68    cout << "compile and execute php file: " << fileName << endl; 
     69
     70 
     71/** 
     72 * compile to llvm bytecode 
     73 */ 
     74void pDriver::compileToBC(string fileName) { 
     75    cout << "compiling " << fileName << " to bytecode " << endl; 
     76 
     77    llvm::Module* phpModule = compileToIR(fileName); 
     78 
     79    boost::replace_last(fileName, ".php", ".rbc"); 
     80 
     81    std::ofstream OS(fileName.c_str(), std::ios_base::out|std::ios::trunc|std::ios::binary); 
     82    if (!OS.fail()) 
     83        llvm::WriteBitcodeToFile(phpModule, OS); 
     84 
     85    //if (OS.fail()) 
     86    //    return -1; 
     87 
     88    delete phpModule; 
     89 
     90
     91 
     92/** 
     93 * compile to llvm assembly 
     94 */ 
     95void pDriver::compileToAsm(string fileName) { 
     96    cout << "compiling " << fileName << " to llvm assembly " << endl; 
     97
     98 
     99/** 
     100 * compile to native binary 
     101 */ 
     102void pDriver::compileToNative(string fileName) { 
     103    cout << "compiling " << fileName << " to native binary " << endl; 
     104
     105 
     106/** 
     107 *  compile the given file to an llvm::Module, which is returned 
     108 *  the caller is responsible for deleting the module 
     109 */ 
     110llvm::Module* pDriver::compileToIR(string fileName) { 
     111 
     112    // TODO: llvm example module. this whole project will work better if this 
     113    // thing actually compiles the file in fileName 
     114 
     115    // Create the "module" or "program" or "translation unit" to hold the 
     116    // function 
     117    llvm::Module *M = new llvm::Module(fileName); 
     118 
     119    // Create the main function: first create the type 'int ()' 
     120    llvm::FunctionType *FT = llvm::FunctionType::get(llvm::Type::Int32Ty, std::vector<const llvm::Type*>(), 
     121                                        /*not vararg*/false); 
     122 
     123    // By passing a module as the last parameter to the Function constructor, 
     124    // it automatically gets appended to the Module. 
     125    llvm::Function *F = llvm::Function::Create(FT, llvm::Function::ExternalLinkage, "main", M); 
     126 
     127    // Add a basic block to the function... again, it automatically inserts 
     128    // because of the last argument. 
     129    llvm::BasicBlock *BB = llvm::BasicBlock::Create("EntryBlock", F); 
     130 
     131    // Get pointers to the constant integers... 
     132    llvm::Value *Two = llvm::ConstantInt::get(llvm::Type::Int32Ty, 2); 
     133    llvm::Value *Three = llvm::ConstantInt::get(llvm::Type::Int32Ty, 3); 
     134 
     135    // Create the add instruction... does not insert... 
     136    llvm::Instruction *Add = llvm::BinaryOperator::create(llvm::Instruction::Add, Two, Three, 
     137                                                "addresult"); 
     138 
     139    // explicitly insert it into the basic block... 
     140    BB->getInstList().push_back(Add); 
     141 
     142    // Create the return instruction and add it to the basic block 
     143    BB->getInstList().push_back(llvm::ReturnInst::Create(Add)); 
     144 
     145    return M; 
     146 
     147
     148 
     149// dump LLVM IR 
     150void pDriver::dumpIR(string fileName) { 
     151 
     152    llvm::Module* phpModule = compileToIR(fileName); 
     153    phpModule->dump(); 
     154    delete phpModule; 
     155 
     156
     157 
     158 
     159/** 
     160* print the token with the same text as php tokens - so they can be compared with 
     161* the result of get_token_all (see test-tokenize.php) 
     162**/ 
     163template <class LexerType, class StringType> 
     164void printToken(int token, const LexerType& lexer, const StringType& content) 
     165
     166    int begin = lexer.tokenBegin(); 
     167    int end = lexer.tokenEnd(); 
     168    //UnicodeString tokenText = content.replace(begin, end-begin+1,"\n", "\\n"); 
     169    StringType tokenText(content, begin, end-begin+1); 
     170    if (token == parser::Token_INLINE_HTML) { 
     171        cout << tokenText << " T_INLINE_HTML" << endl; 
     172    } else if (token == parser::Token_OPEN_TAG) { 
     173        cout << tokenText << " T_OPEN_TAG" << endl; 
     174    } else if (token == parser::Token_CLOSE_TAG) { 
     175        cout << tokenText << " T_CLOSE_TAG" << endl; 
     176    } else if (token == parser::Token_ECHO) { 
     177        cout << tokenText << " T_ECHO" << endl; 
     178    } else if (token == parser::Token_WHITESPACE) { 
     179        cout << tokenText << " T_WHITESPACE" << endl; 
     180    } else if (token == parser::Token_CONSTANT_ENCAPSED_STRING) { 
     181        cout << tokenText << " T_CONSTANT_ENCAPSED_STRING" << endl; 
     182    } else if (token == parser::Token_SEMICOLON) { 
     183        cout << tokenText << " ;" << endl; 
     184    } else if (token == parser::Token_VARIABLE) { 
     185        cout << tokenText << " T_VARIABLE" << endl; 
     186    } else if (token == parser::Token_DOUBLE_QUOTE) { 
     187        cout << tokenText << " \"" << endl; 
     188    } else if (token == parser::Token_ENCAPSED_AND_WHITESPACE) { 
     189        cout << tokenText << " T_ENCAPSED_AND_WHITESPACE" << endl; 
     190    } else if (token == parser::Token_OBJECT_OPERATOR) { 
     191        cout << tokenText << " T_OBJECT_OPERATOR" << endl; 
     192    } else if (token == parser::Token_LBRACKET) { 
     193        cout << tokenText << " [" << endl; 
     194    } else if (token == parser::Token_RBRACKET) { 
     195        cout << tokenText << " ]" << endl; 
     196    } else if (token == parser::Token_NUM_STRING) { 
     197        cout << tokenText << " T_NUM_STRING" << endl; 
     198    } else if (token == parser::Token_STRING) { 
     199        cout << tokenText << " T_STRING" << endl; 
     200    } else if (token == parser::Token_ASSIGN) { 
     201        cout << tokenText << " =" << endl; 
     202    } else if (token == parser::Token_DNUMBER) { 
     203        cout << tokenText << " T_DNUMBER" << endl; 
     204    } else if (token == parser::Token_LNUMBER) { 
     205        cout << tokenText << " T_LNUMBER" << endl; 
     206    } else if (token == parser::Token_PLUS) { 
     207        cout << tokenText << " +" << endl; 
     208    } else if (token == parser::Token_MINUS) { 
     209        cout << tokenText << " -" << endl; 
     210    } else if (token == parser::Token_CONCAT) { 
     211        cout << tokenText << " ." << endl; 
     212    } else if (token == parser::Token_INC) { 
     213        cout << tokenText << " T_INC" << endl; 
     214    } else if (token == parser::Token_DEC) { 
     215        cout << tokenText << " T_DEC" << endl; 
     216    } else if (token == parser::Token_IS_EQUAL) { 
     217        cout << tokenText << " T_IS_EQUAL" << endl; 
     218    } else if (token == parser::Token_IS_NOT_EQUAL) { 
     219        cout << tokenText << " T_IS_NOT_EQUAL" << endl; 
     220    } else if (token == parser::Token_IS_IDENTICAL) { 
     221        cout << tokenText << " T_IS_IDENTICAL" << endl; 
     222    } else if (token == parser::Token_IS_NOT_IDENTICAL) { 
     223        cout << tokenText << " T_IS_NOT_IDENTICAL" << endl; 
     224    } else if (token == parser::Token_IS_SMALLER) { 
     225        cout << tokenText << " <" << endl; 
     226    } else if (token == parser::Token_IS_GREATER) { 
     227        cout << tokenText << " >" << endl; 
     228    } else if (token == parser::Token_IS_SMALLER_OR_EQUAL) { 
     229        cout << tokenText << " T_IS_SMALLER_OR_EQUAL" << endl; 
     230    } else if (token == parser::Token_IS_GREATER_OR_EQUAL) { 
     231        cout << tokenText << " T_IS_GREATER_OR_EQUAL" << endl; 
     232    } else if (token == parser::Token_BOOLEAN_OR) { 
     233        cout << tokenText << " T_BOOLEAN_OR" << endl; 
     234    } else if (token == parser::Token_BOOLEAN_AND) { 
     235        cout << tokenText << " T_BOOLEAN_AND" << endl; 
     236    } else if (token == parser::Token_PLUS_ASSIGN) { 
     237        cout << tokenText << " T_PLUS_EQUAL" << endl; 
     238    } else if (token == parser::Token_MINUS_ASSIGN) { 
     239        cout << tokenText << " T_MINUS_EQUAL" << endl; 
     240    } else if (token == parser::Token_MUL_ASSIGN) { 
     241        cout << tokenText << " T_MUL_EQUAL" << endl; 
     242    } else if (token == parser::Token_DIV_ASSIGN) { 
     243        cout << tokenText << " T_DIV_EQUAL" << endl; 
     244    } else if (token == parser::Token_CONCAT_ASSIGN) { 
     245        cout << tokenText << " T_CONCAT_EQUAL" << endl; 
     246    } else if (token == parser::Token_MOD_ASSIGN) { 
     247        cout << tokenText << " T_MOD_EQUAL" << endl; 
     248    } else if (token == parser::Token_AND_ASSIGN) { 
     249        cout << tokenText << " T_AND_EQUAL" << endl; 
     250    } else if (token == parser::Token_OR_ASSIGN) { 
     251        cout << tokenText << " T_OR_EQUAL" << endl; 
     252    } else if (token == parser::Token_XOR_ASSIGN) { 
     253        cout << tokenText << " T_XOR_EQUAL" << endl; 
     254    } else if (token == parser::Token_SL_ASSIGN) { 
     255        cout << tokenText << " T_SL_EQUAL" << endl; 
     256    } else if (token == parser::Token_SR_ASSIGN) { 
     257        cout << tokenText << " T_SR_EQUAL" << endl; 
     258    } else if (token == parser::Token_BANG) { 
     259        cout << tokenText << " !" << endl; 
     260    } else if (token == parser::Token_QUESTION) { 
     261        cout << tokenText << " ?" << endl; 
     262    } else if (token == parser::Token_COLON) { 
     263        cout << tokenText << " :" << endl; 
     264    } else if (token == parser::Token_BIT_AND) { 
     265        cout << tokenText << " &" << endl; 
     266    } else if (token == parser::Token_BIT_OR) { 
     267        cout << tokenText << " |" << endl; 
     268    } else if (token == parser::Token_BIT_XOR) { 
     269        cout << tokenText << " ^" << endl; 
     270    } else if (token == parser::Token_SL) { 
     271        cout << tokenText << " T_SL" << endl; 
     272    } else if (token == parser::Token_SR) { 
     273        cout << tokenText << " T_SR" << endl; 
     274    } else if (token == parser::Token_MUL) { 
     275        cout << tokenText << " *" << endl; 
     276    } else if (token == parser::Token_DIV) { 
     277        cout << tokenText << " /" << endl; 
     278    } else if (token == parser::Token_MOD) { 
     279        cout << tokenText << " %" << endl; 
     280    } else if (token == parser::Token_TILDE) { 
     281        cout << tokenText << " ~" << endl; 
     282    } else if (token == parser::Token_LPAREN) { 
     283        cout << tokenText << " (" << endl; 
     284    } else if (token == parser::Token_RPAREN) { 
     285        cout << tokenText << " )" << endl; 
     286    } else if (token == parser::Token_LBRACE) { 
     287        cout << tokenText << " {" << endl; 
     288    } else if (token == parser::Token_RBRACE) { 
     289        cout << tokenText << " }" << endl; 
     290    } else if (token == parser::Token_COMMA) { 
     291        cout << tokenText << " ," << endl; 
     292    } else if (token == parser::Token_AT) { 
     293        cout << tokenText << " @" << endl; 
     294    } else if (token == parser::Token_INCLUDE) { 
     295        cout << tokenText << " T_INCLUDE" << endl; 
     296    } else if (token == parser::Token_INCLUDE_ONCE) { 
     297        cout << tokenText << " T_INCLUDE_ONCE" << endl; 
     298    } else if (token == parser::Token_EVAL) { 
     299        cout << tokenText << " T_EVAL" << endl; 
     300    } else if (token == parser::Token_REQUIRE) { 
     301        cout << tokenText << " T_REQUIRE" << endl; 
     302    } else if (token == parser::Token_REQUIRE_ONCE) { 
     303        cout << tokenText << " T_REQUIRE_ONCE" << endl; 
     304    } else if (token == parser::Token_PRINT) { 
     305        cout << tokenText << " T_PRINT" << endl; 
     306    } else if (token == parser::Token_ABSTRACT) { 
     307        cout << tokenText << " T_ABSTRACT" << endl; 
     308    } else if (token == parser::Token_BREAK) { 
     309        cout << tokenText << " T_BREAK" << endl; 
     310    } else if (token == parser::Token_CASE) { 
     311        cout << tokenText << " T_CASE" << endl; 
     312    } else if (token == parser::Token_CATCH) { 
     313        cout << tokenText << " T_CATCH" << endl; 
     314    } else if (token == parser::Token_CLASS) { 
     315        cout << tokenText << " T_CLASS" << endl; 
     316    } else if (token == parser::Token_CONST) { 
     317        cout << tokenText << " T_CONST" << endl; 
     318    } else if (token == parser::Token_CONTINUE) { 
     319        cout << tokenText << " T_CONTINUE" << endl; 
     320    } else if (token == parser::Token_DEFAULT) { 
     321        cout << tokenText << " T_DEFAULT" << endl; 
     322    } else if (token == parser::Token_DO) { 
     323        cout << tokenText << " T_DO" << endl; 
     324    } else if (token == parser::Token_ELSE) { 
     325        cout << tokenText << " T_ELSE" << endl; 
     326    } else if (token == parser::Token_EXTENDS) { 
     327        cout << tokenText << " T_EXTENDS" << endl; 
     328    } else if (token == parser::Token_FINAL) { 
     329        cout << tokenText << " T_FINAL" << endl; 
     330    } else if (token == parser::Token_FOR) { 
     331        cout << tokenText << " T_FOR" << endl; 
     332    } else if (token == parser::Token_IF) { 
     333        cout << tokenText << " T_IF" << endl; 
     334    } else if (token == parser::Token_IMPLEMENTS) { 
     335        cout << tokenText << " T_IMPLEMENTS" << endl; 
     336    } else if (token == parser::Token_INSTANCEOF) { 
     337        cout << tokenText << " T_INSTANCEOF" << endl; 
     338    } else if (token == parser::Token_INTERFACE) { 
     339        cout << tokenText << " T_INTERFACE" << endl; 
     340    } else if (token == parser::Token_NEW) { 
     341        cout << tokenText << " T_NEW" << endl; 
     342    } else if (token == parser::Token_PRIVATE) { 
     343        cout << tokenText << " T_PRIVATE" << endl; 
     344    } else if (token == parser::Token_PROTECTED) { 
     345        cout << tokenText << " T_PROTECTED" << endl; 
     346    } else if (token == parser::Token_PUBLIC) { 
     347        cout << tokenText << " T_PUBLIC" << endl; 
     348    } else if (token == parser::Token_RETURN) { 
     349        cout << tokenText << " T_RETURN" << endl; 
     350    } else if (token == parser::Token_STATIC) { 
     351        cout << tokenText << " T_STATIC" << endl; 
     352    } else if (token == parser::Token_SWITCH) { 
     353        cout << tokenText << " T_SWITCH" << endl; 
     354    } else if (token == parser::Token_THROW) { 
     355        cout << tokenText << " T_THROW" << endl; 
     356    } else if (token == parser::Token_TRY) { 
     357        cout << tokenText << " T_TRY" << endl; 
     358    } else if (token == parser::Token_WHILE) { 
     359        cout << tokenText << " T_WHILE" << endl; 
     360    } else if (token == parser::Token_INT_CAST) { 
     361        cout << tokenText << " T_INT_CAST" << endl; 
     362    } else if (token == parser::Token_DOUBLE_CAST) { 
     363        cout << tokenText << " T_DOUBLE_CAST" << endl; 
     364    } else if (token == parser::Token_STRING_CAST) { 
     365        cout << tokenText << " T_STRING_CAST" << endl; 
     366    } else if (token == parser::Token_ARRAY_CAST) { 
     367        cout << tokenText << " T_ARRAY_CAST" << endl; 
     368    } else if (token == parser::Token_OBJECT_CAST) { 
     369        cout << tokenText << " T_OBJECT_CAST" << endl; 
     370    } else if (token == parser::Token_BOOL_CAST) { 
     371        cout << tokenText << " T_BOOL_CAST" << endl; 
     372    } else if (token == parser::Token_UNSET_CAST) { 
     373        cout << tokenText << " T_UNSET_CAST" << endl; 
     374    } else if (token == parser::Token_CLONE) { 
     375        cout << tokenText << " T_CLONE" << endl; 
     376    } else if (token == parser::Token_EXIT) { 
     377        cout << tokenText << " T_EXIT" << endl; 
     378    } else if (token == parser::Token_ELSEIF) { 
     379        cout << tokenText << " T_ELSEIF" << endl; 
     380    } else if (token == parser::Token_ENDIF) { 
     381        cout << tokenText << " T_ENDIF" << endl; 
     382    } else if (token == parser::Token_ENDWHILE) { 
     383        cout << tokenText << " T_ENDWHILE" << endl; 
     384    } else if (token == parser::Token_ENDFOR) { 
     385        cout << tokenText << " T_ENDFOR" << endl; 
     386    } else if (token == parser::Token_FOREACH) { 
     387        cout << tokenText << " T_FOREACH" << endl; 
     388    } else if (token == parser::Token_ENDFOREACH) { 
     389        cout << tokenText << " T_ENDFOREACH" << endl; 
     390    } else if (token == parser::Token_DECLARE) { 
     391        cout << tokenText << " T_DECLARE" << endl; 
     392    } else if (token == parser::Token_ENDDECLARE) { 
     393        cout << tokenText << " T_ENDDECLARE" << endl; 
     394    } else if (token == parser::Token_AS) { 
     395        cout << tokenText << " T_AS" << endl; 
     396    } else if (token == parser::Token_ENDSWITCH) { 
     397        cout << tokenText << " T_ENDSWITCH" << endl; 
     398    } else if (token == parser::Token_FUNCTION) { 
     399        cout << tokenText << " T_FUNCTION" << endl; 
     400    } else if (token == parser::Token_USE) { 
     401        cout << tokenText << " T_USE" << endl; 
     402    } else if (token == parser::Token_GLOBAL) { 
     403        cout << tokenText << " T_GLOBAL" << endl; 
     404    } else if (token == parser::Token_VAR) { 
     405        cout << tokenText << " T_VAR" << endl; 
     406    } else if (token == parser::Token_UNSET) { 
     407        cout << tokenText << " T_UNSET" << endl; 
     408    } else if (token == parser::Token_ISSET) { 
     409        cout << tokenText << " T_ISSET" << endl; 
     410    } else if (token == parser::Token_ISSET) { 
     411        cout << tokenText << " T_ISSET" << endl; 
     412    } else if (token == parser::Token_EMPTY) { 
     413        cout << tokenText << " T_EMPTY" << endl; 
     414    } else if (token == parser::Token_HALT_COMPILER) { 
     415        cout << tokenText << " T_HALT_COMPILER" << endl; 
     416    } else if (token == parser::Token_DOUBLE_ARROW) { 
     417        cout << tokenText << " T_DOUBLE_ARROW" << endl; 
     418    } else if (token == parser::Token_LIST) { 
     419        cout << tokenText << " T_LIST" << endl; 
     420    } else if (token == parser::Token_ARRAY) { 
     421        cout << tokenText << " T_ARRAY" << endl; 
     422    } else if (token == parser::Token_CLASS_C) { 
     423        cout << tokenText << " T_CLASS_C" << endl; 
     424    } else if (token == parser::Token_METHOD_C) { 
     425        cout << tokenText << " T_METHOD_C" << endl; 
     426    } else if (token == parser::Token_FUNC_C) { 
     427        cout << tokenText << " T_FUNC_C" << endl; 
     428    } else if (token == parser::Token_LINE) { 
     429        cout << tokenText << " T_LINE" << endl; 
     430    } else if (token == parser::Token_FILE) { 
     431        cout << tokenText << " T_FILE" << endl; 
     432    } else if (token == parser::Token_COMMENT) { 
     433        cout << tokenText << " T_COMMENT" << endl; 
     434    } else if (token == parser::Token_DOC_COMMENT) { 
     435        cout << tokenText << " T_DOC_COMMENT" << endl; 
     436    } else if (token == parser::Token_PAAMAYIM_NEKUDOTAYIM) { 
     437        cout << tokenText << " T_DOUBLE_COLON" << endl; 
     438    } else if (token == parser::Token_OPEN_TAG_WITH_ECHO) { 
     439        cout << tokenText << " T_OPEN_TAG_WITH_ECHO" << endl; 
     440    } else if (token == parser::Token_CURLY_OPEN) { 
     441        cout << tokenText << " T_CURLY_OPEN" << endl; 
     442    } else if (token == parser::Token_STRING_VARNAME) { 
     443        cout << tokenText << " T_STRING_VARNAME" << endl; 
     444    } else if (token == parser::Token_DOLLAR_OPEN_CURLY_BRACES) { 
     445        cout << tokenText << " T_DOLLAR_OPEN_CURLY_BRACES" << endl; 
     446    } else if (token == parser::Token_DOLLAR) { 
     447        cout << tokenText << " $" << endl; 
     448    } else if (token == parser::Token_LOGICAL_XOR) { 
     449        cout << tokenText << " T_LOGICAL_XOR" << endl; 
     450    } else if (token == parser::Token_LOGICAL_AND) { 
     451        cout << tokenText << " T_LOGICAL_AND" << endl; 
     452    } else if (token == parser::Token_LOGICAL_OR) { 
     453        cout << tokenText << " T_LOGICAL_OR" << endl; 
     454    } else if (token == parser::Token_START_HEREDOC) { 
     455        cout << tokenText << " T_START_HEREDOC" << endl; 
     456    } else if (token == parser::Token_END_HEREDOC) { 
     457        cout << tokenText << " T_END_HEREDOC" << endl; 
     458    } else if (token == parser::Token_BACKTICK) { 
     459        cout << tokenText << " `" << endl; 
     460    } else if (token == 0) { 
     461        cout << tokenText << " end of file" << endl; 
     462    } else { 
     463        cout << tokenText << " unknown token" << token; 
     464    } 
     465
     466 
     467void pDriver::dumpTokens(string fileName) { 
     468 
     469    ifstream inFile; 
     470 
     471    inFile.open(fileName.c_str(), ifstream::in); 
     472    if (!inFile) { 
     473        cout << "Unable to open file: " << endl; 
     474        exit(1); // terminate with error 
     475    } 
     476 
     477    string contents; 
     478    char buf[512]; 
     479    while (inFile) { 
     480        inFile.getline(buf, 512); 
     481        //cout << "read: " << buf << endl; 
     482        contents += buf; 
     483    } 
     484 
     485    inFile.close(); 
     486 
     487    cout << "contents: " << contents << endl; 
     488 
     489    BLexer lexer(0, contents); 
     490    int token; 
     491    while (token = lexer.nextTokenKind()) { 
     492        printToken(token, lexer, contents); 
     493    } 
     494    printToken(token, lexer, contents); 
     495 
     496
     497 
     498void pDriver::dumpAST(string fileName) { 
     499 
     500    ifstream inFile; 
     501 
     502    inFile.open(fileName.c_str(), ifstream::in); 
     503    if (!inFile) { 
     504        cout << "Unable to open file: " << endl; 
     505        exit(1); // terminate with error 
     506    } 
     507 
     508    UnicodeString contents; 
     509    char buf[512]; 
     510    while (inFile) { 
     511        inFile.getline(buf, 512); 
     512        //cout << "read: " << buf << endl; 
     513        contents += buf; 
     514    } 
     515 
     516    inFile.close(); 
     517 
     518    parser p; 
     519    p.set_token_stream( new parser::token_stream_type() ); 
     520    p.set_memory_pool( new parser::memory_pool_type() ); 
     521    p.setDebug( true ); 
     522 
     523    p.tokenize(contents); 
     524    start_ast* phpAst; 
     525    bool matched = p.parse_start(&phpAst); 
     526    if( matched ) 
    91527    { 
    92         int begin = lexer.tokenBegin(); 
    93         int end = lexer.tokenEnd(); 
    94         //UnicodeString tokenText = content.replace(begin, end-begin+1,"\n", "\\n"); 
    95         StringType tokenText(content, begin, end-begin+1); 
    96         if (token == parser::Token_INLINE_HTML) { 
    97             cout << tokenText << " T_INLINE_HTML" << endl; 
    98         } else if (token == parser::Token_OPEN_TAG) { 
    99             cout << tokenText << " T_OPEN_TAG" << endl; 
    100         } else if (token == parser::Token_CLOSE_TAG) { 
    101             cout << tokenText << " T_CLOSE_TAG" << endl; 
    102         } else if (token == parser::Token_ECHO) { 
    103             cout << tokenText << " T_ECHO" << endl; 
    104         } else if (token == parser::Token_WHITESPACE) { 
    105             cout << tokenText << " T_WHITESPACE" << endl; 
    106         } else if (token == parser::Token_CONSTANT_ENCAPSED_STRING) { 
    107             cout << tokenText << " T_CONSTANT_ENCAPSED_STRING" << endl; 
    108         } else if (token == parser::Token_SEMICOLON) { 
    109             cout << tokenText << " ;" << endl; 
    110         } else if (token == parser::Token_VARIABLE) { 
    111             cout << tokenText << " T_VARIABLE" << endl; 
    112         } else if (token == parser::Token_DOUBLE_QUOTE) { 
    113             cout << tokenText << " \"" << endl; 
    114         } else if (token == parser::Token_ENCAPSED_AND_WHITESPACE) { 
    115             cout << tokenText << " T_ENCAPSED_AND_WHITESPACE" << endl; 
    116         } else if (token == parser::Token_OBJECT_OPERATOR) { 
    117             cout << tokenText << " T_OBJECT_OPERATOR" << endl; 
    118         } else if (token == parser::Token_LBRACKET) { 
    119             cout << tokenText << " [" << endl; 
    120         } else if (token == parser::Token_RBRACKET) { 
    121             cout << tokenText << " ]" << endl; 
    122         } else if (token == parser::Token_NUM_STRING) { 
    123             cout << tokenText << " T_NUM_STRING" << endl; 
    124         } else if (token == parser::Token_STRING) { 
    125             cout << tokenText << " T_STRING" << endl; 
    126         } else if (token == parser::Token_ASSIGN) { 
    127             cout << tokenText << " =" << endl; 
    128         } else if (token == parser::Token_DNUMBER) { 
    129             cout << tokenText << " T_DNUMBER" << endl; 
    130         } else if (token == parser::Token_LNUMBER) { 
    131             cout << tokenText << " T_LNUMBER" << endl; 
    132         } else if (token == parser::Token_PLUS) { 
    133             cout << tokenText << " +" << endl; 
    134         } else if (token == parser::Token_MINUS) { 
    135             cout << tokenText << " -" << endl; 
    136         } else if (token == parser::Token_CONCAT) { 
    137             cout << tokenText << " ." << endl; 
    138         } else if (token == parser::Token_INC) { 
    139             cout << tokenText << " T_INC" << endl; 
    140         } else if (token == parser::Token_DEC) { 
    141             cout << tokenText << " T_DEC" << endl; 
    142         } else if (token == parser::Token_IS_EQUAL) { 
    143             cout << tokenText << " T_IS_EQUAL" << endl; 
    144         } else if (token == parser::Token_IS_NOT_EQUAL) { 
    145             cout << tokenText << " T_IS_NOT_EQUAL" << endl; 
    146         } else if (token == parser::Token_IS_IDENTICAL) { 
    147             cout << tokenText << " T_IS_IDENTICAL" << endl; 
    148         } else if (token == parser::Token_IS_NOT_IDENTICAL) { 
    149             cout << tokenText << " T_IS_NOT_IDENTICAL" << endl; 
    150         } else if (token == parser::Token_IS_SMALLER) { 
    151             cout << tokenText << " <" << endl; 
    152         } else if (token == parser::Token_IS_GREATER) { 
    153             cout << tokenText << " >" << endl; 
    154         } else if (token == parser::Token_IS_SMALLER_OR_EQUAL) { 
    155             cout << tokenText << " T_IS_SMALLER_OR_EQUAL" << endl; 
    156         } else if (token == parser::Token_IS_GREATER_OR_EQUAL) { 
    157             cout << tokenText << " T_IS_GREATER_OR_EQUAL" << endl; 
    158         } else if (token == parser::Token_BOOLEAN_OR) { 
    159             cout << tokenText << " T_BOOLEAN_OR" << endl; 
    160         } else if (token == parser::Token_BOOLEAN_AND) { 
    161             cout << tokenText << " T_BOOLEAN_AND" << endl; 
    162         } else if (token == parser::Token_PLUS_ASSIGN) { 
    163             cout << tokenText << " T_PLUS_EQUAL" << endl; 
    164         } else if (token == parser::Token_MINUS_ASSIGN) { 
    165             cout << tokenText << " T_MINUS_EQUAL" << endl; 
    166         } else if (token == parser::Token_MUL_ASSIGN) { 
    167             cout << tokenText << " T_MUL_EQUAL" << endl; 
    168         } else if (token == parser::Token_DIV_ASSIGN) { 
    169             cout << tokenText << " T_DIV_EQUAL" << endl; 
    170         } else if (token == parser::Token_CONCAT_ASSIGN) { 
    171             cout << tokenText << " T_CONCAT_EQUAL" << endl; 
    172         } else if (token == parser::Token_MOD_ASSIGN) { 
    173             cout << tokenText << " T_MOD_EQUAL" << endl; 
    174         } else if (token == parser::Token_AND_ASSIGN) { 
    175             cout << tokenText << " T_AND_EQUAL" << endl; 
    176         } else if (token == parser::Token_OR_ASSIGN) { 
    177             cout << tokenText << " T_OR_EQUAL" << endl; 
    178         } else if (token == parser::Token_XOR_ASSIGN) { 
    179             cout << tokenText << " T_XOR_EQUAL" << endl; 
    180         } else if (token == parser::Token_SL_ASSIGN) { 
    181             cout << tokenText << " T_SL_EQUAL" << endl; 
    182         } else if (token == parser::Token_SR_ASSIGN) { 
    183             cout << tokenText << " T_SR_EQUAL" << endl; 
    184         } else if (token == parser::Token_BANG) { 
    185             cout << tokenText << " !" << endl; 
    186         } else if (token == parser::Token_QUESTION) { 
    187             cout << tokenText << " ?" << endl; 
    188         } else if (token == parser::Token_COLON) { 
    189             cout << tokenText << " :" << endl; 
    190         } else if (token == parser::Token_BIT_AND) { 
    191             cout << tokenText << " &" << endl; 
    192         } else if (token == parser::Token_BIT_OR) { 
    193             cout << tokenText << " |" << endl; 
    194         } else if (token == parser::Token_BIT_XOR) { 
    195             cout << tokenText << " ^" << endl; 
    196         } else if (token == parser::Token_SL) { 
    197             cout << tokenText << " T_SL" << endl; 
    198         } else if (token == parser::Token_SR) { 
    199             cout << tokenText << " T_SR" << endl; 
    200         } else if (token == parser::Token_MUL) { 
    201             cout << tokenText << " *" << endl; 
    202         } else if (token == parser::Token_DIV) { 
    203             cout << tokenText << " /" << endl; 
    204         } else if (token == parser::Token_MOD) { 
    205             cout << tokenText << " %" << endl; 
    206         } else if (token == parser::Token_TILDE) { 
    207             cout << tokenText << " ~" << endl; 
    208         } else if (token == parser::Token_LPAREN) { 
    209             cout << tokenText << " (" << endl; 
    210         } else if (token == parser::Token_RPAREN) { 
    211             cout << tokenText << " )" << endl; 
    212         } else if (token == parser::Token_LBRACE) { 
    213             cout << tokenText << " {" << endl; 
    214         } else if (token == parser::Token_RBRACE) { 
    215             cout << tokenText << " }" << endl; 
    216         } else if (token == parser::Token_COMMA) { 
    217             cout << tokenText << " ," << endl; 
    218         } else if (token == parser::Token_AT) { 
    219             cout << tokenText << " @" << endl; 
    220         } else if (token == parser::Token_INCLUDE) { 
    221             cout << tokenText << " T_INCLUDE" << endl; 
    222         } else if (token == parser::Token_INCLUDE_ONCE) { 
    223             cout << tokenText << " T_INCLUDE_ONCE" << endl; 
    224         } else if (token == parser::Token_EVAL) { 
    225             cout << tokenText << " T_EVAL" << endl; 
    226         } else if (token == parser::Token_REQUIRE) { 
    227             cout << tokenText << " T_REQUIRE" << endl; 
    228         } else if (token == parser::Token_REQUIRE_ONCE) { 
    229             cout << tokenText << " T_REQUIRE_ONCE" << endl; 
    230         } else if (token == parser::Token_PRINT) { 
    231             cout << tokenText << " T_PRINT" << endl; 
    232         } else if (token == parser::Token_ABSTRACT) { 
    233             cout << tokenText << " T_ABSTRACT" << endl; 
    234         } else if (token == parser::Token_BREAK) { 
    235             cout << tokenText << " T_BREAK" << endl; 
    236         } else if (token == parser::Token_CASE) { 
    237             cout << tokenText << " T_CASE" << endl; 
    238         } else if (token == parser::Token_CATCH) { 
    239             cout << tokenText << " T_CATCH" << endl; 
    240         } else if (token == parser::Token_CLASS) { 
    241             cout << tokenText << " T_CLASS" << endl; 
    242         } else if (token == parser::Token_CONST) { 
    243             cout << tokenText << " T_CONST" << endl; 
    244         } else if (token == parser::Token_CONTINUE) { 
    245             cout << tokenText << " T_CONTINUE" << endl; 
    246         } else if (token == parser::Token_DEFAULT) { 
    247             cout << tokenText << " T_DEFAULT" << endl; 
    248         } else if (token == parser::Token_DO) { 
    249             cout << tokenText << " T_DO" << endl; 
    250         } else if (token == parser::Token_ELSE) { 
    251             cout << tokenText << " T_ELSE" << endl; 
    252         } else if (token == parser::Token_EXTENDS) { 
    253             cout << tokenText << " T_EXTENDS" << endl; 
    254         } else if (token == parser::Token_FINAL) { 
    255             cout << tokenText << " T_FINAL" << endl; 
    256         } else if (token == parser::Token_FOR) { 
    257             cout << tokenText << " T_FOR" << endl; 
    258         } else if (token == parser::Token_IF) { 
    259             cout << tokenText << " T_IF" << endl; 
    260         } else if (token == parser::Token_IMPLEMENTS) { 
    261             cout << tokenText << " T_IMPLEMENTS" << endl; 
    262         } else if (token == parser::Token_INSTANCEOF) { 
    263             cout << tokenText << " T_INSTANCEOF" << endl; 
    264         } else if (token == parser::Token_INTERFACE) { 
    265             cout << tokenText << " T_INTERFACE" << endl; 
    266         } else if (token == parser::Token_NEW) { 
    267             cout << tokenText << " T_NEW" << endl; 
    268         } else if (token == parser::Token_PRIVATE) { 
    269             cout << tokenText << " T_PRIVATE" << endl; 
    270         } else if (token == parser::Token_PROTECTED) { 
    271             cout << tokenText << " T_PROTECTED" << endl; 
    272         } else if (token == parser::Token_PUBLIC) { 
    273             cout << tokenText << " T_PUBLIC" << endl; 
    274         } else if (token == parser::Token_RETURN) { 
    275             cout << tokenText << " T_RETURN" << endl; 
    276         } else if (token == parser::Token_STATIC) { 
    277             cout << tokenText << " T_STATIC" << endl; 
    278         } else if (token == parser::Token_SWITCH) { 
    279             cout << tokenText << " T_SWITCH" << endl; 
    280         } else if (token == parser::Token_THROW) { 
    281             cout << tokenText << " T_THROW" << endl; 
    282         } else if (token == parser::Token_TRY) { 
    283             cout << tokenText << " T_TRY" << endl; 
    284         } else if (token == parser::Token_WHILE) { 
    285             cout << tokenText << " T_WHILE" << endl; 
    286         } else if (token == parser::Token_INT_CAST) { 
    287             cout << tokenText << " T_INT_CAST" << endl; 
    288         } else if (token == parser::Token_DOUBLE_CAST) { 
    289             cout << tokenText << " T_DOUBLE_CAST" << endl; 
    290         } else if (token == parser::Token_STRING_CAST) { 
    291             cout << tokenText << " T_STRING_CAST" << endl; 
    292         } else if (token == parser::Token_ARRAY_CAST) { 
    293             cout << tokenText << " T_ARRAY_CAST" << endl; 
    294         } else if (token == parser::Token_OBJECT_CAST) { 
    295             cout << tokenText << " T_OBJECT_CAST" << endl; 
    296         } else if (token == parser::Token_BOOL_CAST) { 
    297             cout << tokenText << " T_BOOL_CAST" << endl; 
    298         } else if (token == parser::Token_UNSET_CAST) { 
    299             cout << tokenText << " T_UNSET_CAST" << endl; 
    300         } else if (token == parser::Token_CLONE) { 
    301             cout << tokenText << " T_CLONE" << endl; 
    302         } else if (token == parser::Token_EXIT) { 
    303             cout << tokenText << " T_EXIT" << endl; 
    304         } else if (token == parser::Token_ELSEIF) { 
    305             cout << tokenText << " T_ELSEIF" << endl; 
    306         } else if (token == parser::Token_ENDIF) { 
    307             cout << tokenText << " T_ENDIF" << endl; 
    308         } else if (token == parser::Token_ENDWHILE) { 
    309             cout << tokenText << " T_ENDWHILE" << endl; 
    310         } else if (token == parser::Token_ENDFOR) { 
    311             cout << tokenText << " T_ENDFOR" << endl; 
    312         } else if (token == parser::Token_FOREACH) { 
    313             cout << tokenText << " T_FOREACH" << endl; 
    314         } else if (token == parser::Token_ENDFOREACH) { 
    315             cout << tokenText << " T_ENDFOREACH" << endl; 
    316         } else if (token == parser::Token_DECLARE) { 
    317             cout << tokenText << " T_DECLARE" << endl; 
    318         } else if (token == parser::Token_ENDDECLARE) { 
    319             cout << tokenText << " T_ENDDECLARE" << endl; 
    320         } else if (token == parser::Token_AS) { 
    321             cout << tokenText << " T_AS" << endl; 
    322         } else if (token == parser::Token_ENDSWITCH) { 
    323             cout << tokenText << " T_ENDSWITCH" << endl; 
    324         } else if (token == parser::Token_FUNCTION) { 
    325             cout << tokenText << " T_FUNCTION" << endl; 
    326         } else if (token == parser::Token_USE) { 
    327             cout << tokenText << " T_USE" << endl; 
    328         } else if (token == parser::Token_GLOBAL) { 
    329             cout << tokenText << " T_GLOBAL" << endl; 
    330         } else if (token == parser::Token_VAR) { 
    331             cout << tokenText << " T_VAR" << endl; 
    332         } else if (token == parser::Token_UNSET) { 
    333             cout << tokenText << " T_UNSET" << endl; 
    334         } else if (token == parser::Token_ISSET) { 
    335             cout << tokenText << " T_ISSET" << endl; 
    336         } else if (token == parser::Token_ISSET) { 
    337             cout << tokenText << " T_ISSET" << endl; 
    338         } else if (token == parser::Token_EMPTY) { 
    339             cout << tokenText << " T_EMPTY" << endl; 
    340         } else if (token == parser::Token_HALT_COMPILER) { 
    341             cout << tokenText << " T_HALT_COMPILER" << endl; 
    342         } else if (token == parser::Token_DOUBLE_ARROW) { 
    343             cout << tokenText << " T_DOUBLE_ARROW" << endl; 
    344         } else if (token == parser::Token_LIST) { 
    345             cout << tokenText << " T_LIST" << endl; 
    346         } else if (token == parser::Token_ARRAY) { 
    347             cout << tokenText << " T_ARRAY" << endl; 
    348         } else if (token == parser::Token_CLASS_C) { 
    349             cout << tokenText << " T_CLASS_C" << endl; 
    350         } else if (token == parser::Token_METHOD_C) { 
    351             cout << tokenText << " T_METHOD_C" << endl; 
    352         } else if (token == parser::Token_FUNC_C) { 
    353             cout << tokenText << " T_FUNC_C" << endl; 
    354         } else if (token == parser::Token_LINE) { 
    355             cout << tokenText << " T_LINE" << endl; 
    356         } else if (token == parser::Token_FILE) { 
    357             cout << tokenText << " T_FILE" << endl; 
    358         } else if (token == parser::Token_COMMENT) { 
    359             cout << tokenText << " T_COMMENT" << endl; 
    360         } else if (token == parser::Token_DOC_COMMENT) { 
    361             cout << tokenText << " T_DOC_COMMENT" << endl; 
    362         } else if (token == parser::Token_PAAMAYIM_NEKUDOTAYIM) { 
    363             cout << tokenText << " T_DOUBLE_COLON" << endl; 
    364         } else if (token == parser::Token_OPEN_TAG_WITH_ECHO) { 
    365             cout << tokenText << " T_OPEN_TAG_WITH_ECHO" << endl; 
    366         } else if (token == parser::Token_CURLY_OPEN) { 
    367             cout << tokenText << " T_CURLY_OPEN" << endl; 
    368         } else if (token == parser::Token_STRING_VARNAME) { 
    369             cout << tokenText << " T_STRING_VARNAME" << endl; 
    370         } else if (token == parser::Token_DOLLAR_OPEN_CURLY_BRACES) { 
    371             cout << tokenText << " T_DOLLAR_OPEN_CURLY_BRACES" << endl; 
    372         } else if (token == parser::Token_DOLLAR) { 
    373             cout << tokenText << " $" << endl; 
    374         } else if (token == parser::Token_LOGICAL_XOR) { 
    375             cout << tokenText << " T_LOGICAL_XOR" << endl; 
    376         } else if (token == parser::Token_LOGICAL_AND) { 
    377             cout << tokenText << " T_LOGICAL_AND" << endl; 
    378         } else if (token == parser::Token_LOGICAL_OR) { 
    379             cout << tokenText << " T_LOGICAL_OR" << endl; 
    380         } else if (token == parser::Token_START_HEREDOC) { 
    381             cout << tokenText << " T_START_HEREDOC" << endl; 
    382         } else if (token == parser::Token_END_HEREDOC) { 
    383             cout << tokenText << " T_END_HEREDOC" << endl; 
    384         } else if (token == parser::Token_BACKTICK) { 
    385             cout << tokenText << " `" << endl; 
    386         } else if (token == 0) { 
    387             cout << tokenText << " end of file" << endl; 
    388         } else { 
    389             cout << tokenText << " unknown token" << token; 
    390         } 
    391     } 
    392  
    393     void pDriver::dumpTokens(string fileName) { 
    394  
    395         ifstream inFile; 
    396  
    397         inFile.open(fileName.c_str(), ifstream::in); 
    398         if (!inFile) { 
    399             cout << "Unable to open file: " << endl; 
    400             exit(1); // terminate with error 
    401         } 
    402  
    403         string contents; 
    404         char buf[512]; 
    405         while (inFile) { 
    406             inFile.getline(buf, 512); 
    407             //cout << "read: " << buf << endl; 
    408             contents += buf; 
    409         } 
    410  
    411         inFile.close(); 
    412  
    413         cout << "contents: " << contents << endl; 
    414  
    415         BLexer lexer(0, contents); 
    416         int token; 
    417         while (token = lexer.nextTokenKind()) { 
    418             printToken(token, lexer, contents); 
    419         } 
    420         printToken(token, lexer, contents); 
    421  
    422     } 
    423  
    424     void pDriver::dumpAST(string fileName) { 
    425  
    426         ifstream inFile; 
    427  
    428         inFile.open(fileName.c_str(), ifstream::in); 
    429         if (!inFile) { 
    430             cout << "Unable to open file: " << endl; 
    431             exit(1); // terminate with error 
    432         } 
    433  
    434         UnicodeString contents; 
    435         char buf[512]; 
    436         while (inFile) { 
    437             inFile.getline(buf, 512); 
    438             //cout << "read: " << buf << endl; 
    439             contents += buf; 
    440         } 
    441  
    442         inFile.close(); 
    443  
    444         parser p; 
    445         p.set_token_stream( new parser::token_stream_type() ); 
    446         p.set_memory_pool( new parser::memory_pool_type() ); 
    447         p.setDebug( true ); 
    448  
    449         p.tokenize(contents); 
    450         start_ast* phpAst; 
    451         bool matched = p.parse_start(&phpAst); 
    452         if( matched ) 
    453         { 
    454             std::cout << "Successfully parsed" << std::endl; 
    455             debug_visitor dv; 
    456             dv.visit_start(phpAst); 
    457         }else 
    458         { 
    459             //*ast = 0; 
    460             //std::cout << p.expected_symbol(ast_node::Kind_start, "start"); 
    461             std::cout << "Couldn't parse content" << std::endl; 
    462         } 
    463  
    464     } 
    465  
    466 
    467  
    468  
     528        std::cout << "Successfully parsed" << std::endl; 
     529        debug_visitor dv; 
     530        dv.visit_start(phpAst); 
     531    }else 
     532    { 
     533        //*ast = 0; 
     534        //std::cout << p.expected_symbol(ast_node::Kind_start, "start"); 
     535        std::cout << "Couldn't parse content" << std::endl; 
     536    } 
     537 
     538
     539 
     540 
     541
     542 
     543 
  • trunk/rphp/compiler/pDriver.h

    r621 r622  
    66;; as published by the Free Software Foundation; either version 2 
    77;; of the License, or (at your option) any later version. 
    8 ;;  
     8;; 
    99;; This program is distributed in the hope that it will be useful, 
    1010;; but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1111;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212;; GNU General Public License for more details. 
    13 ;;  
     13;; 
    1414;; You should have received a copy of the GNU General Public License 
    1515;; along with this program; if not, write to the Free Software 
     
    2323#include <string> 
    2424 
     25namespace llvm { 
     26    class Module; 
     27} 
     28 
    2529namespace rphp { 
    2630 
     31    class pDriver { 
     32    private: 
     33        llvm::Module* compileToIR(std::string fileName); 
    2734 
    28     class pDriver { 
     35    publ