diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2011-09-08 12:23:16 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-19 12:07:46 +0200 |
commit | f3a0513259e38e3104600983be81d239750a8e6e (patch) | |
tree | f163499385bf35d56fdabb5d5e7154460fdb81e1 /src | |
parent | 3c45c63827867995277432ffa19b787c8717ccce (diff) |
Fix the implementation of Lexer::tokenText().
Lexer::tokenText() should return the contents of the
string literal without the quotes.
Change-Id: I968ca2e5142d8c55c75990c24380d2faa9b313a3
Reviewed-on: http://codereview.qt-project.org/4440
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejslexer.cpp | 17 | ||||
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejslexer_p.h | 1 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index def1aa87ad..def027c1f8 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -104,6 +104,7 @@ Lexer::Lexer(Engine *engine) , _parenthesesCount(0) , _stackToken(-1) , _patternFlags(0) + , _tokenKind(0) , _tokenLength(0) , _tokenLine(0) , _validTokenText(false) @@ -175,14 +176,14 @@ void Lexer::scanChar() int Lexer::lex() { _tokenSpell = QStringRef(); - int token = scanToken(); + _tokenKind = scanToken(); _tokenLength = _codePtr - _tokenStartPtr - 1; _delimited = false; _restrictedKeyword = false; // update the flags - switch (token) { + switch (_tokenKind) { case T_LBRACE: case T_SEMICOLON: _delimited = true; @@ -214,11 +215,11 @@ int Lexer::lex() break; case CountParentheses: - if (token == T_RPAREN) { + if (_tokenKind == T_RPAREN) { --_parenthesesCount; if (_parenthesesCount == 0) _parenthesesState = BalancedParentheses; - } else if (token == T_LPAREN) { + } else if (_tokenKind == T_LPAREN) { ++_parenthesesCount; } break; @@ -228,7 +229,7 @@ int Lexer::lex() break; } // switch - return token; + return _tokenKind; } bool Lexer::isUnicodeEscapeSequence(const QChar *chars) @@ -541,8 +542,6 @@ again: case '\'': case '"': { const QChar quote = ch; - _validTokenText = true; - bool multilineStringLiteral = false; const QChar *startCode = _codePtr; @@ -561,6 +560,7 @@ again: } } + _validTokenText = true; _tokenText.resize(0); startCode--; while (startCode != _codePtr - 1) @@ -1010,6 +1010,9 @@ QString Lexer::tokenText() const if (_validTokenText) return _tokenText; + if (_tokenKind == T_STRING_LITERAL) + return QString(_tokenStartPtr + 1, _tokenLength - 2); + return QString(_tokenStartPtr, _tokenLength); } diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h index 3080a05d07..34cd9873ae 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer_p.h +++ b/src/declarative/qml/parser/qdeclarativejslexer_p.h @@ -193,6 +193,7 @@ private: int _stackToken; int _patternFlags; + int _tokenKind; int _tokenLength; int _tokenLine; |