Changeset 557
- Timestamp:
- 06/21/08 04:20:51 (5 months ago)
- Files:
-
- trunk/rphp/compiler/parser/php.g (modified) (9 diffs)
- trunk/rphp/compiler/parser/rphp_ast.h (modified) (1 diff)
- trunk/rphp/compiler/parser/rphp_parser.cpp (modified) (5 diffs)
- trunk/rphp/compiler/parser/rphp_parser.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/compiler/parser/php.g
r555 r557 23 23 [: 24 24 25 #include <QtCore/QString> 26 #include <kdebug.h> 27 28 namespace Php 25 namespace RPHP 29 26 { 30 27 class Lexer; … … 54 51 * and any parse*() method can be called. 55 52 */ 56 void tokenize( const QString& contents );53 void tokenize( const std::string& contents ); 57 54 58 55 enum ProblemType { … … 61 58 Info 62 59 }; 63 void reportProblem( Parser::ProblemType type, const QString& message );64 QString tokenText(qint64 begin, qint64 end);60 void reportProblem( Parser::ProblemType type, const std::string& message ); 61 std::string tokenText(qint64 begin, qint64 end); 65 62 void setDebug(bool debug); 66 63 … … 74 71 OnlyNewObject 75 72 }; 76 QString m_contents;73 std::string m_contents; 77 74 bool m_debug; 78 75 … … 717 714 { 718 715 719 void Parser::tokenize( const QString& contents )716 void Parser::tokenize( const std::string& contents ) 720 717 { 721 718 m_contents = contents; … … 745 742 746 743 747 QString Parser::tokenText(qint64 begin, qint64 end)744 std::string Parser::tokenText(qint64 begin, qint64 end) 748 745 { 749 746 return m_contents.mid(begin,end-begin+1); … … 751 748 752 749 753 void Parser::reportProblem( Parser::ProblemType type, const QString& message )750 void Parser::reportProblem( Parser::ProblemType type, const std::string& message ) 754 751 { 755 752 if (type == Error) … … 763 760 764 761 // custom error recovery 765 void Parser::expectedToken(int /*expected*/, qint64 /*where*/, const QString& name) 766 { 767 reportProblem( Parser::Error, QString("Expected token \"%1\"").arg(name)); 762 void Parser::expectedToken(int /*expected*/, qint64 /*where*/, const std::string& name) 763 { 764 // TODO port me 765 // reportProblem( Parser::Error, QString("Expected token \"%1\"").arg(name)); 768 766 } 769 767 770 void Parser::expectedSymbol(int /*expectedSymbol*/, const QString& name)768 void Parser::expectedSymbol(int /*expectedSymbol*/, const std::string& name) 771 769 { 772 770 qint64 line; … … 774 772 qint64 index = tokenStream->index()-1; 775 773 Token &token = tokenStream->token(index); 776 kDebug() << "token starts at:" << token.begin; 777 kDebug() << "index is:" << index; 774 // TODO port me 775 // kDebug() << "token starts at:" << token.begin; 776 // kDebug() << "index is:" << index; 778 777 tokenStream->startPosition(index, &line, &col); 779 QString tokenValue = tokenText(token.begin, token.end);778 std::string tokenValue = tokenText(token.begin, token.end); 780 779 reportProblem( Parser::Error, 781 QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 780 // TODO port me 781 // QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 782 782 .arg(name) 783 783 .arg(token.kind != 0 ? tokenValue : "EOF") trunk/rphp/compiler/parser/rphp_ast.h
r555 r557 10 10 11 11 12 #include <QtCore/QString> 13 #include <kdebug.h> 14 15 namespace Php 12 namespace RPHP 16 13 { 17 14 trunk/rphp/compiler/parser/rphp_parser.cpp
r555 r557 11 11 { 12 12 13 void Parser::tokenize( const QString& contents )13 void Parser::tokenize( const std::string& contents ) 14 14 { 15 15 m_contents = contents; … … 43 43 44 44 45 QString Parser::tokenText(qint64 begin, qint64 end)45 std::string Parser::tokenText(qint64 begin, qint64 end) 46 46 { 47 47 return m_contents.mid(begin, end - begin + 1); … … 49 49 50 50 51 void Parser::reportProblem( Parser::ProblemType type, const QString& message )51 void Parser::reportProblem( Parser::ProblemType type, const std::string& message ) 52 52 { 53 53 if (type == Error) … … 61 61 62 62 // custom error recovery 63 void Parser::expectedToken(int /*expected*/, qint64 /*where*/, const QString& name)63 void Parser::expectedToken(int /*expected*/, qint64 /*where*/, const std::string& name) 64 64 { 65 reportProblem( Parser::Error, QString("Expected token \"%1\"").arg(name)); 65 // TODO port me 66 // reportProblem( Parser::Error, QString("Expected token \"%1\"").arg(name)); 66 67 } 67 68 68 void Parser::expectedSymbol(int /*expectedSymbol*/, const QString& name)69 void Parser::expectedSymbol(int /*expectedSymbol*/, const std::string& name) 69 70 { 70 71 qint64 line; … … 72 73 qint64 index = tokenStream->index() - 1; 73 74 Token &token = tokenStream->token(index); 74 kDebug() << "token starts at:" << token.begin; 75 kDebug() << "index is:" << index; 75 // TODO port me 76 // kDebug() << "token starts at:" << token.begin; 77 // kDebug() << "index is:" << index; 76 78 tokenStream->startPosition(index, &line, &col); 77 QString tokenValue = tokenText(token.begin, token.end);79 std::string tokenValue = tokenText(token.begin, token.end); 78 80 reportProblem( Parser::Error, 79 QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 81 // TODO port me 82 // QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 80 83 .arg(name) 81 84 .arg(token.kind != 0 ? tokenValue : "EOF") trunk/rphp/compiler/parser/rphp_parser.h
r555 r557 235 235 * and any parse*() method can be called. 236 236 */ 237 void tokenize( const QString& contents );237 void tokenize( const std::string& contents ); 238 238 239 239 enum ProblemType { … … 242 242 Info 243 243 }; 244 void reportProblem( Parser::ProblemType type, const QString& message );245 QString tokenText(qint64 begin, qint64 end);244 void reportProblem( Parser::ProblemType type, const std::string& message ); 245 std::string tokenText(qint64 begin, qint64 end); 246 246 void setDebug(bool debug); 247 247 … … 254 254 OnlyNewObject 255 255 }; 256 QString m_contents;256 std::string m_contents; 257 257 bool m_debug; 258 258
