Changeset 620
- Timestamp:
- 08/02/08 11:10:49 (4 months ago)
- Files:
-
- trunk/rphp/compiler/pDriver.cpp (modified) (2 diffs)
- trunk/rphp/compiler/pDriver.h (modified) (1 diff)
- trunk/rphp/frontend/cli/main.cpp (modified) (2 diffs)
- trunk/rphp/runtime/pFunctionManager.cpp (modified) (1 diff)
- trunk/rphp/runtime/standard/pStandardExt.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/compiler/pDriver.cpp
r616 r620 25 25 #include <unicode/ustream.h> 26 26 27 #include "parser/rphp_debug_visitor.h" 27 28 #include "parser/phplexer.h" 28 29 #include "parser/rphp_parser.h" … … 369 370 } 370 371 372 void pDriver::dumpAST(string fileName) { 373 374 ifstream inFile; 375 376 inFile.open(fileName.c_str(), ifstream::in); 377 if (!inFile) { 378 cout << "Unable to open file: " << endl; 379 exit(1); // terminate with error 380 } 381 382 UnicodeString contents; 383 char buf[512]; 384 while (inFile) { 385 inFile.getline(buf, 512); 386 //cout << "read: " << buf << endl; 387 contents += buf; 388 } 389 390 inFile.close(); 391 392 parser p; 393 p.set_token_stream( new parser::token_stream_type() ); 394 p.set_memory_pool( new parser::memory_pool_type() ); 395 p.setDebug( true ); 396 397 p.tokenize(contents); 398 start_ast* phpAst; 399 bool matched = p.parse_start(&phpAst); 400 if( matched ) 401 { 402 std::cout << "Successfully parsed" << std::endl; 403 debug_visitor dv; 404 dv.visit_start(phpAst); 405 }else 406 { 407 //*ast = 0; 408 //std::cout << p.expected_symbol(ast_node::Kind_start, "start"); 409 std::cout << "Couldn't parse content" << std::endl; 410 } 411 412 } 413 414 371 415 } 372 416 trunk/rphp/compiler/pDriver.h
r614 r620 30 30 public: 31 31 void dumpTokens(std::string fileName); 32 void dumpAST(std::string fileName); 32 33 33 34 }; trunk/rphp/frontend/cli/main.cpp
r618 r620 19 19 desc.add_options() 20 20 ("help", "produce help message") 21 ("dump-toks", "dump tokens from lexer") 22 ("dump-ast", "dump AST") 21 23 // ("optimization", po::value<int>(&opt)->default_value(10), "optimization level") 22 24 ("input-file", po::value< std::vector<std::string> >(), "input file") … … 32 34 33 35 if (vm.count("help") || !vm.count("input-file")) { 36 std::cout << "Roadsend PHP" << std::endl; 34 37 std::cout << desc << "\n"; 35 38 return 1; 36 39 } 37 40 38 //std::cout << "Roadsend PHP" << std::endl;39 41 40 std::vector<std::string> infiles = vm["input-file"].as< std::vector<std::string> >(); 41 for (std::vector<std::string>::iterator it = infiles.begin(); it!=infiles.end(); ++it) { 42 driver.dumpTokens(*it); 42 if (vm.count("dump-toks")) { 43 std::vector<std::string> infiles = vm["input-file"].as< std::vector<std::string> >(); 44 for (std::vector<std::string>::iterator it = infiles.begin(); it!=infiles.end(); ++it) { 45 driver.dumpTokens(*it); 46 } 47 } 48 else if (vm.count("dump-ast")) { 49 std::vector<std::string> infiles = vm["input-file"].as< std::vector<std::string> >(); 50 for (std::vector<std::string>::iterator it = infiles.begin(); it!=infiles.end(); ++it) { 51 driver.dumpAST(*it); 52 } 53 } 54 else { 55 std::cout << "Roadsend PHP" << std::endl; 56 std::cout << desc << "\n"; 57 return 1; 43 58 } 44 59 45 //std::cout << "Optimization level is " << opt << "\n";60 return 0; 46 61 47 62 } trunk/rphp/runtime/pFunctionManager.cpp
r619 r620 24 24 void pFunctionManager::registerBuiltin(const pExtBase* sourceExt, const pUString& funName, const pFunPointer1& f) { 25 25 26 std::cout << "registering " << funName << std::endl;27 26 functionRegistry.insert(functionEntry(funName, new pFunctionSig(sourceExt, funName, f))); 28 27 trunk/rphp/runtime/standard/pStandardExt.cpp
r618 r620 24 24 void pStandardExt::extensionStartup() { 25 25 26 std::cout << "initializing standard extension" << std::endl;26 //std::cout << "initializing standard extension" << std::endl; 27 27 28 28 registerBuiltin("strlen", boost::bind(&pStandardExt::strlen, this, _1)); … … 32 32 void pStandardExt::extensionShutdown() { 33 33 34 std::cout << "deinitializing standard extension" << std::endl;34 //std::cout << "deinitializing standard extension" << std::endl; 35 35 36 36 }
