forked from qt-creator/qt-creator
qmljs: use new qml parser
adds support for singleton and getter/setter properties Change-Id: Ia6691ac7799a46885db0df44617617dcc3c13189 Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -41,6 +41,12 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qmljslexer_p.h"
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
namespace QmlJS {
|
||||
|
||||
// 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
|
||||
@@ -82,10 +88,17 @@ static inline int classify3(const QChar *s, bool qmlMode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0].unicode() == 'g') {
|
||||
if (s[1].unicode() == 'e') {
|
||||
if (s[2].unicode() == 't') {
|
||||
return Lexer::T_GET;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0].unicode() == 'i') {
|
||||
if (s[1].unicode() == 'n') {
|
||||
if (s[2].unicode() == 't') {
|
||||
return qmlMode ? int(Lexer::T_INT) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +109,13 @@ static inline int classify3(const QChar *s, bool qmlMode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0].unicode() == 's') {
|
||||
if (s[1].unicode() == 'e') {
|
||||
if (s[2].unicode() == 't') {
|
||||
return Lexer::T_SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0].unicode() == 't') {
|
||||
if (s[1].unicode() == 'r') {
|
||||
if (s[2].unicode() == 'y') {
|
||||
@@ -118,7 +138,7 @@ static inline int classify4(const QChar *s, bool qmlMode) {
|
||||
if (s[1].unicode() == 'y') {
|
||||
if (s[2].unicode() == 't') {
|
||||
if (s[3].unicode() == 'e') {
|
||||
return qmlMode ? int(Lexer::T_BYTE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +154,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 qmlMode ? int(Lexer::T_CHAR) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +179,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 qmlMode ? int(Lexer::T_GOTO) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +188,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 qmlMode ? int(Lexer::T_LONG) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +274,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 qmlMode ? Lexer::T_CONST : Lexer::T_RESERVED_WORD;
|
||||
return qmlMode ? int(Lexer::T_CONST) : int(Lexer::T_RESERVED_WORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,7 +294,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 qmlMode ? int(Lexer::T_FINAL) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +303,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 qmlMode ? int(Lexer::T_FLOAT) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +314,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 qmlMode ? int(Lexer::T_SHORT) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +323,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 qmlMode ? int(Lexer::T_SUPER) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_SUPER) : int(Lexer::T_RESERVED_WORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,7 +372,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 qmlMode ? int(Lexer::T_DOUBLE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,7 +398,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
||||
if (s[3].unicode() == 'o') {
|
||||
if (s[4].unicode() == 'r') {
|
||||
if (s[5].unicode() == 't') {
|
||||
return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD;
|
||||
return qmlMode ? int(Lexer::T_IMPORT) : int(Lexer::T_RESERVED_WORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,7 +411,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 qmlMode ? int(Lexer::T_NATIVE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,6 +430,17 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[1].unicode() == 'r') {
|
||||
if (s[2].unicode() == 'a') {
|
||||
if (s[3].unicode() == 'g') {
|
||||
if (s[4].unicode() == 'm') {
|
||||
if (s[5].unicode() == 'a') {
|
||||
return qmlMode ? Lexer::T_PRAGMA : Lexer::T_IDENTIFIER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0].unicode() == 'r') {
|
||||
if (s[1].unicode() == 'e') {
|
||||
@@ -441,7 +472,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 qmlMode ? int(Lexer::T_STATIC) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +496,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 qmlMode ? int(Lexer::T_THROWS) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,7 +525,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 qmlMode ? int(Lexer::T_BOOLEAN) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +585,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 qmlMode ? int(Lexer::T_PACKAGE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,7 +598,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 qmlMode ? int(Lexer::T_PRIVATE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -587,7 +618,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 qmlMode ? int(Lexer::T_ABSTRACT) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -689,7 +720,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 qmlMode ? int(Lexer::T_VOLATILE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -711,7 +742,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 qmlMode ? int(Lexer::T_INTERFACE) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -730,7 +761,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 qmlMode ? int(Lexer::T_PROTECTED) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,7 +780,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 qmlMode ? int(Lexer::T_TRANSIENT) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -773,7 +804,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 qmlMode ? int(Lexer::T_IMPLEMENTS) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -819,7 +850,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 qmlMode ? int(Lexer::T_SYNCHRONIZED) : Lexer::T_IDENTIFIER;
|
||||
return qmlMode ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -851,4 +882,8 @@ int Lexer::classify(const QChar *s, int n, bool qmlMode) {
|
||||
} // switch
|
||||
}
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
|
||||
#endif // QMLJSKEYWORDS_P_H
|
||||
|
||||
Reference in New Issue
Block a user