diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2011-12-06 14:09:22 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-06 15:29:39 +0100 |
commit | e7d1a74d994445749275e8e5cb88b0a21938bb09 (patch) | |
tree | 6dde884c6079e8a448a4f645b144fd252b4e3d6e /src/declarative | |
parent | e7281e2dc89ca934d3c1e89484d279331a96de71 (diff) |
Improve parsing of escape characters and regexp literals.
That is, in QML/JS you can escape characters in identifiers, e.g.
var c\u0061se = 25
declares a variable called `case' with value 25. In such cases
qmlmin needs to preserve the escape sequence in the declaration.
Also, fix possible errors when pasting keywords after regexp literals.
The minifier needs to preserve the whitespace character after the
regexp delimiter, e.g.
/x/instanceof blah
without the white space after the regexp, the `i' of `instanceof'
is parsed as a regexp flag.
Change-Id: I5f426ac62949e34d092d4fdb0a41243de8ff2236
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejslexer.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejslexer_p.h | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index 9b9af3868d..5e008d27f1 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -113,6 +113,11 @@ Lexer::Lexer(Engine *engine) engine->setLexer(this); } +bool Lexer::qmlMode() const +{ + return _qmlMode; +} + QString Lexer::code() const { return _code; diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h index a0f02afa60..31eeff8181 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer_p.h +++ b/src/declarative/qml/parser/qdeclarativejslexer_p.h @@ -145,6 +145,8 @@ public: public: Lexer(Engine *engine); + bool qmlMode() const; + QString code() const; void setCode(const QString &code, int lineno, bool qmlMode = true); @@ -183,12 +185,13 @@ public: BalancedParentheses }; +protected: + int classify(const QChar *s, int n, bool qmlMode); + private: inline void scanChar(); int scanToken(); - int classify(const QChar *s, int n, bool qmlMode); - bool isLineTerminator() const; static bool isIdentLetter(QChar c); static bool isDecimalDigit(ushort c); |