update qml parser to current version from qtdeclarative
Change-Id: Ic623614aa3c63197e44bf1ae04001997fe7deaac Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
parent
d3d8ac3546
commit
8977d2fbb4
@ -71,7 +71,7 @@ SOURCES += atom.cpp \
|
|||||||
|
|
||||||
### QML/JS Parser ###
|
### QML/JS Parser ###
|
||||||
|
|
||||||
include(qmlparser/qmlparser.pri)
|
include(qmlparser/parser.pri)
|
||||||
|
|
||||||
HEADERS += jscodemarker.h \
|
HEADERS += jscodemarker.h \
|
||||||
qmlcodemarker.h \
|
qmlcodemarker.h \
|
||||||
|
@ -407,7 +407,7 @@ bool QmlMarkupVisitor::visit(QQmlJS::AST::Elision *elision)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlMarkupVisitor::visit(QQmlJS::AST::PropertyNameAndValueList *list)
|
bool QmlMarkupVisitor::visit(QQmlJS::AST::PropertyNameAndValue *list)
|
||||||
{
|
{
|
||||||
QQmlJS::AST::Node::accept(list->name, this);
|
QQmlJS::AST::Node::accept(list->name, this);
|
||||||
addVerbatim(list->colonToken, list->colonToken);
|
addVerbatim(list->colonToken, list->colonToken);
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
virtual bool visit(QQmlJS::AST::ElementList *);
|
virtual bool visit(QQmlJS::AST::ElementList *);
|
||||||
virtual bool visit(QQmlJS::AST::Elision *);
|
virtual bool visit(QQmlJS::AST::Elision *);
|
||||||
virtual bool visit(QQmlJS::AST::PropertyNameAndValueList *);
|
virtual bool visit(QQmlJS::AST::PropertyNameAndValue *);
|
||||||
virtual bool visit(QQmlJS::AST::ArrayMemberExpression *);
|
virtual bool visit(QQmlJS::AST::ArrayMemberExpression *);
|
||||||
virtual bool visit(QQmlJS::AST::FieldMemberExpression *);
|
virtual bool visit(QQmlJS::AST::FieldMemberExpression *);
|
||||||
virtual bool visit(QQmlJS::AST::NewMemberExpression *);
|
virtual bool visit(QQmlJS::AST::NewMemberExpression *);
|
||||||
|
@ -8,7 +8,7 @@ HEADERS += \
|
|||||||
$$PWD/qqmljsmemorypool_p.h \
|
$$PWD/qqmljsmemorypool_p.h \
|
||||||
$$PWD/qqmljsparser_p.h \
|
$$PWD/qqmljsparser_p.h \
|
||||||
$$PWD/qqmljsglobal_p.h \
|
$$PWD/qqmljsglobal_p.h \
|
||||||
$$PWD/qqmljskeywords_p.h
|
$$PWD/qqmljskeywords_p.h \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/qqmljsast.cpp \
|
$$PWD/qqmljsast.cpp \
|
||||||
@ -16,4 +16,7 @@ SOURCES += \
|
|||||||
$$PWD/qqmljsengine_p.cpp \
|
$$PWD/qqmljsengine_p.cpp \
|
||||||
$$PWD/qqmljsgrammar.cpp \
|
$$PWD/qqmljsgrammar.cpp \
|
||||||
$$PWD/qqmljslexer.cpp \
|
$$PWD/qqmljslexer.cpp \
|
||||||
$$PWD/qqmljsparser.cpp
|
$$PWD/qqmljsparser.cpp \
|
||||||
|
|
||||||
|
OTHER_FILES += \
|
||||||
|
$$PWD/qqmljs.g
|
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
%parser QQmlJSGrammar
|
%parser QQmlJSGrammar
|
||||||
%decl qqmljsparser_p.h
|
%decl qqmljsparser_p.h
|
||||||
%impl qdeclarativejsparser.cpp
|
%impl qqmljsparser.cpp
|
||||||
%expect 2
|
%expect 5
|
||||||
%expect-rr 2
|
%expect-rr 2
|
||||||
|
|
||||||
%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
|
%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
|
||||||
@ -60,12 +60,15 @@
|
|||||||
%token T_RESERVED_WORD "reserved word"
|
%token T_RESERVED_WORD "reserved word"
|
||||||
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
|
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
|
||||||
%token T_COMMENT "comment"
|
%token T_COMMENT "comment"
|
||||||
|
%token T_COMPATIBILITY_SEMICOLON
|
||||||
|
|
||||||
--- context keywords.
|
--- context keywords.
|
||||||
%token T_PUBLIC "public"
|
%token T_PUBLIC "public"
|
||||||
%token T_IMPORT "import"
|
%token T_IMPORT "import"
|
||||||
%token T_AS "as"
|
%token T_AS "as"
|
||||||
%token T_ON "on"
|
%token T_ON "on"
|
||||||
|
%token T_GET "get"
|
||||||
|
%token T_SET "set"
|
||||||
|
|
||||||
%token T_ERROR
|
%token T_ERROR
|
||||||
|
|
||||||
@ -78,7 +81,7 @@
|
|||||||
%token T_FEED_JS_PROGRAM
|
%token T_FEED_JS_PROGRAM
|
||||||
|
|
||||||
%nonassoc SHIFT_THERE
|
%nonassoc SHIFT_THERE
|
||||||
%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
|
%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET
|
||||||
%nonassoc REDUCE_HERE
|
%nonassoc REDUCE_HERE
|
||||||
|
|
||||||
%start TopLevel
|
%start TopLevel
|
||||||
@ -124,16 +127,16 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <qdebug.h>
|
|
||||||
#include <qcoreapplication.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "qqmljsengine_p.h"
|
#include "qqmljsengine_p.h"
|
||||||
#include "qqmljslexer_p.h"
|
#include "qqmljslexer_p.h"
|
||||||
#include "qqmljsast_p.h"
|
#include "qqmljsast_p.h"
|
||||||
#include "qqmljsmemorypool_p.h"
|
#include "qqmljsmemorypool_p.h"
|
||||||
|
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
#include <QtCore/qcoreapplication.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
./
|
./
|
||||||
|
|
||||||
/:/****************************************************************************
|
/:/****************************************************************************
|
||||||
@ -190,20 +193,27 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// This file is automatically generated from qmljs.g.
|
// W A R N I N G
|
||||||
// Changes will be lost.
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is automatically generated from qqmljs.g.
|
||||||
|
// Changes should be made to that file, not here. Any change to this file will
|
||||||
|
// be lost!
|
||||||
|
//
|
||||||
|
// To regenerate this file, run:
|
||||||
|
// qlalr --no-debug --no-lines --qt qqmljs.g
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef QDECLARATIVEJSPARSER_P_H
|
#ifndef QQMLJSPARSER_P_H
|
||||||
#define QDECLARATIVEJSPARSER_P_H
|
#define QQMLJSPARSER_P_H
|
||||||
|
|
||||||
#include "qqmljsglobal_p.h"
|
#include "qqmljsglobal_p.h"
|
||||||
#include "qqmljsgrammar_p.h"
|
#include "qqmljsgrammar_p.h"
|
||||||
#include "qqmljsast_p.h"
|
#include "qqmljsast_p.h"
|
||||||
#include "qqmljsengine_p.h"
|
#include "qqmljsengine_p.h"
|
||||||
|
|
||||||
#include <qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -232,7 +242,8 @@ public:
|
|||||||
AST::FunctionDeclaration *FunctionDeclaration;
|
AST::FunctionDeclaration *FunctionDeclaration;
|
||||||
AST::Node *Node;
|
AST::Node *Node;
|
||||||
AST::PropertyName *PropertyName;
|
AST::PropertyName *PropertyName;
|
||||||
AST::PropertyNameAndValueList *PropertyNameAndValueList;
|
AST::PropertyAssignment *PropertyAssignment;
|
||||||
|
AST::PropertyAssignmentList *PropertyAssignmentList;
|
||||||
AST::SourceElement *SourceElement;
|
AST::SourceElement *SourceElement;
|
||||||
AST::SourceElements *SourceElements;
|
AST::SourceElements *SourceElements;
|
||||||
AST::Statement *Statement;
|
AST::Statement *Statement;
|
||||||
@ -380,11 +391,19 @@ protected:
|
|||||||
/.
|
/.
|
||||||
|
|
||||||
#include "qqmljsparser_p.h"
|
#include "qqmljsparser_p.h"
|
||||||
#include <qvarlengtharray.h>
|
|
||||||
|
#include <QtCore/qvarlengtharray.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// This file is automatically generated from qmljs.g.
|
// W A R N I N G
|
||||||
// Changes will be lost.
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is automatically generated from qqmljs.g.
|
||||||
|
// Changes should be made to that file, not here. Any change to this file will
|
||||||
|
// be lost!
|
||||||
|
//
|
||||||
|
// To regenerate this file, run:
|
||||||
|
// qlalr --no-debug --no-lines --qt qqmljs.g
|
||||||
//
|
//
|
||||||
|
|
||||||
using namespace QQmlJS;
|
using namespace QQmlJS;
|
||||||
@ -413,6 +432,7 @@ Parser::Parser(Engine *engine):
|
|||||||
state_stack(0),
|
state_stack(0),
|
||||||
location_stack(0),
|
location_stack(0),
|
||||||
string_stack(0),
|
string_stack(0),
|
||||||
|
program(0),
|
||||||
first_token(0),
|
first_token(0),
|
||||||
last_token(0)
|
last_token(0)
|
||||||
{
|
{
|
||||||
@ -835,6 +855,7 @@ UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
|
|||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
|
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
|
||||||
|
node->propertyTypeToken = loc(3);
|
||||||
node->commaToken = loc(2);
|
node->commaToken = loc(2);
|
||||||
node->identifierToken = loc(4);
|
node->identifierToken = loc(4);
|
||||||
sym(1).Node = node;
|
sym(1).Node = node;
|
||||||
@ -1026,6 +1047,8 @@ JsIdentifier: T_PROPERTY ;
|
|||||||
JsIdentifier: T_SIGNAL ;
|
JsIdentifier: T_SIGNAL ;
|
||||||
JsIdentifier: T_READONLY ;
|
JsIdentifier: T_READONLY ;
|
||||||
JsIdentifier: T_ON ;
|
JsIdentifier: T_ON ;
|
||||||
|
JsIdentifier: T_GET ;
|
||||||
|
JsIdentifier: T_SET ;
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------
|
||||||
-- Expressions
|
-- Expressions
|
||||||
@ -1202,13 +1225,13 @@ case $rule_number: {
|
|||||||
-- } break;
|
-- } break;
|
||||||
-- ./
|
-- ./
|
||||||
|
|
||||||
PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
|
PrimaryExpression: T_LBRACE PropertyAssignmentListOpt T_RBRACE ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::ObjectLiteral *node = 0;
|
AST::ObjectLiteral *node = 0;
|
||||||
if (sym(2).Node)
|
if (sym(2).Node)
|
||||||
node = new (pool) AST::ObjectLiteral(
|
node = new (pool) AST::ObjectLiteral(
|
||||||
sym(2).PropertyNameAndValueList->finish ());
|
sym(2).PropertyAssignmentList->finish ());
|
||||||
else
|
else
|
||||||
node = new (pool) AST::ObjectLiteral();
|
node = new (pool) AST::ObjectLiteral();
|
||||||
node->lbraceToken = loc(1);
|
node->lbraceToken = loc(1);
|
||||||
@ -1217,11 +1240,11 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
|
PrimaryExpression: T_LBRACE PropertyAssignmentList T_COMMA T_RBRACE ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
|
AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
|
||||||
sym(2).PropertyNameAndValueList->finish ());
|
sym(2).PropertyAssignmentList->finish ());
|
||||||
node->lbraceToken = loc(1);
|
node->lbraceToken = loc(1);
|
||||||
node->rbraceToken = loc(4);
|
node->rbraceToken = loc(4);
|
||||||
sym(1).Node = node;
|
sym(1).Node = node;
|
||||||
@ -1313,40 +1336,62 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
|
PropertyAssignment: PropertyName T_COLON AssignmentExpression ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
|
AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue(
|
||||||
sym(1).PropertyName, sym(3).Expression);
|
sym(1).PropertyName, sym(3).Expression);
|
||||||
node->colonToken = loc(2);
|
node->colonToken = loc(2);
|
||||||
sym(1).Node = node;
|
sym(1).Node = node;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
|
PropertyAssignment: T_GET PropertyName T_LPAREN T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
|
AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
|
||||||
sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
|
sym(2).PropertyName, sym(6).FunctionBody);
|
||||||
|
node->getSetToken = loc(1);
|
||||||
|
node->lparenToken = loc(3);
|
||||||
|
node->rparenToken = loc(4);
|
||||||
|
node->lbraceToken = loc(5);
|
||||||
|
node->rbraceToken = loc(7);
|
||||||
|
sym(1).Node = node;
|
||||||
|
} break;
|
||||||
|
./
|
||||||
|
|
||||||
|
PropertyAssignment: T_SET PropertyName T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
||||||
|
/.
|
||||||
|
case $rule_number: {
|
||||||
|
AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
|
||||||
|
sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody);
|
||||||
|
node->getSetToken = loc(1);
|
||||||
|
node->lparenToken = loc(3);
|
||||||
|
node->rparenToken = loc(5);
|
||||||
|
node->lbraceToken = loc(6);
|
||||||
|
node->rbraceToken = loc(8);
|
||||||
|
sym(1).Node = node;
|
||||||
|
} break;
|
||||||
|
./
|
||||||
|
|
||||||
|
PropertyAssignmentList: PropertyAssignment ;
|
||||||
|
/.
|
||||||
|
case $rule_number: {
|
||||||
|
sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment);
|
||||||
|
} break;
|
||||||
|
./
|
||||||
|
|
||||||
|
PropertyAssignmentList: PropertyAssignmentList T_COMMA PropertyAssignment ;
|
||||||
|
/.
|
||||||
|
case $rule_number: {
|
||||||
|
AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList(
|
||||||
|
sym(1).PropertyAssignmentList, sym(3).PropertyAssignment);
|
||||||
node->commaToken = loc(2);
|
node->commaToken = loc(2);
|
||||||
node->colonToken = loc(4);
|
|
||||||
sym(1).Node = node;
|
sym(1).Node = node;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
PropertyName: T_IDENTIFIER %prec SHIFT_THERE ;
|
PropertyName: JsIdentifier %prec SHIFT_THERE ;
|
||||||
/.
|
|
||||||
case $rule_number: {
|
|
||||||
AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
|
|
||||||
node->propertyNameToken = loc(1);
|
|
||||||
sym(1).Node = node;
|
|
||||||
} break;
|
|
||||||
./
|
|
||||||
|
|
||||||
PropertyName: T_SIGNAL ;
|
|
||||||
/.case $rule_number:./
|
|
||||||
|
|
||||||
PropertyName: T_PROPERTY ;
|
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
|
AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
|
||||||
@ -2423,6 +2468,7 @@ case $rule_number: {
|
|||||||
|
|
||||||
|
|
||||||
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
|
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
|
||||||
|
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_COMPATIBILITY_SEMICOLON ; -- for JSC/V8 compatibility
|
||||||
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
|
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
@ -2651,20 +2697,7 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
LabelledStatement: T_SIGNAL T_COLON Statement ;
|
LabelledStatement: JsIdentifier T_COLON Statement ;
|
||||||
/.case $rule_number:./
|
|
||||||
|
|
||||||
LabelledStatement: T_PROPERTY T_COLON Statement ;
|
|
||||||
/.
|
|
||||||
case $rule_number: {
|
|
||||||
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
|
|
||||||
node->identifierToken = loc(1);
|
|
||||||
node->colonToken = loc(2);
|
|
||||||
sym(1).Node = node;
|
|
||||||
} break;
|
|
||||||
./
|
|
||||||
|
|
||||||
LabelledStatement: T_IDENTIFIER T_COLON Statement ;
|
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
|
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
|
||||||
@ -2744,7 +2777,12 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
-- tell the parser to prefer function declarations to function expressions.
|
||||||
|
-- That is, the `Function' symbol is used to mark the start of a function
|
||||||
|
-- declaration.
|
||||||
|
Function: T_FUNCTION %prec REDUCE_HERE ;
|
||||||
|
|
||||||
|
FunctionDeclaration: Function JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
|
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
|
||||||
@ -2758,7 +2796,7 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
FunctionExpression: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
|
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
|
||||||
@ -2773,6 +2811,19 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
|
FunctionExpression: T_FUNCTION T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
|
||||||
|
/.
|
||||||
|
case $rule_number: {
|
||||||
|
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody);
|
||||||
|
node->functionToken = loc(1);
|
||||||
|
node->lparenToken = loc(2);
|
||||||
|
node->rparenToken = loc(4);
|
||||||
|
node->lbraceToken = loc(5);
|
||||||
|
node->rbraceToken = loc(7);
|
||||||
|
sym(1).Node = node;
|
||||||
|
} break;
|
||||||
|
./
|
||||||
|
|
||||||
FormalParameterList: JsIdentifier ;
|
FormalParameterList: JsIdentifier ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
@ -2859,23 +2910,14 @@ case $rule_number: {
|
|||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
IdentifierOpt: ;
|
PropertyAssignmentListOpt: ;
|
||||||
/.
|
|
||||||
case $rule_number: {
|
|
||||||
stringRef(1) = QStringRef();
|
|
||||||
} break;
|
|
||||||
./
|
|
||||||
|
|
||||||
IdentifierOpt: JsIdentifier ;
|
|
||||||
|
|
||||||
PropertyNameAndValueListOpt: ;
|
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
sym(1).Node = 0;
|
sym(1).Node = 0;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
PropertyNameAndValueListOpt: PropertyNameAndValueList ;
|
PropertyAssignmentListOpt: PropertyAssignmentList ;
|
||||||
|
|
||||||
/.
|
/.
|
||||||
} // switch
|
} // switch
|
||||||
@ -2887,7 +2929,8 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
|
|||||||
const int errorState = state_stack[tos];
|
const int errorState = state_stack[tos];
|
||||||
|
|
||||||
// automatic insertion of `;'
|
// automatic insertion of `;'
|
||||||
if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
|
if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken))
|
||||||
|
|| t_action(errorState, T_COMPATIBILITY_SEMICOLON))) {
|
||||||
SavedToken &tk = token_buffer[0];
|
SavedToken &tk = token_buffer[0];
|
||||||
tk.token = yytoken;
|
tk.token = yytoken;
|
||||||
tk.dval = yylval;
|
tk.dval = yylval;
|
||||||
@ -3012,5 +3055,5 @@ QT_QML_END_NAMESPACE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // QDECLARATIVEJSPARSER_P_H
|
#endif // QQMLJSPARSER_P_H
|
||||||
:/
|
:/
|
||||||
|
@ -213,12 +213,32 @@ void Elision::accept0(Visitor *visitor)
|
|||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyNameAndValueList::accept0(Visitor *visitor)
|
void PropertyNameAndValue::accept0(Visitor *visitor)
|
||||||
{
|
{
|
||||||
if (visitor->visit(this)) {
|
if (visitor->visit(this)) {
|
||||||
for (PropertyNameAndValueList *it = this; it; it = it->next) {
|
accept(name, visitor);
|
||||||
accept(it->name, visitor);
|
accept(value, visitor);
|
||||||
accept(it->value, visitor);
|
}
|
||||||
|
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyGetterSetter::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
accept(name, visitor);
|
||||||
|
accept(formals, visitor);
|
||||||
|
accept(functionBody, visitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyAssignmentList::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
for (PropertyAssignmentList *it = this; it; it = it->next) {
|
||||||
|
accept(it->assignment, visitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,6 +857,13 @@ void UiObjectInitializer::accept0(Visitor *visitor)
|
|||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UiParameterList::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
}
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
void UiObjectBinding::accept0(Visitor *visitor)
|
void UiObjectBinding::accept0(Visitor *visitor)
|
||||||
{
|
{
|
||||||
if (visitor->visit(this)) {
|
if (visitor->visit(this)) {
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include "qqmljsglobal_p.h"
|
#include "qqmljsglobal_p.h"
|
||||||
#include "qqmljsmemorypool_p.h"
|
#include "qqmljsmemorypool_p.h"
|
||||||
|
|
||||||
#include <qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -176,8 +176,10 @@ public:
|
|||||||
Kind_PreDecrementExpression,
|
Kind_PreDecrementExpression,
|
||||||
Kind_PreIncrementExpression,
|
Kind_PreIncrementExpression,
|
||||||
Kind_Program,
|
Kind_Program,
|
||||||
|
Kind_PropertyAssignmentList,
|
||||||
|
Kind_PropertyGetterSetter,
|
||||||
Kind_PropertyName,
|
Kind_PropertyName,
|
||||||
Kind_PropertyNameAndValueList,
|
Kind_PropertyNameAndValue,
|
||||||
Kind_RegExpLiteral,
|
Kind_RegExpLiteral,
|
||||||
Kind_ReturnStatement,
|
Kind_ReturnStatement,
|
||||||
Kind_SourceElement,
|
Kind_SourceElement,
|
||||||
@ -487,7 +489,7 @@ public:
|
|||||||
ObjectLiteral():
|
ObjectLiteral():
|
||||||
properties (0) { kind = K; }
|
properties (0) { kind = K; }
|
||||||
|
|
||||||
ObjectLiteral(PropertyNameAndValueList *plist):
|
ObjectLiteral(PropertyAssignmentList *plist):
|
||||||
properties (plist) { kind = K; }
|
properties (plist) { kind = K; }
|
||||||
|
|
||||||
virtual void accept0(Visitor *visitor);
|
virtual void accept0(Visitor *visitor);
|
||||||
@ -499,7 +501,7 @@ public:
|
|||||||
{ return rbraceToken; }
|
{ return rbraceToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
PropertyNameAndValueList *properties;
|
PropertyAssignmentList *properties;
|
||||||
SourceLocation lbraceToken;
|
SourceLocation lbraceToken;
|
||||||
SourceLocation rbraceToken;
|
SourceLocation rbraceToken;
|
||||||
};
|
};
|
||||||
@ -603,50 +605,113 @@ public:
|
|||||||
SourceLocation propertyNameToken;
|
SourceLocation propertyNameToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT PropertyNameAndValueList: public Node
|
class QML_PARSER_EXPORT PropertyAssignment: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(PropertyNameAndValueList)
|
PropertyAssignment() {}
|
||||||
|
};
|
||||||
|
|
||||||
PropertyNameAndValueList(PropertyName *n, ExpressionNode *v):
|
class QML_PARSER_EXPORT PropertyAssignmentList: public Node
|
||||||
name (n), value (v), next (this)
|
{
|
||||||
{ kind = K; }
|
public:
|
||||||
|
QQMLJS_DECLARE_AST_NODE(PropertyAssignmentList)
|
||||||
|
|
||||||
PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v):
|
PropertyAssignmentList(PropertyAssignment *assignment)
|
||||||
name (n), value (v)
|
: assignment(assignment)
|
||||||
|
, next(this)
|
||||||
|
{ kind = K; }
|
||||||
|
|
||||||
|
PropertyAssignmentList(PropertyAssignmentList *previous, PropertyAssignment *assignment)
|
||||||
|
: assignment(assignment)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
next = previous->next;
|
next = previous->next;
|
||||||
previous->next = this;
|
previous->next = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline PropertyAssignmentList *finish ()
|
||||||
|
{
|
||||||
|
PropertyAssignmentList *front = next;
|
||||||
|
next = 0;
|
||||||
|
return front;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
virtual SourceLocation firstSourceLocation() const
|
||||||
|
{ return assignment->firstSourceLocation(); }
|
||||||
|
|
||||||
|
virtual SourceLocation lastSourceLocation() const
|
||||||
|
{ return next ? next->lastSourceLocation() : assignment->lastSourceLocation(); }
|
||||||
|
|
||||||
|
// attributes
|
||||||
|
PropertyAssignment *assignment;
|
||||||
|
PropertyAssignmentList *next;
|
||||||
|
SourceLocation commaToken;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QML_PARSER_EXPORT PropertyNameAndValue: public PropertyAssignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QQMLJS_DECLARE_AST_NODE(PropertyNameAndValue)
|
||||||
|
|
||||||
|
PropertyNameAndValue(PropertyName *n, ExpressionNode *v)
|
||||||
|
: name(n), value(v)
|
||||||
|
{ kind = K; }
|
||||||
|
|
||||||
virtual void accept0(Visitor *visitor);
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
virtual SourceLocation firstSourceLocation() const
|
virtual SourceLocation firstSourceLocation() const
|
||||||
{ return name->firstSourceLocation(); }
|
{ return name->firstSourceLocation(); }
|
||||||
|
|
||||||
virtual SourceLocation lastSourceLocation() const
|
virtual SourceLocation lastSourceLocation() const
|
||||||
{
|
{ return value->lastSourceLocation(); }
|
||||||
if (next)
|
|
||||||
return next->lastSourceLocation();
|
|
||||||
return value->lastSourceLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline PropertyNameAndValueList *finish ()
|
|
||||||
{
|
|
||||||
PropertyNameAndValueList *front = next;
|
|
||||||
next = 0;
|
|
||||||
return front;
|
|
||||||
}
|
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
PropertyName *name;
|
PropertyName *name;
|
||||||
ExpressionNode *value;
|
|
||||||
PropertyNameAndValueList *next;
|
|
||||||
SourceLocation colonToken;
|
SourceLocation colonToken;
|
||||||
|
ExpressionNode *value;
|
||||||
SourceLocation commaToken;
|
SourceLocation commaToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QML_PARSER_EXPORT PropertyGetterSetter: public PropertyAssignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QQMLJS_DECLARE_AST_NODE(PropertyGetterSetter)
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
Getter,
|
||||||
|
Setter
|
||||||
|
};
|
||||||
|
|
||||||
|
PropertyGetterSetter(PropertyName *n, FunctionBody *b)
|
||||||
|
: type(Getter), name(n), formals(0), functionBody (b)
|
||||||
|
{ kind = K; }
|
||||||
|
|
||||||
|
PropertyGetterSetter(PropertyName *n, FormalParameterList *f, FunctionBody *b)
|
||||||
|
: type(Setter), name(n), formals(f), functionBody (b)
|
||||||
|
{ kind = K; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
virtual SourceLocation firstSourceLocation() const
|
||||||
|
{ return getSetToken; }
|
||||||
|
|
||||||
|
virtual SourceLocation lastSourceLocation() const
|
||||||
|
{ return rbraceToken; }
|
||||||
|
|
||||||
|
// attributes
|
||||||
|
Type type;
|
||||||
|
SourceLocation getSetToken;
|
||||||
|
PropertyName *name;
|
||||||
|
SourceLocation lparenToken;
|
||||||
|
FormalParameterList *formals;
|
||||||
|
SourceLocation rparenToken;
|
||||||
|
SourceLocation lbraceToken;
|
||||||
|
FunctionBody *functionBody;
|
||||||
|
SourceLocation rbraceToken;
|
||||||
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -1642,7 +1707,7 @@ class QML_PARSER_EXPORT CaseBlock: public Node
|
|||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(CaseBlock)
|
QQMLJS_DECLARE_AST_NODE(CaseBlock)
|
||||||
|
|
||||||
explicit CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
|
CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
|
||||||
clauses (c), defaultClause (d), moreClauses (r)
|
clauses (c), defaultClause (d), moreClauses (r)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
@ -2402,7 +2467,7 @@ public:
|
|||||||
previous->next = this;
|
previous->next = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void accept0(Visitor *) {}
|
virtual void accept0(Visitor *);
|
||||||
|
|
||||||
virtual SourceLocation firstSourceLocation() const
|
virtual SourceLocation firstSourceLocation() const
|
||||||
{ return propertyTypeToken; }
|
{ return propertyTypeToken; }
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef QQMLJSASTFWD_P_H
|
#ifndef QQMLJSAST_FWD_P_H
|
||||||
#define QQMLJSASTFWD_P_H
|
#define QQMLJSAST_FWD_P_H
|
||||||
|
|
||||||
#include "qqmljsglobal_p.h"
|
#include "qqmljsglobal_p.h"
|
||||||
|
|
||||||
#include <qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
@ -64,7 +64,7 @@ namespace QQmlJS { namespace AST {
|
|||||||
class SourceLocation
|
class SourceLocation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
|
SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
|
||||||
: offset(offset), length(length),
|
: offset(offset), length(length),
|
||||||
startLine(line), startColumn(column)
|
startLine(line), startColumn(column)
|
||||||
{ }
|
{ }
|
||||||
@ -98,7 +98,9 @@ class ArrayLiteral;
|
|||||||
class ObjectLiteral;
|
class ObjectLiteral;
|
||||||
class ElementList;
|
class ElementList;
|
||||||
class Elision;
|
class Elision;
|
||||||
class PropertyNameAndValueList;
|
class PropertyAssignmentList;
|
||||||
|
class PropertyGetterSetter;
|
||||||
|
class PropertyNameAndValue;
|
||||||
class PropertyName;
|
class PropertyName;
|
||||||
class IdentifierPropertyName;
|
class IdentifierPropertyName;
|
||||||
class StringLiteralPropertyName;
|
class StringLiteralPropertyName;
|
||||||
@ -168,6 +170,7 @@ class UiProgram;
|
|||||||
class UiImportList;
|
class UiImportList;
|
||||||
class UiImport;
|
class UiImport;
|
||||||
class UiPublicMember;
|
class UiPublicMember;
|
||||||
|
class UiParameterList;
|
||||||
class UiObjectDefinition;
|
class UiObjectDefinition;
|
||||||
class UiObjectInitializer;
|
class UiObjectInitializer;
|
||||||
class UiObjectBinding;
|
class UiObjectBinding;
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
virtual bool visit(UiObjectBinding *) { return true; }
|
virtual bool visit(UiObjectBinding *) { return true; }
|
||||||
virtual bool visit(UiScriptBinding *) { return true; }
|
virtual bool visit(UiScriptBinding *) { return true; }
|
||||||
virtual bool visit(UiArrayBinding *) { return true; }
|
virtual bool visit(UiArrayBinding *) { return true; }
|
||||||
|
virtual bool visit(UiParameterList *) { return true; }
|
||||||
virtual bool visit(UiObjectMemberList *) { return true; }
|
virtual bool visit(UiObjectMemberList *) { return true; }
|
||||||
virtual bool visit(UiArrayMemberList *) { return true; }
|
virtual bool visit(UiArrayMemberList *) { return true; }
|
||||||
virtual bool visit(UiQualifiedId *) { return true; }
|
virtual bool visit(UiQualifiedId *) { return true; }
|
||||||
@ -94,6 +95,7 @@ public:
|
|||||||
virtual void endVisit(UiObjectBinding *) {}
|
virtual void endVisit(UiObjectBinding *) {}
|
||||||
virtual void endVisit(UiScriptBinding *) {}
|
virtual void endVisit(UiScriptBinding *) {}
|
||||||
virtual void endVisit(UiArrayBinding *) {}
|
virtual void endVisit(UiArrayBinding *) {}
|
||||||
|
virtual void endVisit(UiParameterList *) {}
|
||||||
virtual void endVisit(UiObjectMemberList *) {}
|
virtual void endVisit(UiObjectMemberList *) {}
|
||||||
virtual void endVisit(UiArrayMemberList *) {}
|
virtual void endVisit(UiArrayMemberList *) {}
|
||||||
virtual void endVisit(UiQualifiedId *) {}
|
virtual void endVisit(UiQualifiedId *) {}
|
||||||
@ -135,8 +137,14 @@ public:
|
|||||||
virtual bool visit(Elision *) { return true; }
|
virtual bool visit(Elision *) { return true; }
|
||||||
virtual void endVisit(Elision *) {}
|
virtual void endVisit(Elision *) {}
|
||||||
|
|
||||||
virtual bool visit(PropertyNameAndValueList *) { return true; }
|
virtual bool visit(PropertyAssignmentList *) { return true; }
|
||||||
virtual void endVisit(PropertyNameAndValueList *) {}
|
virtual void endVisit(PropertyAssignmentList *) {}
|
||||||
|
|
||||||
|
virtual bool visit(PropertyNameAndValue *) { return true; }
|
||||||
|
virtual void endVisit(PropertyNameAndValue *) {}
|
||||||
|
|
||||||
|
virtual bool visit(PropertyGetterSetter *) { return true; }
|
||||||
|
virtual void endVisit(PropertyGetterSetter *) {}
|
||||||
|
|
||||||
virtual bool visit(NestedExpression *) { return true; }
|
virtual bool visit(NestedExpression *) { return true; }
|
||||||
virtual void endVisit(NestedExpression *) {}
|
virtual void endVisit(NestedExpression *) {}
|
||||||
|
@ -42,15 +42,15 @@
|
|||||||
#include "qqmljsengine_p.h"
|
#include "qqmljsengine_p.h"
|
||||||
#include "qqmljsglobal_p.h"
|
#include "qqmljsglobal_p.h"
|
||||||
|
|
||||||
#include <qnumeric.h>
|
#include <QtCore/qnumeric.h>
|
||||||
#include <qhash.h>
|
#include <QtCore/qhash.h>
|
||||||
#include <qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QQmlJS {
|
namespace QQmlJS {
|
||||||
|
|
||||||
static int toDigit(char c)
|
static inline int toDigit(char c)
|
||||||
{
|
{
|
||||||
if ((c >= '0') && (c <= '9'))
|
if ((c >= '0') && (c <= '9'))
|
||||||
return c - '0';
|
return c - '0';
|
||||||
|
@ -57,8 +57,8 @@
|
|||||||
#include "qqmljsastfwd_p.h"
|
#include "qqmljsastfwd_p.h"
|
||||||
#include "qqmljsmemorypool_p.h"
|
#include "qqmljsmemorypool_p.h"
|
||||||
|
|
||||||
#include <qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <qset.h>
|
#include <QtCore/qset.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
** This file is part of the Qt Toolkit.
|
||||||
**
|
**
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
** Commercial License Usage
|
** Commercial License Usage
|
||||||
@ -63,12 +63,12 @@ class QQmlJSGrammar
|
|||||||
public:
|
public:
|
||||||
enum VariousConstants {
|
enum VariousConstants {
|
||||||
EOF_SYMBOL = 0,
|
EOF_SYMBOL = 0,
|
||||||
REDUCE_HERE = 101,
|
REDUCE_HERE = 104,
|
||||||
SHIFT_THERE = 100,
|
SHIFT_THERE = 103,
|
||||||
T_AND = 1,
|
T_AND = 1,
|
||||||
T_AND_AND = 2,
|
T_AND_AND = 2,
|
||||||
T_AND_EQ = 3,
|
T_AND_EQ = 3,
|
||||||
T_AS = 91,
|
T_AS = 92,
|
||||||
T_AUTOMATIC_SEMICOLON = 62,
|
T_AUTOMATIC_SEMICOLON = 62,
|
||||||
T_BREAK = 4,
|
T_BREAK = 4,
|
||||||
T_CASE = 5,
|
T_CASE = 5,
|
||||||
@ -76,6 +76,7 @@ public:
|
|||||||
T_COLON = 7,
|
T_COLON = 7,
|
||||||
T_COMMA = 8,
|
T_COMMA = 8,
|
||||||
T_COMMENT = 88,
|
T_COMMENT = 88,
|
||||||
|
T_COMPATIBILITY_SEMICOLON = 89,
|
||||||
T_CONST = 84,
|
T_CONST = 84,
|
||||||
T_CONTINUE = 9,
|
T_CONTINUE = 9,
|
||||||
T_DEBUGGER = 85,
|
T_DEBUGGER = 85,
|
||||||
@ -89,18 +90,19 @@ public:
|
|||||||
T_EQ = 17,
|
T_EQ = 17,
|
||||||
T_EQ_EQ = 18,
|
T_EQ_EQ = 18,
|
||||||
T_EQ_EQ_EQ = 19,
|
T_EQ_EQ_EQ = 19,
|
||||||
T_ERROR = 93,
|
T_ERROR = 96,
|
||||||
T_FALSE = 83,
|
T_FALSE = 83,
|
||||||
T_FEED_JS_EXPRESSION = 97,
|
T_FEED_JS_EXPRESSION = 100,
|
||||||
T_FEED_JS_PROGRAM = 99,
|
T_FEED_JS_PROGRAM = 102,
|
||||||
T_FEED_JS_SOURCE_ELEMENT = 98,
|
T_FEED_JS_SOURCE_ELEMENT = 101,
|
||||||
T_FEED_JS_STATEMENT = 96,
|
T_FEED_JS_STATEMENT = 99,
|
||||||
T_FEED_UI_OBJECT_MEMBER = 95,
|
T_FEED_UI_OBJECT_MEMBER = 98,
|
||||||
T_FEED_UI_PROGRAM = 94,
|
T_FEED_UI_PROGRAM = 97,
|
||||||
T_FINALLY = 20,
|
T_FINALLY = 20,
|
||||||
T_FOR = 21,
|
T_FOR = 21,
|
||||||
T_FUNCTION = 22,
|
T_FUNCTION = 22,
|
||||||
T_GE = 23,
|
T_GE = 23,
|
||||||
|
T_GET = 94,
|
||||||
T_GT = 24,
|
T_GT = 24,
|
||||||
T_GT_GT = 25,
|
T_GT_GT = 25,
|
||||||
T_GT_GT_EQ = 26,
|
T_GT_GT_EQ = 26,
|
||||||
@ -108,7 +110,7 @@ public:
|
|||||||
T_GT_GT_GT_EQ = 28,
|
T_GT_GT_GT_EQ = 28,
|
||||||
T_IDENTIFIER = 29,
|
T_IDENTIFIER = 29,
|
||||||
T_IF = 30,
|
T_IF = 30,
|
||||||
T_IMPORT = 90,
|
T_IMPORT = 91,
|
||||||
T_IN = 31,
|
T_IN = 31,
|
||||||
T_INSTANCEOF = 32,
|
T_INSTANCEOF = 32,
|
||||||
T_LBRACE = 33,
|
T_LBRACE = 33,
|
||||||
@ -128,7 +130,7 @@ public:
|
|||||||
T_NOT_EQ_EQ = 46,
|
T_NOT_EQ_EQ = 46,
|
||||||
T_NULL = 81,
|
T_NULL = 81,
|
||||||
T_NUMERIC_LITERAL = 47,
|
T_NUMERIC_LITERAL = 47,
|
||||||
T_ON = 92,
|
T_ON = 93,
|
||||||
T_OR = 48,
|
T_OR = 48,
|
||||||
T_OR_EQ = 49,
|
T_OR_EQ = 49,
|
||||||
T_OR_OR = 50,
|
T_OR_OR = 50,
|
||||||
@ -136,7 +138,7 @@ public:
|
|||||||
T_PLUS_EQ = 52,
|
T_PLUS_EQ = 52,
|
||||||
T_PLUS_PLUS = 53,
|
T_PLUS_PLUS = 53,
|
||||||
T_PROPERTY = 66,
|
T_PROPERTY = 66,
|
||||||
T_PUBLIC = 89,
|
T_PUBLIC = 90,
|
||||||
T_QUESTION = 54,
|
T_QUESTION = 54,
|
||||||
T_RBRACE = 55,
|
T_RBRACE = 55,
|
||||||
T_RBRACKET = 56,
|
T_RBRACKET = 56,
|
||||||
@ -147,6 +149,7 @@ public:
|
|||||||
T_RETURN = 59,
|
T_RETURN = 59,
|
||||||
T_RPAREN = 60,
|
T_RPAREN = 60,
|
||||||
T_SEMICOLON = 61,
|
T_SEMICOLON = 61,
|
||||||
|
T_SET = 95,
|
||||||
T_SIGNAL = 67,
|
T_SIGNAL = 67,
|
||||||
T_STAR = 63,
|
T_STAR = 63,
|
||||||
T_STAR_EQ = 64,
|
T_STAR_EQ = 64,
|
||||||
@ -165,15 +168,15 @@ public:
|
|||||||
T_XOR = 79,
|
T_XOR = 79,
|
||||||
T_XOR_EQ = 80,
|
T_XOR_EQ = 80,
|
||||||
|
|
||||||
ACCEPT_STATE = 644,
|
ACCEPT_STATE = 655,
|
||||||
RULE_COUNT = 349,
|
RULE_COUNT = 351,
|
||||||
STATE_COUNT = 645,
|
STATE_COUNT = 656,
|
||||||
TERMINAL_COUNT = 102,
|
TERMINAL_COUNT = 105,
|
||||||
NON_TERMINAL_COUNT = 107,
|
NON_TERMINAL_COUNT = 108,
|
||||||
|
|
||||||
GOTO_INDEX_OFFSET = 645,
|
GOTO_INDEX_OFFSET = 656,
|
||||||
GOTO_INFO_OFFSET = 2807,
|
GOTO_INFO_OFFSET = 2970,
|
||||||
GOTO_CHECK_OFFSET = 2807
|
GOTO_CHECK_OFFSET = 2970
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const spell [];
|
static const char *const spell [];
|
||||||
|
@ -53,10 +53,16 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "qqmljslexer_p.h"
|
||||||
|
|
||||||
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QQmlJS {
|
||||||
|
|
||||||
static inline int classify2(const QChar *s, bool qmlMode) {
|
static inline int classify2(const QChar *s, bool qmlMode) {
|
||||||
if (s[0].unicode() == 'a') {
|
if (s[0].unicode() == 'a') {
|
||||||
if (s[1].unicode() == 's') {
|
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') {
|
else if (s[0].unicode() == 'd') {
|
||||||
@ -74,13 +80,13 @@ static inline int classify2(const QChar *s, bool qmlMode) {
|
|||||||
}
|
}
|
||||||
else if (qmlMode && s[0].unicode() == 'o') {
|
else if (qmlMode && s[0].unicode() == 'o') {
|
||||||
if (s[1].unicode() == 'n') {
|
if (s[1].unicode() == 'n') {
|
||||||
return Lexer::T_ON;
|
return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 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[0].unicode() == 'f') {
|
||||||
if (s[1].unicode() == 'o') {
|
if (s[1].unicode() == 'o') {
|
||||||
if (s[2].unicode() == 'r') {
|
if (s[2].unicode() == 'r') {
|
||||||
@ -88,10 +94,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') {
|
else if (s[0].unicode() == 'i') {
|
||||||
if (s[1].unicode() == 'n') {
|
if (s[1].unicode() == 'n') {
|
||||||
if (s[2].unicode() == 't') {
|
if (s[2].unicode() == 't') {
|
||||||
return Lexer::T_INT;
|
return qmlMode ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,6 +115,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') {
|
else if (s[0].unicode() == 't') {
|
||||||
if (s[1].unicode() == 'r') {
|
if (s[1].unicode() == 'r') {
|
||||||
if (s[2].unicode() == 'y') {
|
if (s[2].unicode() == 'y') {
|
||||||
@ -119,12 +139,12 @@ static inline int classify3(const QChar *s, bool /*qmlMode*/) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 'b') {
|
||||||
if (s[1].unicode() == 'y') {
|
if (s[1].unicode() == 'y') {
|
||||||
if (s[2].unicode() == 't') {
|
if (s[2].unicode() == 't') {
|
||||||
if (s[3].unicode() == 'e') {
|
if (s[3].unicode() == 'e') {
|
||||||
return Lexer::T_BYTE;
|
return qmlMode ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +160,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
|
|||||||
else if (s[1].unicode() == 'h') {
|
else if (s[1].unicode() == 'h') {
|
||||||
if (s[2].unicode() == 'a') {
|
if (s[2].unicode() == 'a') {
|
||||||
if (s[3].unicode() == 'r') {
|
if (s[3].unicode() == 'r') {
|
||||||
return Lexer::T_CHAR;
|
return qmlMode ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +185,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[1].unicode() == 'o') {
|
if (s[1].unicode() == 'o') {
|
||||||
if (s[2].unicode() == 't') {
|
if (s[2].unicode() == 't') {
|
||||||
if (s[3].unicode() == 'o') {
|
if (s[3].unicode() == 'o') {
|
||||||
return Lexer::T_GOTO;
|
return qmlMode ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +194,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[1].unicode() == 'o') {
|
if (s[1].unicode() == 'o') {
|
||||||
if (s[2].unicode() == 'n') {
|
if (s[2].unicode() == 'n') {
|
||||||
if (s[3].unicode() == 'g') {
|
if (s[3].unicode() == 'g') {
|
||||||
return Lexer::T_LONG;
|
return qmlMode ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +245,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 'b') {
|
||||||
if (s[1].unicode() == 'r') {
|
if (s[1].unicode() == 'r') {
|
||||||
if (s[2].unicode() == 'e') {
|
if (s[2].unicode() == 'e') {
|
||||||
@ -260,7 +280,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[2].unicode() == 'n') {
|
if (s[2].unicode() == 'n') {
|
||||||
if (s[3].unicode() == 's') {
|
if (s[3].unicode() == 's') {
|
||||||
if (s[4].unicode() == 't') {
|
if (s[4].unicode() == 't') {
|
||||||
return Lexer::T_CONST;
|
return qmlMode ? int(Lexer::T_CONST) : int(Lexer::T_RESERVED_WORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,7 +300,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[2].unicode() == 'n') {
|
if (s[2].unicode() == 'n') {
|
||||||
if (s[3].unicode() == 'a') {
|
if (s[3].unicode() == 'a') {
|
||||||
if (s[4].unicode() == 'l') {
|
if (s[4].unicode() == 'l') {
|
||||||
return Lexer::T_FINAL;
|
return qmlMode ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +309,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[2].unicode() == 'o') {
|
if (s[2].unicode() == 'o') {
|
||||||
if (s[3].unicode() == 'a') {
|
if (s[3].unicode() == 'a') {
|
||||||
if (s[4].unicode() == 't') {
|
if (s[4].unicode() == 't') {
|
||||||
return Lexer::T_FLOAT;
|
return qmlMode ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +320,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[2].unicode() == 'o') {
|
if (s[2].unicode() == 'o') {
|
||||||
if (s[3].unicode() == 'r') {
|
if (s[3].unicode() == 'r') {
|
||||||
if (s[4].unicode() == 't') {
|
if (s[4].unicode() == 't') {
|
||||||
return Lexer::T_SHORT;
|
return qmlMode ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +329,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[2].unicode() == 'p') {
|
if (s[2].unicode() == 'p') {
|
||||||
if (s[3].unicode() == 'e') {
|
if (s[3].unicode() == 'e') {
|
||||||
if (s[4].unicode() == 'r') {
|
if (s[4].unicode() == 'r') {
|
||||||
return Lexer::T_SUPER;
|
return qmlMode ? int(Lexer::T_SUPER) : int(Lexer::T_RESERVED_WORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +378,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 'b') {
|
if (s[3].unicode() == 'b') {
|
||||||
if (s[4].unicode() == 'l') {
|
if (s[4].unicode() == 'l') {
|
||||||
if (s[5].unicode() == 'e') {
|
if (s[5].unicode() == 'e') {
|
||||||
return Lexer::T_DOUBLE;
|
return qmlMode ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +404,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 'o') {
|
if (s[3].unicode() == 'o') {
|
||||||
if (s[4].unicode() == 'r') {
|
if (s[4].unicode() == 'r') {
|
||||||
if (s[5].unicode() == 't') {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,7 +417,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 'i') {
|
if (s[3].unicode() == 'i') {
|
||||||
if (s[4].unicode() == 'v') {
|
if (s[4].unicode() == 'v') {
|
||||||
if (s[5].unicode() == 'e') {
|
if (s[5].unicode() == 'e') {
|
||||||
return Lexer::T_NATIVE;
|
return qmlMode ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,7 +430,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 'l') {
|
if (s[3].unicode() == 'l') {
|
||||||
if (s[4].unicode() == 'i') {
|
if (s[4].unicode() == 'i') {
|
||||||
if (s[5].unicode() == 'c') {
|
if (s[5].unicode() == 'c') {
|
||||||
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD;
|
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,7 +467,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 't') {
|
if (s[3].unicode() == 't') {
|
||||||
if (s[4].unicode() == 'i') {
|
if (s[4].unicode() == 'i') {
|
||||||
if (s[5].unicode() == 'c') {
|
if (s[5].unicode() == 'c') {
|
||||||
return Lexer::T_STATIC;
|
return qmlMode ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,7 +491,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
if (s[3].unicode() == 'o') {
|
if (s[3].unicode() == 'o') {
|
||||||
if (s[4].unicode() == 'w') {
|
if (s[4].unicode() == 'w') {
|
||||||
if (s[5].unicode() == 's') {
|
if (s[5].unicode() == 's') {
|
||||||
return Lexer::T_THROWS;
|
return qmlMode ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +512,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 'b') {
|
||||||
if (s[1].unicode() == 'o') {
|
if (s[1].unicode() == 'o') {
|
||||||
if (s[2].unicode() == 'o') {
|
if (s[2].unicode() == 'o') {
|
||||||
@ -500,7 +520,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[4].unicode() == 'e') {
|
if (s[4].unicode() == 'e') {
|
||||||
if (s[5].unicode() == 'a') {
|
if (s[5].unicode() == 'a') {
|
||||||
if (s[6].unicode() == 'n') {
|
if (s[6].unicode() == 'n') {
|
||||||
return Lexer::T_BOOLEAN;
|
return qmlMode ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -560,7 +580,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[4].unicode() == 'a') {
|
if (s[4].unicode() == 'a') {
|
||||||
if (s[5].unicode() == 'g') {
|
if (s[5].unicode() == 'g') {
|
||||||
if (s[6].unicode() == 'e') {
|
if (s[6].unicode() == 'e') {
|
||||||
return Lexer::T_PACKAGE;
|
return qmlMode ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,7 +593,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[4].unicode() == 'a') {
|
if (s[4].unicode() == 'a') {
|
||||||
if (s[5].unicode() == 't') {
|
if (s[5].unicode() == 't') {
|
||||||
if (s[6].unicode() == 'e') {
|
if (s[6].unicode() == 'e') {
|
||||||
return Lexer::T_PRIVATE;
|
return qmlMode ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,7 +613,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
|
|||||||
if (s[5].unicode() == 'a') {
|
if (s[5].unicode() == 'a') {
|
||||||
if (s[6].unicode() == 'c') {
|
if (s[6].unicode() == 'c') {
|
||||||
if (s[7].unicode() == 't') {
|
if (s[7].unicode() == 't') {
|
||||||
return Lexer::T_ABSTRACT;
|
return qmlMode ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,7 +681,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
|
|||||||
if (s[5].unicode() == 'r') {
|
if (s[5].unicode() == 'r') {
|
||||||
if (s[6].unicode() == 't') {
|
if (s[6].unicode() == 't') {
|
||||||
if (s[7].unicode() == 'y') {
|
if (s[7].unicode() == 'y') {
|
||||||
return Lexer::T_PROPERTY;
|
return qmlMode ? Lexer::T_PROPERTY : Lexer::T_IDENTIFIER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -695,7 +715,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
|
|||||||
if (s[5].unicode() == 'i') {
|
if (s[5].unicode() == 'i') {
|
||||||
if (s[6].unicode() == 'l') {
|
if (s[6].unicode() == 'l') {
|
||||||
if (s[7].unicode() == 'e') {
|
if (s[7].unicode() == 'e') {
|
||||||
return Lexer::T_VOLATILE;
|
return qmlMode ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,7 +727,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 'i') {
|
||||||
if (s[1].unicode() == 'n') {
|
if (s[1].unicode() == 'n') {
|
||||||
if (s[2].unicode() == 't') {
|
if (s[2].unicode() == 't') {
|
||||||
@ -717,7 +737,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[6].unicode() == 'a') {
|
if (s[6].unicode() == 'a') {
|
||||||
if (s[7].unicode() == 'c') {
|
if (s[7].unicode() == 'c') {
|
||||||
if (s[8].unicode() == 'e') {
|
if (s[8].unicode() == 'e') {
|
||||||
return Lexer::T_INTERFACE;
|
return qmlMode ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -736,7 +756,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[6].unicode() == 't') {
|
if (s[6].unicode() == 't') {
|
||||||
if (s[7].unicode() == 'e') {
|
if (s[7].unicode() == 'e') {
|
||||||
if (s[8].unicode() == 'd') {
|
if (s[8].unicode() == 'd') {
|
||||||
return Lexer::T_PROTECTED;
|
return qmlMode ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,7 +775,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[6].unicode() == 'e') {
|
if (s[6].unicode() == 'e') {
|
||||||
if (s[7].unicode() == 'n') {
|
if (s[7].unicode() == 'n') {
|
||||||
if (s[8].unicode() == 't') {
|
if (s[8].unicode() == 't') {
|
||||||
return Lexer::T_TRANSIENT;
|
return qmlMode ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,7 +788,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 'i') {
|
||||||
if (s[1].unicode() == 'm') {
|
if (s[1].unicode() == 'm') {
|
||||||
if (s[2].unicode() == 'p') {
|
if (s[2].unicode() == 'p') {
|
||||||
@ -779,7 +799,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[7].unicode() == 'n') {
|
if (s[7].unicode() == 'n') {
|
||||||
if (s[8].unicode() == 't') {
|
if (s[8].unicode() == 't') {
|
||||||
if (s[9].unicode() == 's') {
|
if (s[9].unicode() == 's') {
|
||||||
return Lexer::T_IMPLEMENTS;
|
return qmlMode ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -812,7 +832,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
|
|||||||
return Lexer::T_IDENTIFIER;
|
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[0].unicode() == 's') {
|
||||||
if (s[1].unicode() == 'y') {
|
if (s[1].unicode() == 'y') {
|
||||||
if (s[2].unicode() == 'n') {
|
if (s[2].unicode() == 'n') {
|
||||||
@ -825,7 +845,7 @@ static inline int classify12(const QChar *s, bool /*qmlMode*/) {
|
|||||||
if (s[9].unicode() == 'z') {
|
if (s[9].unicode() == 'z') {
|
||||||
if (s[10].unicode() == 'e') {
|
if (s[10].unicode() == 'e') {
|
||||||
if (s[11].unicode() == 'd') {
|
if (s[11].unicode() == 'd') {
|
||||||
return Lexer::T_SYNCHRONIZED;
|
return qmlMode ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,4 +877,8 @@ int Lexer::classify(const QChar *s, int n, bool qmlMode) {
|
|||||||
} // switch
|
} // switch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace QQmlJS
|
||||||
|
|
||||||
|
QT_QML_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QQMLJSKEYWORDS_P_H
|
#endif // QQMLJSKEYWORDS_P_H
|
||||||
|
@ -42,15 +42,11 @@
|
|||||||
#include "qqmljslexer_p.h"
|
#include "qqmljslexer_p.h"
|
||||||
#include "qqmljsengine_p.h"
|
#include "qqmljsengine_p.h"
|
||||||
#include "qqmljsmemorypool_p.h"
|
#include "qqmljsmemorypool_p.h"
|
||||||
|
#include "qqmljskeywords_p.h"
|
||||||
|
|
||||||
#ifdef QT_BOOTSTRAPPED
|
#include <QtCore/qcoreapplication.h>
|
||||||
#define tr(x, y) QString(QLatin1String(y))
|
#include <QtCore/qvarlengtharray.h>
|
||||||
#else
|
#include <QtCore/qdebug.h>
|
||||||
#include <qcoreapplication.h>
|
|
||||||
#define tr(x, y) QCoreApplication::translate(x, y)
|
|
||||||
#endif
|
|
||||||
#include <qvarlengtharray.h>
|
|
||||||
#include <qdebug.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
|
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
|
||||||
@ -58,7 +54,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
using namespace QQmlJS;
|
using namespace QQmlJS;
|
||||||
|
|
||||||
static inline int regExpFlagFromChar(QChar ch)
|
static int regExpFlagFromChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
switch (ch.unicode()) {
|
switch (ch.unicode()) {
|
||||||
case 'g': return Lexer::RegExp_Global;
|
case 'g': return Lexer::RegExp_Global;
|
||||||
@ -141,6 +137,7 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
|
|||||||
_tokenSpell = QStringRef();
|
_tokenSpell = QStringRef();
|
||||||
|
|
||||||
_codePtr = code.unicode();
|
_codePtr = code.unicode();
|
||||||
|
_endPtr = _codePtr + code.length();
|
||||||
_lastLinePtr = _codePtr;
|
_lastLinePtr = _codePtr;
|
||||||
_tokenLinePtr = _codePtr;
|
_tokenLinePtr = _codePtr;
|
||||||
_tokenStartPtr = _codePtr;
|
_tokenStartPtr = _codePtr;
|
||||||
@ -171,14 +168,63 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
|
|||||||
|
|
||||||
void Lexer::scanChar()
|
void Lexer::scanChar()
|
||||||
{
|
{
|
||||||
|
unsigned sequenceLength = isLineTerminatorSequence();
|
||||||
_char = *_codePtr++;
|
_char = *_codePtr++;
|
||||||
|
if (sequenceLength == 2)
|
||||||
|
_char = *_codePtr++;
|
||||||
|
|
||||||
if (_char == QLatin1Char('\n')) {
|
if (unsigned sequenceLength = isLineTerminatorSequence()) {
|
||||||
_lastLinePtr = _codePtr; // points to the first character after the newline
|
_lastLinePtr = _codePtr + sequenceLength - 1; // points to the first character after the newline
|
||||||
++_currentLineNumber;
|
++_currentLineNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
inline bool isBinop(int tok)
|
||||||
|
{
|
||||||
|
switch (tok) {
|
||||||
|
case Lexer::T_AND:
|
||||||
|
case Lexer::T_AND_AND:
|
||||||
|
case Lexer::T_AND_EQ:
|
||||||
|
case Lexer::T_DIVIDE_:
|
||||||
|
case Lexer::T_DIVIDE_EQ:
|
||||||
|
case Lexer::T_EQ:
|
||||||
|
case Lexer::T_EQ_EQ:
|
||||||
|
case Lexer::T_EQ_EQ_EQ:
|
||||||
|
case Lexer::T_GE:
|
||||||
|
case Lexer::T_GT:
|
||||||
|
case Lexer::T_GT_GT:
|
||||||
|
case Lexer::T_GT_GT_EQ:
|
||||||
|
case Lexer::T_GT_GT_GT:
|
||||||
|
case Lexer::T_GT_GT_GT_EQ:
|
||||||
|
case Lexer::T_LE:
|
||||||
|
case Lexer::T_LT:
|
||||||
|
case Lexer::T_LT_LT:
|
||||||
|
case Lexer::T_LT_LT_EQ:
|
||||||
|
case Lexer::T_MINUS:
|
||||||
|
case Lexer::T_MINUS_EQ:
|
||||||
|
case Lexer::T_NOT_EQ:
|
||||||
|
case Lexer::T_NOT_EQ_EQ:
|
||||||
|
case Lexer::T_OR:
|
||||||
|
case Lexer::T_OR_EQ:
|
||||||
|
case Lexer::T_OR_OR:
|
||||||
|
case Lexer::T_PLUS:
|
||||||
|
case Lexer::T_PLUS_EQ:
|
||||||
|
case Lexer::T_REMAINDER:
|
||||||
|
case Lexer::T_REMAINDER_EQ:
|
||||||
|
case Lexer::T_RETURN:
|
||||||
|
case Lexer::T_STAR:
|
||||||
|
case Lexer::T_STAR_EQ:
|
||||||
|
case Lexer::T_XOR:
|
||||||
|
case Lexer::T_XOR_EQ:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
int Lexer::lex()
|
int Lexer::lex()
|
||||||
{
|
{
|
||||||
const int previousTokenKind = _tokenKind;
|
const int previousTokenKind = _tokenKind;
|
||||||
@ -195,9 +241,15 @@ int Lexer::lex()
|
|||||||
switch (_tokenKind) {
|
switch (_tokenKind) {
|
||||||
case T_LBRACE:
|
case T_LBRACE:
|
||||||
case T_SEMICOLON:
|
case T_SEMICOLON:
|
||||||
|
case T_QUESTION:
|
||||||
case T_COLON:
|
case T_COLON:
|
||||||
|
case T_TILDE:
|
||||||
_delimited = true;
|
_delimited = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (isBinop(_tokenKind))
|
||||||
|
_delimited = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case T_IF:
|
case T_IF:
|
||||||
case T_FOR:
|
case T_FOR:
|
||||||
@ -277,6 +329,59 @@ QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok)
|
|||||||
return QChar();
|
return QChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool isIdentifierStart(QChar ch)
|
||||||
|
{
|
||||||
|
// fast path for ascii
|
||||||
|
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
|
||||||
|
(ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
|
||||||
|
ch == '$' || ch == '_')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
switch (ch.category()) {
|
||||||
|
case QChar::Number_Letter:
|
||||||
|
case QChar::Letter_Uppercase:
|
||||||
|
case QChar::Letter_Lowercase:
|
||||||
|
case QChar::Letter_Titlecase:
|
||||||
|
case QChar::Letter_Modifier:
|
||||||
|
case QChar::Letter_Other:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isIdentifierPart(QChar ch)
|
||||||
|
{
|
||||||
|
// fast path for ascii
|
||||||
|
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
|
||||||
|
(ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
|
||||||
|
(ch.unicode() >= '0' && ch.unicode() <= '9') ||
|
||||||
|
ch == '$' || ch == '_' ||
|
||||||
|
ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
switch (ch.category()) {
|
||||||
|
case QChar::Mark_NonSpacing:
|
||||||
|
case QChar::Mark_SpacingCombining:
|
||||||
|
|
||||||
|
case QChar::Number_DecimalDigit:
|
||||||
|
case QChar::Number_Letter:
|
||||||
|
|
||||||
|
case QChar::Letter_Uppercase:
|
||||||
|
case QChar::Letter_Lowercase:
|
||||||
|
case QChar::Letter_Titlecase:
|
||||||
|
case QChar::Letter_Modifier:
|
||||||
|
case QChar::Letter_Other:
|
||||||
|
|
||||||
|
case QChar::Punctuation_Connector:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int Lexer::scanToken()
|
int Lexer::scanToken()
|
||||||
{
|
{
|
||||||
if (_stackToken != -1) {
|
if (_stackToken != -1) {
|
||||||
@ -292,13 +397,13 @@ again:
|
|||||||
_tokenLinePtr = _lastLinePtr;
|
_tokenLinePtr = _lastLinePtr;
|
||||||
|
|
||||||
while (_char.isSpace()) {
|
while (_char.isSpace()) {
|
||||||
if (_char == QLatin1Char('\n')) {
|
if (unsigned sequenceLength = isLineTerminatorSequence()) {
|
||||||
_tokenLinePtr = _codePtr;
|
_tokenLinePtr = _codePtr + sequenceLength - 1;
|
||||||
|
|
||||||
if (_restrictedKeyword) {
|
if (_restrictedKeyword) {
|
||||||
// automatic semicolon insertion
|
// automatic semicolon insertion
|
||||||
_tokenLine = _currentLineNumber;
|
_tokenLine = _currentLineNumber;
|
||||||
_tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence.
|
_tokenStartPtr = _codePtr - 1;
|
||||||
return T_SEMICOLON;
|
return T_SEMICOLON;
|
||||||
} else {
|
} else {
|
||||||
_terminator = true;
|
_terminator = true;
|
||||||
@ -312,7 +417,7 @@ again:
|
|||||||
_tokenStartPtr = _codePtr - 1;
|
_tokenStartPtr = _codePtr - 1;
|
||||||
_tokenLine = _currentLineNumber;
|
_tokenLine = _currentLineNumber;
|
||||||
|
|
||||||
if (_char.isNull())
|
if (_codePtr > _endPtr)
|
||||||
return EOF_SYMBOL;
|
return EOF_SYMBOL;
|
||||||
|
|
||||||
const QChar ch = _char;
|
const QChar ch = _char;
|
||||||
@ -397,7 +502,7 @@ again:
|
|||||||
case '/':
|
case '/':
|
||||||
if (_char == QLatin1Char('*')) {
|
if (_char == QLatin1Char('*')) {
|
||||||
scanChar();
|
scanChar();
|
||||||
while (!_char.isNull()) {
|
while (_codePtr <= _endPtr) {
|
||||||
if (_char == QLatin1Char('*')) {
|
if (_char == QLatin1Char('*')) {
|
||||||
scanChar();
|
scanChar();
|
||||||
if (_char == QLatin1Char('/')) {
|
if (_char == QLatin1Char('/')) {
|
||||||
@ -415,7 +520,7 @@ again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_char == QLatin1Char('/')) {
|
} else if (_char == QLatin1Char('/')) {
|
||||||
while (!_char.isNull() && _char != QLatin1Char('\n')) {
|
while (_codePtr <= _endPtr && !isLineTerminator()) {
|
||||||
scanChar();
|
scanChar();
|
||||||
}
|
}
|
||||||
if (_engine) {
|
if (_engine) {
|
||||||
@ -469,7 +574,7 @@ again:
|
|||||||
|
|
||||||
if (end - begin != chars.size() - 1) {
|
if (end - begin != chars.size() - 1) {
|
||||||
_errorCode = IllegalExponentIndicator;
|
_errorCode = IllegalExponentIndicator;
|
||||||
_errorMessage = tr("QQmlParser", "Illegal syntax for exponential number");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Illegal syntax for exponential number");
|
||||||
return T_ERROR;
|
return T_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,8 +662,14 @@ again:
|
|||||||
const QChar *startCode = _codePtr;
|
const QChar *startCode = _codePtr;
|
||||||
|
|
||||||
if (_engine) {
|
if (_engine) {
|
||||||
while (!_char.isNull()) {
|
while (_codePtr <= _endPtr) {
|
||||||
if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) {
|
if (isLineTerminator()) {
|
||||||
|
if (qmlMode())
|
||||||
|
break;
|
||||||
|
_errorCode = IllegalCharacter;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal");
|
||||||
|
return T_ERROR;
|
||||||
|
} else if (_char == QLatin1Char('\\')) {
|
||||||
break;
|
break;
|
||||||
} else if (_char == quote) {
|
} else if (_char == quote) {
|
||||||
_tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
|
_tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
|
||||||
@ -573,13 +684,15 @@ again:
|
|||||||
_validTokenText = true;
|
_validTokenText = true;
|
||||||
_tokenText.resize(0);
|
_tokenText.resize(0);
|
||||||
startCode--;
|
startCode--;
|
||||||
while (startCode != _codePtr - 1)
|
while (startCode != _codePtr - 1)
|
||||||
_tokenText += *startCode++;
|
_tokenText += *startCode++;
|
||||||
|
|
||||||
while (! _char.isNull()) {
|
while (_codePtr <= _endPtr) {
|
||||||
if (_char == QLatin1Char('\n')) {
|
if (unsigned sequenceLength = isLineTerminatorSequence()) {
|
||||||
multilineStringLiteral = true;
|
multilineStringLiteral = true;
|
||||||
_tokenText += _char;
|
_tokenText += _char;
|
||||||
|
if (sequenceLength == 2)
|
||||||
|
_tokenText += *_codePtr;
|
||||||
scanChar();
|
scanChar();
|
||||||
} else if (_char == quote) {
|
} else if (_char == quote) {
|
||||||
scanChar();
|
scanChar();
|
||||||
@ -598,13 +711,15 @@ again:
|
|||||||
// unicode escape sequence
|
// unicode escape sequence
|
||||||
case 'u':
|
case 'u':
|
||||||
u = decodeUnicodeEscapeCharacter(&ok);
|
u = decodeUnicodeEscapeCharacter(&ok);
|
||||||
if (! ok)
|
if (! ok) {
|
||||||
u = _char;
|
_errorCode = IllegalUnicodeEscapeSequence;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
|
||||||
|
return T_ERROR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// hex escape sequence
|
// hex escape sequence
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
|
||||||
if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) {
|
if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) {
|
||||||
scanChar();
|
scanChar();
|
||||||
|
|
||||||
@ -632,33 +747,43 @@ again:
|
|||||||
case 'v': u = QLatin1Char('\v'); scanChar(); break;
|
case 'v': u = QLatin1Char('\v'); scanChar(); break;
|
||||||
|
|
||||||
case '0':
|
case '0':
|
||||||
if (! _codePtr[1].isDigit()) {
|
if (! _codePtr->isDigit()) {
|
||||||
scanChar();
|
scanChar();
|
||||||
u = QLatin1Char('\0');
|
u = QLatin1Char('\0');
|
||||||
} else {
|
break;
|
||||||
// ### parse deprecated octal escape sequence ?
|
|
||||||
u = _char;
|
|
||||||
}
|
}
|
||||||
break;
|
// fall through
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
_errorCode = IllegalEscapeSequence;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Octal escape sequences are not allowed");
|
||||||
|
return T_ERROR;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
while (_char == QLatin1Char('\r'))
|
if (isLineTerminatorSequence() == 2) {
|
||||||
scanChar();
|
_tokenText += QLatin1Char('\r');
|
||||||
|
|
||||||
if (_char == QLatin1Char('\n')) {
|
|
||||||
u = _char;
|
|
||||||
scanChar();
|
|
||||||
} else {
|
|
||||||
u = QLatin1Char('\n');
|
u = QLatin1Char('\n');
|
||||||
|
} else {
|
||||||
|
u = QLatin1Char('\r');
|
||||||
}
|
}
|
||||||
|
scanChar();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
|
case 0x2028u:
|
||||||
|
case 0x2029u:
|
||||||
u = _char;
|
u = _char;
|
||||||
scanChar();
|
scanChar();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// non escape character
|
// non escape character
|
||||||
u = _char;
|
u = _char;
|
||||||
@ -673,32 +798,43 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
_errorCode = UnclosedStringLiteral;
|
_errorCode = UnclosedStringLiteral;
|
||||||
_errorMessage = tr("QQmlParser", "Unclosed string at end of line");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line");
|
||||||
return T_ERROR;
|
return T_ERROR;
|
||||||
}
|
}
|
||||||
|
case '0':
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
return scanNumber(ch);
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) {
|
QChar c = ch;
|
||||||
bool identifierWithEscapeChars = false;
|
bool identifierWithEscapeChars = false;
|
||||||
if (ch == QLatin1Char('\\')) {
|
if (c == QLatin1Char('\\') && _char == QLatin1Char('u')) {
|
||||||
identifierWithEscapeChars = true;
|
identifierWithEscapeChars = true;
|
||||||
|
bool ok = false;
|
||||||
|
c = decodeUnicodeEscapeCharacter(&ok);
|
||||||
|
if (! ok) {
|
||||||
|
_errorCode = IllegalUnicodeEscapeSequence;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
|
||||||
|
return T_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isIdentifierStart(c)) {
|
||||||
|
if (identifierWithEscapeChars) {
|
||||||
_tokenText.resize(0);
|
_tokenText.resize(0);
|
||||||
bool ok = false;
|
_tokenText += c;
|
||||||
_tokenText += decodeUnicodeEscapeCharacter(&ok);
|
|
||||||
_validTokenText = true;
|
_validTokenText = true;
|
||||||
if (! ok) {
|
|
||||||
_errorCode = IllegalUnicodeEscapeSequence;
|
|
||||||
_errorMessage = tr("QQmlParser", "Illegal unicode escape sequence");
|
|
||||||
return T_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) {
|
c = _char;
|
||||||
if (identifierWithEscapeChars)
|
if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
|
||||||
_tokenText += _char;
|
|
||||||
|
|
||||||
scanChar();
|
|
||||||
} else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
|
|
||||||
if (! identifierWithEscapeChars) {
|
if (! identifierWithEscapeChars) {
|
||||||
identifierWithEscapeChars = true;
|
identifierWithEscapeChars = true;
|
||||||
_tokenText.resize(0);
|
_tokenText.resize(0);
|
||||||
@ -708,136 +844,40 @@ again:
|
|||||||
|
|
||||||
scanChar(); // skip '\\'
|
scanChar(); // skip '\\'
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
_tokenText += decodeUnicodeEscapeCharacter(&ok);
|
c = decodeUnicodeEscapeCharacter(&ok);
|
||||||
if (! ok) {
|
if (! ok) {
|
||||||
_errorCode = IllegalUnicodeEscapeSequence;
|
_errorCode = IllegalUnicodeEscapeSequence;
|
||||||
_errorMessage = tr("QQmlParser", "Illegal unicode escape sequence");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
|
||||||
return T_ERROR;
|
return T_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
if (isIdentifierPart(c))
|
||||||
_tokenLength = _codePtr - _tokenStartPtr - 1;
|
_tokenText += c;
|
||||||
|
continue;
|
||||||
|
} else if (isIdentifierPart(c)) {
|
||||||
|
if (identifierWithEscapeChars)
|
||||||
|
_tokenText += c;
|
||||||
|
|
||||||
int kind = T_IDENTIFIER;
|
|
||||||
|
|
||||||
if (! identifierWithEscapeChars)
|
|
||||||
kind = classify(_tokenStartPtr, _tokenLength, _qmlMode);
|
|
||||||
|
|
||||||
if (_engine) {
|
|
||||||
if (kind == T_IDENTIFIER && identifierWithEscapeChars)
|
|
||||||
_tokenSpell = _engine->newStringRef(_tokenText);
|
|
||||||
else
|
|
||||||
_tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
return kind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ch.isDigit()) {
|
|
||||||
if (ch != QLatin1Char('0')) {
|
|
||||||
double integer = ch.unicode() - '0';
|
|
||||||
|
|
||||||
QChar n = _char;
|
|
||||||
const QChar *code = _codePtr;
|
|
||||||
while (n.isDigit()) {
|
|
||||||
integer = integer * 10 + (n.unicode() - '0');
|
|
||||||
n = *code++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
|
|
||||||
if (code != _codePtr) {
|
|
||||||
_codePtr = code - 1;
|
|
||||||
scanChar();
|
|
||||||
}
|
|
||||||
_tokenValue = integer;
|
|
||||||
return T_NUMERIC_LITERAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVarLengthArray<char,32> chars;
|
|
||||||
chars.append(ch.unicode());
|
|
||||||
|
|
||||||
if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) {
|
|
||||||
// parse hex integer literal
|
|
||||||
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume `x'
|
|
||||||
|
|
||||||
while (isHexDigit(_char)) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar();
|
scanChar();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tokenValue = integerFromString(chars.constData(), chars.size(), 16);
|
_tokenLength = _codePtr - _tokenStartPtr - 1;
|
||||||
return T_NUMERIC_LITERAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// decimal integer literal
|
int kind = T_IDENTIFIER;
|
||||||
while (_char.isDigit()) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume the digit
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_char == QLatin1Char('.')) {
|
if (! identifierWithEscapeChars)
|
||||||
chars.append(_char.unicode());
|
kind = classify(_tokenStartPtr, _tokenLength, _qmlMode);
|
||||||
scanChar(); // consume `.'
|
|
||||||
|
|
||||||
while (_char.isDigit()) {
|
if (_engine) {
|
||||||
chars.append(_char.unicode());
|
if (kind == T_IDENTIFIER && identifierWithEscapeChars)
|
||||||
scanChar();
|
_tokenSpell = _engine->newStringRef(_tokenText);
|
||||||
|
else
|
||||||
|
_tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
|
return kind;
|
||||||
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
|
|
||||||
_codePtr[1].isDigit())) {
|
|
||||||
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume `e'
|
|
||||||
|
|
||||||
if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume the sign
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_char.isDigit()) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
|
|
||||||
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
|
|
||||||
_codePtr[1].isDigit())) {
|
|
||||||
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume `e'
|
|
||||||
|
|
||||||
if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar(); // consume the sign
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_char.isDigit()) {
|
|
||||||
chars.append(_char.unicode());
|
|
||||||
scanChar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
chars.append('\0');
|
|
||||||
|
|
||||||
const char *begin = chars.constData();
|
|
||||||
const char *end = 0;
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
_tokenValue = qstrtod(begin, &end, &ok);
|
|
||||||
|
|
||||||
if (end - begin != chars.size() - 1) {
|
|
||||||
_errorCode = IllegalExponentIndicator;
|
|
||||||
_errorMessage = tr("QQmlParser", "Illegal syntax for exponential number");
|
|
||||||
return T_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return T_NUMERIC_LITERAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -846,6 +886,135 @@ again:
|
|||||||
return T_ERROR;
|
return T_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Lexer::scanNumber(QChar ch)
|
||||||
|
{
|
||||||
|
if (ch != QLatin1Char('0')) {
|
||||||
|
QByteArray buf;
|
||||||
|
buf.reserve(64);
|
||||||
|
buf += ch.toLatin1();
|
||||||
|
|
||||||
|
QChar n = _char;
|
||||||
|
const QChar *code = _codePtr;
|
||||||
|
while (n.isDigit()) {
|
||||||
|
buf += n.toLatin1();
|
||||||
|
n = *code++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
|
||||||
|
if (code != _codePtr) {
|
||||||
|
_codePtr = code - 1;
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
|
buf.append('\0');
|
||||||
|
_tokenValue = strtod(buf.constData(), 0);
|
||||||
|
return T_NUMERIC_LITERAL;
|
||||||
|
}
|
||||||
|
} else if (_char.isDigit() && !qmlMode()) {
|
||||||
|
_errorCode = IllegalCharacter;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Decimal numbers can't start with '0'");
|
||||||
|
return T_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVarLengthArray<char,32> chars;
|
||||||
|
chars.append(ch.unicode());
|
||||||
|
|
||||||
|
if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) {
|
||||||
|
ch = _char; // remember the x or X to use it in the error message below.
|
||||||
|
|
||||||
|
// parse hex integer literal
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume `x'
|
||||||
|
|
||||||
|
while (isHexDigit(_char)) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chars.size() < 3) {
|
||||||
|
_errorCode = IllegalHexNumber;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "At least one hexadecimal digit is required after '0%1'").arg(ch);
|
||||||
|
return T_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
_tokenValue = integerFromString(chars.constData(), chars.size(), 16);
|
||||||
|
return T_NUMERIC_LITERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// decimal integer literal
|
||||||
|
while (_char.isDigit()) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume the digit
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_char == QLatin1Char('.')) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume `.'
|
||||||
|
|
||||||
|
while (_char.isDigit()) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
|
||||||
|
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
|
||||||
|
_codePtr[1].isDigit())) {
|
||||||
|
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume `e'
|
||||||
|
|
||||||
|
if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume the sign
|
||||||
|
}
|
||||||
|
|
||||||
|
while (_char.isDigit()) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
|
||||||
|
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
|
||||||
|
_codePtr[1].isDigit())) {
|
||||||
|
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume `e'
|
||||||
|
|
||||||
|
if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar(); // consume the sign
|
||||||
|
}
|
||||||
|
|
||||||
|
while (_char.isDigit()) {
|
||||||
|
chars.append(_char.unicode());
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chars.length() == 1) {
|
||||||
|
// if we ended up with a single digit, then it was a '0'
|
||||||
|
_tokenValue = 0;
|
||||||
|
return T_NUMERIC_LITERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
chars.append('\0');
|
||||||
|
|
||||||
|
const char *begin = chars.constData();
|
||||||
|
const char *end = 0;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
_tokenValue = qstrtod(begin, &end, &ok);
|
||||||
|
|
||||||
|
if (end - begin != chars.size() - 1) {
|
||||||
|
_errorCode = IllegalExponentIndicator;
|
||||||
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Illegal syntax for exponential number");
|
||||||
|
return T_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return T_NUMERIC_LITERAL;
|
||||||
|
}
|
||||||
|
|
||||||
bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
||||||
{
|
{
|
||||||
_tokenText.resize(0);
|
_tokenText.resize(0);
|
||||||
@ -857,11 +1026,6 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (_char.unicode()) {
|
switch (_char.unicode()) {
|
||||||
case 0: // eof
|
|
||||||
case '\n': case '\r': // line terminator
|
|
||||||
_errorMessage = tr("QQmlParser", "Unterminated regular expression literal");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
scanChar();
|
scanChar();
|
||||||
|
|
||||||
@ -870,7 +1034,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
while (isIdentLetter(_char)) {
|
while (isIdentLetter(_char)) {
|
||||||
int flag = regExpFlagFromChar(_char);
|
int flag = regExpFlagFromChar(_char);
|
||||||
if (flag == 0) {
|
if (flag == 0) {
|
||||||
_errorMessage = tr("QQmlParser", "Invalid regular expression flag '%0'")
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Invalid regular expression flag '%0'")
|
||||||
.arg(QChar(_char));
|
.arg(QChar(_char));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -886,8 +1050,8 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
_tokenText += _char;
|
_tokenText += _char;
|
||||||
scanChar();
|
scanChar();
|
||||||
|
|
||||||
if (_char.isNull() || isLineTerminator()) {
|
if (_codePtr > _endPtr || isLineTerminator()) {
|
||||||
_errorMessage = tr("QQmlParser", "Unterminated regular expression backslash sequence");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +1064,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
_tokenText += _char;
|
_tokenText += _char;
|
||||||
scanChar();
|
scanChar();
|
||||||
|
|
||||||
while (! _char.isNull() && ! isLineTerminator()) {
|
while (_codePtr <= _endPtr && ! isLineTerminator()) {
|
||||||
if (_char == QLatin1Char(']'))
|
if (_char == QLatin1Char(']'))
|
||||||
break;
|
break;
|
||||||
else if (_char == QLatin1Char('\\')) {
|
else if (_char == QLatin1Char('\\')) {
|
||||||
@ -908,8 +1072,8 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
_tokenText += _char;
|
_tokenText += _char;
|
||||||
scanChar();
|
scanChar();
|
||||||
|
|
||||||
if (_char.isNull() || isLineTerminator()) {
|
if (_codePtr > _endPtr || isLineTerminator()) {
|
||||||
_errorMessage = tr("QQmlParser", "Unterminated regular expression backslash sequence");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,7 +1086,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_char != QLatin1Char(']')) {
|
if (_char != QLatin1Char(']')) {
|
||||||
_errorMessage = tr("QQmlParser", "Unterminated regular expression class");
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression class");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,8 +1095,13 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_tokenText += _char;
|
if (_codePtr > _endPtr || isLineTerminator()) {
|
||||||
scanChar();
|
_errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression literal");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
_tokenText += _char;
|
||||||
|
scanChar();
|
||||||
|
}
|
||||||
} // switch
|
} // switch
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
@ -941,7 +1110,28 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
|||||||
|
|
||||||
bool Lexer::isLineTerminator() const
|
bool Lexer::isLineTerminator() const
|
||||||
{
|
{
|
||||||
return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r'));
|
const ushort unicode = _char.unicode();
|
||||||
|
return unicode == 0x000Au
|
||||||
|
|| unicode == 0x000Du
|
||||||
|
|| unicode == 0x2028u
|
||||||
|
|| unicode == 0x2029u;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Lexer::isLineTerminatorSequence() const
|
||||||
|
{
|
||||||
|
switch (_char.unicode()) {
|
||||||
|
case 0x000Au:
|
||||||
|
case 0x2028u:
|
||||||
|
case 0x2029u:
|
||||||
|
return 1;
|
||||||
|
case 0x000Du:
|
||||||
|
if (_codePtr->unicode() == 0x000Au)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Lexer::isIdentLetter(QChar ch)
|
bool Lexer::isIdentLetter(QChar ch)
|
||||||
@ -975,31 +1165,6 @@ bool Lexer::isOctalDigit(ushort c)
|
|||||||
return (c >= '0' && c <= '7');
|
return (c >= '0' && c <= '7');
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lexer::tokenKind() const
|
|
||||||
{
|
|
||||||
return _tokenKind;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lexer::tokenOffset() const
|
|
||||||
{
|
|
||||||
return _tokenStartPtr - _code.unicode();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lexer::tokenLength() const
|
|
||||||
{
|
|
||||||
return _tokenLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lexer::tokenStartLine() const
|
|
||||||
{
|
|
||||||
return _tokenLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lexer::tokenStartColumn() const
|
|
||||||
{
|
|
||||||
return _tokenStartPtr - _tokenLinePtr + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lexer::tokenEndLine() const
|
int Lexer::tokenEndLine() const
|
||||||
{
|
{
|
||||||
return _currentLineNumber;
|
return _currentLineNumber;
|
||||||
@ -1010,16 +1175,6 @@ int Lexer::tokenEndColumn() const
|
|||||||
return _codePtr - _lastLinePtr;
|
return _codePtr - _lastLinePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef Lexer::tokenSpell() const
|
|
||||||
{
|
|
||||||
return _tokenSpell;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Lexer::tokenValue() const
|
|
||||||
{
|
|
||||||
return _tokenValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Lexer::tokenText() const
|
QString Lexer::tokenText() const
|
||||||
{
|
{
|
||||||
if (_validTokenText)
|
if (_validTokenText)
|
||||||
@ -1144,7 +1299,7 @@ bool Lexer::scanDirectives(Directives *directives)
|
|||||||
//
|
//
|
||||||
// recognize the mandatory `as' followed by the module name
|
// recognize the mandatory `as' followed by the module name
|
||||||
//
|
//
|
||||||
if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as")))
|
if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as")))
|
||||||
return false; // expected `as'
|
return false; // expected `as'
|
||||||
|
|
||||||
if (lex() != T_IDENTIFIER)
|
if (lex() != T_IDENTIFIER)
|
||||||
@ -1167,5 +1322,3 @@ bool Lexer::scanDirectives(Directives *directives)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "qqmljskeywords_p.h"
|
|
||||||
|
@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
#include "qqmljsglobal_p.h"
|
#include "qqmljsglobal_p.h"
|
||||||
#include "qqmljsgrammar_p.h"
|
#include "qqmljsgrammar_p.h"
|
||||||
#include "tr.h"
|
|
||||||
#include <qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -88,8 +88,6 @@ public:
|
|||||||
|
|
||||||
class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar
|
class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(QDoc::QQmlJS::Lexer)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
T_ABSTRACT = T_RESERVED_WORD,
|
T_ABSTRACT = T_RESERVED_WORD,
|
||||||
@ -107,7 +105,6 @@ public:
|
|||||||
T_IMPLEMENTS = T_RESERVED_WORD,
|
T_IMPLEMENTS = T_RESERVED_WORD,
|
||||||
T_INT = T_RESERVED_WORD,
|
T_INT = T_RESERVED_WORD,
|
||||||
T_INTERFACE = T_RESERVED_WORD,
|
T_INTERFACE = T_RESERVED_WORD,
|
||||||
T_LET = T_RESERVED_WORD,
|
|
||||||
T_LONG = T_RESERVED_WORD,
|
T_LONG = T_RESERVED_WORD,
|
||||||
T_NATIVE = T_RESERVED_WORD,
|
T_NATIVE = T_RESERVED_WORD,
|
||||||
T_PACKAGE = T_RESERVED_WORD,
|
T_PACKAGE = T_RESERVED_WORD,
|
||||||
@ -119,13 +116,13 @@ public:
|
|||||||
T_SYNCHRONIZED = T_RESERVED_WORD,
|
T_SYNCHRONIZED = T_RESERVED_WORD,
|
||||||
T_THROWS = T_RESERVED_WORD,
|
T_THROWS = T_RESERVED_WORD,
|
||||||
T_TRANSIENT = T_RESERVED_WORD,
|
T_TRANSIENT = T_RESERVED_WORD,
|
||||||
T_VOLATILE = T_RESERVED_WORD,
|
T_VOLATILE = T_RESERVED_WORD
|
||||||
T_YIELD = T_RESERVED_WORD
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Error {
|
enum Error {
|
||||||
NoError,
|
NoError,
|
||||||
IllegalCharacter,
|
IllegalCharacter,
|
||||||
|
IllegalHexNumber,
|
||||||
UnclosedStringLiteral,
|
UnclosedStringLiteral,
|
||||||
IllegalEscapeSequence,
|
IllegalEscapeSequence,
|
||||||
IllegalUnicodeEscapeSequence,
|
IllegalUnicodeEscapeSequence,
|
||||||
@ -161,18 +158,18 @@ public:
|
|||||||
int regExpFlags() const { return _patternFlags; }
|
int regExpFlags() const { return _patternFlags; }
|
||||||
QString regExpPattern() const { return _tokenText; }
|
QString regExpPattern() const { return _tokenText; }
|
||||||
|
|
||||||
int tokenKind() const;
|
int tokenKind() const { return _tokenKind; }
|
||||||
int tokenOffset() const;
|
int tokenOffset() const { return _tokenStartPtr - _code.unicode(); }
|
||||||
int tokenLength() const;
|
int tokenLength() const { return _tokenLength; }
|
||||||
|
|
||||||
int tokenStartLine() const;
|
int tokenStartLine() const { return _tokenLine; }
|
||||||
int tokenStartColumn() const;
|
int tokenStartColumn() const { return _tokenStartPtr - _tokenLinePtr + 1; }
|
||||||
|
|
||||||
int tokenEndLine() const;
|
int tokenEndLine() const;
|
||||||
int tokenEndColumn() const;
|
int tokenEndColumn() const;
|
||||||
|
|
||||||
QStringRef tokenSpell() const;
|
inline QStringRef tokenSpell() const { return _tokenSpell; }
|
||||||
double tokenValue() const;
|
double tokenValue() const { return _tokenValue; }
|
||||||
QString tokenText() const;
|
QString tokenText() const;
|
||||||
|
|
||||||
Error errorCode() const;
|
Error errorCode() const;
|
||||||
@ -194,8 +191,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
inline void scanChar();
|
inline void scanChar();
|
||||||
int scanToken();
|
int scanToken();
|
||||||
|
int scanNumber(QChar ch);
|
||||||
|
|
||||||
bool isLineTerminator() const;
|
bool isLineTerminator() const;
|
||||||
|
unsigned isLineTerminatorSequence() const;
|
||||||
static bool isIdentLetter(QChar c);
|
static bool isIdentLetter(QChar c);
|
||||||
static bool isDecimalDigit(ushort c);
|
static bool isDecimalDigit(ushort c);
|
||||||
static bool isHexDigit(QChar c);
|
static bool isHexDigit(QChar c);
|
||||||
@ -214,6 +213,7 @@ private:
|
|||||||
QStringRef _tokenSpell;
|
QStringRef _tokenSpell;
|
||||||
|
|
||||||
const QChar *_codePtr;
|
const QChar *_codePtr;
|
||||||
|
const QChar *_endPtr;
|
||||||
const QChar *_lastLinePtr;
|
const QChar *_lastLinePtr;
|
||||||
const QChar *_tokenLinePtr;
|
const QChar *_tokenLinePtr;
|
||||||
const QChar *_tokenStartPtr;
|
const QChar *_tokenStartPtr;
|
||||||
|
@ -60,7 +60,6 @@
|
|||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -52,8 +52,15 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// This file is automatically generated from qmljs.g.
|
// W A R N I N G
|
||||||
// Changes will be lost.
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is automatically generated from qqmljs.g.
|
||||||
|
// Changes should be made to that file, not here. Any change to this file will
|
||||||
|
// be lost!
|
||||||
|
//
|
||||||
|
// To regenerate this file, run:
|
||||||
|
// qlalr --no-debug --no-lines --qt qqmljs.g
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef QQMLJSPARSER_P_H
|
#ifndef QQMLJSPARSER_P_H
|
||||||
@ -64,8 +71,8 @@
|
|||||||
#include "qqmljsast_p.h"
|
#include "qqmljsast_p.h"
|
||||||
#include "qqmljsengine_p.h"
|
#include "qqmljsengine_p.h"
|
||||||
|
|
||||||
#include <qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
QT_QML_BEGIN_NAMESPACE
|
QT_QML_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -75,8 +82,6 @@ class Engine;
|
|||||||
|
|
||||||
class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar
|
class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(QDoc::QQmlJS::Parser)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
union Value {
|
union Value {
|
||||||
int ival;
|
int ival;
|
||||||
@ -96,7 +101,8 @@ public:
|
|||||||
AST::FunctionDeclaration *FunctionDeclaration;
|
AST::FunctionDeclaration *FunctionDeclaration;
|
||||||
AST::Node *Node;
|
AST::Node *Node;
|
||||||
AST::PropertyName *PropertyName;
|
AST::PropertyName *PropertyName;
|
||||||
AST::PropertyNameAndValueList *PropertyNameAndValueList;
|
AST::PropertyAssignment *PropertyAssignment;
|
||||||
|
AST::PropertyAssignmentList *PropertyAssignmentList;
|
||||||
AST::SourceElement *SourceElement;
|
AST::SourceElement *SourceElement;
|
||||||
AST::SourceElements *SourceElements;
|
AST::SourceElements *SourceElements;
|
||||||
AST::Statement *Statement;
|
AST::Statement *Statement;
|
||||||
@ -239,9 +245,9 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define J_SCRIPT_REGEXPLITERAL_RULE1 79
|
#define J_SCRIPT_REGEXPLITERAL_RULE1 81
|
||||||
|
|
||||||
#define J_SCRIPT_REGEXPLITERAL_RULE2 80
|
#define J_SCRIPT_REGEXPLITERAL_RULE2 82
|
||||||
|
|
||||||
QT_QML_END_NAMESPACE
|
QT_QML_END_NAMESPACE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user