Changeset 561
- Timestamp:
- 06/22/08 07:53:01 (5 months ago)
- Files:
-
- trunk/rphp/compiler/parser/php.g (modified) (9 diffs)
- trunk/rphp/compiler/parser/rphp_ast.h (modified) (2 diffs)
- trunk/rphp/compiler/parser/rphp_parser.cpp (modified) (7 diffs)
- trunk/rphp/compiler/parser/rphp_parser.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/compiler/parser/php.g
r560 r561 23 23 [: 24 24 25 #include <string> 26 #include <iostream> 27 25 28 namespace rphp 26 29 { … … 30 33 DoubleNumber, 31 34 }; 35 36 // TODO define win macro 37 #ifdef WIN 38 typedef __int64 rint64; 39 #else 40 typedef long long rint64; 41 #endif 42 32 43 } 33 44 :] … … 57 68 }; 58 69 void reportProblem( parser::ProblemType type, const std::string& message ); 59 std::string tokenText( qint64 begin, qint64 end);70 std::string tokenText(rint64 begin, rint64 end); 60 71 void setDebug(bool debug); 61 72 … … 727 738 kind = parser::Token_EOF; 728 739 } 729 parser:: Token &t = tokenStream->next();740 parser::token_type &t = token_stream->next(); 730 741 t.begin = lexer.tokenBegin(); 731 742 t.end = lexer.tokenEnd(); … … 739 750 740 751 741 std::string parser::tokenText(qint64 begin, qint64 end) 742 { 752 std::string parser::tokenText(rint64 begin, rint64 end) 753 { 754 #ifdef PENDING_THOMAS 755 // TODO pending 743 756 return m_contents.mid(begin,end-begin+1); 757 #endif 758 return ""; 744 759 } 745 760 … … 748 763 { 749 764 if (type == Error) 750 cout << "** ERROR:" << message;765 std::cout << "** ERROR:" << message; 751 766 else if (type == Warning) 752 cout << "** WARNING:" << message;767 std::cout << "** WARNING:" << message; 753 768 else if (type == Info) 754 cout << "** Info:" << message;769 std::cout << "** Info:" << message; 755 770 } 756 771 757 772 #ifdef PEDNING_THOMAS 773 // TODO pending 758 774 // custom error recovery 759 void parser::expectedToken(int /*expected*/, qint64 /*where*/, const std::string& name) 760 { 761 // TODO port me 762 // reportProblem( parser::Error, QString("Expected token \"%1\"").arg(name)); 775 void parser::expectedToken(int /*expected*/, rint64 /*where*/, const std::string& name) 776 { 777 reportProblem( parser::Error, QString("Expected token \"%1\"").arg(name)); 763 778 } 764 779 765 780 void parser::expectedSymbol(int /*expectedSymbol*/, const std::string& name) 766 781 { 767 qint64 line; 768 qint64 col; 769 qint64 index = tokenStream->index()-1; 770 Token &token = tokenStream->token(index); 771 // TODO port me 772 // kDebug() << "token starts at:" << token.begin; 773 // kDebug() << "index is:" << index; 774 tokenStream->startPosition(index, &line, &col); 782 rint64 line; 783 rint64 col; 784 rint64 index = token_stream->index()-1; 785 token_type &token = token_stream->token(index); 786 kDebug() << "token starts at:" << token.begin; 787 kDebug() << "index is:" << index; 788 token_stream->startPosition(index, &line, &col); 775 789 std::string tokenValue = tokenText(token.begin, token.end); 776 790 reportProblem( parser::Error, … … 783 797 .arg(col)); 784 798 } 799 #endif 785 800 786 801 void parser::setDebug( bool debug ) … … 789 804 } 790 805 791 parser::parser_state *parser::copy CurrentState()806 parser::parser_state *parser::copy_current_state() 792 807 { 793 808 parser_state *state = new parser_state(); … … 797 812 } 798 813 799 void parser::restore State( parser::parser_state* state)814 void parser::restore_state( parser::parser_state* state) 800 815 { 801 816 m_state.varExpressionState = state->varExpressionState; trunk/rphp/compiler/parser/rphp_ast.h
r559 r561 8 8 9 9 10 11 #include <string> 12 #include <iostream> 10 13 11 14 namespace rphp … … 17 20 DoubleNumber, 18 21 }; 22 23 // TODO define win macro 24 #ifdef WIN 25 typedef __int64 rint64; 26 #else 27 typedef long long rint64; 28 #endif 29 19 30 } 20 31 trunk/rphp/compiler/parser/rphp_parser.cpp
r560 r561 6 6 7 7 #include "phplexer.h" 8 #include <string>9 8 10 9 namespace rphp … … 30 29 kind = parser::Token_EOF; 31 30 } 32 parser:: Token &t = tokenStream->next();31 parser::token_type &t = token_stream->next(); 33 32 t.begin = lexer.tokenBegin(); 34 33 t.end = lexer.tokenEnd(); … … 43 42 44 43 45 std::string parser::tokenText( qint64 begin, qint64 end)44 std::string parser::tokenText(rint64 begin, rint64 end) 46 45 { 46 #ifdef PENDING_THOMAS 47 // TODO pending 47 48 return m_contents.mid(begin, end - begin + 1); 49 #endif 50 return ""; 48 51 } 49 52 … … 52 55 { 53 56 if (type == Error) 54 cout << "** ERROR:" << message;57 std::cout << "** ERROR:" << message; 55 58 else if (type == Warning) 56 cout << "** WARNING:" << message;59 std::cout << "** WARNING:" << message; 57 60 else if (type == Info) 58 cout << "** Info:" << message;61 std::cout << "** Info:" << message; 59 62 } 60 63 61 64 #ifdef PEDNING_THOMAS 65 // TODO pending 62 66 // custom error recovery 63 void parser::expectedToken(int /*expected*/, qint64 /*where*/, const std::string& name)67 void parser::expectedToken(int /*expected*/, rint64 /*where*/, const std::string& name) 64 68 { 65 // TODO port me 66 // reportProblem( parser::Error, QString("Expected token \"%1\"").arg(name)); 69 reportProblem( parser::Error, QString("Expected token \"%1\"").arg(name)); 67 70 } 68 71 69 72 void parser::expectedSymbol(int /*expectedSymbol*/, const std::string& name) 70 73 { 71 qint64 line; 72 qint64 col; 73 qint64 index = tokenStream->index() - 1; 74 Token &token = tokenStream->token(index); 75 // TODO port me 76 // kDebug() << "token starts at:" << token.begin; 77 // kDebug() << "index is:" << index; 78 tokenStream->startPosition(index, &line, &col); 74 rint64 line; 75 rint64 col; 76 rint64 index = token_stream->index() - 1; 77 token_type &token = token_stream->token(index); 78 kDebug() << "token starts at:" << token.begin; 79 kDebug() << "index is:" << index; 80 token_stream->startPosition(index, &line, &col); 79 81 std::string tokenValue = tokenText(token.begin, token.end); 80 82 reportProblem( parser::Error, … … 88 90 } 89 91 92 #endif 93 90 94 void parser::setDebug( bool debug ) 91 95 { … … 93 97 } 94 98 95 parser::parser_state *parser::copy CurrentState()99 parser::parser_state *parser::copy_current_state() 96 100 { 97 101 parser_state *state = new parser_state(); … … 101 105 } 102 106 103 void parser::restore State( parser::parser_state* state)107 void parser::restore_state( parser::parser_state* state) 104 108 { 105 109 m_state.varExpressionState = state->varExpressionState; trunk/rphp/compiler/parser/rphp_parser.h
r560 r561 4 4 #ifndef rphp_H_INCLUDED 5 5 #define rphp_H_INCLUDED 6 #include <string> 6 7 7 #include "rphp_ast.h" 8 8 #include <kdev-pg-memory-pool.h> … … 241 241 }; 242 242 void reportProblem( parser::ProblemType type, const std::string& message ); 243 std::string tokenText( qint64 begin, qint64 end);243 std::string tokenText(rint64 begin, rint64 end); 244 244 void setDebug(bool debug); 245 245
