qmljs/parser: update to latest qt5 parser

fix error semicolon insertion of loops, strict mode

Change-Id: Ic67d6b1fff6f476ea7eb64ae0ee43515d29654a5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Fawzi Mohamed
2013-01-22 11:15:23 +01:00
parent 6c1094aef5
commit 259145f080
14 changed files with 1394 additions and 1014 deletions

View File

@@ -41,10 +41,16 @@
// We mean it.
//
// Note on the int() casts in the following code:
// they casts values from Lexer's anonymous enum (aliasing some of the inherited
// QmlJSGrammar::VariousConstants) to int when used with inherited values of the
// enum QmlJSGrammar::VariousConstants in a ?: expression to suppress gcc
// "enumeral mismatch" warning
static inline int classify2(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'a') {
if (s[1].unicode() == 's') {
return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD;
return qmlMode ? Lexer::T_AS : Lexer::T_IDENTIFIER;
}
}
else if (s[0].unicode() == 'd') {
@@ -62,13 +68,13 @@ static inline int classify2(const QChar *s, bool qmlMode) {
}
else if (qmlMode && s[0].unicode() == 'o') {
if (s[1].unicode() == 'n') {
return Lexer::T_ON;
return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER;
}
}
return Lexer::T_IDENTIFIER;
}
static inline int classify3(const QChar *s, bool /*qmlMode*/) {
static inline int classify3(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'f') {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'r') {
@@ -79,7 +85,7 @@ static inline int classify3(const QChar *s, bool /*qmlMode*/) {
else if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') {
return Lexer::T_INT;
return qmlMode ? int(Lexer::T_INT) : Lexer::T_IDENTIFIER;
}
}
}
@@ -107,12 +113,12 @@ static inline int classify3(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER;
}
static inline int classify4(const QChar *s, bool /*qmlMode*/) {
static inline int classify4(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'y') {
if (s[2].unicode() == 't') {
if (s[3].unicode() == 'e') {
return Lexer::T_BYTE;
return qmlMode ? int(Lexer::T_BYTE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -128,7 +134,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
else if (s[1].unicode() == 'h') {
if (s[2].unicode() == 'a') {
if (s[3].unicode() == 'r') {
return Lexer::T_CHAR;
return qmlMode ? int(Lexer::T_CHAR) : Lexer::T_IDENTIFIER;
}
}
}
@@ -153,7 +159,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 't') {
if (s[3].unicode() == 'o') {
return Lexer::T_GOTO;
return qmlMode ? int(Lexer::T_GOTO) : Lexer::T_IDENTIFIER;
}
}
}
@@ -162,7 +168,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'g') {
return Lexer::T_LONG;
return qmlMode ? int(Lexer::T_LONG) : Lexer::T_IDENTIFIER;
}
}
}
@@ -213,7 +219,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER;
}
static inline int classify5(const QChar *s, bool /*qmlMode*/) {
static inline int classify5(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'r') {
if (s[2].unicode() == 'e') {
@@ -248,7 +254,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'n') {
if (s[3].unicode() == 's') {
if (s[4].unicode() == 't') {
return Lexer::T_CONST;
return qmlMode ? Lexer::T_CONST : Lexer::T_RESERVED_WORD;
}
}
}
@@ -268,7 +274,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'a') {
if (s[4].unicode() == 'l') {
return Lexer::T_FINAL;
return qmlMode ? int(Lexer::T_FINAL) : Lexer::T_IDENTIFIER;
}
}
}
@@ -277,7 +283,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'a') {
if (s[4].unicode() == 't') {
return Lexer::T_FLOAT;
return qmlMode ? int(Lexer::T_FLOAT) : Lexer::T_IDENTIFIER;
}
}
}
@@ -288,7 +294,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'r') {
if (s[4].unicode() == 't') {
return Lexer::T_SHORT;
return qmlMode ? int(Lexer::T_SHORT) : Lexer::T_IDENTIFIER;
}
}
}
@@ -297,7 +303,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'p') {
if (s[3].unicode() == 'e') {
if (s[4].unicode() == 'r') {
return Lexer::T_SUPER;
return qmlMode ? int(Lexer::T_SUPER) : Lexer::T_IDENTIFIER;
}
}
}
@@ -346,7 +352,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'b') {
if (s[4].unicode() == 'l') {
if (s[5].unicode() == 'e') {
return Lexer::T_DOUBLE;
return qmlMode ? int(Lexer::T_DOUBLE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -385,7 +391,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'i') {
if (s[4].unicode() == 'v') {
if (s[5].unicode() == 'e') {
return Lexer::T_NATIVE;
return qmlMode ? int(Lexer::T_NATIVE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -398,7 +404,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'l') {
if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') {
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD;
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER;
}
}
}
@@ -435,7 +441,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 't') {
if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') {
return Lexer::T_STATIC;
return qmlMode ? int(Lexer::T_STATIC) : Lexer::T_IDENTIFIER;
}
}
}
@@ -459,7 +465,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'o') {
if (s[4].unicode() == 'w') {
if (s[5].unicode() == 's') {
return Lexer::T_THROWS;
return qmlMode ? int(Lexer::T_THROWS) : Lexer::T_IDENTIFIER;
}
}
}
@@ -480,7 +486,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
static inline int classify7(const QChar *s, bool /*qmlMode*/) {
static inline int classify7(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'o') {
@@ -488,7 +494,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'e') {
if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'n') {
return Lexer::T_BOOLEAN;
return qmlMode ? int(Lexer::T_BOOLEAN) : Lexer::T_IDENTIFIER;
}
}
}
@@ -548,7 +554,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'a') {
if (s[5].unicode() == 'g') {
if (s[6].unicode() == 'e') {
return Lexer::T_PACKAGE;
return qmlMode ? int(Lexer::T_PACKAGE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -561,7 +567,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'a') {
if (s[5].unicode() == 't') {
if (s[6].unicode() == 'e') {
return Lexer::T_PRIVATE;
return qmlMode ? int(Lexer::T_PRIVATE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -581,7 +587,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'c') {
if (s[7].unicode() == 't') {
return Lexer::T_ABSTRACT;
return qmlMode ? int(Lexer::T_ABSTRACT) : Lexer::T_IDENTIFIER;
}
}
}
@@ -649,7 +655,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'r') {
if (s[6].unicode() == 't') {
if (s[7].unicode() == 'y') {
return Lexer::T_PROPERTY;
return qmlMode ? Lexer::T_PROPERTY : Lexer::T_IDENTIFIER;
}
}
}
@@ -683,7 +689,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'i') {
if (s[6].unicode() == 'l') {
if (s[7].unicode() == 'e') {
return Lexer::T_VOLATILE;
return qmlMode ? int(Lexer::T_VOLATILE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -695,7 +701,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
static inline int classify9(const QChar *s, bool /*qmlMode*/) {
static inline int classify9(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') {
@@ -705,7 +711,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 'a') {
if (s[7].unicode() == 'c') {
if (s[8].unicode() == 'e') {
return Lexer::T_INTERFACE;
return qmlMode ? int(Lexer::T_INTERFACE) : Lexer::T_IDENTIFIER;
}
}
}
@@ -724,7 +730,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 't') {
if (s[7].unicode() == 'e') {
if (s[8].unicode() == 'd') {
return Lexer::T_PROTECTED;
return qmlMode ? int(Lexer::T_PROTECTED) : Lexer::T_IDENTIFIER;
}
}
}
@@ -743,7 +749,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 'e') {
if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') {
return Lexer::T_TRANSIENT;
return qmlMode ? int(Lexer::T_TRANSIENT) : Lexer::T_IDENTIFIER;
}
}
}
@@ -756,7 +762,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER;
}
static inline int classify10(const QChar *s, bool /*qmlMode*/) {
static inline int classify10(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'm') {
if (s[2].unicode() == 'p') {
@@ -767,7 +773,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') {
if (s[9].unicode() == 's') {
return Lexer::T_IMPLEMENTS;
return qmlMode ? int(Lexer::T_IMPLEMENTS) : Lexer::T_IDENTIFIER;
}
}
}
@@ -800,7 +806,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER;
}
static inline int classify12(const QChar *s, bool /*qmlMode*/) {
static inline int classify12(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 's') {
if (s[1].unicode() == 'y') {
if (s[2].unicode() == 'n') {
@@ -813,7 +819,7 @@ static inline int classify12(const QChar *s, bool /*qmlMode*/) {
if (s[9].unicode() == 'z') {
if (s[10].unicode() == 'e') {
if (s[11].unicode() == 'd') {
return Lexer::T_SYNCHRONIZED;
return qmlMode ? int(Lexer::T_SYNCHRONIZED) : Lexer::T_IDENTIFIER;
}
}
}