2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-09-13 08:42:52 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-09-13 08:42:52 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-09-13 08:42:52 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-09-13 08:42:52 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-09-13 08:42:52 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-09-13 08:42:52 +02:00
|
|
|
|
|
|
|
|
#ifndef QMLJSKEYWORDS_P_H
|
|
|
|
|
#define QMLJSKEYWORDS_P_H
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// W A R N I N G
|
|
|
|
|
// -------------
|
|
|
|
|
//
|
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
|
//
|
|
|
|
|
// We mean it.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
static inline int classify2(const QChar *s, bool qmlMode) {
|
|
|
|
|
if (s[0].unicode() == 'a') {
|
|
|
|
|
if (s[1].unicode() == 's') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'd') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
return Lexer::T_DO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'i') {
|
|
|
|
|
if (s[1].unicode() == 'f') {
|
|
|
|
|
return Lexer::T_IF;
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'n') {
|
|
|
|
|
return Lexer::T_IN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (qmlMode && s[0].unicode() == 'o') {
|
|
|
|
|
if (s[1].unicode() == 'n') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_ON;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify3(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'f') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'r') {
|
|
|
|
|
return Lexer::T_FOR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'i') {
|
|
|
|
|
if (s[1].unicode() == 'n') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_INT;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'n') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 'w') {
|
|
|
|
|
return Lexer::T_NEW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 't') {
|
|
|
|
|
if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'y') {
|
|
|
|
|
return Lexer::T_TRY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'v') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 'r') {
|
|
|
|
|
return Lexer::T_VAR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify4(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'b') {
|
|
|
|
|
if (s[1].unicode() == 'y') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_BYTE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'c') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 's') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_CASE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'a') {
|
|
|
|
|
if (s[3].unicode() == 'r') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_CHAR;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'e') {
|
|
|
|
|
if (s[1].unicode() == 'l') {
|
|
|
|
|
if (s[2].unicode() == 's') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_ELSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'n') {
|
|
|
|
|
if (s[2].unicode() == 'u') {
|
|
|
|
|
if (s[3].unicode() == 'm') {
|
|
|
|
|
return Lexer::T_ENUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'g') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'o') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_GOTO;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'l') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 'g') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_LONG;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'n') {
|
|
|
|
|
if (s[1].unicode() == 'u') {
|
|
|
|
|
if (s[2].unicode() == 'l') {
|
|
|
|
|
if (s[3].unicode() == 'l') {
|
|
|
|
|
return Lexer::T_NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 't') {
|
|
|
|
|
if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'i') {
|
|
|
|
|
if (s[3].unicode() == 's') {
|
|
|
|
|
return Lexer::T_THIS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'u') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'v') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'i') {
|
|
|
|
|
if (s[3].unicode() == 'd') {
|
|
|
|
|
return Lexer::T_VOID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'w') {
|
|
|
|
|
if (s[1].unicode() == 'i') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'h') {
|
|
|
|
|
return Lexer::T_WITH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'b') {
|
|
|
|
|
if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'e') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 'k') {
|
|
|
|
|
return Lexer::T_BREAK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'c') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'c') {
|
|
|
|
|
if (s[4].unicode() == 'h') {
|
|
|
|
|
return Lexer::T_CATCH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'l') {
|
|
|
|
|
if (s[2].unicode() == 'a') {
|
|
|
|
|
if (s[3].unicode() == 's') {
|
|
|
|
|
if (s[4].unicode() == 's') {
|
|
|
|
|
return Lexer::T_CLASS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 's') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_CONST;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'f') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 'l') {
|
|
|
|
|
if (s[3].unicode() == 's') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'i') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 'l') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_FINAL;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'l') {
|
|
|
|
|
if (s[2].unicode() == 'o') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_FLOAT;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 's') {
|
|
|
|
|
if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'o') {
|
|
|
|
|
if (s[3].unicode() == 'r') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_SHORT;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'u') {
|
|
|
|
|
if (s[2].unicode() == 'p') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_SUPER;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 't') {
|
|
|
|
|
if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'r') {
|
|
|
|
|
if (s[3].unicode() == 'o') {
|
|
|
|
|
if (s[4].unicode() == 'w') {
|
|
|
|
|
return Lexer::T_THROW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'w') {
|
|
|
|
|
if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'i') {
|
|
|
|
|
if (s[3].unicode() == 'l') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_WHILE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int classify6(const QChar *s, bool qmlMode) {
|
|
|
|
|
if (s[0].unicode() == 'd') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 'l') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
|
|
|
|
if (s[5].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_DELETE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'u') {
|
|
|
|
|
if (s[3].unicode() == 'b') {
|
|
|
|
|
if (s[4].unicode() == 'l') {
|
|
|
|
|
if (s[5].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_DOUBLE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'e') {
|
|
|
|
|
if (s[1].unicode() == 'x') {
|
|
|
|
|
if (s[2].unicode() == 'p') {
|
|
|
|
|
if (s[3].unicode() == 'o') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
|
|
|
|
if (s[5].unicode() == 't') {
|
|
|
|
|
return Lexer::T_EXPORT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'i') {
|
|
|
|
|
if (s[1].unicode() == 'm') {
|
|
|
|
|
if (s[2].unicode() == 'p') {
|
|
|
|
|
if (s[3].unicode() == 'o') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
|
|
|
|
if (s[5].unicode() == 't') {
|
|
|
|
|
return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'n') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'i') {
|
|
|
|
|
if (s[4].unicode() == 'v') {
|
|
|
|
|
if (s[5].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_NATIVE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'p') {
|
|
|
|
|
if (s[1].unicode() == 'u') {
|
|
|
|
|
if (s[2].unicode() == 'b') {
|
|
|
|
|
if (s[3].unicode() == 'l') {
|
|
|
|
|
if (s[4].unicode() == 'i') {
|
|
|
|
|
if (s[5].unicode() == 'c') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'r') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'u') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
|
|
|
|
if (s[5].unicode() == 'n') {
|
|
|
|
|
return Lexer::T_RETURN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 's') {
|
|
|
|
|
if (qmlMode && s[1].unicode() == 'i') {
|
|
|
|
|
if (s[2].unicode() == 'g') {
|
|
|
|
|
if (s[3].unicode() == 'n') {
|
|
|
|
|
if (s[4].unicode() == 'a') {
|
|
|
|
|
if (s[5].unicode() == 'l') {
|
|
|
|
|
return Lexer::T_SIGNAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 't') {
|
|
|
|
|
if (s[2].unicode() == 'a') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'i') {
|
|
|
|
|
if (s[5].unicode() == 'c') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_STATIC;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'w') {
|
|
|
|
|
if (s[2].unicode() == 'i') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'c') {
|
|
|
|
|
if (s[5].unicode() == 'h') {
|
|
|
|
|
return Lexer::T_SWITCH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 't') {
|
|
|
|
|
if (s[1].unicode() == 'h') {
|
|
|
|
|
if (s[2].unicode() == 'r') {
|
|
|
|
|
if (s[3].unicode() == 'o') {
|
|
|
|
|
if (s[4].unicode() == 'w') {
|
|
|
|
|
if (s[5].unicode() == 's') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_THROWS;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'y') {
|
|
|
|
|
if (s[2].unicode() == 'p') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
if (s[4].unicode() == 'o') {
|
|
|
|
|
if (s[5].unicode() == 'f') {
|
|
|
|
|
return Lexer::T_TYPEOF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify7(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'b') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'o') {
|
|
|
|
|
if (s[3].unicode() == 'l') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
if (s[5].unicode() == 'a') {
|
|
|
|
|
if (s[6].unicode() == 'n') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_BOOLEAN;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'd') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 'f') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 'u') {
|
|
|
|
|
if (s[5].unicode() == 'l') {
|
|
|
|
|
if (s[6].unicode() == 't') {
|
|
|
|
|
return Lexer::T_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'e') {
|
|
|
|
|
if (s[1].unicode() == 'x') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
if (s[4].unicode() == 'n') {
|
|
|
|
|
if (s[5].unicode() == 'd') {
|
|
|
|
|
if (s[6].unicode() == 's') {
|
|
|
|
|
return Lexer::T_EXTENDS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'f') {
|
|
|
|
|
if (s[1].unicode() == 'i') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 'l') {
|
|
|
|
|
if (s[5].unicode() == 'l') {
|
|
|
|
|
if (s[6].unicode() == 'y') {
|
|
|
|
|
return Lexer::T_FINALLY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'p') {
|
|
|
|
|
if (s[1].unicode() == 'a') {
|
|
|
|
|
if (s[2].unicode() == 'c') {
|
|
|
|
|
if (s[3].unicode() == 'k') {
|
|
|
|
|
if (s[4].unicode() == 'a') {
|
|
|
|
|
if (s[5].unicode() == 'g') {
|
|
|
|
|
if (s[6].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_PACKAGE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'i') {
|
|
|
|
|
if (s[3].unicode() == 'v') {
|
|
|
|
|
if (s[4].unicode() == 'a') {
|
|
|
|
|
if (s[5].unicode() == 't') {
|
|
|
|
|
if (s[6].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_PRIVATE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int classify8(const QChar *s, bool qmlMode) {
|
|
|
|
|
if (s[0].unicode() == 'a') {
|
|
|
|
|
if (s[1].unicode() == 'b') {
|
|
|
|
|
if (s[2].unicode() == 's') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
|
|
|
|
if (s[5].unicode() == 'a') {
|
|
|
|
|
if (s[6].unicode() == 'c') {
|
|
|
|
|
if (s[7].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_ABSTRACT;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'c') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'i') {
|
|
|
|
|
if (s[5].unicode() == 'n') {
|
|
|
|
|
if (s[6].unicode() == 'u') {
|
|
|
|
|
if (s[7].unicode() == 'e') {
|
|
|
|
|
return Lexer::T_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'd') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 'b') {
|
|
|
|
|
if (s[3].unicode() == 'u') {
|
|
|
|
|
if (s[4].unicode() == 'g') {
|
|
|
|
|
if (s[5].unicode() == 'g') {
|
|
|
|
|
if (s[6].unicode() == 'e') {
|
|
|
|
|
if (s[7].unicode() == 'r') {
|
|
|
|
|
return Lexer::T_DEBUGGER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'f') {
|
|
|
|
|
if (s[1].unicode() == 'u') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 'c') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
|
|
|
|
if (s[5].unicode() == 'i') {
|
|
|
|
|
if (s[6].unicode() == 'o') {
|
|
|
|
|
if (s[7].unicode() == 'n') {
|
|
|
|
|
return Lexer::T_FUNCTION;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (qmlMode && s[0].unicode() == 'p') {
|
|
|
|
|
if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'o') {
|
|
|
|
|
if (s[3].unicode() == 'p') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
if (s[5].unicode() == 'r') {
|
|
|
|
|
if (s[6].unicode() == 't') {
|
|
|
|
|
if (s[7].unicode() == 'y') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_PROPERTY;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (qmlMode && s[0].unicode() == 'r') {
|
|
|
|
|
if (s[1].unicode() == 'e') {
|
|
|
|
|
if (s[2].unicode() == 'a') {
|
|
|
|
|
if (s[3].unicode() == 'd') {
|
|
|
|
|
if (s[4].unicode() == 'o') {
|
|
|
|
|
if (s[5].unicode() == 'n') {
|
|
|
|
|
if (s[6].unicode() == 'l') {
|
|
|
|
|
if (s[7].unicode() == 'y') {
|
|
|
|
|
return Lexer::T_READONLY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'v') {
|
|
|
|
|
if (s[1].unicode() == 'o') {
|
|
|
|
|
if (s[2].unicode() == 'l') {
|
|
|
|
|
if (s[3].unicode() == 'a') {
|
|
|
|
|
if (s[4].unicode() == 't') {
|
|
|
|
|
if (s[5].unicode() == 'i') {
|
|
|
|
|
if (s[6].unicode() == 'l') {
|
|
|
|
|
if (s[7].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_VOLATILE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify9(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'i') {
|
|
|
|
|
if (s[1].unicode() == 'n') {
|
|
|
|
|
if (s[2].unicode() == 't') {
|
|
|
|
|
if (s[3].unicode() == 'e') {
|
|
|
|
|
if (s[4].unicode() == 'r') {
|
|
|
|
|
if (s[5].unicode() == 'f') {
|
|
|
|
|
if (s[6].unicode() == 'a') {
|
|
|
|
|
if (s[7].unicode() == 'c') {
|
|
|
|
|
if (s[8].unicode() == 'e') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_INTERFACE;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 'p') {
|
|
|
|
|
if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'o') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
if (s[5].unicode() == 'c') {
|
|
|
|
|
if (s[6].unicode() == 't') {
|
|
|
|
|
if (s[7].unicode() == 'e') {
|
|
|
|
|
if (s[8].unicode() == 'd') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_PROTECTED;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[0].unicode() == 't') {
|
|
|
|
|
if (s[1].unicode() == 'r') {
|
|
|
|
|
if (s[2].unicode() == 'a') {
|
|
|
|
|
if (s[3].unicode() == 'n') {
|
|
|
|
|
if (s[4].unicode() == 's') {
|
|
|
|
|
if (s[5].unicode() == 'i') {
|
|
|
|
|
if (s[6].unicode() == 'e') {
|
|
|
|
|
if (s[7].unicode() == 'n') {
|
|
|
|
|
if (s[8].unicode() == 't') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_TRANSIENT;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify10(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 'i') {
|
|
|
|
|
if (s[1].unicode() == 'm') {
|
|
|
|
|
if (s[2].unicode() == 'p') {
|
|
|
|
|
if (s[3].unicode() == 'l') {
|
|
|
|
|
if (s[4].unicode() == 'e') {
|
|
|
|
|
if (s[5].unicode() == 'm') {
|
|
|
|
|
if (s[6].unicode() == 'e') {
|
|
|
|
|
if (s[7].unicode() == 'n') {
|
|
|
|
|
if (s[8].unicode() == 't') {
|
|
|
|
|
if (s[9].unicode() == 's') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_IMPLEMENTS;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (s[1].unicode() == 'n') {
|
|
|
|
|
if (s[2].unicode() == 's') {
|
|
|
|
|
if (s[3].unicode() == 't') {
|
|
|
|
|
if (s[4].unicode() == 'a') {
|
|
|
|
|
if (s[5].unicode() == 'n') {
|
|
|
|
|
if (s[6].unicode() == 'c') {
|
|
|
|
|
if (s[7].unicode() == 'e') {
|
|
|
|
|
if (s[8].unicode() == 'o') {
|
|
|
|
|
if (s[9].unicode() == 'f') {
|
|
|
|
|
return Lexer::T_INSTANCEOF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 15:06:08 +01:00
|
|
|
static inline int classify12(const QChar *s, bool /*qmlMode*/) {
|
2011-09-13 08:42:52 +02:00
|
|
|
if (s[0].unicode() == 's') {
|
|
|
|
|
if (s[1].unicode() == 'y') {
|
|
|
|
|
if (s[2].unicode() == 'n') {
|
|
|
|
|
if (s[3].unicode() == 'c') {
|
|
|
|
|
if (s[4].unicode() == 'h') {
|
|
|
|
|
if (s[5].unicode() == 'r') {
|
|
|
|
|
if (s[6].unicode() == 'o') {
|
|
|
|
|
if (s[7].unicode() == 'n') {
|
|
|
|
|
if (s[8].unicode() == 'i') {
|
|
|
|
|
if (s[9].unicode() == 'z') {
|
|
|
|
|
if (s[10].unicode() == 'e') {
|
|
|
|
|
if (s[11].unicode() == 'd') {
|
2013-01-23 15:06:08 +01:00
|
|
|
return Lexer::T_SYNCHRONIZED;
|
2011-09-13 08:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Lexer::T_IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Lexer::classify(const QChar *s, int n, bool qmlMode) {
|
|
|
|
|
switch (n) {
|
|
|
|
|
case 2: return classify2(s, qmlMode);
|
|
|
|
|
case 3: return classify3(s, qmlMode);
|
|
|
|
|
case 4: return classify4(s, qmlMode);
|
|
|
|
|
case 5: return classify5(s, qmlMode);
|
|
|
|
|
case 6: return classify6(s, qmlMode);
|
|
|
|
|
case 7: return classify7(s, qmlMode);
|
|
|
|
|
case 8: return classify8(s, qmlMode);
|
|
|
|
|
case 9: return classify9(s, qmlMode);
|
|
|
|
|
case 10: return classify10(s, qmlMode);
|
|
|
|
|
case 12: return classify12(s, qmlMode);
|
|
|
|
|
default: return Lexer::T_IDENTIFIER;
|
|
|
|
|
} // switch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSKEYWORDS_P_H
|