From 3cefb43441a9879cc512dc3fcc7dca0d42e9ca8c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 Aug 2013 13:17:32 +0200 Subject: Move the parser folder from src/qml/qml to src/qml Change-Id: I5e5684f5b98b00f791ade99c4cb6bc2ed880ad6a Reviewed-by: Simon Hausmann --- src/qml/parser/parser.pri | 22 + src/qml/parser/qqmljs.g | 3063 +++++++++++++++++++++++++++++++ src/qml/parser/qqmljsast.cpp | 958 ++++++++++ src/qml/parser/qqmljsast_p.h | 2705 +++++++++++++++++++++++++++ src/qml/parser/qqmljsastfwd_p.h | 189 ++ src/qml/parser/qqmljsastvisitor.cpp | 58 + src/qml/parser/qqmljsastvisitor_p.h | 337 ++++ src/qml/parser/qqmljsengine_p.cpp | 161 ++ src/qml/parser/qqmljsengine_p.h | 126 ++ src/qml/parser/qqmljsglobal_p.h | 71 + src/qml/parser/qqmljsgrammar.cpp | 1068 +++++++++++ src/qml/parser/qqmljsgrammar_p.h | 214 +++ src/qml/parser/qqmljskeywords_p.h | 884 +++++++++ src/qml/parser/qqmljslexer.cpp | 1329 ++++++++++++++ src/qml/parser/qqmljslexer_p.h | 253 +++ src/qml/parser/qqmljsmemorypool_p.h | 173 ++ src/qml/parser/qqmljsparser.cpp | 1844 +++++++++++++++++++ src/qml/parser/qqmljsparser_p.h | 256 +++ src/qml/qml.pro | 1 + src/qml/qml/parser/parser.pri | 22 - src/qml/qml/parser/qqmljs.g | 3063 ------------------------------- src/qml/qml/parser/qqmljsast.cpp | 958 ---------- src/qml/qml/parser/qqmljsast_p.h | 2705 --------------------------- src/qml/qml/parser/qqmljsastfwd_p.h | 189 -- src/qml/qml/parser/qqmljsastvisitor.cpp | 58 - src/qml/qml/parser/qqmljsastvisitor_p.h | 337 ---- src/qml/qml/parser/qqmljsengine_p.cpp | 161 -- src/qml/qml/parser/qqmljsengine_p.h | 126 -- src/qml/qml/parser/qqmljsglobal_p.h | 71 - src/qml/qml/parser/qqmljsgrammar.cpp | 1068 ----------- src/qml/qml/parser/qqmljsgrammar_p.h | 214 --- src/qml/qml/parser/qqmljskeywords_p.h | 884 --------- src/qml/qml/parser/qqmljslexer.cpp | 1329 -------------- src/qml/qml/parser/qqmljslexer_p.h | 253 --- src/qml/qml/parser/qqmljsmemorypool_p.h | 173 -- src/qml/qml/parser/qqmljsparser.cpp | 1844 ------------------- src/qml/qml/parser/qqmljsparser_p.h | 256 --- src/qml/qml/qml.pri | 1 - src/qmldevtools/qmldevtools.pro | 2 +- 39 files changed, 13713 insertions(+), 13713 deletions(-) create mode 100644 src/qml/parser/parser.pri create mode 100644 src/qml/parser/qqmljs.g create mode 100644 src/qml/parser/qqmljsast.cpp create mode 100644 src/qml/parser/qqmljsast_p.h create mode 100644 src/qml/parser/qqmljsastfwd_p.h create mode 100644 src/qml/parser/qqmljsastvisitor.cpp create mode 100644 src/qml/parser/qqmljsastvisitor_p.h create mode 100644 src/qml/parser/qqmljsengine_p.cpp create mode 100644 src/qml/parser/qqmljsengine_p.h create mode 100644 src/qml/parser/qqmljsglobal_p.h create mode 100644 src/qml/parser/qqmljsgrammar.cpp create mode 100644 src/qml/parser/qqmljsgrammar_p.h create mode 100644 src/qml/parser/qqmljskeywords_p.h create mode 100644 src/qml/parser/qqmljslexer.cpp create mode 100644 src/qml/parser/qqmljslexer_p.h create mode 100644 src/qml/parser/qqmljsmemorypool_p.h create mode 100644 src/qml/parser/qqmljsparser.cpp create mode 100644 src/qml/parser/qqmljsparser_p.h delete mode 100644 src/qml/qml/parser/parser.pri delete mode 100644 src/qml/qml/parser/qqmljs.g delete mode 100644 src/qml/qml/parser/qqmljsast.cpp delete mode 100644 src/qml/qml/parser/qqmljsast_p.h delete mode 100644 src/qml/qml/parser/qqmljsastfwd_p.h delete mode 100644 src/qml/qml/parser/qqmljsastvisitor.cpp delete mode 100644 src/qml/qml/parser/qqmljsastvisitor_p.h delete mode 100644 src/qml/qml/parser/qqmljsengine_p.cpp delete mode 100644 src/qml/qml/parser/qqmljsengine_p.h delete mode 100644 src/qml/qml/parser/qqmljsglobal_p.h delete mode 100644 src/qml/qml/parser/qqmljsgrammar.cpp delete mode 100644 src/qml/qml/parser/qqmljsgrammar_p.h delete mode 100644 src/qml/qml/parser/qqmljskeywords_p.h delete mode 100644 src/qml/qml/parser/qqmljslexer.cpp delete mode 100644 src/qml/qml/parser/qqmljslexer_p.h delete mode 100644 src/qml/qml/parser/qqmljsmemorypool_p.h delete mode 100644 src/qml/qml/parser/qqmljsparser.cpp delete mode 100644 src/qml/qml/parser/qqmljsparser_p.h (limited to 'src') diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri new file mode 100644 index 0000000000..e5b8ae2749 --- /dev/null +++ b/src/qml/parser/parser.pri @@ -0,0 +1,22 @@ +HEADERS += \ + $$PWD/qqmljsast_p.h \ + $$PWD/qqmljsastfwd_p.h \ + $$PWD/qqmljsastvisitor_p.h \ + $$PWD/qqmljsengine_p.h \ + $$PWD/qqmljsgrammar_p.h \ + $$PWD/qqmljslexer_p.h \ + $$PWD/qqmljsmemorypool_p.h \ + $$PWD/qqmljsparser_p.h \ + $$PWD/qqmljsglobal_p.h \ + $$PWD/qqmljskeywords_p.h \ + +SOURCES += \ + $$PWD/qqmljsast.cpp \ + $$PWD/qqmljsastvisitor.cpp \ + $$PWD/qqmljsengine_p.cpp \ + $$PWD/qqmljsgrammar.cpp \ + $$PWD/qqmljslexer.cpp \ + $$PWD/qqmljsparser.cpp \ + +OTHER_FILES += \ + $$PWD/qqmljs.g diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g new file mode 100644 index 0000000000..5d279ef1a2 --- /dev/null +++ b/src/qml/parser/qqmljs.g @@ -0,0 +1,3063 @@ +---------------------------------------------------------------------------- +-- +-- Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +-- Contact: http://www.qt-project.org/legal +-- +-- This file is part of the QtQml module of the Qt Toolkit. +-- +-- $QT_BEGIN_LICENSE:LGPL-ONLY$ +-- GNU Lesser General Public License Usage +-- This file may be used under the terms of the GNU Lesser +-- General Public License version 2.1 as published by the Free Software +-- Foundation and appearing in the file LICENSE.LGPL included in the +-- packaging of this file. Please review the following information to +-- ensure the GNU Lesser General Public License version 2.1 requirements +-- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +-- +-- If you have questions regarding the use of this file, please contact +-- us via http://www.qt-project.org/. +-- +-- $QT_END_LICENSE$ +-- +---------------------------------------------------------------------------- + +%parser QQmlJSGrammar +%decl qqmljsparser_p.h +%impl qqmljsparser.cpp +%expect 5 +%expect-rr 2 + +%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" +%token T_BREAK "break" T_CASE "case" T_CATCH "catch" +%token T_COLON ":" T_COMMA "," T_CONTINUE "continue" +%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/" +%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "." +%token T_ELSE "else" T_EQ "=" T_EQ_EQ "==" +%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for" +%token T_FUNCTION "function" T_GE ">=" T_GT ">" +%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>" +%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if" +%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{" +%token T_LBRACKET "[" T_LE "<=" T_LPAREN "(" +%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<=" +%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--" +%token T_NEW "new" T_NOT "!" T_NOT_EQ "!=" +%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|" +%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+" +%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?" +%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%" +%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")" +%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*" +%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal" +%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly" +%token T_SWITCH "switch" T_THIS "this" T_THROW "throw" +%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof" +%token T_VAR "var" T_VOID "void" T_WHILE "while" +%token T_WITH "with" T_XOR "^" T_XOR_EQ "^=" +%token T_NULL "null" T_TRUE "true" T_FALSE "false" +%token T_CONST "const" +%token T_DEBUGGER "debugger" +%token T_RESERVED_WORD "reserved word" +%token T_MULTILINE_STRING_LITERAL "multiline string literal" +%token T_COMMENT "comment" +%token T_COMPATIBILITY_SEMICOLON + +--- context keywords. +%token T_PUBLIC "public" +%token T_IMPORT "import" +%token T_AS "as" +%token T_ON "on" +%token T_GET "get" +%token T_SET "set" + +%token T_ERROR + +--- feed tokens +%token T_FEED_UI_PROGRAM +%token T_FEED_UI_OBJECT_MEMBER +%token T_FEED_JS_STATEMENT +%token T_FEED_JS_EXPRESSION +%token T_FEED_JS_SOURCE_ELEMENT +%token T_FEED_JS_PROGRAM + +%nonassoc SHIFT_THERE +%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET +%nonassoc REDUCE_HERE + +%start TopLevel + +/./**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljsengine_p.h" +#include "qqmljslexer_p.h" +#include "qqmljsast_p.h" +#include "qqmljsmemorypool_p.h" + +#include +#include + +#include + +./ + +/:/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// W A R N I N G +// ------------- +// +// 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 +#define QQMLJSPARSER_P_H + +#include "qqmljsglobal_p.h" +#include "qqmljsgrammar_p.h" +#include "qqmljsast_p.h" +#include "qqmljsengine_p.h" + +#include +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Engine; + +class QML_PARSER_EXPORT Parser: protected $table +{ +public: + union Value { + int ival; + double dval; + AST::ArgumentList *ArgumentList; + AST::CaseBlock *CaseBlock; + AST::CaseClause *CaseClause; + AST::CaseClauses *CaseClauses; + AST::Catch *Catch; + AST::DefaultClause *DefaultClause; + AST::ElementList *ElementList; + AST::Elision *Elision; + AST::ExpressionNode *Expression; + AST::Finally *Finally; + AST::FormalParameterList *FormalParameterList; + AST::FunctionBody *FunctionBody; + AST::FunctionDeclaration *FunctionDeclaration; + AST::Node *Node; + AST::PropertyName *PropertyName; + AST::PropertyAssignment *PropertyAssignment; + AST::PropertyAssignmentList *PropertyAssignmentList; + AST::SourceElement *SourceElement; + AST::SourceElements *SourceElements; + AST::Statement *Statement; + AST::StatementList *StatementList; + AST::Block *Block; + AST::VariableDeclaration *VariableDeclaration; + AST::VariableDeclarationList *VariableDeclarationList; + + AST::UiProgram *UiProgram; + AST::UiImportList *UiImportList; + AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; + AST::UiPublicMember *UiPublicMember; + AST::UiObjectDefinition *UiObjectDefinition; + AST::UiObjectInitializer *UiObjectInitializer; + AST::UiObjectBinding *UiObjectBinding; + AST::UiScriptBinding *UiScriptBinding; + AST::UiArrayBinding *UiArrayBinding; + AST::UiObjectMember *UiObjectMember; + AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; + AST::UiQualifiedId *UiQualifiedId; + }; + +public: + Parser(Engine *engine); + ~Parser(); + + // parse a UI program + bool parse() { return parse(T_FEED_UI_PROGRAM); } + bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } + bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } + bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } + bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } + bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } + + AST::UiProgram *ast() const + { return AST::cast(program); } + + AST::Statement *statement() const + { + if (! program) + return 0; + + return program->statementCast(); + } + + AST::ExpressionNode *expression() const + { + if (! program) + return 0; + + return program->expressionCast(); + } + + AST::UiObjectMember *uiObjectMember() const + { + if (! program) + return 0; + + return program->uiObjectMemberCast(); + } + + AST::Node *rootNode() const + { return program; } + + QList diagnosticMessages() const + { return diagnostic_messages; } + + inline DiagnosticMessage diagnosticMessage() const + { + foreach (const DiagnosticMessage &d, diagnostic_messages) { + if (! d.kind == DiagnosticMessage::Warning) + return d; + } + + return DiagnosticMessage(); + } + + inline QString errorMessage() const + { return diagnosticMessage().message; } + + inline int errorLineNumber() const + { return diagnosticMessage().loc.startLine; } + + inline int errorColumnNumber() const + { return diagnosticMessage().loc.startColumn; } + +protected: + bool parse(int startToken); + + void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline QStringRef &stringRef(int index) + { return string_stack [tos + index - 1]; } + + inline AST::SourceLocation &loc(int index) + { return location_stack [tos + index - 1]; } + + AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); + +protected: + Engine *driver; + MemoryPool *pool; + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + AST::SourceLocation *location_stack; + QStringRef *string_stack; + + AST::Node *program; + + // error recovery + enum { TOKEN_BUFFER_SIZE = 3 }; + + struct SavedToken { + int token; + double dval; + AST::SourceLocation loc; + QStringRef spell; + }; + + double yylval; + QStringRef yytokenspell; + AST::SourceLocation yylloc; + AST::SourceLocation yyprevlloc; + + SavedToken token_buffer[TOKEN_BUFFER_SIZE]; + SavedToken *first_token; + SavedToken *last_token; + + QList diagnostic_messages; +}; + +} // end of namespace QQmlJS + + +:/ + + +/. + +#include "qqmljsparser_p.h" + +#include + +// +// W A R N I N G +// ------------- +// +// 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; + +QT_QML_BEGIN_NAMESPACE + +void Parser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); +} + +Parser::Parser(Engine *engine): + driver(engine), + pool(engine->pool()), + tos(0), + stack_size(0), + sym_stack(0), + state_stack(0), + location_stack(0), + string_stack(0), + program(0), + first_token(0), + last_token(0) +{ +} + +Parser::~Parser() +{ + if (stack_size) { + free(sym_stack); + free(state_stack); + free(location_stack); + free(string_stack); + } +} + +static inline AST::SourceLocation location(Lexer *lexer) +{ + AST::SourceLocation loc; + loc.offset = lexer->tokenOffset(); + loc.length = lexer->tokenLength(); + loc.startLine = lexer->tokenStartLine(); + loc.startColumn = lexer->tokenStartColumn(); + return loc; +} + +AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) +{ + QVarLengthArray nameIds; + QVarLengthArray locations; + + AST::ExpressionNode *it = expr; + while (AST::FieldMemberExpression *m = AST::cast(it)) { + nameIds.append(m->name); + locations.append(m->identifierToken); + it = m->base; + } + + if (AST::IdentifierExpression *idExpr = AST::cast(it)) { + AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); + q->identifierToken = idExpr->identifierToken; + + AST::UiQualifiedId *currentId = q; + for (int i = nameIds.size() - 1; i != -1; --i) { + currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); + currentId->identifierToken = locations[i]; + } + + return currentId->finish(); + } + + return 0; +} + +bool Parser::parse(int startToken) +{ + Lexer *lexer = driver->lexer(); + bool hadErrors = false; + int yytoken = -1; + int action = 0; + + token_buffer[0].token = startToken; + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + tos = -1; + program = 0; + + do { + if (++tos == stack_size) + reallocateStack(); + + state_stack[tos] = action; + + _Lcheck_token: + if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + + if (first_token == last_token) { + yytoken = lexer->lex(); + yylval = lexer->tokenValue(); + yytokenspell = lexer->tokenSpell(); + yylloc = location(lexer); + } else { + yytoken = first_token->token; + yylval = first_token->dval; + yytokenspell = first_token->spell; + yylloc = first_token->loc; + ++first_token; + } + } + + action = t_action(action, yytoken); + if (action > 0) { + if (action != ACCEPT_STATE) { + yytoken = -1; + sym(1).dval = yylval; + stringRef(1) = yytokenspell; + loc(1) = yylloc; + } else { + --tos; + return ! hadErrors; + } + } else if (action < 0) { + const int r = -action - 1; + tos -= rhs[r]; + + switch (r) { +./ + +-------------------------------------------------------------------------------------------------------- +-- Declarative UI +-------------------------------------------------------------------------------------------------------- + +TopLevel: T_FEED_UI_PROGRAM UiProgram ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_STATEMENT Statement ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_EXPRESSION Expression ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_PROGRAM Program ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +UiProgram: UiImportListOpt UiRootMember ; +/. +case $rule_number: { + sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, + sym(2).UiObjectMemberList->finish()); +} break; +./ + +UiImportListOpt: Empty ; +UiImportListOpt: UiImportList ; +/. +case $rule_number: { + sym(1).Node = sym(1).UiImportList->finish(); +} break; +./ + +UiImportList: UiImport ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); +} break; +./ + +UiImportList: UiImportList UiImport ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); +} break; +./ + +ImportId: MemberExpression ; + +UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->semicolonToken = loc(2); +} break; +./ + +UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->semicolonToken = loc(3); +} break; +./ + +UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->asToken = loc(3); + sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = stringRef(4); + sym(1).UiImport->semicolonToken = loc(5); +} break; +./ + +UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->asToken = loc(2); + sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = stringRef(3); + sym(1).UiImport->semicolonToken = loc(4); +} break; +./ + + +UiImportHead: T_IMPORT ImportId ; +/. +case $rule_number: { + AST::UiImport *node = 0; + + if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { + node = new (pool) AST::UiImport(importIdLiteral->value); + node->fileNameToken = loc(2); + } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { + node = new (pool) AST::UiImport(qualifiedId); + node->fileNameToken = loc(2); + } + + sym(1).Node = node; + + if (node) { + node->importToken = loc(1); + } else { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id or a string literal"))); + + return false; // ### remove me + } +} break; +./ + +Empty: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +UiRootMember: UiObjectDefinition ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; +./ + +UiObjectMemberList: UiObjectMember ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; +./ + +UiObjectMemberList: UiObjectMemberList UiObjectMember ; +/. +case $rule_number: { + AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( + sym(1).UiObjectMemberList, sym(2).UiObjectMember); + sym(1).Node = node; +} break; +./ + +UiArrayMemberList: UiObjectDefinition ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); +} break; +./ + +UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ; +/. +case $rule_number: { + AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( + sym(1).UiArrayMemberList, sym(3).UiObjectMember); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectInitializer: T_LBRACE T_RBRACE ; +/. +case $rule_number: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); + node->lbraceToken = loc(1); + node->rbraceToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ; +/. +case $rule_number: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiObjectDefinition: UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, + sym(2).UiObjectInitializer); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiObjectDefinition ; + +UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; +/. +case $rule_number: { + AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( + sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); + node->colonToken = loc(2); + node->lbracketToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + node->hasOnToken = true; + sym(1).Node = node; +} break; +./ + +UiScriptStatement: Block ; +UiScriptStatement: EmptyStatement ; +UiScriptStatement: ExpressionStatement ; +UiScriptStatement: IfStatement ; +UiScriptStatement: WithStatement ; +UiScriptStatement: SwitchStatement ; +UiScriptStatement: TryStatement ; + +UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ; +/. +case $rule_number: +{ + AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( + sym(1).UiQualifiedId, sym(3).Statement); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiPropertyType: T_VAR ; +UiPropertyType: T_RESERVED_WORD ; +UiPropertyType: T_IDENTIFIER ; + +UiParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +UiParameterListOpt: UiParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; +./ + +UiParameterList: UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + node->propertyTypeToken = loc(1); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); + node->propertyTypeToken = loc(3); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->parameters = sym(4).UiParameterList; + node->semicolonToken = loc(6); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), + sym(5).Statement); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); + propertyName->identifierToken = loc(6); + propertyName->next = 0; + + AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( + propertyName, sym(9).UiArrayMemberList->finish()); + binding->colonToken = loc(7); + binding->lbracketToken = loc(8); + binding->rbracketToken = loc(10); + + node->binding = binding; + + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); + propertyName->identifierToken = loc(3); + propertyName->next = 0; + + AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( + propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); + binding->colonToken = loc(4); + + node->binding = binding; + + sym(1).Node = node; +} break; +./ + +UiObjectMember: FunctionDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; +./ + +UiObjectMember: VariableStatement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; +./ + +JsIdentifier: T_IDENTIFIER; + +JsIdentifier: T_PROPERTY ; +JsIdentifier: T_SIGNAL ; +JsIdentifier: T_READONLY ; +JsIdentifier: T_ON ; +JsIdentifier: T_GET ; +JsIdentifier: T_SET ; + +-------------------------------------------------------------------------------------------------------- +-- Expressions +-------------------------------------------------------------------------------------------------------- + +PrimaryExpression: T_THIS ; +/. +case $rule_number: { + AST::ThisExpression *node = new (pool) AST::ThisExpression(); + node->thisToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: JsIdentifier ; +/. +case $rule_number: { + AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_NULL ; +/. +case $rule_number: { + AST::NullExpression *node = new (pool) AST::NullExpression(); + node->nullToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_TRUE ; +/. +case $rule_number: { + AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); + node->trueToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_FALSE ; +/. +case $rule_number: { + AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); + node->falseToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_MULTILINE_STRING_LITERAL ; +/.case $rule_number:./ + +PrimaryExpression: T_STRING_LITERAL ; +/. +case $rule_number: { + AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_DIVIDE_ ; +/: +#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(Lexer::NoPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; // ### remove me + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_DIVIDE_EQ ; +/: +#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(Lexer::EqualPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); + node->lbracketToken = loc(1); + node->rbracketToken = loc(2); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET Elision T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + (AST::Elision *) 0); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + sym(4).Elision->finish()); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; +./ + +-- PrimaryExpression: T_LBRACE T_RBRACE ; +-- /. +-- case $rule_number: { +-- sym(1).Node = new (pool) AST::ObjectLiteral(); +-- } break; +-- ./ + +PrimaryExpression: T_LBRACE PropertyAssignmentListOpt T_RBRACE ; +/. +case $rule_number: { + AST::ObjectLiteral *node = 0; + if (sym(2).Node) + node = new (pool) AST::ObjectLiteral( + sym(2).PropertyAssignmentList->finish ()); + else + node = new (pool) AST::ObjectLiteral(); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACE PropertyAssignmentList T_COMMA T_RBRACE ; +/. +case $rule_number: { + AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( + sym(2).PropertyAssignmentList->finish ()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(4); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LPAREN Expression T_RPAREN ; +/. +case $rule_number: { + AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); + node->lparenToken = loc(1); + node->rparenToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiQualifiedId: MemberExpression ; +/. +case $rule_number: { + if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, + QLatin1String("Ignored annotation"))); + + sym(1).Expression = mem->base; + } + + if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { + sym(1).UiQualifiedId = qualifiedId; + } else { + sym(1).UiQualifiedId = 0; + + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id"))); + + return false; // ### recover + } +} break; +./ + +ElementList: AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); +} break; +./ + +ElementList: Elision AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); +} break; +./ + +ElementList: ElementList T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, + (AST::Elision *) 0, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ElementList: ElementList T_COMMA Elision AssignmentExpression ; +/. +case $rule_number: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), + sym(4).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +Elision: T_COMMA ; +/. +case $rule_number: { + AST::Elision *node = new (pool) AST::Elision(); + node->commaToken = loc(1); + sym(1).Node = node; +} break; +./ + +Elision: Elision T_COMMA ; +/. +case $rule_number: { + AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +PropertyAssignment: PropertyName T_COLON AssignmentExpression ; +/. +case $rule_number: { + AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( + sym(1).PropertyName, sym(3).Expression); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +PropertyAssignment: T_GET PropertyName T_LPAREN T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( + 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); + sym(1).Node = node; +} break; +./ + +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_STRING_LITERAL ; +/. +case $rule_number: { + AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: ReservedIdentifier ; +/. +case $rule_number: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +ReservedIdentifier: T_BREAK ; +ReservedIdentifier: T_CASE ; +ReservedIdentifier: T_CATCH ; +ReservedIdentifier: T_CONTINUE ; +ReservedIdentifier: T_DEFAULT ; +ReservedIdentifier: T_DELETE ; +ReservedIdentifier: T_DO ; +ReservedIdentifier: T_ELSE ; +ReservedIdentifier: T_FALSE ; +ReservedIdentifier: T_FINALLY ; +ReservedIdentifier: T_FOR ; +ReservedIdentifier: T_FUNCTION ; +ReservedIdentifier: T_IF ; +ReservedIdentifier: T_IN ; +ReservedIdentifier: T_INSTANCEOF ; +ReservedIdentifier: T_NEW ; +ReservedIdentifier: T_NULL ; +ReservedIdentifier: T_RETURN ; +ReservedIdentifier: T_SWITCH ; +ReservedIdentifier: T_THIS ; +ReservedIdentifier: T_THROW ; +ReservedIdentifier: T_TRUE ; +ReservedIdentifier: T_TRY ; +ReservedIdentifier: T_TYPEOF ; +ReservedIdentifier: T_VAR ; +ReservedIdentifier: T_VOID ; +ReservedIdentifier: T_WHILE ; +ReservedIdentifier: T_CONST ; +ReservedIdentifier: T_DEBUGGER ; +ReservedIdentifier: T_RESERVED_WORD ; +ReservedIdentifier: T_WITH ; + +PropertyIdentifier: JsIdentifier ; +PropertyIdentifier: ReservedIdentifier ; + +MemberExpression: PrimaryExpression ; +MemberExpression: FunctionExpression ; + +MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +MemberExpression: MemberExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); + node->newToken = loc(1); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + sym(1).Node = node; +} break; +./ + +NewExpression: MemberExpression ; + +NewExpression: T_NEW NewExpression ; +/. +case $rule_number: { + AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); + node->newToken = loc(1); + sym(1).Node = node; +} break; +./ + +CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +ArgumentListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ArgumentListOpt: ArgumentList ; +/. +case $rule_number: { + sym(1).Node = sym(1).ArgumentList->finish(); +} break; +./ + +ArgumentList: AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); +} break; +./ + +ArgumentList: ArgumentList T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +LeftHandSideExpression: NewExpression ; +LeftHandSideExpression: CallExpression ; +PostfixExpression: LeftHandSideExpression ; + +PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; +/. +case $rule_number: { + AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); + node->incrementToken = loc(2); + sym(1).Node = node; +} break; +./ + +PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; +/. +case $rule_number: { + AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); + node->decrementToken = loc(2); + sym(1).Node = node; +} break; +./ + +UnaryExpression: PostfixExpression ; + +UnaryExpression: T_DELETE UnaryExpression ; +/. +case $rule_number: { + AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); + node->deleteToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_VOID UnaryExpression ; +/. +case $rule_number: { + AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); + node->voidToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_TYPEOF UnaryExpression ; +/. +case $rule_number: { + AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); + node->typeofToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_PLUS_PLUS UnaryExpression ; +/. +case $rule_number: { + AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); + node->incrementToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_MINUS_MINUS UnaryExpression ; +/. +case $rule_number: { + AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); + node->decrementToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_PLUS UnaryExpression ; +/. +case $rule_number: { + AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); + node->plusToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_MINUS UnaryExpression ; +/. +case $rule_number: { + AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); + node->minusToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_TILDE UnaryExpression ; +/. +case $rule_number: { + AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); + node->tildeToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_NOT UnaryExpression ; +/. +case $rule_number: { + AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); + node->notToken = loc(1); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: UnaryExpression ; + +MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mul, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Div, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mod, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AdditiveExpression: MultiplicativeExpression ; + +AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Add, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Sub, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: AdditiveExpression ; + +ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::LShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::RShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::URShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: ShiftExpression ; + +RelationalExpression: RelationalExpression T_LT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_GT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_LE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_GE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_IN ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::In, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: ShiftExpression ; + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: RelationalExpression ; + +EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: RelationalExpressionNotIn ; + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseANDExpression: EqualityExpression ; + +BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; + +BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseXORExpression: BitwiseANDExpression ; + +BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; + +BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseORExpression: BitwiseXORExpression ; + +BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; + +BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalANDExpression: BitwiseORExpression ; + +LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; + +LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalORExpression: LogicalANDExpression ; + +LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; + +LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ConditionalExpression: LogicalORExpression ; + +ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; +/. +case $rule_number: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +ConditionalExpressionNotIn: LogicalORExpressionNotIn ; + +ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +AssignmentExpression: ConditionalExpression ; + +AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AssignmentExpressionNotIn: ConditionalExpressionNotIn ; + +AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AssignmentOperator: T_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::Assign; +} break; +./ + +AssignmentOperator: T_STAR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceMul; +} break; +./ + +AssignmentOperator: T_DIVIDE_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceDiv; +} break; +./ + +AssignmentOperator: T_REMAINDER_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceMod; +} break; +./ + +AssignmentOperator: T_PLUS_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceAdd; +} break; +./ + +AssignmentOperator: T_MINUS_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceSub; +} break; +./ + +AssignmentOperator: T_LT_LT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceLeftShift; +} break; +./ + +AssignmentOperator: T_GT_GT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceRightShift; +} break; +./ + +AssignmentOperator: T_GT_GT_GT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceURightShift; +} break; +./ + +AssignmentOperator: T_AND_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceAnd; +} break; +./ + +AssignmentOperator: T_XOR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceXor; +} break; +./ + +AssignmentOperator: T_OR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceOr; +} break; +./ + +Expression: AssignmentExpression ; + +Expression: Expression T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ExpressionOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ExpressionOpt: Expression ; + +ExpressionNotIn: AssignmentExpressionNotIn ; + +ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ExpressionNotInOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ExpressionNotInOpt: ExpressionNotIn ; + +Statement: Block ; +Statement: VariableStatement ; +Statement: EmptyStatement ; +Statement: ExpressionStatement ; +Statement: IfStatement ; +Statement: IterationStatement ; +Statement: ContinueStatement ; +Statement: BreakStatement ; +Statement: ReturnStatement ; +Statement: WithStatement ; +Statement: LabelledStatement ; +Statement: SwitchStatement ; +Statement: ThrowStatement ; +Statement: TryStatement ; +Statement: DebuggerStatement ; + + +Block: T_LBRACE StatementListOpt T_RBRACE ; +/. +case $rule_number: { + AST::Block *node = new (pool) AST::Block(sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +StatementList: Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); +} break; +./ + +StatementList: StatementList Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); +} break; +./ + +StatementListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +StatementListOpt: StatementList ; +/. +case $rule_number: { + sym(1).Node = sym(1).StatementList->finish (); +} break; +./ + +VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; +/. +case $rule_number: { + AST::VariableStatement *node = new (pool) AST::VariableStatement( + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + node->declarationKindToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +VariableDeclarationKind: T_CONST ; +/. +case $rule_number: { + sym(1).ival = T_CONST; +} break; +./ + +VariableDeclarationKind: T_VAR ; +/. +case $rule_number: { + sym(1).ival = T_VAR; +} break; +./ + +VariableDeclarationList: VariableDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; +./ + +VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; +/. +case $rule_number: { + AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); +} break; +./ + +VariableDeclaration: JsIdentifier InitialiserOpt ; +/. +case $rule_number: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ; +/. +case $rule_number: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +Initialiser: T_EQ AssignmentExpression ; +/. +case $rule_number: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; +./ + +InitialiserOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserOpt: Initialiser ; + +InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; +/. +case $rule_number: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; +./ + +InitialiserNotInOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserNotInOpt: InitialiserNotIn ; + +EmptyStatement: T_SEMICOLON ; +/. +case $rule_number: { + AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); + node->semicolonToken = loc(1); + sym(1).Node = node; +} break; +./ + +ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ExpressionStatement: Expression T_SEMICOLON ; +/. +case $rule_number: { + AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; +/. +case $rule_number: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(6); + sym(1).Node = node; +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + + +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 ; +/. +case $rule_number: { + AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + AST::LocalForStatement *node = new (pool) AST::LocalForStatement( + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; +} break; +./ + +ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE T_SEMICOLON ; +/. +case $rule_number: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK T_SEMICOLON ; +/. +case $rule_number: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; +/. +case $rule_number: { + AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; + if (lexer->qmlMode()) { + const QString msg = qApp->translate("QQmlParser", "Deprecated JavaScript `with' statement detected in QML expression. Support for this will be removed in Qt 5.2!"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, node->withToken, msg)); + } +} break; +./ + +SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; +/. +case $rule_number: { + AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; +} break; +./ + +CaseClauses: CaseClause ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); +} break; +./ + +CaseClauses: CaseClauses CaseClause ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); +} break; +./ + +CaseClausesOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +CaseClausesOpt: CaseClauses ; +/. +case $rule_number: { + sym(1).Node = sym(1).CaseClauses->finish (); +} break; +./ + +CaseClause: T_CASE Expression T_COLON StatementListOpt ; +/. +case $rule_number: { + AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; +} break; +./ + +DefaultClause: T_DEFAULT T_COLON StatementListOpt ; +/. +case $rule_number: { + AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +LabelledStatement: JsIdentifier 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; +./ + +ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ThrowStatement: T_THROW Expression T_SEMICOLON ; +/. +case $rule_number: { + AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Catch ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Finally ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Catch Finally ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ; +/. +case $rule_number: { + AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +Finally: T_FINALLY Block ; +/. +case $rule_number: { + AST::Finally *node = new (pool) AST::Finally(sym(2).Block); + node->finallyToken = loc(1); + sym(1).Node = node; +} break; +./ + +DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +DebuggerStatement: T_DEBUGGER T_SEMICOLON ; +/. +case $rule_number: { + AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +-- 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: { + AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; +./ + +FunctionExpression: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + if (! stringRef(2).isNull()) + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} 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 ; +/. +case $rule_number: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +FormalParameterList: FormalParameterList T_COMMA JsIdentifier ; +/. +case $rule_number: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); + node->commaToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +FormalParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FormalParameterListOpt: FormalParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).FormalParameterList->finish (); +} break; +./ + +FunctionBodyOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FunctionBodyOpt: FunctionBody ; + +FunctionBody: SourceElements ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); +} break; +./ + +Program: Empty ; + +Program: SourceElements ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); +} break; +./ + +SourceElements: SourceElement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); +} break; +./ + +SourceElements: SourceElements SourceElement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); +} break; +./ + +SourceElement: Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); +} break; +./ + +SourceElement: FunctionDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); +} break; +./ + +PropertyAssignmentListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +PropertyAssignmentListOpt: PropertyAssignmentList ; + +/. + } // switch + action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); + } // if + } while (action != 0); + + if (first_token == last_token) { + const int errorState = state_stack[tos]; + + // automatic insertion of `;' + if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) + || t_action(errorState, T_COMPATIBILITY_SEMICOLON))) { + SavedToken &tk = token_buffer[0]; + tk.token = yytoken; + tk.dval = yylval; + tk.spell = yytokenspell; + tk.loc = yylloc; + + yylloc = yyprevlloc; + yylloc.offset += yylloc.length; + yylloc.startColumn += yylloc.length; + yylloc.length = 0; + + //const QString msg = qApp->translate("QQmlParser", "Missing `;'"); + //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); + + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + yytoken = T_SEMICOLON; + yylval = 0; + + action = errorState; + + goto _Lcheck_token; + } + + hadErrors = true; + + token_buffer[0].token = yytoken; + token_buffer[0].dval = yylval; + token_buffer[0].spell = yytokenspell; + token_buffer[0].loc = yylloc; + + token_buffer[1].token = yytoken = lexer->lex(); + token_buffer[1].dval = yylval = lexer->tokenValue(); + token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); + token_buffer[1].loc = yylloc = location(lexer); + + if (t_action(errorState, yytoken)) { + QString msg; + int token = token_buffer[0].token; + if (token < 0 || token >= TERMINAL_COUNT) + msg = qApp->translate("QQmlParser", "Syntax error"); + else + msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + action = errorState; + goto _Lcheck_token; + } + + static int tokens[] = { + T_PLUS, + T_EQ, + + T_COMMA, + T_COLON, + T_SEMICOLON, + + T_RPAREN, T_RBRACKET, T_RBRACE, + + T_NUMERIC_LITERAL, + T_IDENTIFIER, + + T_LPAREN, T_LBRACKET, T_LBRACE, + + EOF_SYMBOL + }; + + for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { + int a = t_action(errorState, *tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = *tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + first_token = &token_buffer[0]; + last_token = &token_buffer[2]; + + action = errorState; + goto _Lcheck_token; + } + } + + for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { + if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || + tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || + tk == T_FEED_JS_SOURCE_ELEMENT) + continue; + + int a = t_action(errorState, tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + action = errorState; + goto _Lcheck_token; + } + } + + const QString msg = qApp->translate("QQmlParser", "Syntax error"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + } + + return false; +} + +QT_QML_END_NAMESPACE + + +./ +/: +QT_QML_END_NAMESPACE + + + +#endif // QQMLJSPARSER_P_H +:/ diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp new file mode 100644 index 0000000000..ea0df4a537 --- /dev/null +++ b/src/qml/parser/qqmljsast.cpp @@ -0,0 +1,958 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljsast_p.h" + +#include "qqmljsastvisitor_p.h" + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { namespace AST { + +void Node::accept(Visitor *visitor) +{ + if (visitor->preVisit(this)) { + accept0(visitor); + } + visitor->postVisit(this); +} + +void Node::accept(Node *node, Visitor *visitor) +{ + if (node) + node->accept(visitor); +} + +ExpressionNode *Node::expressionCast() +{ + return 0; +} + +BinaryExpression *Node::binaryExpressionCast() +{ + return 0; +} + +Statement *Node::statementCast() +{ + return 0; +} + +UiObjectMember *Node::uiObjectMemberCast() +{ + return 0; +} + +ExpressionNode *ExpressionNode::expressionCast() +{ + return this; +} + +BinaryExpression *BinaryExpression::binaryExpressionCast() +{ + return this; +} + +Statement *Statement::statementCast() +{ + return this; +} + +UiObjectMember *UiObjectMember::uiObjectMemberCast() +{ + return this; +} + +void NestedExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + visitor->endVisit(this); +} + +void ThisExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void IdentifierExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NullExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void TrueLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void FalseLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void StringLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NumericLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void RegExpLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ArrayLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + accept(elision, visitor); + } + + visitor->endVisit(this); +} + +void ObjectLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(properties, visitor); + } + + visitor->endVisit(this); +} + +void ElementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ElementList *it = this; it; it = it->next) { + accept(it->elision, visitor); + accept(it->expression, visitor); + } + } + + visitor->endVisit(this); +} + +void Elision::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + // ### + } + + visitor->endVisit(this); +} + +void PropertyNameAndValue::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(name, visitor); + accept(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); + } + } + + visitor->endVisit(this); +} + +void IdentifierPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void StringLiteralPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NumericLiteralPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ArrayMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void FieldMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void NewMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(arguments, visitor); + } + + visitor->endVisit(this); +} + +void NewExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void CallExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(arguments, visitor); + } + + visitor->endVisit(this); +} + +void ArgumentList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ArgumentList *it = this; it; it = it->next) { + accept(it->expression, visitor); + } + } + + visitor->endVisit(this); +} + +void PostIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void PostDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void DeleteExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void VoidExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TypeOfExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryPlusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryMinusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TildeExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void NotExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void BinaryExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(left, visitor); + accept(right, visitor); + } + + visitor->endVisit(this); +} + +void ConditionalExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); + } + + visitor->endVisit(this); +} + +void Expression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(left, visitor); + accept(right, visitor); + } + + visitor->endVisit(this); +} + +void Block::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void StatementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (StatementList *it = this; it; it = it->next) { + accept(it->statement, visitor); + } + } + + visitor->endVisit(this); +} + +void VariableStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declarations, visitor); + } + + visitor->endVisit(this); +} + +void VariableDeclarationList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (VariableDeclarationList *it = this; it; it = it->next) { + accept(it->declaration, visitor); + } + } + + visitor->endVisit(this); +} + +void VariableDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void EmptyStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ExpressionStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void IfStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); + } + + visitor->endVisit(this); +} + +void DoWhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void WhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(initialiser, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declarations, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(initialiser, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declaration, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ContinueStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void BreakStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ReturnStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void WithStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void SwitchStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(block, visitor); + } + + visitor->endVisit(this); +} + +void CaseBlock::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(clauses, visitor); + accept(defaultClause, visitor); + accept(moreClauses, visitor); + } + + visitor->endVisit(this); +} + +void CaseClauses::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (CaseClauses *it = this; it; it = it->next) { + accept(it->clause, visitor); + } + } + + visitor->endVisit(this); +} + +void CaseClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void DefaultClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void LabelledStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ThrowStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TryStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(catchExpression, visitor); + accept(finallyExpression, visitor); + } + + visitor->endVisit(this); +} + +void Catch::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void Finally::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void FunctionDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(formals, visitor); + accept(body, visitor); + } + + visitor->endVisit(this); +} + +void FunctionExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(formals, visitor); + accept(body, visitor); + } + + visitor->endVisit(this); +} + +void FormalParameterList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + // ### + } + + visitor->endVisit(this); +} + +void FunctionBody::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + } + + visitor->endVisit(this); +} + +void Program::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + } + + visitor->endVisit(this); +} + +void SourceElements::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (SourceElements *it = this; it; it = it->next) { + accept(it->element, visitor); + } + } + + visitor->endVisit(this); +} + +void FunctionSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declaration, visitor); + } + + visitor->endVisit(this); +} + +void StatementSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void DebuggerStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void UiProgram::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(imports, visitor); + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiPublicMember::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(binding, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectDefinition::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectInitializer::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiParameterList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + visitor->endVisit(this); +} + +void UiObjectBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); + } + + visitor->endVisit(this); +} + +void UiScriptBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void UiArrayBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectMemberList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (UiObjectMemberList *it = this; it; it = it->next) + accept(it->member, visitor); + } + + visitor->endVisit(this); +} + +void UiArrayMemberList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (UiArrayMemberList *it = this; it; it = it->next) + accept(it->member, visitor); + } + + visitor->endVisit(this); +} + +void UiQualifiedId::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void UiImport::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(importUri, visitor); + } + + visitor->endVisit(this); +} + +void UiImportList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(import, visitor); + accept(next, visitor); + } + + visitor->endVisit(this); +} + +void UiSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(sourceElement, visitor); + } + + visitor->endVisit(this); +} + +} } // namespace QQmlJS::AST + +QT_QML_END_NAMESPACE + + diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h new file mode 100644 index 0000000000..01a872f1e8 --- /dev/null +++ b/src/qml/parser/qqmljsast_p.h @@ -0,0 +1,2705 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSAST_P_H +#define QQMLJSAST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsastvisitor_p.h" +#include "qqmljsglobal_p.h" +#include "qqmljsmemorypool_p.h" + +#include + +QT_QML_BEGIN_NAMESPACE + +#define QQMLJS_DECLARE_AST_NODE(name) \ + enum { K = Kind_##name }; + +namespace QSOperator // ### rename +{ + +enum Op { + Add, + And, + InplaceAnd, + Assign, + BitAnd, + BitOr, + BitXor, + InplaceSub, + Div, + InplaceDiv, + Equal, + Ge, + Gt, + In, + InplaceAdd, + InstanceOf, + Le, + LShift, + InplaceLeftShift, + Lt, + Mod, + InplaceMod, + Mul, + InplaceMul, + NotEqual, + Or, + InplaceOr, + RShift, + InplaceRightShift, + StrictEqual, + StrictNotEqual, + Sub, + URShift, + InplaceURightShift, + InplaceXor +}; + +} // namespace QSOperator + +namespace QQmlJS { + +namespace AST { + +template +_T1 cast(_T2 *ast) +{ + if (ast && ast->kind == static_cast<_T1>(0)->K) + return static_cast<_T1>(ast); + + return 0; +} + +class QML_PARSER_EXPORT Node: public Managed +{ +public: + enum Kind { + Kind_Undefined, + + Kind_ArgumentList, + Kind_ArrayLiteral, + Kind_ArrayMemberExpression, + Kind_BinaryExpression, + Kind_Block, + Kind_BreakStatement, + Kind_CallExpression, + Kind_CaseBlock, + Kind_CaseClause, + Kind_CaseClauses, + Kind_Catch, + Kind_ConditionalExpression, + Kind_ContinueStatement, + Kind_DebuggerStatement, + Kind_DefaultClause, + Kind_DeleteExpression, + Kind_DoWhileStatement, + Kind_ElementList, + Kind_Elision, + Kind_EmptyStatement, + Kind_Expression, + Kind_ExpressionStatement, + Kind_FalseLiteral, + Kind_FieldMemberExpression, + Kind_Finally, + Kind_ForEachStatement, + Kind_ForStatement, + Kind_FormalParameterList, + Kind_FunctionBody, + Kind_FunctionDeclaration, + Kind_FunctionExpression, + Kind_FunctionSourceElement, + Kind_IdentifierExpression, + Kind_IdentifierPropertyName, + Kind_IfStatement, + Kind_LabelledStatement, + Kind_LocalForEachStatement, + Kind_LocalForStatement, + Kind_NewExpression, + Kind_NewMemberExpression, + Kind_NotExpression, + Kind_NullExpression, + Kind_NumericLiteral, + Kind_NumericLiteralPropertyName, + Kind_ObjectLiteral, + Kind_PostDecrementExpression, + Kind_PostIncrementExpression, + Kind_PreDecrementExpression, + Kind_PreIncrementExpression, + Kind_Program, + Kind_PropertyAssignmentList, + Kind_PropertyGetterSetter, + Kind_PropertyName, + Kind_PropertyNameAndValue, + Kind_RegExpLiteral, + Kind_ReturnStatement, + Kind_SourceElement, + Kind_SourceElements, + Kind_StatementList, + Kind_StatementSourceElement, + Kind_StringLiteral, + Kind_StringLiteralPropertyName, + Kind_SwitchStatement, + Kind_ThisExpression, + Kind_ThrowStatement, + Kind_TildeExpression, + Kind_TrueLiteral, + Kind_TryStatement, + Kind_TypeOfExpression, + Kind_UnaryMinusExpression, + Kind_UnaryPlusExpression, + Kind_VariableDeclaration, + Kind_VariableDeclarationList, + Kind_VariableStatement, + Kind_VoidExpression, + Kind_WhileStatement, + Kind_WithStatement, + Kind_NestedExpression, + + Kind_UiArrayBinding, + Kind_UiImport, + Kind_UiImportList, + Kind_UiObjectBinding, + Kind_UiObjectDefinition, + Kind_UiObjectInitializer, + Kind_UiObjectMemberList, + Kind_UiArrayMemberList, + Kind_UiProgram, + Kind_UiParameterList, + Kind_UiPublicMember, + Kind_UiQualifiedId, + Kind_UiScriptBinding, + Kind_UiSourceElement + }; + + inline Node() + : kind(Kind_Undefined) {} + + // NOTE: node destructors are never called, + // instead we block free the memory + // (see the NodePool class) + virtual ~Node() {} + + virtual ExpressionNode *expressionCast(); + virtual BinaryExpression *binaryExpressionCast(); + virtual Statement *statementCast(); + virtual UiObjectMember *uiObjectMemberCast(); + + void accept(Visitor *visitor); + static void accept(Node *node, Visitor *visitor); + + inline static void acceptChild(Node *node, Visitor *visitor) + { return accept(node, visitor); } // ### remove + + virtual void accept0(Visitor *visitor) = 0; + virtual SourceLocation firstSourceLocation() const = 0; + virtual SourceLocation lastSourceLocation() const = 0; + +// attributes + int kind; +}; + +class QML_PARSER_EXPORT ExpressionNode: public Node +{ +public: + ExpressionNode() {} + + virtual ExpressionNode *expressionCast(); +}; + +class QML_PARSER_EXPORT Statement: public Node +{ +public: + Statement() {} + + virtual Statement *statementCast(); +}; + +class QML_PARSER_EXPORT NestedExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NestedExpression) + + NestedExpression(ExpressionNode *expression) + : expression(expression) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lparenToken; } + + virtual SourceLocation lastSourceLocation() const + { return rparenToken; } + +// attributes + ExpressionNode *expression; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ThisExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ThisExpression) + + ThisExpression() { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return thisToken; } + + virtual SourceLocation lastSourceLocation() const + { return thisToken; } + +// attributes + SourceLocation thisToken; +}; + +class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(IdentifierExpression) + + IdentifierExpression(const QStringRef &n): + name (n) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return identifierToken; } + +// attributes + QStringRef name; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT NullExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NullExpression) + + NullExpression() { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return nullToken; } + + virtual SourceLocation lastSourceLocation() const + { return nullToken; } + +// attributes + SourceLocation nullToken; +}; + +class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TrueLiteral) + + TrueLiteral() { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return trueToken; } + + virtual SourceLocation lastSourceLocation() const + { return trueToken; } + +// attributes + SourceLocation trueToken; +}; + +class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(FalseLiteral) + + FalseLiteral() { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return falseToken; } + + virtual SourceLocation lastSourceLocation() const + { return falseToken; } + +// attributes + SourceLocation falseToken; +}; + +class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NumericLiteral) + + NumericLiteral(double v): + value(v) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return literalToken; } + + virtual SourceLocation lastSourceLocation() const + { return literalToken; } + +// attributes: + double value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT StringLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(StringLiteral) + + StringLiteral(const QStringRef &v): + value (v) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return literalToken; } + + virtual SourceLocation lastSourceLocation() const + { return literalToken; } + +// attributes: + QStringRef value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(RegExpLiteral) + + RegExpLiteral(const QStringRef &p, int f): + pattern (p), flags (f) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return literalToken; } + + virtual SourceLocation lastSourceLocation() const + { return literalToken; } + +// attributes: + QStringRef pattern; + int flags; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ArrayLiteral) + + ArrayLiteral(Elision *e): + elements (0), elision (e) + { kind = K; } + + ArrayLiteral(ElementList *elts): + elements (elts), elision (0) + { kind = K; } + + ArrayLiteral(ElementList *elts, Elision *e): + elements (elts), elision (e) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lbracketToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbracketToken; } + +// attributes + ElementList *elements; + Elision *elision; + SourceLocation lbracketToken; + SourceLocation commaToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ObjectLiteral) + + ObjectLiteral(): + properties (0) { kind = K; } + + ObjectLiteral(PropertyAssignmentList *plist): + properties (plist) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lbraceToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbraceToken; } + +// attributes + PropertyAssignmentList *properties; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT Elision: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Elision) + + Elision(): + next (this) { kind = K; } + + Elision(Elision *previous) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return commaToken; } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : commaToken; } + + inline Elision *finish () + { + Elision *front = next; + next = 0; + return front; + } + +// attributes + Elision *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT ElementList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ElementList) + + ElementList(Elision *e, ExpressionNode *expr): + elision (e), expression (expr), next (this) + { kind = K; } + + ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): + elision (e), expression (expr) + { + kind = K; + next = previous->next; + previous->next = this; + } + + inline ElementList *finish () + { + ElementList *front = next; + next = 0; + return front; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { + if (elision) + return elision->firstSourceLocation(); + return expression->firstSourceLocation(); + } + + virtual SourceLocation lastSourceLocation() const + { + if (next) + return next->lastSourceLocation(); + return expression->lastSourceLocation(); + } + +// attributes + Elision *elision; + ExpressionNode *expression; + ElementList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT PropertyName: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PropertyName) + + PropertyName() { kind = K; } + + virtual SourceLocation firstSourceLocation() const + { return propertyNameToken; } + + virtual SourceLocation lastSourceLocation() const + { return propertyNameToken; } + +// attributes + SourceLocation propertyNameToken; +}; + +class QML_PARSER_EXPORT PropertyAssignment: public Node +{ +public: + PropertyAssignment() {} +}; + +class QML_PARSER_EXPORT PropertyAssignmentList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PropertyAssignmentList) + + PropertyAssignmentList(PropertyAssignment *assignment) + : assignment(assignment) + , next(this) + { kind = K; } + + PropertyAssignmentList(PropertyAssignmentList *previous, PropertyAssignment *assignment) + : assignment(assignment) + { + kind = K; + next = previous->next; + 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 SourceLocation firstSourceLocation() const + { return name->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return value->lastSourceLocation(); } + +// attributes + PropertyName *name; + SourceLocation colonToken; + ExpressionNode *value; + 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 +{ +public: + QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName) + + IdentifierPropertyName(const QStringRef &n): + id (n) { kind = K; } + + virtual void accept0(Visitor *visitor); + +// attributes + QStringRef id; +}; + +class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName) + + StringLiteralPropertyName(const QStringRef &n): + id (n) { kind = K; } + + virtual void accept0(Visitor *visitor); + +// attributes + QStringRef id; +}; + +class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName) + + NumericLiteralPropertyName(double n): + id (n) { kind = K; } + + virtual void accept0(Visitor *visitor); + +// attributes + double id; +}; + +class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ArrayMemberExpression) + + ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): + base (b), expression (e) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return base->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return rbracketToken; } + +// attributes + ExpressionNode *base; + ExpressionNode *expression; + SourceLocation lbracketToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(FieldMemberExpression) + + FieldMemberExpression(ExpressionNode *b, const QStringRef &n): + base (b), name (n) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return base->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return identifierToken; } + + // attributes + ExpressionNode *base; + QStringRef name; + SourceLocation dotToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NewMemberExpression) + + NewMemberExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return newToken; } + + virtual SourceLocation lastSourceLocation() const + { return rparenToken; } + + // attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation newToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT NewExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NewExpression) + + NewExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return newToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation newToken; +}; + +class QML_PARSER_EXPORT CallExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(CallExpression) + + CallExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return base->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return rparenToken; } + +// attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ArgumentList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ArgumentList) + + ArgumentList(ExpressionNode *e): + expression (e), next (this) + { kind = K; } + + ArgumentList(ArgumentList *previous, ExpressionNode *e): + expression (e) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return expression->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { + if (next) + return next->lastSourceLocation(); + return expression->lastSourceLocation(); + } + + inline ArgumentList *finish () + { + ArgumentList *front = next; + next = 0; + return front; + } + +// attributes + ExpressionNode *expression; + ArgumentList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PostIncrementExpression) + + PostIncrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return base->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return incrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PostDecrementExpression) + + PostDecrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return base->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return decrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(DeleteExpression) + + DeleteExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return deleteToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation deleteToken; +}; + +class QML_PARSER_EXPORT VoidExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(VoidExpression) + + VoidExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return voidToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation voidToken; +}; + +class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TypeOfExpression) + + TypeOfExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return typeofToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation typeofToken; +}; + +class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PreIncrementExpression) + + PreIncrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return incrementToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PreDecrementExpression) + + PreDecrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return decrementToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(UnaryPlusExpression) + + UnaryPlusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return plusToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation plusToken; +}; + +class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(UnaryMinusExpression) + + UnaryMinusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return minusToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation minusToken; +}; + +class QML_PARSER_EXPORT TildeExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TildeExpression) + + TildeExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return tildeToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation tildeToken; +}; + +class QML_PARSER_EXPORT NotExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NotExpression) + + NotExpression(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return notToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation notToken; +}; + +class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(BinaryExpression) + + BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): + left (l), op (o), right (r) + { kind = K; } + + virtual BinaryExpression *binaryExpressionCast(); + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return left->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + int op; + ExpressionNode *right; + SourceLocation operatorToken; +}; + +class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ConditionalExpression) + + ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): + expression (e), ok (t), ko (f) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return expression->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return ko->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + ExpressionNode *ok; + ExpressionNode *ko; + SourceLocation questionToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename +{ +public: + QQMLJS_DECLARE_AST_NODE(Expression) + + Expression(ExpressionNode *l, ExpressionNode *r): + left (l), right (r) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return left->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + ExpressionNode *right; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT Block: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(Block) + + Block(StatementList *slist): + statements (slist) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lbraceToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbraceToken; } + + // attributes + StatementList *statements; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT StatementList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(StatementList) + + StatementList(Statement *stmt): + statement (stmt), next (this) + { kind = K; } + + StatementList(StatementList *previous, Statement *stmt): + statement (stmt) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return statement->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); } + + inline StatementList *finish () + { + StatementList *front = next; + next = 0; + return front; + } + +// attributes + Statement *statement; + StatementList *next; +}; + +class QML_PARSER_EXPORT VariableStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(VariableStatement) + + VariableStatement(VariableDeclarationList *vlist): + declarations (vlist) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return declarationKindToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + VariableDeclarationList *declarations; + SourceLocation declarationKindToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT VariableDeclaration: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(VariableDeclaration) + + VariableDeclaration(const QStringRef &n, ExpressionNode *e): + name (n), expression (e), readOnly(false) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return expression ? expression->lastSourceLocation() : identifierToken; } + +// attributes + QStringRef name; + ExpressionNode *expression; + bool readOnly; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT VariableDeclarationList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(VariableDeclarationList) + + VariableDeclarationList(VariableDeclaration *decl): + declaration (decl), next (this) + { kind = K; } + + VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): + declaration (decl) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return declaration->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { + if (next) + return next->lastSourceLocation(); + return declaration->lastSourceLocation(); + } + + inline VariableDeclarationList *finish (bool readOnly) + { + VariableDeclarationList *front = next; + next = 0; + if (readOnly) { + VariableDeclarationList *vdl; + for (vdl = front; vdl != 0; vdl = vdl->next) + vdl->declaration->readOnly = true; + } + return front; + } + +// attributes + VariableDeclaration *declaration; + VariableDeclarationList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT EmptyStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(EmptyStatement) + + EmptyStatement() { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return semicolonToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ExpressionStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ExpressionStatement) + + ExpressionStatement(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return expression->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT IfStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(IfStatement) + + IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): + expression (e), ok (t), ko (f) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return ifToken; } + + virtual SourceLocation lastSourceLocation() const + { + if (ko) + return ko->lastSourceLocation(); + + return ok->lastSourceLocation(); + } + +// attributes + ExpressionNode *expression; + Statement *ok; + Statement *ko; + SourceLocation ifToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation elseToken; +}; + +class QML_PARSER_EXPORT DoWhileStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(DoWhileStatement) + + DoWhileStatement(Statement *stmt, ExpressionNode *e): + statement (stmt), expression (e) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return doToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + Statement *statement; + ExpressionNode *expression; + SourceLocation doToken; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT WhileStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(WhileStatement) + + WhileStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return whileToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ForStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ForStatement) + + ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + initialiser (i), condition (c), expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return forToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *initialiser; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT LocalForStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(LocalForStatement) + + LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + declarations (vlist), condition (c), expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return forToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + VariableDeclarationList *declarations; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ForEachStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ForEachStatement) + + ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): + initialiser (i), expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return forToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *initialiser; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation inToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT LocalForEachStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(LocalForEachStatement) + + LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): + declaration (v), expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return forToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + VariableDeclaration *declaration; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation inToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ContinueStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ContinueStatement) + + ContinueStatement(const QStringRef &l = QStringRef()): + label (l) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return continueToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + QStringRef label; + SourceLocation continueToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT BreakStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(BreakStatement) + + BreakStatement(const QStringRef &l): + label (l) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return breakToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + + // attributes + QStringRef label; + SourceLocation breakToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ReturnStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ReturnStatement) + + ReturnStatement(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return returnToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation returnToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT WithStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(WithStatement) + + WithStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return withToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation withToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseBlock: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseBlock) + + CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): + clauses (c), defaultClause (d), moreClauses (r) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lbraceToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbraceToken; } + +// attributes + CaseClauses *clauses; + DefaultClause *defaultClause; + CaseClauses *moreClauses; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT SwitchStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(SwitchStatement) + + SwitchStatement(ExpressionNode *e, CaseBlock *b): + expression (e), block (b) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return switchToken; } + + virtual SourceLocation lastSourceLocation() const + { return block->rbraceToken; } + +// attributes + ExpressionNode *expression; + CaseBlock *block; + SourceLocation switchToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseClause) + + CaseClause(ExpressionNode *e, StatementList *slist): + expression (e), statements (slist) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return caseToken; } + + virtual SourceLocation lastSourceLocation() const + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + ExpressionNode *expression; + StatementList *statements; + SourceLocation caseToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT CaseClauses: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseClauses) + + CaseClauses(CaseClause *c): + clause (c), next (this) + { kind = K; } + + CaseClauses(CaseClauses *previous, CaseClause *c): + clause (c) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return clause->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); } + + inline CaseClauses *finish () + { + CaseClauses *front = next; + next = 0; + return front; + } + +//attributes + CaseClause *clause; + CaseClauses *next; +}; + +class QML_PARSER_EXPORT DefaultClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(DefaultClause) + + DefaultClause(StatementList *slist): + statements (slist) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return defaultToken; } + + virtual SourceLocation lastSourceLocation() const + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + StatementList *statements; + SourceLocation defaultToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT LabelledStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(LabelledStatement) + + LabelledStatement(const QStringRef &l, Statement *stmt): + label (l), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + QStringRef label; + Statement *statement; + SourceLocation identifierToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT ThrowStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ThrowStatement) + + ThrowStatement(ExpressionNode *e): + expression (e) { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return throwToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + + // attributes + ExpressionNode *expression; + SourceLocation throwToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT Catch: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Catch) + + Catch(const QStringRef &n, Block *stmt): + name (n), statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return catchToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + QStringRef name; + Block *statement; + SourceLocation catchToken; + SourceLocation lparenToken; + SourceLocation identifierToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT Finally: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Finally) + + Finally(Block *stmt): + statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return finallyToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement ? statement->lastSourceLocation() : finallyToken; } + +// attributes + Block *statement; + SourceLocation finallyToken; +}; + +class QML_PARSER_EXPORT TryStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(TryStatement) + + TryStatement(Statement *stmt, Catch *c, Finally *f): + statement (stmt), catchExpression (c), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Finally *f): + statement (stmt), catchExpression (0), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Catch *c): + statement (stmt), catchExpression (c), finallyExpression (0) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return tryToken; } + + virtual SourceLocation lastSourceLocation() const + { + if (finallyExpression) + return finallyExpression->statement->rbraceToken; + else if (catchExpression) + return catchExpression->statement->rbraceToken; + + return statement->lastSourceLocation(); + } + +// attributes + Statement *statement; + Catch *catchExpression; + Finally *finallyExpression; + SourceLocation tryToken; +}; + +class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionExpression) + + FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b): + name (n), formals (f), body (b) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return functionToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbraceToken; } + +// attributes + QStringRef name; + FormalParameterList *formals; + FunctionBody *body; + SourceLocation functionToken; + SourceLocation identifierToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionDeclaration) + + FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b): + FunctionExpression(n, f, b) + { kind = K; } + + virtual void accept0(Visitor *visitor); +}; + +class QML_PARSER_EXPORT FormalParameterList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(FormalParameterList) + + FormalParameterList(const QStringRef &n): + name (n), next (this) + { kind = K; } + + FormalParameterList(FormalParameterList *previous, const QStringRef &n): + name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : identifierToken; } + + inline FormalParameterList *finish () + { + FormalParameterList *front = next; + next = 0; + return front; + } + +// attributes + QStringRef name; + FormalParameterList *next; + SourceLocation commaToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT SourceElement: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(SourceElement) + + inline SourceElement() + { kind = K; } +}; + +class QML_PARSER_EXPORT SourceElements: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(SourceElements) + + SourceElements(SourceElement *elt): + element (elt), next (this) + { kind = K; } + + SourceElements(SourceElements *previous, SourceElement *elt): + element (elt) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return element->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : element->lastSourceLocation(); } + + inline SourceElements *finish () + { + SourceElements *front = next; + next = 0; + return front; + } + +// attributes + SourceElement *element; + SourceElements *next; +}; + +class QML_PARSER_EXPORT FunctionBody: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionBody) + + FunctionBody(SourceElements *elts): + elements (elts) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return elements ? elements->firstSourceLocation() : SourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return elements ? elements->lastSourceLocation() : SourceLocation(); } + +// attributes + SourceElements *elements; +}; + +class QML_PARSER_EXPORT Program: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Program) + + Program(SourceElements *elts): + elements (elts) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return elements ? elements->firstSourceLocation() : SourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return elements ? elements->lastSourceLocation() : SourceLocation(); } + +// attributes + SourceElements *elements; +}; + +class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionSourceElement) + + FunctionSourceElement(FunctionDeclaration *f): + declaration (f) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return declaration->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return declaration->lastSourceLocation(); } + +// attributes + FunctionDeclaration *declaration; +}; + +class QML_PARSER_EXPORT StatementSourceElement: public SourceElement +{ +public: + QQMLJS_DECLARE_AST_NODE(StatementSourceElement) + + StatementSourceElement(Statement *stmt): + statement (stmt) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return statement->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + +// attributes + Statement *statement; +}; + +class QML_PARSER_EXPORT DebuggerStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(DebuggerStatement) + + DebuggerStatement() + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return debuggerToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + SourceLocation debuggerToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiQualifiedId: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiQualifiedId) + + UiQualifiedId(const QStringRef &name) + : next(this), name(name) + { kind = K; } + + UiQualifiedId(UiQualifiedId *previous, const QStringRef &name) + : name(name) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiQualifiedId *finish() + { + UiQualifiedId *head = next; + next = 0; + return head; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : identifierToken; } + +// attributes + UiQualifiedId *next; + QStringRef name; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT UiImport: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiImport) + + UiImport(const QStringRef &fileName) + : fileName(fileName), importUri(0) + { kind = K; } + + UiImport(UiQualifiedId *uri) + : importUri(uri) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return importToken; } + + virtual SourceLocation lastSourceLocation() const + { return semicolonToken; } + +// attributes + QStringRef fileName; + UiQualifiedId *importUri; + QStringRef importId; + SourceLocation importToken; + SourceLocation fileNameToken; + SourceLocation versionToken; + SourceLocation asToken; + SourceLocation importIdToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiImportList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiImportList) + + UiImportList(UiImport *import) + : import(import), + next(this) + { kind = K; } + + UiImportList(UiImportList *previous, UiImport *import) + : import(import) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiImportList *finish() + { + UiImportList *head = next; + next = 0; + return head; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return import->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : import->lastSourceLocation(); } + +// attributes + UiImport *import; + UiImportList *next; +}; + +class QML_PARSER_EXPORT UiObjectMember: public Node +{ +public: + virtual SourceLocation firstSourceLocation() const = 0; + virtual SourceLocation lastSourceLocation() const = 0; + + virtual UiObjectMember *uiObjectMemberCast(); +}; + +class QML_PARSER_EXPORT UiObjectMemberList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectMemberList) + + UiObjectMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return member->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } + + UiObjectMemberList *finish() + { + UiObjectMemberList *head = next; + next = 0; + return head; + } + +// attributes + UiObjectMemberList *next; + UiObjectMember *member; +}; + +class QML_PARSER_EXPORT UiProgram: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiProgram) + + UiProgram(UiImportList *imports, UiObjectMemberList *members) + : imports(imports), members(members) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { + if (imports) + return imports->firstSourceLocation(); + else if (members) + return members->firstSourceLocation(); + return SourceLocation(); + } + + virtual SourceLocation lastSourceLocation() const + { + if (members) + return members->lastSourceLocation(); + else if (imports) + return imports->lastSourceLocation(); + return SourceLocation(); + } + +// attributes + UiImportList *imports; + UiObjectMemberList *members; +}; + +class QML_PARSER_EXPORT UiArrayMemberList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiArrayMemberList) + + UiArrayMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return member->firstSourceLocation(); } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } + + UiArrayMemberList *finish() + { + UiArrayMemberList *head = next; + next = 0; + return head; + } + +// attributes + UiArrayMemberList *next; + UiObjectMember *member; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT UiObjectInitializer: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectInitializer) + + UiObjectInitializer(UiObjectMemberList *members) + : members(members) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return lbraceToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbraceToken; } + +// attributes + SourceLocation lbraceToken; + UiObjectMemberList *members; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT UiParameterList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiParameterList) + + UiParameterList(const QStringRef &t, const QStringRef &n): + type (t), name (n), next (this) + { kind = K; } + + UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): + type (t), name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual void accept0(Visitor *); + + virtual SourceLocation firstSourceLocation() const + { return propertyTypeToken; } + + virtual SourceLocation lastSourceLocation() const + { return next ? next->lastSourceLocation() : identifierToken; } + + inline UiParameterList *finish () + { + UiParameterList *front = next; + next = 0; + return front; + } + +// attributes + QStringRef type; + QStringRef name; + UiParameterList *next; + SourceLocation commaToken; + SourceLocation propertyTypeToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiPublicMember) + + UiPublicMember(const QStringRef &memberType, + const QStringRef &name) + : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) + { kind = K; } + + UiPublicMember(const QStringRef &memberType, + const QStringRef &name, + Statement *statement) + : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { + if (defaultToken.isValid()) + return defaultToken; + else if (readonlyToken.isValid()) + return readonlyToken; + + return propertyToken; + } + + virtual SourceLocation lastSourceLocation() const + { + if (binding) + return binding->lastSourceLocation(); + if (statement) + return statement->lastSourceLocation(); + + return semicolonToken; + } + +// attributes + enum { Signal, Property } type; + QStringRef typeModifier; + QStringRef memberType; + QStringRef name; + Statement *statement; // initialized with a JS expression + UiObjectMember *binding; // initialized with a QML object or array. + bool isDefaultMember; + bool isReadonlyMember; + UiParameterList *parameters; + SourceLocation defaultToken; + SourceLocation readonlyToken; + SourceLocation propertyToken; + SourceLocation typeModifierToken; + SourceLocation typeToken; + SourceLocation identifierToken; + SourceLocation colonToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectDefinition) + + UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) + { kind = K; } + + virtual void accept0(Visitor *visitor); + + virtual SourceLocation firstSourceLocation() const + { return qualifiedTypeNameId->identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return initializer->rbraceToken; } + +// attributes + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; +}; + +class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiSourceElement) + + UiSourceElement(Node *sourceElement) + : sourceElement(sourceElement) + { kind = K; } + + virtual SourceLocation firstSourceLocation() const + { + if (FunctionDeclaration *funDecl = cast(sourceElement)) + return funDecl->firstSourceLocation(); + else if (VariableStatement *varStmt = cast(sourceElement)) + return varStmt->firstSourceLocation(); + + return SourceLocation(); + } + + virtual SourceLocation lastSourceLocation() const + { + if (FunctionDeclaration *funDecl = cast(sourceElement)) + return funDecl->lastSourceLocation(); + else if (VariableStatement *varStmt = cast(sourceElement)) + return varStmt->lastSourceLocation(); + + return SourceLocation(); + } + + virtual void accept0(Visitor *visitor); + + +// attributes + Node *sourceElement; +}; + +class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectBinding) + + UiObjectBinding(UiQualifiedId *qualifiedId, + UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedId(qualifiedId), + qualifiedTypeNameId(qualifiedTypeNameId), + initializer(initializer), + hasOnToken(false) + { kind = K; } + + virtual SourceLocation firstSourceLocation() const + { + if (hasOnToken && qualifiedTypeNameId) + return qualifiedTypeNameId->identifierToken; + + return qualifiedId->identifierToken; + } + + virtual SourceLocation lastSourceLocation() const + { return initializer->rbraceToken; } + + virtual void accept0(Visitor *visitor); + + +// attributes + UiQualifiedId *qualifiedId; + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; + SourceLocation colonToken; + bool hasOnToken; +}; + +class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiScriptBinding) + + UiScriptBinding(UiQualifiedId *qualifiedId, + Statement *statement) + : qualifiedId(qualifiedId), + statement(statement) + { kind = K; } + + virtual SourceLocation firstSourceLocation() const + { return qualifiedId->identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return statement->lastSourceLocation(); } + + virtual void accept0(Visitor *visitor); + +// attributes + UiQualifiedId *qualifiedId; + Statement *statement; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiArrayBinding) + + UiArrayBinding(UiQualifiedId *qualifiedId, + UiArrayMemberList *members) + : qualifiedId(qualifiedId), + members(members) + { kind = K; } + + virtual SourceLocation firstSourceLocation() const + { return qualifiedId->identifierToken; } + + virtual SourceLocation lastSourceLocation() const + { return rbracketToken; } + + virtual void accept0(Visitor *visitor); + +// attributes + UiQualifiedId *qualifiedId; + UiArrayMemberList *members; + SourceLocation colonToken; + SourceLocation lbracketToken; + SourceLocation rbracketToken; +}; + +} } // namespace AST + + + +QT_QML_END_NAMESPACE + +#endif diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h new file mode 100644 index 0000000000..fe5572c4b2 --- /dev/null +++ b/src/qml/parser/qqmljsastfwd_p.h @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSAST_FWD_P_H +#define QQMLJSAST_FWD_P_H + +#include "qqmljsglobal_p.h" + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { namespace AST { + +class SourceLocation +{ +public: + SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) + : offset(offset), length(length), + startLine(line), startColumn(column) + { } + + bool isValid() const { return length != 0; } + + quint32 begin() const { return offset; } + quint32 end() const { return offset + length; } + +// attributes + // ### encode + quint32 offset; + quint32 length; + quint32 startLine; + quint32 startColumn; +}; + +class Visitor; +class Node; +class ExpressionNode; +class Statement; +class ThisExpression; +class IdentifierExpression; +class NullExpression; +class TrueLiteral; +class FalseLiteral; +class NumericLiteral; +class StringLiteral; +class RegExpLiteral; +class ArrayLiteral; +class ObjectLiteral; +class ElementList; +class Elision; +class PropertyAssignmentList; +class PropertyGetterSetter; +class PropertyNameAndValue; +class PropertyName; +class IdentifierPropertyName; +class StringLiteralPropertyName; +class NumericLiteralPropertyName; +class ArrayMemberExpression; +class FieldMemberExpression; +class NewMemberExpression; +class NewExpression; +class CallExpression; +class ArgumentList; +class PostIncrementExpression; +class PostDecrementExpression; +class DeleteExpression; +class VoidExpression; +class TypeOfExpression; +class PreIncrementExpression; +class PreDecrementExpression; +class UnaryPlusExpression; +class UnaryMinusExpression; +class TildeExpression; +class NotExpression; +class BinaryExpression; +class ConditionalExpression; +class Expression; // ### rename +class Block; +class StatementList; +class VariableStatement; +class VariableDeclarationList; +class VariableDeclaration; +class EmptyStatement; +class ExpressionStatement; +class IfStatement; +class DoWhileStatement; +class WhileStatement; +class ForStatement; +class LocalForStatement; +class ForEachStatement; +class LocalForEachStatement; +class ContinueStatement; +class BreakStatement; +class ReturnStatement; +class WithStatement; +class SwitchStatement; +class CaseBlock; +class CaseClauses; +class CaseClause; +class DefaultClause; +class LabelledStatement; +class ThrowStatement; +class TryStatement; +class Catch; +class Finally; +class FunctionDeclaration; +class FunctionExpression; +class FormalParameterList; +class FunctionBody; +class Program; +class SourceElements; +class SourceElement; +class FunctionSourceElement; +class StatementSourceElement; +class DebuggerStatement; +class NestedExpression; + +// ui elements +class UiProgram; +class UiImportList; +class UiImport; +class UiPublicMember; +class UiParameterList; +class UiObjectDefinition; +class UiObjectInitializer; +class UiObjectBinding; +class UiScriptBinding; +class UiSourceElement; +class UiArrayBinding; +class UiObjectMember; +class UiObjectMemberList; +class UiArrayMemberList; +class UiQualifiedId; + +} } // namespace AST + +QT_QML_END_NAMESPACE + +#endif diff --git a/src/qml/parser/qqmljsastvisitor.cpp b/src/qml/parser/qqmljsastvisitor.cpp new file mode 100644 index 0000000000..be2a082f43 --- /dev/null +++ b/src/qml/parser/qqmljsastvisitor.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljsastvisitor_p.h" + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { namespace AST { + +Visitor::Visitor() +{ +} + +Visitor::~Visitor() +{ +} + +} } // namespace QQmlJS::AST + +QT_QML_END_NAMESPACE diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h new file mode 100644 index 0000000000..ef022f617c --- /dev/null +++ b/src/qml/parser/qqmljsastvisitor_p.h @@ -0,0 +1,337 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSASTVISITOR_P_H +#define QQMLJSASTVISITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsastfwd_p.h" +#include "qqmljsglobal_p.h" + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { namespace AST { + +class QML_PARSER_EXPORT Visitor +{ +public: + Visitor(); + virtual ~Visitor(); + + virtual bool preVisit(Node *) { return true; } + virtual void postVisit(Node *) {} + + // Ui + virtual bool visit(UiProgram *) { return true; } + virtual bool visit(UiImportList *) { return true; } + virtual bool visit(UiImport *) { return true; } + virtual bool visit(UiPublicMember *) { return true; } + virtual bool visit(UiSourceElement *) { return true; } + virtual bool visit(UiObjectDefinition *) { return true; } + virtual bool visit(UiObjectInitializer *) { return true; } + virtual bool visit(UiObjectBinding *) { return true; } + virtual bool visit(UiScriptBinding *) { return true; } + virtual bool visit(UiArrayBinding *) { return true; } + virtual bool visit(UiParameterList *) { return true; } + virtual bool visit(UiObjectMemberList *) { return true; } + virtual bool visit(UiArrayMemberList *) { return true; } + virtual bool visit(UiQualifiedId *) { return true; } + + virtual void endVisit(UiProgram *) {} + virtual void endVisit(UiImportList *) {} + virtual void endVisit(UiImport *) {} + virtual void endVisit(UiPublicMember *) {} + virtual void endVisit(UiSourceElement *) {} + virtual void endVisit(UiObjectDefinition *) {} + virtual void endVisit(UiObjectInitializer *) {} + virtual void endVisit(UiObjectBinding *) {} + virtual void endVisit(UiScriptBinding *) {} + virtual void endVisit(UiArrayBinding *) {} + virtual void endVisit(UiParameterList *) {} + virtual void endVisit(UiObjectMemberList *) {} + virtual void endVisit(UiArrayMemberList *) {} + virtual void endVisit(UiQualifiedId *) {} + + // QQmlJS + virtual bool visit(ThisExpression *) { return true; } + virtual void endVisit(ThisExpression *) {} + + virtual bool visit(IdentifierExpression *) { return true; } + virtual void endVisit(IdentifierExpression *) {} + + virtual bool visit(NullExpression *) { return true; } + virtual void endVisit(NullExpression *) {} + + virtual bool visit(TrueLiteral *) { return true; } + virtual void endVisit(TrueLiteral *) {} + + virtual bool visit(FalseLiteral *) { return true; } + virtual void endVisit(FalseLiteral *) {} + + virtual bool visit(StringLiteral *) { return true; } + virtual void endVisit(StringLiteral *) {} + + virtual bool visit(NumericLiteral *) { return true; } + virtual void endVisit(NumericLiteral *) {} + + virtual bool visit(RegExpLiteral *) { return true; } + virtual void endVisit(RegExpLiteral *) {} + + virtual bool visit(ArrayLiteral *) { return true; } + virtual void endVisit(ArrayLiteral *) {} + + virtual bool visit(ObjectLiteral *) { return true; } + virtual void endVisit(ObjectLiteral *) {} + + virtual bool visit(ElementList *) { return true; } + virtual void endVisit(ElementList *) {} + + virtual bool visit(Elision *) { return true; } + virtual void endVisit(Elision *) {} + + virtual bool visit(PropertyAssignmentList *) { return true; } + 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 void endVisit(NestedExpression *) {} + + virtual bool visit(IdentifierPropertyName *) { return true; } + virtual void endVisit(IdentifierPropertyName *) {} + + virtual bool visit(StringLiteralPropertyName *) { return true; } + virtual void endVisit(StringLiteralPropertyName *) {} + + virtual bool visit(NumericLiteralPropertyName *) { return true; } + virtual void endVisit(NumericLiteralPropertyName *) {} + + virtual bool visit(ArrayMemberExpression *) { return true; } + virtual void endVisit(ArrayMemberExpression *) {} + + virtual bool visit(FieldMemberExpression *) { return true; } + virtual void endVisit(FieldMemberExpression *) {} + + virtual bool visit(NewMemberExpression *) { return true; } + virtual void endVisit(NewMemberExpression *) {} + + virtual bool visit(NewExpression *) { return true; } + virtual void endVisit(NewExpression *) {} + + virtual bool visit(CallExpression *) { return true; } + virtual void endVisit(CallExpression *) {} + + virtual bool visit(ArgumentList *) { return true; } + virtual void endVisit(ArgumentList *) {} + + virtual bool visit(PostIncrementExpression *) { return true; } + virtual void endVisit(PostIncrementExpression *) {} + + virtual bool visit(PostDecrementExpression *) { return true; } + virtual void endVisit(PostDecrementExpression *) {} + + virtual bool visit(DeleteExpression *) { return true; } + virtual void endVisit(DeleteExpression *) {} + + virtual bool visit(VoidExpression *) { return true; } + virtual void endVisit(VoidExpression *) {} + + virtual bool visit(TypeOfExpression *) { return true; } + virtual void endVisit(TypeOfExpression *) {} + + virtual bool visit(PreIncrementExpression *) { return true; } + virtual void endVisit(PreIncrementExpression *) {} + + virtual bool visit(PreDecrementExpression *) { return true; } + virtual void endVisit(PreDecrementExpression *) {} + + virtual bool visit(UnaryPlusExpression *) { return true; } + virtual void endVisit(UnaryPlusExpression *) {} + + virtual bool visit(UnaryMinusExpression *) { return true; } + virtual void endVisit(UnaryMinusExpression *) {} + + virtual bool visit(TildeExpression *) { return true; } + virtual void endVisit(TildeExpression *) {} + + virtual bool visit(NotExpression *) { return true; } + virtual void endVisit(NotExpression *) {} + + virtual bool visit(BinaryExpression *) { return true; } + virtual void endVisit(BinaryExpression *) {} + + virtual bool visit(ConditionalExpression *) { return true; } + virtual void endVisit(ConditionalExpression *) {} + + virtual bool visit(Expression *) { return true; } + virtual void endVisit(Expression *) {} + + virtual bool visit(Block *) { return true; } + virtual void endVisit(Block *) {} + + virtual bool visit(StatementList *) { return true; } + virtual void endVisit(StatementList *) {} + + virtual bool visit(VariableStatement *) { return true; } + virtual void endVisit(VariableStatement *) {} + + virtual bool visit(VariableDeclarationList *) { return true; } + virtual void endVisit(VariableDeclarationList *) {} + + virtual bool visit(VariableDeclaration *) { return true; } + virtual void endVisit(VariableDeclaration *) {} + + virtual bool visit(EmptyStatement *) { return true; } + virtual void endVisit(EmptyStatement *) {} + + virtual bool visit(ExpressionStatement *) { return true; } + virtual void endVisit(ExpressionStatement *) {} + + virtual bool visit(IfStatement *) { return true; } + virtual void endVisit(IfStatement *) {} + + virtual bool visit(DoWhileStatement *) { return true; } + virtual void endVisit(DoWhileStatement *) {} + + virtual bool visit(WhileStatement *) { return true; } + virtual void endVisit(WhileStatement *) {} + + virtual bool visit(ForStatement *) { return true; } + virtual void endVisit(ForStatement *) {} + + virtual bool visit(LocalForStatement *) { return true; } + virtual void endVisit(LocalForStatement *) {} + + virtual bool visit(ForEachStatement *) { return true; } + virtual void endVisit(ForEachStatement *) {} + + virtual bool visit(LocalForEachStatement *) { return true; } + virtual void endVisit(LocalForEachStatement *) {} + + virtual bool visit(ContinueStatement *) { return true; } + virtual void endVisit(ContinueStatement *) {} + + virtual bool visit(BreakStatement *) { return true; } + virtual void endVisit(BreakStatement *) {} + + virtual bool visit(ReturnStatement *) { return true; } + virtual void endVisit(ReturnStatement *) {} + + virtual bool visit(WithStatement *) { return true; } + virtual void endVisit(WithStatement *) {} + + virtual bool visit(SwitchStatement *) { return true; } + virtual void endVisit(SwitchStatement *) {} + + virtual bool visit(CaseBlock *) { return true; } + virtual void endVisit(CaseBlock *) {} + + virtual bool visit(CaseClauses *) { return true; } + virtual void endVisit(CaseClauses *) {} + + virtual bool visit(CaseClause *) { return true; } + virtual void endVisit(CaseClause *) {} + + virtual bool visit(DefaultClause *) { return true; } + virtual void endVisit(DefaultClause *) {} + + virtual bool visit(LabelledStatement *) { return true; } + virtual void endVisit(LabelledStatement *) {} + + virtual bool visit(ThrowStatement *) { return true; } + virtual void endVisit(ThrowStatement *) {} + + virtual bool visit(TryStatement *) { return true; } + virtual void endVisit(TryStatement *) {} + + virtual bool visit(Catch *) { return true; } + virtual void endVisit(Catch *) {} + + virtual bool visit(Finally *) { return true; } + virtual void endVisit(Finally *) {} + + virtual bool visit(FunctionDeclaration *) { return true; } + virtual void endVisit(FunctionDeclaration *) {} + + virtual bool visit(FunctionExpression *) { return true; } + virtual void endVisit(FunctionExpression *) {} + + virtual bool visit(FormalParameterList *) { return true; } + virtual void endVisit(FormalParameterList *) {} + + virtual bool visit(FunctionBody *) { return true; } + virtual void endVisit(FunctionBody *) {} + + virtual bool visit(Program *) { return true; } + virtual void endVisit(Program *) {} + + virtual bool visit(SourceElements *) { return true; } + virtual void endVisit(SourceElements *) {} + + virtual bool visit(FunctionSourceElement *) { return true; } + virtual void endVisit(FunctionSourceElement *) {} + + virtual bool visit(StatementSourceElement *) { return true; } + virtual void endVisit(StatementSourceElement *) {} + + virtual bool visit(DebuggerStatement *) { return true; } + virtual void endVisit(DebuggerStatement *) {} +}; + +} } // namespace AST + +QT_QML_END_NAMESPACE + +#endif // QQMLJSASTVISITOR_P_H diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp new file mode 100644 index 0000000000..7dc3b6f6cb --- /dev/null +++ b/src/qml/parser/qqmljsengine_p.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljsengine_p.h" +#include "qqmljsglobal_p.h" + +#include +#include +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +static inline int toDigit(char c) +{ + if ((c >= '0') && (c <= '9')) + return c - '0'; + else if ((c >= 'a') && (c <= 'z')) + return 10 + c - 'a'; + else if ((c >= 'A') && (c <= 'Z')) + return 10 + c - 'A'; + return -1; +} + +double integerFromString(const char *buf, int size, int radix) +{ + if (size == 0) + return qSNaN(); + + double sign = 1.0; + int i = 0; + if (buf[0] == '+') { + ++i; + } else if (buf[0] == '-') { + sign = -1.0; + ++i; + } + + if (((size-i) >= 2) && (buf[i] == '0')) { + if (((buf[i+1] == 'x') || (buf[i+1] == 'X')) + && (radix < 34)) { + if ((radix != 0) && (radix != 16)) + return 0; + radix = 16; + i += 2; + } else { + if (radix == 0) { + radix = 8; + ++i; + } + } + } else if (radix == 0) { + radix = 10; + } + + int j = i; + for ( ; i < size; ++i) { + int d = toDigit(buf[i]); + if ((d == -1) || (d >= radix)) + break; + } + double result; + if (j == i) { + if (!qstrcmp(buf, "Infinity")) + result = qInf(); + else + result = qSNaN(); + } else { + result = 0; + double multiplier = 1; + for (--i ; i >= j; --i, multiplier *= radix) + result += toDigit(buf[i]) * multiplier; + } + result *= sign; + return result; +} + +double integerFromString(const QString &str, int radix) +{ + QByteArray ba = str.trimmed().toLatin1(); + return integerFromString(ba.constData(), ba.size(), radix); +} + + +Engine::Engine() + : _lexer(0) +{ } + +Engine::~Engine() +{ } + +void Engine::setCode(const QString &code) +{ _code = code; } + +void Engine::addComment(int pos, int len, int line, int col) +{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); } + +QList Engine::comments() const +{ return _comments; } + +Lexer *Engine::lexer() const +{ return _lexer; } + +void Engine::setLexer(Lexer *lexer) +{ _lexer = lexer; } + +MemoryPool *Engine::pool() +{ return &_pool; } + +QStringRef Engine::newStringRef(const QString &text) +{ + const int pos = _extraCode.length(); + _extraCode += text; + return _extraCode.midRef(pos, text.length()); +} + +QStringRef Engine::newStringRef(const QChar *chars, int size) +{ return newStringRef(QString(chars, size)); } + +} // end of namespace QQmlJS + +QT_QML_END_NAMESPACE diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h new file mode 100644 index 0000000000..4f58e7f8ea --- /dev/null +++ b/src/qml/parser/qqmljsengine_p.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSENGINE_P_H +#define QQMLJSENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsglobal_p.h" +#include "qqmljsastfwd_p.h" +#include "qqmljsmemorypool_p.h" + +#include +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Lexer; +class MemoryPool; + +class QML_PARSER_EXPORT DiagnosticMessage +{ +public: + enum Kind { Warning, Error }; + + DiagnosticMessage() + : kind(Error) {} + + DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) + : kind(kind), loc(loc), message(message) {} + + bool isWarning() const + { return kind == Warning; } + + bool isError() const + { return kind == Error; } + + Kind kind; + AST::SourceLocation loc; + QString message; +}; + +class QML_PARSER_EXPORT Engine +{ + Lexer *_lexer; + MemoryPool _pool; + QList _comments; + QString _extraCode; + QString _code; + +public: + Engine(); + ~Engine(); + + void setCode(const QString &code); + + void addComment(int pos, int len, int line, int col); + QList comments() const; + + Lexer *lexer() const; + void setLexer(Lexer *lexer); + + MemoryPool *pool(); + + inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } + + QStringRef newStringRef(const QString &s); + QStringRef newStringRef(const QChar *chars, int size); +}; + +double integerFromString(const char *buf, int size, int radix); + +} // end of namespace QQmlJS + +QT_QML_END_NAMESPACE + +#endif // QQMLJSENGINE_P_H diff --git a/src/qml/parser/qqmljsglobal_p.h b/src/qml/parser/qqmljsglobal_p.h new file mode 100644 index 0000000000..c53e12ea56 --- /dev/null +++ b/src/qml/parser/qqmljsglobal_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QQMLJSGLOBAL_P_H +#define QQMLJSGLOBAL_P_H + +#include + +#ifdef QT_CREATOR +# define QT_QML_BEGIN_NAMESPACE +# define QT_QML_END_NAMESPACE + +# ifdef QDECLARATIVEJS_BUILD_DIR +# define QML_PARSER_EXPORT Q_DECL_EXPORT +# elif QML_BUILD_STATIC_LIB +# define QML_PARSER_EXPORT +# else +# define QML_PARSER_EXPORT Q_DECL_IMPORT +# endif // QQMLJS_BUILD_DIR + +#else // !QT_CREATOR +# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE +# define QT_QML_END_NAMESPACE QT_END_NAMESPACE +# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) + // QmlDevTools is a static library +# define QML_PARSER_EXPORT +# elif defined(QT_BUILD_QML_LIB) +# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT +# else +# define QML_PARSER_EXPORT +# endif +#endif // QT_CREATOR + +#endif // QQMLJSGLOBAL_P_H diff --git a/src/qml/parser/qqmljsgrammar.cpp b/src/qml/parser/qqmljsgrammar.cpp new file mode 100644 index 0000000000..4a5672a796 --- /dev/null +++ b/src/qml/parser/qqmljsgrammar.cpp @@ -0,0 +1,1068 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was generated by qlalr - DO NOT EDIT! +#include "qqmljsgrammar_p.h" + +QT_BEGIN_NAMESPACE + +const char *const QQmlJSGrammar::spell [] = { + "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue", + "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", + "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", + "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=", + "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=", + "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", + ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch", + "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", + "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", 0, + "public", "import", "as", "on", "get", "set", 0, 0, 0, 0, + 0, 0, 0, 0, 0}; + +const short QQmlJSGrammar::lhs [] = { + 105, 105, 105, 105, 105, 105, 106, 112, 112, 115, + 115, 117, 116, 116, 116, 116, 116, 116, 116, 116, + 119, 114, 113, 122, 122, 123, 123, 124, 124, 121, + 110, 110, 110, 110, 126, 126, 126, 126, 126, 126, + 126, 110, 134, 134, 134, 135, 135, 136, 136, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, + 120, 120, 120, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 125, 141, 141, 141, 141, 140, 140, 145, 145, + 145, 143, 143, 146, 146, 146, 146, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 150, 150, + 118, 118, 118, 118, 118, 153, 153, 154, 154, 154, + 154, 152, 152, 155, 155, 156, 156, 157, 157, 157, + 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 159, 159, 159, 159, 160, 160, 160, 161, 161, 161, + 161, 162, 162, 162, 162, 162, 162, 162, 163, 163, + 163, 163, 163, 163, 164, 164, 164, 164, 164, 165, + 165, 165, 165, 165, 166, 166, 167, 167, 168, 168, + 169, 169, 170, 170, 171, 171, 172, 172, 173, 173, + 174, 174, 175, 175, 176, 176, 177, 177, 144, 144, + 178, 178, 179, 179, 179, 179, 179, 179, 179, 179, + 179, 179, 179, 179, 108, 108, 180, 180, 181, 181, + 182, 182, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 127, 191, 191, + 190, 190, 138, 138, 192, 192, 193, 193, 195, 195, + 194, 196, 199, 197, 197, 200, 198, 198, 128, 129, + 129, 130, 130, 183, 183, 183, 183, 183, 183, 183, + 183, 184, 184, 184, 184, 185, 185, 185, 185, 186, + 186, 131, 132, 201, 201, 204, 204, 202, 202, 205, + 203, 187, 188, 188, 133, 133, 133, 206, 207, 189, + 189, 208, 137, 151, 151, 209, 209, 148, 148, 147, + 147, 210, 111, 111, 211, 211, 109, 109, 142, 142, + 212}; + +const short QQmlJSGrammar::rhs [] = { + 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 2, 1, 2, 2, 3, 3, 5, 5, 4, 4, + 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, + 1, 5, 4, 4, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 1, 1, 0, 1, 2, 4, 6, + 6, 3, 3, 7, 7, 4, 4, 5, 5, 5, + 6, 6, 10, 6, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 3, 3, 4, 5, 3, 4, + 3, 1, 1, 2, 3, 4, 1, 2, 3, 7, + 8, 1, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 3, 5, 1, 2, 4, 4, 4, + 3, 0, 1, 1, 3, 1, 1, 1, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, + 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, + 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, + 3, 3, 3, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 5, 1, 5, 1, 3, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 0, 1, 1, 3, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, + 0, 1, 3, 3, 1, 1, 1, 3, 1, 3, + 2, 2, 2, 0, 1, 2, 0, 1, 1, 2, + 2, 7, 5, 7, 7, 7, 5, 9, 10, 7, + 8, 2, 2, 3, 3, 2, 2, 3, 3, 3, + 3, 5, 5, 3, 5, 1, 2, 0, 1, 4, + 3, 3, 3, 3, 3, 3, 4, 5, 2, 2, + 2, 1, 8, 8, 7, 1, 3, 0, 1, 0, + 1, 1, 1, 1, 1, 2, 1, 1, 0, 1, + 2}; + +const short QQmlJSGrammar::action_default [] = { + 0, 0, 22, 0, 0, 0, 22, 0, 178, 245, + 209, 217, 213, 157, 229, 205, 3, 142, 75, 158, + 221, 225, 146, 175, 156, 161, 141, 195, 182, 0, + 82, 83, 78, 0, 72, 67, 349, 0, 0, 0, + 0, 80, 0, 0, 76, 79, 71, 0, 0, 68, + 70, 73, 69, 81, 74, 0, 77, 0, 0, 171, + 0, 0, 158, 177, 160, 159, 0, 0, 0, 173, + 174, 172, 176, 0, 206, 0, 0, 0, 0, 196, + 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, + 180, 181, 179, 184, 188, 187, 185, 183, 198, 197, + 199, 0, 214, 0, 210, 0, 0, 152, 139, 151, + 140, 108, 109, 110, 135, 111, 136, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 137, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 138, 0, 0, 150, 246, 153, 0, 154, 0, + 155, 149, 0, 242, 235, 233, 240, 241, 239, 238, + 244, 237, 236, 234, 243, 230, 0, 218, 0, 0, + 222, 0, 0, 226, 0, 0, 152, 144, 0, 143, + 0, 148, 162, 0, 338, 338, 339, 0, 336, 0, + 337, 0, 340, 253, 260, 259, 267, 255, 0, 256, + 0, 341, 0, 348, 257, 258, 75, 263, 261, 345, + 342, 347, 264, 0, 275, 0, 0, 0, 0, 332, + 0, 349, 247, 289, 0, 0, 0, 276, 0, 0, + 265, 266, 0, 254, 262, 290, 291, 0, 338, 0, + 0, 340, 0, 333, 334, 0, 322, 346, 0, 306, + 307, 308, 309, 0, 302, 303, 304, 305, 330, 331, + 0, 0, 0, 0, 0, 294, 295, 296, 251, 249, + 211, 219, 215, 231, 207, 252, 0, 158, 223, 227, + 200, 189, 0, 0, 208, 0, 0, 0, 0, 201, + 0, 0, 0, 0, 0, 193, 191, 194, 192, 190, + 203, 202, 204, 0, 216, 0, 212, 0, 250, 158, + 0, 232, 247, 248, 0, 247, 0, 0, 298, 0, + 0, 0, 300, 0, 220, 0, 0, 224, 0, 0, + 228, 287, 0, 279, 288, 282, 0, 286, 0, 247, + 280, 0, 247, 0, 0, 299, 0, 0, 0, 301, + 0, 0, 0, 293, 0, 292, 75, 102, 350, 0, + 0, 107, 269, 272, 0, 108, 275, 111, 136, 113, + 114, 78, 118, 119, 72, 120, 123, 76, 79, 247, + 73, 81, 126, 74, 128, 77, 130, 131, 276, 133, + 134, 138, 0, 104, 103, 106, 90, 105, 89, 0, + 99, 270, 268, 0, 0, 0, 340, 0, 100, 146, + 147, 152, 0, 145, 0, 310, 311, 0, 338, 0, + 0, 340, 0, 101, 0, 0, 0, 313, 318, 316, + 319, 0, 0, 317, 318, 0, 314, 0, 315, 271, + 321, 0, 271, 320, 0, 323, 324, 0, 271, 325, + 326, 0, 0, 327, 0, 0, 0, 328, 329, 164, + 163, 0, 0, 0, 297, 0, 0, 0, 312, 284, + 277, 0, 285, 281, 0, 283, 273, 0, 274, 278, + 0, 0, 340, 0, 335, 93, 0, 0, 97, 84, + 0, 86, 95, 0, 87, 96, 98, 88, 94, 85, + 0, 91, 168, 166, 170, 167, 165, 169, 343, 6, + 344, 4, 2, 65, 92, 0, 0, 68, 70, 69, + 31, 5, 0, 66, 0, 45, 44, 43, 0, 0, + 58, 0, 59, 35, 36, 37, 38, 40, 41, 62, + 39, 0, 45, 0, 0, 0, 0, 0, 54, 0, + 55, 0, 0, 26, 0, 0, 63, 27, 0, 30, + 28, 24, 0, 29, 25, 0, 56, 0, 57, 146, + 0, 60, 64, 0, 0, 0, 0, 61, 0, 52, + 46, 53, 47, 0, 0, 0, 0, 49, 0, 50, + 51, 48, 0, 0, 146, 271, 0, 0, 42, 75, + 108, 275, 111, 136, 113, 114, 78, 118, 119, 120, + 123, 76, 79, 247, 81, 126, 74, 128, 77, 130, + 131, 276, 133, 134, 138, 0, 32, 33, 0, 34, + 8, 0, 10, 0, 9, 0, 1, 21, 12, 0, + 13, 0, 14, 0, 19, 20, 0, 15, 16, 0, + 17, 18, 11, 23, 7, 351}; + +const short QQmlJSGrammar::goto_default [] = { + 7, 636, 211, 198, 209, 521, 509, 635, 654, 508, + 634, 632, 637, 22, 633, 18, 520, 562, 552, 559, + 554, 539, 193, 197, 199, 204, 234, 212, 231, 543, + 583, 582, 203, 233, 26, 487, 486, 359, 358, 9, + 357, 360, 202, 480, 361, 109, 17, 147, 24, 13, + 146, 19, 25, 59, 23, 8, 28, 27, 280, 15, + 274, 10, 270, 12, 272, 11, 271, 20, 278, 21, + 279, 14, 273, 269, 310, 414, 275, 276, 205, 195, + 194, 208, 207, 230, 196, 364, 363, 232, 471, 470, + 332, 333, 473, 335, 472, 334, 427, 431, 434, 430, + 429, 449, 450, 200, 186, 201, 210, 0}; + +const short QQmlJSGrammar::action_index [] = { + 235, 1289, 2663, 2663, 2562, 1005, 64, 90, 103, -105, + 88, 94, 79, 173, -105, 302, 69, -105, -105, 724, + 65, 135, 195, 239, -105, -105, -105, 367, 278, 1289, + -105, -105, -105, 485, -105, -105, 2360, 1772, 1289, 1289, + 1289, -105, 817, 1289, -105, -105, -105, 1289, 1289, -105, + -105, -105, -105, -105, -105, 1289, -105, 1289, 1289, -105, + 1289, 1289, 95, 207, -105, -105, 1289, 1289, 1289, -105, + -105, -105, 202, 1289, 300, 1289, 1289, 1289, 1289, 377, + 1289, 1289, 1289, 1289, 1289, 1289, 253, 1289, 1289, 1289, + 151, 147, 129, 196, 170, 199, 279, 270, 470, 470, + 387, 1289, 53, 1289, 80, 2158, 1289, 1289, -105, -105, + -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, 128, 1289, -105, -105, 74, 52, -105, 1289, + -105, -105, 1289, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, -105, -105, -105, 1289, 51, 1289, 1289, + 77, 66, 1289, -105, 2158, 1289, 1289, -105, 125, -105, + 48, -105, -105, 47, 451, 374, 83, 87, -105, 397, + -105, 62, 2663, -105, -105, -105, -105, -105, 205, -105, + 415, -105, 68, -105, -105, -105, 86, -105, -105, -105, + 2663, -105, -105, 622, -105, 576, 102, 2562, 75, 89, + 81, 2865, 1289, -105, 70, 1289, 63, -105, 92, 93, + -105, -105, 546, -105, -105, -105, -105, 91, 546, 40, + 45, 2663, 49, -105, -105, 2562, -105, -105, 106, -105, + -105, -105, -105, 121, -105, -105, -105, -105, -105, -105, + 42, 44, 1289, 114, 222, -105, -105, -105, 1481, -105, + 84, 57, 56, -105, 388, 78, 54, 682, 82, 99, + 357, 247, 546, 1289, 295, 1289, 1289, 1289, 1289, 334, + 1289, 1289, 1289, 1289, 1289, 203, 217, 244, 263, 211, + 341, 319, 351, 1289, 56, 1289, 73, 1289, -105, 724, + 1289, -105, 1289, 67, 46, 1289, 61, 2562, -105, 1289, + 136, 2562, -105, 1289, 76, 1289, 1289, 85, 59, 1289, + -105, 71, 133, 72, -105, -105, 1289, -105, 546, 1289, + -105, -53, 1289, -60, 2562, -105, 1289, 143, 2562, -105, + 1289, 132, 2562, 8, 2562, -105, 7, -105, 12, -37, + 107, -105, -105, 2562, -33, 622, 22, 555, 115, 1289, + 2562, 23, -13, 502, 2259, -10, 817, 18, 6, 1387, + 2259, 0, 9, -6, 1289, -4, -23, 1289, 5, 1289, + -25, -27, 2461, -105, -105, -105, -105, -105, -105, 1289, + -105, -105, -105, -3, -1, 21, 2663, 1, -105, 218, + -105, 1289, 4, -105, 111, -105, -105, 26, 466, 16, + 38, 2663, 39, -105, 1289, 110, 37, -105, 55, -105, + 60, 116, 1289, -105, 58, 43, -105, -15, -105, 2562, + -105, 123, 2562, -105, 154, -105, -105, 96, 2562, 32, + -105, 3, 14, -105, 546, -11, 13, -105, -105, -105, + -105, 1289, 126, 2562, -105, 1289, 130, 2562, -105, 15, + -105, 301, -105, -105, 1289, -105, -105, 546, -105, -105, + -45, -12, 2663, -24, -105, -105, 204, 1578, -105, -105, + 1869, -105, -105, 1675, -105, -105, -105, -105, -105, -105, + 101, -105, -105, -105, -105, -105, -105, -105, -105, -105, + 2663, -105, -105, -105, 105, 2, 910, 206, -47, -2, + -105, -105, 246, -105, 214, -105, -105, -105, 364, 232, + -105, 1963, -105, -105, -105, -105, -105, -105, -105, -105, + -105, 191, 24, 394, 172, -18, 384, 215, -105, -30, + -105, 910, 149, -105, -16, 910, -105, -105, 1100, -105, + -105, -105, 1195, -105, -105, 225, -105, 1963, -105, 316, + -17, -105, -105, 269, 418, -5, 1963, -105, 184, -105, + 175, -105, 20, -9, 546, 182, 469, -105, 104, -105, + -105, -105, 2057, 910, 292, 2764, 1772, 10, -105, 35, + 622, 34, 525, 98, 1289, 2562, 50, 17, 536, 19, + 817, 31, 27, 1387, 28, 9, 29, 1289, 30, 11, + 1289, 41, 1289, 33, 36, 137, -105, -105, 25, -105, + -105, 910, -105, 268, -86, 910, -105, -105, 141, 546, + -105, 156, -105, 117, -105, -105, 546, -105, -105, 138, + -105, -105, -105, -105, -105, -105, + + -108, 0, 79, 128, 132, 301, 2, -108, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -47, + -108, -108, -108, -108, -108, -108, -108, -108, -108, 51, + -108, -108, -108, -3, -108, -108, 8, -23, 12, 78, + 106, -108, 69, 74, -108, -108, -108, 195, 204, -108, + -108, -108, -108, -108, -108, 188, -108, 201, 200, -108, + 127, 129, -108, -108, -108, -108, 140, 137, 133, -108, + -108, -108, -108, 146, -108, 177, 168, 170, 167, -108, + 144, 152, 166, 158, 160, 131, -108, 194, 187, 207, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, 88, -108, 112, -108, 121, 90, -38, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, 32, -108, -108, -108, -108, -108, 26, + -108, -108, 27, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, -108, -108, -108, 102, -108, 103, 41, + -108, -108, 37, -108, 250, 38, 83, -108, -108, -108, + -108, -108, -108, -108, 42, 126, -108, -108, -108, 40, + -108, -108, 43, -108, -108, -108, -108, -108, -108, -108, + 39, -108, -108, -108, -108, -108, -108, -108, -108, -108, + 225, -108, -108, 30, -108, 24, -108, 211, -108, 55, + -108, 77, 60, -108, -108, 66, 34, -108, -108, -108, + -108, -108, -8, -108, -108, -108, -108, -108, 153, -108, + -108, 164, -108, -108, -108, 241, -108, -108, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, 11, -108, -108, -108, -108, -108, 179, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, 19, 259, -108, 255, 228, 240, 246, -108, + 52, 63, 67, 65, 50, -108, -108, -108, -108, -108, + -108, -108, -108, 210, -108, 256, -108, 226, -108, -108, + 252, -108, 161, -108, -108, 268, -108, 197, -108, 5, + -108, 218, -108, 222, -108, 213, 249, -108, -108, 236, + -108, -108, -108, -108, -108, -108, 212, -108, 80, 87, + -108, -108, 86, -108, 98, -108, 61, -108, 245, -108, + 59, -108, 208, -108, 192, -108, -108, -108, -108, -108, + -108, -108, -108, 257, -108, 33, -108, 28, -108, 73, + 71, -108, -108, 36, 57, -108, 62, -108, -108, 46, + 70, -108, -108, -108, 49, -108, 45, 99, -108, 84, + -108, -108, 100, -108, -108, -108, -108, -108, -108, 21, + -108, -108, -108, -108, -108, -108, 118, -108, -108, -108, + -108, 81, -108, -108, -108, -108, -108, -108, 123, -108, + -108, 134, -108, -108, 56, -108, -108, -108, -108, -108, + -58, -108, 47, -108, -57, -108, -108, -108, -108, 265, + -108, -108, 374, -108, -108, -108, -108, -108, 94, -66, + -108, -108, 25, -108, 22, -108, 31, -108, -108, -108, + -108, 58, -108, 229, -108, 35, -108, 235, -108, -108, + -108, -108, -108, -108, 29, -108, -108, 186, -108, -108, + -108, -108, 162, -108, -108, -108, -108, 48, -108, -108, + 163, -108, -108, 44, -108, -108, -108, -108, -108, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, + 141, -108, -108, -108, -108, -108, -7, -108, -108, -108, + -108, -108, -108, -108, -19, -108, -108, -108, -6, -108, + -108, 334, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, -108, -15, -27, -108, -10, -108, -108, -108, + -108, 159, -108, -108, -108, 176, -108, -108, 319, -108, + -108, -108, 322, -108, -108, -108, -108, 469, -108, -108, + 10, -108, -108, 6, 16, -108, 342, -108, -108, -108, + 17, -108, -108, -108, 15, 3, 9, -108, -108, -108, + -108, -108, 358, 68, -108, 82, 310, 1, -108, -108, + -2, -108, 7, -108, 54, 76, -108, -108, 4, -108, + 64, -108, -108, 23, -108, -108, -108, 18, -108, -5, + 95, -108, 91, -108, -108, -108, -108, -108, -1, -108, + -108, 20, -108, -108, 14, 142, -108, -108, -108, 13, + -108, -108, -108, -108, -108, -108, -11, -108, -108, -108, + -108, -108, -108, -108, -108, -108}; + +const short QQmlJSGrammar::action_info [] = { + 344, -127, 576, -129, 551, 631, 546, -105, 342, 465, + 448, 461, -132, -106, 245, 481, 558, 558, 398, 573, + 392, 482, 402, 268, 354, -124, 350, 578, 585, -135, + -116, 484, 474, 404, -106, -105, -127, -129, -124, 454, + 438, -135, 245, 558, 448, 424, 448, 448, -132, 456, + 439, 588, 452, 268, 406, 350, 408, -116, 558, 405, + 432, 544, 418, 432, 413, 432, 329, 166, 524, 461, + 428, 421, 465, 172, 283, 143, 420, 143, 241, 166, + 262, 73, 149, 185, 323, 283, 307, 323, 336, 73, + 655, 189, 0, 245, 423, 192, 448, 0, 0, 101, + 240, 0, 451, 346, 243, 303, 424, 315, 181, 143, + 0, 268, 151, 0, 399, 312, 452, 350, 143, 261, + 174, 317, 143, 244, 303, 184, 435, 238, 461, 465, + 442, 143, 103, 143, 143, 305, 143, 64, 143, 175, + 143, 338, 101, 60, 143, 555, 0, 191, 65, 325, + 0, 143, 0, 326, 61, 631, 174, 555, 103, 259, + 258, 501, 143, 259, 258, 590, 589, 252, 251, 60, + 426, 436, 416, 415, 264, 175, 259, 258, 645, 644, + 61, 179, 257, 256, 144, 168, 463, 60, 105, 169, + 467, 60, 352, 626, 339, 87, 321, 88, 61, 651, + 650, 525, 61, 348, 525, 556, 174, 106, 89, 107, + 174, 525, 490, 143, 66, 446, 445, 648, 647, 66, + 580, 87, 549, 88, 87, 175, 88, 411, 87, 175, + 88, 176, 567, 174, 89, 542, 87, 89, 88, 531, + 0, 89, 87, 525, 88, 581, 579, 527, 646, 89, + 527, 66, 175, 592, 411, 89, 0, 527, 526, 67, + 491, 526, 0, 0, 67, 68, 236, 235, 526, 87, + 68, 88, 87, 0, 88, 0, 550, 548, 87, 558, + 88, 527, 89, 267, 265, 89, 568, 566, 87, 527, + 88, 89, 526, 532, 530, 87, 67, 88, 525, 0, + 526, 89, 68, 87, 87, 88, 88, 174, 89, 477, + 0, 266, 0, 285, 286, 641, 89, 89, 75, 76, + 75, 76, 0, 0, 0, -92, 175, 0, 176, 642, + 640, 174, 6, 5, 4, 1, 3, 2, 0, 593, + 287, 288, 290, 291, 527, 77, 78, 77, 78, -92, + 175, 292, 176, 0, 293, 526, 294, 290, 291, 0, + 639, 0, 478, 476, 290, 291, 292, 0, 0, 293, + 0, 294, 0, 292, 290, 291, 293, 0, 294, 0, + 290, 291, 0, 292, 0, 0, 293, 0, 294, 292, + 80, 81, 293, 35, 294, 0, 0, 0, 82, 83, + 80, 81, 84, 35, 85, 0, 285, 286, 82, 83, + 80, 81, 84, 35, 85, 0, 0, 0, 82, 83, + 0, 0, 84, 35, 85, 0, 35, 0, 0, 0, + 49, 52, 50, 287, 288, 0, 0, 0, 0, 0, + 49, 52, 50, 0, 35, 0, 0, 35, 0, 0, + 49, 52, 50, 0, 0, 0, 0, 46, 34, 51, + 49, 52, 50, 49, 52, 50, 0, 46, 34, 51, + 0, 0, 0, 0, 0, 0, 0, 46, 34, 51, + 35, 49, 52, 50, 49, 52, 50, 46, 34, 51, + 46, 34, 51, 80, 81, 35, 0, 0, 35, 0, + 0, 82, 83, 0, 0, 84, 0, 85, 46, 34, + 51, 46, 34, 51, 35, 0, 0, 49, 52, 50, + 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 35, 49, 52, 50, 49, 52, 50, 184, 0, + 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, + 0, 49, 52, 50, 35, 0, 0, 0, 0, 46, + 34, 51, 46, 34, 51, 35, 0, 0, 49, 52, + 50, 0, 184, 0, 0, 35, 0, 0, 46, 34, + 51, 0, 0, 0, 35, 0, 255, 254, 0, 0, + 0, 49, 52, 50, 0, 46, 34, 51, 0, 0, + 0, 0, 49, 52, 50, 35, 0, 0, 0, 0, + 0, 0, 49, 52, 50, 0, 255, 254, 46, 34, + 51, 49, 52, 50, 0, 0, 0, 0, 0, 46, + 34, 51, 0, 0, 0, 0, 0, 255, 254, 46, + 34, 51, 49, 52, 50, 0, 0, 0, 46, 34, + 51, 35, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, + 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 250, 249, 153, 0, 0, 49, 52, + 50, 0, 0, 0, 0, 154, 0, 0, 0, 155, + 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, + 157, 0, 0, 319, 0, 46, 34, 51, 0, 0, + 0, 158, 0, 159, 64, 0, 0, 153, 0, 0, + 0, 160, 0, 0, 161, 65, 0, 154, 0, 0, + 162, 155, 0, 0, 0, 0, 163, 0, 0, 0, + 156, 0, 157, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 164, 158, 0, 159, 64, 0, 0, 0, + 0, 0, 0, 160, 0, 0, 161, 65, 0, 0, + 0, 0, 162, 0, 0, 0, 0, 0, 163, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 36, 37, 0, 38, 0, 0, 0, 0, 0, 0, + 42, 0, 0, 0, 45, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 53, 49, 52, 50, 0, 54, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 44, 56, + 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 30, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, + 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, + 0, 0, 0, 516, 0, 0, 0, 45, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 53, 49, 52, 50, 0, + 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, + 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 515, 0, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, + 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, + 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, + 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 53, 517, 519, 518, 0, 54, 0, 0, 0, 0, + 227, 0, 0, 0, 0, 0, 44, 56, 32, 214, + 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, + 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 515, 0, 30, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 219, 0, 0, 0, 0, 0, 0, 35, + 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, + 0, 0, 0, 516, 0, 0, 0, 45, 0, 0, + 0, 0, 0, 0, 0, 560, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 53, 517, 519, 518, 0, + 54, 0, 0, 0, 0, 227, 0, 0, 0, 0, + 0, 44, 56, 32, 214, 0, 0, 41, 0, 0, + 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 515, 0, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, + 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, + 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, + 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 53, 517, 519, 518, 0, 54, 0, 0, 0, 0, + 227, 0, 0, 0, 0, 0, 44, 56, 32, 214, + 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, + 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, + 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, + 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, + 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, + 0, 55, 0, 57, 0, 58, 0, 0, 0, 0, + 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, + 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -125, 0, 0, 0, 29, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 36, 37, 0, 38, 0, 0, 0, 39, 0, 40, + 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, + 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 53, 49, 52, 50, 0, 54, 0, 55, + 0, 57, 0, 58, 0, 0, 0, 0, 44, 56, + 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, + 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, + 35, 0, 0, 0, 36, 37, 0, 38, 0, 0, + 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, + 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 53, 49, 52, 50, + 0, 54, 0, 55, 0, 57, 282, 58, 0, 0, + 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, + 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 496, 0, 0, 29, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, + 0, 36, 37, 0, 38, 0, 0, 0, 39, 0, + 40, 42, 43, 0, 0, 45, 0, 0, 0, 47, + 0, 48, 0, 0, 499, 0, 0, 0, 0, 0, + 0, 0, 0, 53, 49, 52, 50, 0, 54, 0, + 55, 0, 57, 0, 58, 0, 0, 0, 0, 44, + 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 496, 0, 0, 29, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, + 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, + 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, + 0, 0, 45, 0, 0, 0, 47, 0, 48, 0, + 0, 497, 0, 0, 0, 0, 0, 0, 0, 0, + 53, 49, 52, 50, 0, 54, 0, 55, 0, 57, + 0, 58, 0, 0, 0, 0, 44, 56, 32, 0, + 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, + 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 488, 0, 0, 29, 30, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, + 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, + 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, + 0, 0, 0, 47, 0, 48, 0, 0, 489, 0, + 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, + 50, 0, 54, 0, 55, 0, 57, 0, 58, 0, + 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 488, 0, 0, + 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, + 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, + 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, + 47, 0, 48, 0, 0, 494, 0, 0, 0, 0, + 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, + 0, 55, 0, 57, 0, 58, 0, 0, 0, 0, + 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, + 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, + 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, + 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, + 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, + 0, 0, 0, 0, 223, 0, 0, 0, 53, 49, + 52, 50, 224, 54, 0, 55, 226, 57, 0, 58, + 0, 229, 0, 0, 44, 56, 32, 0, 0, 0, + 41, 0, 0, 0, 0, 0, 46, 34, 51, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 35, 220, 0, 0, + 595, 596, 0, 38, 0, 0, 0, 39, 0, 40, + 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, + 48, 0, 0, 0, 0, 0, 0, 0, 223, 0, + 0, 0, 53, 49, 52, 50, 224, 54, 0, 55, + 226, 57, 0, 58, 0, 229, 0, 0, 44, 56, + 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 111, 112, 113, 0, 0, 115, 117, 118, + 0, 0, 119, 0, 120, 0, 0, 0, 122, 123, + 124, 0, 0, 0, 0, 0, 0, 35, 125, 126, + 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, + 0, 0, 0, 0, 49, 52, 50, 132, 133, 134, + 0, 136, 137, 138, 139, 140, 141, 0, 0, 129, + 135, 121, 114, 116, 130, 0, 0, 0, 0, 0, + 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 111, 112, 113, 0, 0, 115, 117, + 118, 0, 0, 119, 0, 120, 0, 0, 0, 122, + 123, 124, 0, 0, 0, 0, 0, 0, 35, 125, + 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 128, 0, 0, 0, 395, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, + 0, 0, 0, 0, 397, 49, 52, 50, 132, 133, + 134, 0, 136, 137, 138, 139, 140, 141, 0, 0, + 129, 135, 121, 114, 116, 130, 0, 0, 0, 0, + 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 111, 112, 113, 0, 0, 115, + 117, 118, 0, 0, 119, 0, 120, 0, 0, 0, + 122, 123, 124, 0, 0, 0, 0, 0, 0, 35, + 125, 126, 127, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 128, 0, 0, 0, 395, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, + 0, 0, 0, 0, 0, 397, 49, 52, 50, 132, + 133, 134, 0, 136, 137, 138, 139, 140, 141, 0, + 0, 129, 135, 121, 114, 116, 130, 0, 0, 0, + 0, 0, 0, 46, 374, 380, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 111, 112, 113, 0, 0, + 115, 117, 118, 0, 0, 119, 0, 120, 0, 0, + 0, 122, 123, 124, 0, 0, 0, 0, 0, 0, + 35, 125, 126, 127, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 0, 0, 0, 395, 0, + 0, 0, 0, 0, 0, 0, 396, 0, 0, 0, + 131, 0, 0, 0, 0, 0, 397, 49, 52, 50, + 132, 133, 134, 0, 136, 137, 138, 139, 140, 141, + 0, 0, 129, 135, 121, 114, 116, 130, 0, 0, + 0, 0, 0, 0, 46, 374, 380, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 213, 0, 0, 0, + 0, 215, 0, 29, 30, 31, 217, 0, 0, 0, + 0, 0, 0, 218, 33, 0, 0, 0, 0, 0, + 0, 35, 220, 0, 0, 221, 37, 0, 38, 0, + 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, + 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, + 0, 222, 0, 223, 0, 0, 0, 53, 49, 52, + 50, 224, 54, 225, 55, 226, 57, 227, 58, 228, + 229, 0, 0, 44, 56, 32, 214, 216, 0, 41, + 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 213, 0, 0, + 0, 0, 215, 0, 29, 30, 31, 217, 0, 0, + 0, 0, 0, 0, 218, 219, 0, 0, 0, 0, + 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, + 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, + 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, + 0, 0, 222, 0, 223, 0, 0, 0, 53, 49, + 52, 50, 224, 54, 225, 55, 226, 57, 227, 58, + 228, 229, 0, 0, 44, 56, 32, 214, 216, 0, + 41, 0, 0, 0, 0, 0, 46, 34, 51, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 600, 112, + 113, 0, 0, 602, 117, 604, 30, 31, 605, 0, + 120, 0, 0, 0, 122, 607, 608, 0, 0, 0, + 0, 0, 0, 35, 609, 126, 127, 221, 37, 0, + 38, 0, 0, 0, 39, 0, 40, 610, 43, 0, + 0, 612, 0, 0, 0, 47, 0, 48, 0, 0, + 0, 0, 0, 613, 0, 223, 0, 0, 0, 614, + 49, 52, 50, 615, 616, 617, 55, 619, 620, 621, + 622, 623, 624, 0, 0, 611, 618, 606, 601, 603, + 130, 41, 0, 0, 0, 0, 0, 46, 374, 380, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, + 112, 113, 0, 0, 367, 117, 369, 30, 31, 370, + 0, 120, 0, 0, 0, 122, 372, 373, 0, 0, + 0, 0, 0, 0, 35, 375, 126, 127, 221, 37, + 0, 38, 0, 0, 0, 39, 0, 40, 376, 43, + 0, 0, 378, 0, 0, 0, 47, 0, 48, 0, + -271, 0, 0, 0, 379, 0, 223, 0, 0, 0, + 381, 49, 52, 50, 382, 383, 384, 55, 386, 387, + 388, 389, 390, 391, 0, 0, 377, 385, 371, 366, + 368, 130, 41, 0, 0, 0, 0, 0, 46, 374, + 380, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 565, 148, 545, 16, 649, 547, 541, 469, 320, 529, + 528, 630, 183, 248, 263, 500, 485, 447, 629, 183, + 627, 444, 253, 393, 587, 652, 313, 152, 643, 572, + 591, 575, 586, 638, 331, 574, 453, 455, 466, 253, + 437, 178, 433, 253, 0, 248, 584, 458, 248, 313, + 441, 183, 444, 457, 237, 190, 447, 188, 206, 425, + 400, 462, 351, 313, 347, 150, 165, 447, 475, 444, + 183, 145, 393, 260, 0, 409, 173, 409, 260, 362, + 171, 514, 409, 495, 362, 393, 206, 498, 628, 313, + 313, 206, 356, 142, 206, 331, 362, 599, 403, 0, + 345, 62, 62, 62, 182, 62, 299, 182, 295, 206, + 410, 417, 410, 206, 62, 393, 62, 410, 62, 296, + 148, 298, 148, 297, 62, 62, 182, 504, 412, 62, + 180, 502, 511, 206, 512, 62, 108, 460, 188, 62, + 394, 188, 62, 206, 460, 247, 62, 206, 459, 206, + 62, 102, 459, 62, 62, 514, 206, 62, 653, 503, + 407, 343, 341, 62, 313, 110, 419, 167, 188, 187, + 170, 340, 514, 104, 0, 553, 422, 206, 62, 206, + 62, 63, 62, 72, 62, 510, 71, 97, 62, 514, + 70, 62, 557, 69, 355, 62, 239, 62, 493, 318, + 86, 469, 492, 62, 483, 74, 242, 206, 93, 62, + 353, 62, 206, 260, 95, 0, 96, 62, 62, 62, + 322, 62, 94, 206, 100, 98, 206, 99, 62, 247, + 277, 464, 0, 206, 79, 281, 314, 468, 62, 62, + 206, 507, 91, 246, 206, 62, 62, 349, 505, 90, + 206, 62, 62, 460, 459, 62, 206, 506, 62, 401, + 206, 62, 92, 309, 62, 108, 281, 362, 281, 281, + 0, 313, 206, 62, 304, 479, 0, 309, 281, 62, + 206, 327, 281, 0, 281, 337, 300, 309, 324, 0, + 0, 62, 281, 0, 110, 177, 281, 62, 301, 308, + 309, 0, 281, 309, 302, 281, 62, 62, 281, 330, + 62, 281, 281, 289, 514, 281, 0, 0, 306, 284, + 0, 522, 328, 569, 561, 311, 553, 564, 625, 0, + 0, 0, 514, 513, 523, 514, 0, 0, 0, 522, + 0, 0, 522, 316, 0, 0, 0, 0, 0, 485, + 440, 513, 523, 0, 513, 523, 533, 534, 535, 536, + 540, 537, 538, 577, 533, 534, 535, 536, 540, 537, + 538, 594, 0, 0, 0, 0, 362, 0, 597, 598, + 533, 534, 535, 536, 540, 537, 538, 0, 0, 206, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 443, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 569, 0, 0, 0, 0, 0, 0, 570, + 571, 533, 534, 535, 536, 540, 537, 538, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + +const short QQmlJSGrammar::action_check [] = { + 60, 7, 7, 7, 34, 91, 24, 7, 61, 36, + 33, 36, 7, 7, 7, 60, 33, 33, 55, 66, + 8, 33, 55, 36, 16, 7, 36, 29, 8, 7, + 7, 55, 17, 36, 7, 7, 7, 7, 7, 36, + 55, 7, 7, 33, 33, 36, 33, 33, 7, 60, + 7, 60, 20, 36, 33, 36, 55, 7, 33, 60, + 5, 37, 36, 5, 60, 5, 7, 2, 66, 36, + 33, 33, 36, 7, 1, 8, 60, 8, 33, 2, + 36, 1, 8, 36, 2, 1, 8, 2, 17, 1, + 0, 8, -1, 7, 55, 33, 33, -1, -1, 48, + 60, -1, 6, 31, 55, 48, 36, 61, 60, 8, + -1, 36, 60, -1, 7, 61, 20, 36, 8, 77, + 15, 60, 8, 55, 48, 36, 10, 36, 36, 36, + 7, 8, 79, 8, 8, 79, 8, 42, 8, 34, + 8, 8, 48, 40, 8, 8, -1, 60, 53, 50, + -1, 8, -1, 54, 51, 91, 15, 8, 79, 61, + 62, 60, 8, 61, 62, 61, 62, 61, 62, 40, + 60, 55, 61, 62, 60, 34, 61, 62, 61, 62, + 51, 56, 61, 62, 56, 50, 60, 40, 15, 54, + 60, 40, 60, 56, 61, 25, 60, 27, 51, 61, + 62, 29, 51, 60, 29, 56, 15, 34, 38, 36, + 15, 29, 8, 8, 12, 61, 62, 61, 62, 12, + 36, 25, 7, 27, 25, 34, 27, 36, 25, 34, + 27, 36, 7, 15, 38, 29, 25, 38, 27, 7, + -1, 38, 25, 29, 27, 61, 62, 75, 92, 38, + 75, 12, 34, 7, 36, 38, -1, 75, 86, 57, + 56, 86, -1, -1, 57, 63, 61, 62, 86, 25, + 63, 27, 25, -1, 27, -1, 61, 62, 25, 33, + 27, 75, 38, 61, 62, 38, 61, 62, 25, 75, + 27, 38, 86, 61, 62, 25, 57, 27, 29, -1, + 86, 38, 63, 25, 25, 27, 27, 15, 38, 8, + -1, 89, -1, 18, 19, 47, 38, 38, 18, 19, + 18, 19, -1, -1, -1, 33, 34, -1, 36, 61, + 62, 15, 97, 98, 99, 100, 101, 102, -1, 93, + 45, 46, 23, 24, 75, 45, 46, 45, 46, 33, + 34, 32, 36, -1, 35, 86, 37, 23, 24, -1, + 92, -1, 61, 62, 23, 24, 32, -1, -1, 35, + -1, 37, -1, 32, 23, 24, 35, -1, 37, -1, + 23, 24, -1, 32, -1, -1, 35, -1, 37, 32, + 23, 24, 35, 29, 37, -1, -1, -1, 31, 32, + 23, 24, 35, 29, 37, -1, 18, 19, 31, 32, + 23, 24, 35, 29, 37, -1, -1, -1, 31, 32, + -1, -1, 35, 29, 37, -1, 29, -1, -1, -1, + 66, 67, 68, 45, 46, -1, -1, -1, -1, -1, + 66, 67, 68, -1, 29, -1, -1, 29, -1, -1, + 66, 67, 68, -1, -1, -1, -1, 93, 94, 95, + 66, 67, 68, 66, 67, 68, -1, 93, 94, 95, + -1, -1, -1, -1, -1, -1, -1, 93, 94, 95, + 29, 66, 67, 68, 66, 67, 68, 93, 94, 95, + 93, 94, 95, 23, 24, 29, -1, -1, 29, -1, + -1, 31, 32, -1, -1, 35, -1, 37, 93, 94, + 95, 93, 94, 95, 29, -1, -1, 66, 67, 68, + -1, 36, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 29, 66, 67, 68, 66, 67, 68, 36, -1, + -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, + -1, 66, 67, 68, 29, -1, -1, -1, -1, 93, + 94, 95, 93, 94, 95, 29, -1, -1, 66, 67, + 68, -1, 36, -1, -1, 29, -1, -1, 93, 94, + 95, -1, -1, -1, 29, -1, 61, 62, -1, -1, + -1, 66, 67, 68, -1, 93, 94, 95, -1, -1, + -1, -1, 66, 67, 68, 29, -1, -1, -1, -1, + -1, -1, 66, 67, 68, -1, 61, 62, 93, 94, + 95, 66, 67, 68, -1, -1, -1, -1, -1, 93, + 94, 95, -1, -1, -1, -1, -1, 61, 62, 93, + 94, 95, 66, 67, 68, -1, -1, -1, 93, 94, + 95, 29, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, + 94, 95, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 61, 62, 3, -1, -1, 66, 67, + 68, -1, -1, -1, -1, 13, -1, -1, -1, 17, + -1, -1, -1, -1, -1, -1, -1, -1, 26, -1, + 28, -1, -1, 31, -1, 93, 94, 95, -1, -1, + -1, 39, -1, 41, 42, -1, -1, 3, -1, -1, + -1, 49, -1, -1, 52, 53, -1, 13, -1, -1, + 58, 17, -1, -1, -1, -1, 64, -1, -1, -1, + 26, -1, 28, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 80, 39, -1, 41, 42, -1, -1, -1, + -1, -1, -1, 49, -1, -1, 52, 53, -1, -1, + -1, -1, 58, -1, -1, -1, -1, -1, 64, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 80, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, -1, -1, -1, + 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 66, 67, 68, -1, 70, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, + 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, + 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, + -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 10, -1, 12, 13, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, + -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, + -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, + 75, -1, -1, -1, -1, -1, 81, 82, 83, 84, + -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, + 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, -1, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, + 70, -1, -1, -1, -1, 75, -1, -1, -1, -1, + -1, 81, 82, 83, 84, -1, -1, 87, -1, -1, + -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 10, -1, 12, 13, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, + -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, + -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, + 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, + 75, -1, -1, -1, -1, -1, 81, 82, 83, 84, + -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, + 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, + -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, + -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, + -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, + 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, + -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, + 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, + -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 7, -1, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, + -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, + 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, + -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, + -1, 70, -1, 72, -1, 74, 75, 76, -1, -1, + -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, + -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 8, -1, -1, 11, + 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, + -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, + 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, + -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, + -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, + 72, -1, 74, -1, 76, -1, -1, -1, -1, 81, + 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, + -1, 93, 94, 95, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, + -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, + -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, + -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, + 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, + -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, + -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, + -1, -1, -1, 51, -1, 53, -1, -1, 56, -1, + -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, + 68, -1, 70, -1, 72, -1, 74, -1, 76, -1, + -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, + -1, -1, -1, -1, -1, 93, 94, 95, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, + 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, + -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, + -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, + -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, + 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, + -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, + -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, + 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, + -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, + -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, + -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, + -1, -1, -1, -1, 61, -1, -1, -1, 65, 66, + 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, + -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, + 87, -1, -1, -1, -1, -1, 93, 94, 95, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, 30, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, -1, -1, -1, -1, -1, 61, -1, + -1, -1, 65, 66, 67, 68, 69, 70, -1, 72, + 73, 74, -1, 76, -1, 78, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, + 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, + -1, -1, 14, -1, 16, -1, -1, -1, 20, 21, + 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, + 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 43, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, + -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, + -1, 73, 74, 75, 76, 77, 78, -1, -1, 81, + 82, 83, 84, 85, 86, -1, -1, -1, -1, -1, + -1, 93, 94, 95, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, + 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, + 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, + 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 43, -1, -1, -1, 47, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, + -1, -1, -1, -1, 65, 66, 67, 68, 69, 70, + 71, -1, 73, 74, 75, 76, 77, 78, -1, -1, + 81, 82, 83, 84, 85, 86, -1, -1, -1, -1, + -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, + 10, 11, -1, -1, 14, -1, 16, -1, -1, -1, + 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, + 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, 65, 66, 67, 68, 69, + 70, 71, -1, 73, 74, 75, 76, 77, 78, -1, + -1, 81, 82, 83, 84, 85, 86, -1, -1, -1, + -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, + 9, 10, 11, -1, -1, 14, -1, 16, -1, -1, + -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, + 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 43, -1, -1, -1, 47, -1, + -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, + 59, -1, -1, -1, -1, -1, 65, 66, 67, 68, + 69, 70, 71, -1, 73, 74, 75, 76, 77, 78, + -1, -1, 81, 82, 83, 84, 85, 86, -1, -1, + -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, + -1, 9, -1, 11, 12, 13, 14, -1, -1, -1, + -1, -1, -1, 21, 22, -1, -1, -1, -1, -1, + -1, 29, 30, -1, -1, 33, 34, -1, 36, -1, + -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, + -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, + -1, 59, -1, 61, -1, -1, -1, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, -1, -1, 81, 82, 83, 84, 85, -1, 87, + -1, -1, -1, -1, -1, 93, 94, 95, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, + -1, -1, 9, -1, 11, 12, 13, 14, -1, -1, + -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, + -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, + -1, -1, 59, -1, 61, -1, -1, -1, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, -1, -1, 81, 82, 83, 84, 85, -1, + 87, -1, -1, -1, -1, -1, 93, 94, 95, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 4, 5, + 6, -1, -1, 9, 10, 11, 12, 13, 14, -1, + 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, + -1, -1, -1, 29, 30, 31, 32, 33, 34, -1, + 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, + -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, + -1, -1, -1, 59, -1, 61, -1, -1, -1, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, -1, -1, 81, 82, 83, 84, 85, + 86, 87, -1, -1, -1, -1, -1, 93, 94, 95, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, + 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, + -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, + -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, + 55, -1, -1, -1, 59, -1, 61, -1, -1, -1, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, + 85, 86, 87, -1, -1, -1, -1, -1, 93, 94, + 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + 15, 39, 29, 3, 15, 15, 13, 15, 3, 15, + 29, 9, 15, 15, 3, 3, 39, 22, 19, 15, + 19, 3, 15, 15, 15, 11, 3, 74, 15, 19, + 15, 15, 29, 13, 15, 29, 102, 15, 3, 15, + 97, 3, 100, 15, -1, 15, 29, 22, 15, 3, + 3, 15, 3, 22, 15, 15, 22, 15, 15, 3, + 39, 3, 3, 3, 3, 39, 39, 22, 39, 3, + 15, 39, 15, 2, -1, 13, 39, 13, 2, 2, + 39, 13, 13, 39, 2, 15, 15, 39, 20, 3, + 3, 15, 15, 3, 15, 15, 2, 15, 41, -1, + 2, 51, 51, 51, 53, 51, 56, 53, 56, 15, + 48, 41, 48, 15, 51, 15, 51, 48, 51, 56, + 39, 56, 39, 56, 51, 51, 53, 53, 47, 51, + 47, 53, 4, 15, 2, 51, 15, 53, 15, 51, + 40, 15, 51, 15, 53, 4, 51, 15, 53, 15, + 51, 63, 53, 51, 51, 13, 15, 51, 16, 53, + 42, 75, 75, 51, 3, 44, 43, 65, 15, 43, + 67, 91, 13, 61, -1, 16, 42, 15, 51, 15, + 51, 54, 51, 54, 51, 106, 53, 56, 51, 13, + 53, 51, 16, 53, 2, 51, 43, 51, 35, 2, + 56, 15, 39, 51, 42, 59, 42, 15, 56, 51, + 2, 51, 15, 2, 56, -1, 56, 51, 51, 51, + 2, 51, 56, 15, 57, 57, 15, 57, 51, 4, + 51, 2, -1, 15, 57, 56, 75, 2, 51, 51, + 15, 53, 55, 2, 15, 51, 51, 2, 53, 55, + 15, 51, 51, 53, 53, 51, 15, 53, 51, 2, + 15, 51, 55, 51, 51, 15, 56, 2, 56, 56, + -1, 3, 15, 51, 64, 89, -1, 51, 56, 51, + 15, 68, 56, -1, 56, 73, 58, 51, 66, -1, + -1, 51, 56, -1, 44, 45, 56, 51, 58, 73, + 51, -1, 56, 51, 58, 56, 51, 51, 56, 73, + 51, 56, 56, 58, 13, 56, -1, -1, 62, 60, + -1, 20, 73, 13, 5, 73, 16, 5, 18, -1, + -1, -1, 13, 32, 33, 13, -1, -1, -1, 20, + -1, -1, 20, 75, -1, -1, -1, -1, -1, 39, + 85, 32, 33, -1, 32, 33, 22, 23, 24, 25, + 26, 27, 28, 21, 22, 23, 24, 25, 26, 27, + 28, 13, -1, -1, -1, -1, 2, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, -1, -1, 15, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 13, -1, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1}; + +QT_END_NAMESPACE diff --git a/src/qml/parser/qqmljsgrammar_p.h b/src/qml/parser/qqmljsgrammar_p.h new file mode 100644 index 0000000000..9ef4695d69 --- /dev/null +++ b/src/qml/parser/qqmljsgrammar_p.h @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// This file was generated by qlalr - DO NOT EDIT! +#ifndef QQMLJSGRAMMAR_P_H +#define QQMLJSGRAMMAR_P_H + +#include + +QT_BEGIN_NAMESPACE + +class QQmlJSGrammar +{ +public: + enum VariousConstants { + EOF_SYMBOL = 0, + REDUCE_HERE = 104, + SHIFT_THERE = 103, + T_AND = 1, + T_AND_AND = 2, + T_AND_EQ = 3, + T_AS = 92, + T_AUTOMATIC_SEMICOLON = 62, + T_BREAK = 4, + T_CASE = 5, + T_CATCH = 6, + T_COLON = 7, + T_COMMA = 8, + T_COMMENT = 88, + T_COMPATIBILITY_SEMICOLON = 89, + T_CONST = 84, + T_CONTINUE = 9, + T_DEBUGGER = 85, + T_DEFAULT = 10, + T_DELETE = 11, + T_DIVIDE_ = 12, + T_DIVIDE_EQ = 13, + T_DO = 14, + T_DOT = 15, + T_ELSE = 16, + T_EQ = 17, + T_EQ_EQ = 18, + T_EQ_EQ_EQ = 19, + T_ERROR = 96, + T_FALSE = 83, + T_FEED_JS_EXPRESSION = 100, + T_FEED_JS_PROGRAM = 102, + T_FEED_JS_SOURCE_ELEMENT = 101, + T_FEED_JS_STATEMENT = 99, + T_FEED_UI_OBJECT_MEMBER = 98, + T_FEED_UI_PROGRAM = 97, + T_FINALLY = 20, + T_FOR = 21, + T_FUNCTION = 22, + T_GE = 23, + T_GET = 94, + T_GT = 24, + T_GT_GT = 25, + T_GT_GT_EQ = 26, + T_GT_GT_GT = 27, + T_GT_GT_GT_EQ = 28, + T_IDENTIFIER = 29, + T_IF = 30, + T_IMPORT = 91, + T_IN = 31, + T_INSTANCEOF = 32, + T_LBRACE = 33, + T_LBRACKET = 34, + T_LE = 35, + T_LPAREN = 36, + T_LT = 37, + T_LT_LT = 38, + T_LT_LT_EQ = 39, + T_MINUS = 40, + T_MINUS_EQ = 41, + T_MINUS_MINUS = 42, + T_MULTILINE_STRING_LITERAL = 87, + T_NEW = 43, + T_NOT = 44, + T_NOT_EQ = 45, + T_NOT_EQ_EQ = 46, + T_NULL = 81, + T_NUMERIC_LITERAL = 47, + T_ON = 93, + T_OR = 48, + T_OR_EQ = 49, + T_OR_OR = 50, + T_PLUS = 51, + T_PLUS_EQ = 52, + T_PLUS_PLUS = 53, + T_PROPERTY = 66, + T_PUBLIC = 90, + T_QUESTION = 54, + T_RBRACE = 55, + T_RBRACKET = 56, + T_READONLY = 68, + T_REMAINDER = 57, + T_REMAINDER_EQ = 58, + T_RESERVED_WORD = 86, + T_RETURN = 59, + T_RPAREN = 60, + T_SEMICOLON = 61, + T_SET = 95, + T_SIGNAL = 67, + T_STAR = 63, + T_STAR_EQ = 64, + T_STRING_LITERAL = 65, + T_SWITCH = 69, + T_THIS = 70, + T_THROW = 71, + T_TILDE = 72, + T_TRUE = 82, + T_TRY = 73, + T_TYPEOF = 74, + T_VAR = 75, + T_VOID = 76, + T_WHILE = 77, + T_WITH = 78, + T_XOR = 79, + T_XOR_EQ = 80, + + ACCEPT_STATE = 655, + RULE_COUNT = 351, + STATE_COUNT = 656, + TERMINAL_COUNT = 105, + NON_TERMINAL_COUNT = 108, + + GOTO_INDEX_OFFSET = 656, + GOTO_INFO_OFFSET = 2970, + GOTO_CHECK_OFFSET = 2970 + }; + + static const char *const spell []; + static const short lhs []; + static const short rhs []; + static const short goto_default []; + static const short action_default []; + static const short action_index []; + static const short action_info []; + static const short action_check []; + + static inline int nt_action (int state, int nt) + { + const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; + if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) + return goto_default [nt]; + + return action_info [GOTO_INFO_OFFSET + yyn]; + } + + static inline int t_action (int state, int token) + { + const int yyn = action_index [state] + token; + + if (yyn < 0 || action_check [yyn] != token) + return - action_default [state]; + + return action_info [yyn]; + } +}; + + +QT_END_NAMESPACE +#endif // QQMLJSGRAMMAR_P_H + diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h new file mode 100644 index 0000000000..7fcf001303 --- /dev/null +++ b/src/qml/parser/qqmljskeywords_p.h @@ -0,0 +1,884 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSKEYWORDS_P_H +#define QQMLJSKEYWORDS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljslexer_p.h" + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +static inline int classify2(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 's') { + return qmlMode ? Lexer::T_AS : Lexer::T_IDENTIFIER; + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'o') { + return Lexer::T_DO; + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'f') { + return Lexer::T_IF; + } + else if (s[1].unicode() == 'n') { + return Lexer::T_IN; + } + } + else if (qmlMode && s[0].unicode() == 'o') { + if (s[1].unicode() == 'n') { + return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER; + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify3(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'r') { + return Lexer::T_FOR; + } + } + } + else if (s[0].unicode() == 'g') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + return Lexer::T_GET; + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + return qmlMode ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER); + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'w') { + return Lexer::T_NEW; + } + } + } + else if (s[0].unicode() == 's') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + return Lexer::T_SET; + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'y') { + return Lexer::T_TRY; + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'r') { + return Lexer::T_VAR; + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify4(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + return qmlMode ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_CASE; + } + } + } + else if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'r') { + return qmlMode ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'l') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_ELSE; + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'm') { + return Lexer::T_ENUM; + } + } + } + } + else if (s[0].unicode() == 'g') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'o') { + return qmlMode ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'l') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'g') { + return qmlMode ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'l') { + return Lexer::T_NULL; + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 's') { + return Lexer::T_THIS; + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'e') { + return Lexer::T_TRUE; + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'd') { + return Lexer::T_VOID; + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'h') { + return Lexer::T_WITH; + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify5(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'e') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'k') { + return Lexer::T_BREAK; + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + return Lexer::T_CATCH; + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 's') { + return Lexer::T_CLASS; + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 't') { + return qmlMode ? int(Lexer::T_CONST) : int(Lexer::T_RESERVED_WORD); + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 'e') { + return Lexer::T_FALSE; + } + } + } + } + else if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + return qmlMode ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + return qmlMode ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[0].unicode() == 's') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'r') { + if (s[4].unicode() == 't') { + return qmlMode ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + return qmlMode ? int(Lexer::T_SUPER) : int(Lexer::T_RESERVED_WORD); + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + return Lexer::T_THROW; + } + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + return Lexer::T_WHILE; + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify6(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'e') { + return Lexer::T_DELETE; + } + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'b') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'e') { + return qmlMode ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return Lexer::T_EXPORT; + } + } + } + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return qmlMode ? int(Lexer::T_IMPORT) : int(Lexer::T_RESERVED_WORD); + } + } + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'i') { + if (s[4].unicode() == 'v') { + if (s[5].unicode() == 'e') { + return qmlMode ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER; + } + } + } + } + } + } + else if (s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'n') { + return Lexer::T_RETURN; + } + } + } + } + } + } + else if (s[0].unicode() == 's') { + if (qmlMode && s[1].unicode() == 'i') { + if (s[2].unicode() == 'g') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'l') { + return Lexer::T_SIGNAL; + } + } + } + } + } + else if (s[1].unicode() == 't') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return qmlMode ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[1].unicode() == 'w') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'c') { + if (s[5].unicode() == 'h') { + return Lexer::T_SWITCH; + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + if (s[5].unicode() == 's') { + return qmlMode ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'f') { + return Lexer::T_TYPEOF; + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify7(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'n') { + return qmlMode ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'f') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'u') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 't') { + return Lexer::T_DEFAULT; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'n') { + if (s[5].unicode() == 'd') { + if (s[6].unicode() == 's') { + return Lexer::T_EXTENDS; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 'y') { + return Lexer::T_FINALLY; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'c') { + if (s[3].unicode() == 'k') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + return qmlMode ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'v') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 't') { + if (s[6].unicode() == 'e') { + return qmlMode ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify8(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 'b') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 't') { + return qmlMode ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'u') { + if (s[7].unicode() == 'e') { + return Lexer::T_CONTINUE; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'g') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'r') { + return Lexer::T_DEBUGGER; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + return Lexer::T_FUNCTION; + } + } + } + } + } + } + } + } + else if (qmlMode && s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'p') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'y') { + return qmlMode ? Lexer::T_PROPERTY : Lexer::T_IDENTIFIER; + } + } + } + } + } + } + } + } + else if (qmlMode && s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'd') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'y') { + return Lexer::T_READONLY; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'e') { + return qmlMode ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify9(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'f') { + if (s[6].unicode() == 'a') { + if (s[7].unicode() == 'c') { + if (s[8].unicode() == 'e') { + return qmlMode ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'c') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'd') { + return qmlMode ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 's') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + return qmlMode ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify10(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'm') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + if (s[9].unicode() == 's') { + return qmlMode ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'o') { + if (s[9].unicode() == 'f') { + return Lexer::T_INSTANCEOF; + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify12(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 's') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 'i') { + if (s[9].unicode() == 'z') { + if (s[10].unicode() == 'e') { + if (s[11].unicode() == 'd') { + return qmlMode ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +int Lexer::classify(const QChar *s, int n, bool qmlMode) { + switch (n) { + case 2: return classify2(s, qmlMode); + case 3: return classify3(s, qmlMode); + case 4: return classify4(s, qmlMode); + case 5: return classify5(s, qmlMode); + case 6: return classify6(s, qmlMode); + case 7: return classify7(s, qmlMode); + case 8: return classify8(s, qmlMode); + case 9: return classify9(s, qmlMode); + case 10: return classify10(s, qmlMode); + case 12: return classify12(s, qmlMode); + default: return Lexer::T_IDENTIFIER; + } // switch +} + +} // namespace QQmlJS + +QT_QML_END_NAMESPACE + +#endif // QQMLJSKEYWORDS_P_H diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp new file mode 100644 index 0000000000..5d9ca1036f --- /dev/null +++ b/src/qml/parser/qqmljslexer.cpp @@ -0,0 +1,1329 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljslexer_p.h" +#include "qqmljsengine_p.h" +#include "qqmljsmemorypool_p.h" +#include "qqmljskeywords_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); +QT_END_NAMESPACE + +using namespace QQmlJS; + +static inline int regExpFlagFromChar(const QChar &ch) +{ + switch (ch.unicode()) { + case 'g': return Lexer::RegExp_Global; + case 'i': return Lexer::RegExp_IgnoreCase; + case 'm': return Lexer::RegExp_Multiline; + } + return 0; +} + +static inline unsigned char convertHex(ushort c) +{ + if (c >= '0' && c <= '9') + return (c - '0'); + else if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + else + return (c - 'A' + 10); +} + +static inline QChar convertHex(QChar c1, QChar c2) +{ + return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); +} + +static inline QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4) +{ + return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()), + (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); +} + +Lexer::Lexer(Engine *engine) + : _engine(engine) + , _codePtr(0) + , _lastLinePtr(0) + , _tokenLinePtr(0) + , _tokenStartPtr(0) + , _char(QLatin1Char('\n')) + , _errorCode(NoError) + , _currentLineNumber(0) + , _tokenValue(0) + , _parenthesesState(IgnoreParentheses) + , _parenthesesCount(0) + , _stackToken(-1) + , _patternFlags(0) + , _tokenKind(0) + , _tokenLength(0) + , _tokenLine(0) + , _validTokenText(false) + , _prohibitAutomaticSemicolon(false) + , _restrictedKeyword(false) + , _terminator(false) + , _followsClosingBrace(false) + , _delimited(true) + , _qmlMode(true) +{ + if (engine) + engine->setLexer(this); +} + +bool Lexer::qmlMode() const +{ + return _qmlMode; +} + +QString Lexer::code() const +{ + return _code; +} + +void Lexer::setCode(const QString &code, int lineno, bool qmlMode) +{ + if (_engine) + _engine->setCode(code); + + _qmlMode = qmlMode; + _code = code; + _tokenText.clear(); + _tokenText.reserve(1024); + _errorMessage.clear(); + _tokenSpell = QStringRef(); + + _codePtr = code.unicode(); + _endPtr = _codePtr + code.length(); + _lastLinePtr = _codePtr; + _tokenLinePtr = _codePtr; + _tokenStartPtr = _codePtr; + + _char = QLatin1Char('\n'); + _errorCode = NoError; + + _currentLineNumber = lineno; + _tokenValue = 0; + + // parentheses state + _parenthesesState = IgnoreParentheses; + _parenthesesCount = 0; + + _stackToken = -1; + + _patternFlags = 0; + _tokenLength = 0; + _tokenLine = lineno; + + _validTokenText = false; + _prohibitAutomaticSemicolon = false; + _restrictedKeyword = false; + _terminator = false; + _followsClosingBrace = false; + _delimited = true; +} + +void Lexer::scanChar() +{ + unsigned sequenceLength = isLineTerminatorSequence(); + _char = *_codePtr++; + if (sequenceLength == 2) + _char = *_codePtr++; + + if (unsigned sequenceLength = isLineTerminatorSequence()) { + _lastLinePtr = _codePtr + sequenceLength - 1; // points to the first character after the newline + ++_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() +{ + const int previousTokenKind = _tokenKind; + + _tokenSpell = QStringRef(); + _tokenKind = scanToken(); + _tokenLength = _codePtr - _tokenStartPtr - 1; + + _delimited = false; + _restrictedKeyword = false; + _followsClosingBrace = (previousTokenKind == T_RBRACE); + + // update the flags + switch (_tokenKind) { + case T_LBRACE: + case T_SEMICOLON: + case T_QUESTION: + case T_COLON: + case T_TILDE: + _delimited = true; + break; + default: + if (isBinop(_tokenKind)) + _delimited = true; + break; + + case T_IF: + case T_FOR: + case T_WHILE: + case T_WITH: + _parenthesesState = CountParentheses; + _parenthesesCount = 0; + break; + + case T_DO: + _parenthesesState = BalancedParentheses; + break; + + case T_CONTINUE: + case T_BREAK: + case T_RETURN: + case T_THROW: + _restrictedKeyword = true; + break; + } // switch + + // update the parentheses state + switch (_parenthesesState) { + case IgnoreParentheses: + break; + + case CountParentheses: + if (_tokenKind == T_RPAREN) { + --_parenthesesCount; + if (_parenthesesCount == 0) + _parenthesesState = BalancedParentheses; + } else if (_tokenKind == T_LPAREN) { + ++_parenthesesCount; + } + break; + + case BalancedParentheses: + if (_tokenKind != T_DO) + _parenthesesState = IgnoreParentheses; + break; + } // switch + + return _tokenKind; +} + +bool Lexer::isUnicodeEscapeSequence(const QChar *chars) +{ + if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3])) + return true; + + return false; +} + +QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) +{ + if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) { + scanChar(); // skip u + + const QChar c1 = _char; + scanChar(); + + const QChar c2 = _char; + scanChar(); + + const QChar c3 = _char; + scanChar(); + + const QChar c4 = _char; + scanChar(); + + if (ok) + *ok = true; + + return convertUnicode(c1, c2, c3, c4); + } + + *ok = false; + return QChar(); +} + +QChar Lexer::decodeHexEscapeCharacter(bool *ok) +{ + if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { + scanChar(); + + const QChar c1 = _char; + scanChar(); + + const QChar c2 = _char; + scanChar(); + + if (ok) + *ok = true; + + return convertHex(c1, c2); + } + + *ok = false; + 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() +{ + if (_stackToken != -1) { + int tk = _stackToken; + _stackToken = -1; + return tk; + } + + _terminator = false; + +again: + _validTokenText = false; + _tokenLinePtr = _lastLinePtr; + + while (_char.isSpace()) { + if (unsigned sequenceLength = isLineTerminatorSequence()) { + _tokenLinePtr = _codePtr + sequenceLength - 1; + + if (_restrictedKeyword) { + // automatic semicolon insertion + _tokenLine = _currentLineNumber; + _tokenStartPtr = _codePtr - 1; + return T_SEMICOLON; + } else { + _terminator = true; + syncProhibitAutomaticSemicolon(); + } + } + + scanChar(); + } + + _tokenStartPtr = _codePtr - 1; + _tokenLine = _currentLineNumber; + + if (_codePtr > _endPtr) + return EOF_SYMBOL; + + const QChar ch = _char; + scanChar(); + + switch (ch.unicode()) { + case '~': return T_TILDE; + case '}': return T_RBRACE; + + case '|': + if (_char == QLatin1Char('|')) { + scanChar(); + return T_OR_OR; + } else if (_char == QLatin1Char('=')) { + scanChar(); + return T_OR_EQ; + } + return T_OR; + + case '{': return T_LBRACE; + + case '^': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_XOR_EQ; + } + return T_XOR; + + case ']': return T_RBRACKET; + case '[': return T_LBRACKET; + case '?': return T_QUESTION; + + case '>': + if (_char == QLatin1Char('>')) { + scanChar(); + if (_char == QLatin1Char('>')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_GT_GT_GT_EQ; + } + return T_GT_GT_GT; + } else if (_char == QLatin1Char('=')) { + scanChar(); + return T_GT_GT_EQ; + } + return T_GT_GT; + } else if (_char == QLatin1Char('=')) { + scanChar(); + return T_GE; + } + return T_GT; + + case '=': + if (_char == QLatin1Char('=')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_EQ_EQ_EQ; + } + return T_EQ_EQ; + } + return T_EQ; + + case '<': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_LE; + } else if (_char == QLatin1Char('<')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_LT_LT_EQ; + } + return T_LT_LT; + } + return T_LT; + + case ';': return T_SEMICOLON; + case ':': return T_COLON; + + case '/': + if (_char == QLatin1Char('*')) { + scanChar(); + while (_codePtr <= _endPtr) { + if (_char == QLatin1Char('*')) { + scanChar(); + if (_char == QLatin1Char('/')) { + scanChar(); + + if (_engine) { + _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4, + tokenStartLine(), tokenStartColumn() + 2); + } + + goto again; + } + } else { + scanChar(); + } + } + } else if (_char == QLatin1Char('/')) { + while (_codePtr <= _endPtr && !isLineTerminator()) { + scanChar(); + } + if (_engine) { + _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2, + tokenStartLine(), tokenStartColumn() + 2); + } + goto again; + } if (_char == QLatin1Char('=')) { + scanChar(); + return T_DIVIDE_EQ; + } + return T_DIVIDE_; + + case '.': + if (_char.isDigit()) { + QVarLengthArray chars; + + chars.append(ch.unicode()); // append the `.' + + 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(); + } + } + } + + 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; + } + return T_DOT; + + case '-': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_MINUS_EQ; + } else if (_char == QLatin1Char('-')) { + scanChar(); + + if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { + _stackToken = T_MINUS_MINUS; + return T_SEMICOLON; + } + + return T_MINUS_MINUS; + } + return T_MINUS; + + case ',': return T_COMMA; + + case '+': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_PLUS_EQ; + } else if (_char == QLatin1Char('+')) { + scanChar(); + + if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { + _stackToken = T_PLUS_PLUS; + return T_SEMICOLON; + } + + return T_PLUS_PLUS; + } + return T_PLUS; + + case '*': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_STAR_EQ; + } + return T_STAR; + + case ')': return T_RPAREN; + case '(': return T_LPAREN; + + case '&': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_AND_EQ; + } else if (_char == QLatin1Char('&')) { + scanChar(); + return T_AND_AND; + } + return T_AND; + + case '%': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_REMAINDER_EQ; + } + return T_REMAINDER; + + case '!': + if (_char == QLatin1Char('=')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_NOT_EQ_EQ; + } + return T_NOT_EQ; + } + return T_NOT; + + case '\'': + case '"': { + const QChar quote = ch; + bool multilineStringLiteral = false; + + const QChar *startCode = _codePtr; + + if (_engine) { + while (_codePtr <= _endPtr) { + if (isLineTerminator()) { + if (qmlMode()) + break; + _errorCode = IllegalCharacter; + _errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal"); + return T_ERROR; + } else if (_char == QLatin1Char('\\')) { + break; + } else if (_char == quote) { + _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode); + scanChar(); + + return T_STRING_LITERAL; + } + scanChar(); + } + } + + _validTokenText = true; + _tokenText.resize(0); + startCode--; + while (startCode != _codePtr - 1) + _tokenText += *startCode++; + + while (_codePtr <= _endPtr) { + if (unsigned sequenceLength = isLineTerminatorSequence()) { + multilineStringLiteral = true; + _tokenText += _char; + if (sequenceLength == 2) + _tokenText += *_codePtr; + scanChar(); + } else if (_char == quote) { + scanChar(); + + if (_engine) + _tokenSpell = _engine->newStringRef(_tokenText); + + return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL; + } else if (_char == QLatin1Char('\\')) { + scanChar(); + + QChar u; + + switch (_char.unicode()) { + // unicode escape sequence + case 'u': { + bool ok = false; + u = decodeUnicodeEscapeCharacter(&ok); + if (! ok) { + _errorCode = IllegalUnicodeEscapeSequence; + _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + return T_ERROR; + } + } break; + + // hex escape sequence + case 'x': { + bool ok = false; + u = decodeHexEscapeCharacter(&ok); + if (!ok) { + _errorCode = IllegalHexadecimalEscapeSequence; + _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal hexadecimal escape sequence"); + return T_ERROR; + } + } break; + + // single character escape sequence + case '\\': u = QLatin1Char('\\'); scanChar(); break; + case '\'': u = QLatin1Char('\''); scanChar(); break; + case '\"': u = QLatin1Char('\"'); scanChar(); break; + case 'b': u = QLatin1Char('\b'); scanChar(); break; + case 'f': u = QLatin1Char('\f'); scanChar(); break; + case 'n': u = QLatin1Char('\n'); scanChar(); break; + case 'r': u = QLatin1Char('\r'); scanChar(); break; + case 't': u = QLatin1Char('\t'); scanChar(); break; + case 'v': u = QLatin1Char('\v'); scanChar(); break; + + case '0': + if (! _codePtr->isDigit()) { + scanChar(); + u = QLatin1Char('\0'); + 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 '\n': + case 0x2028u: + case 0x2029u: + scanChar(); + continue; + + default: + // non escape character + u = _char; + scanChar(); + } + + _tokenText += u; + } else { + _tokenText += _char; + scanChar(); + } + } + + _errorCode = UnclosedStringLiteral; + _errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line"); + 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: { + QChar c = ch; + bool identifierWithEscapeChars = false; + if (c == QLatin1Char('\\') && _char == QLatin1Char('u')) { + 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 += c; + _validTokenText = true; + } + while (true) { + c = _char; + if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) { + if (! identifierWithEscapeChars) { + identifierWithEscapeChars = true; + _tokenText.resize(0); + _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1); + _validTokenText = true; + } + + scanChar(); // skip '\\' + bool ok = false; + c = decodeUnicodeEscapeCharacter(&ok); + if (! ok) { + _errorCode = IllegalUnicodeEscapeSequence; + _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + return T_ERROR; + } + if (isIdentifierPart(c)) + _tokenText += c; + continue; + } else if (isIdentifierPart(c)) { + if (identifierWithEscapeChars) + _tokenText += c; + + scanChar(); + continue; + } + + _tokenLength = _codePtr - _tokenStartPtr - 1; + + 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; + } + } + } + + break; + } + + 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 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) +{ + _tokenText.resize(0); + _validTokenText = true; + _patternFlags = 0; + + if (prefix == EqualPrefix) + _tokenText += QLatin1Char('='); + + while (true) { + switch (_char.unicode()) { + case '/': + scanChar(); + + // scan the flags + _patternFlags = 0; + while (isIdentLetter(_char)) { + int flag = regExpFlagFromChar(_char); + if (flag == 0 || _patternFlags & flag) { + _errorMessage = QCoreApplication::translate("QQmlParser", "Invalid regular expression flag '%0'") + .arg(QChar(_char)); + return false; + } + _patternFlags |= flag; + scanChar(); + } + + _tokenLength = _codePtr - _tokenStartPtr - 1; + return true; + + case '\\': + // regular expression backslash sequence + _tokenText += _char; + scanChar(); + + if (_codePtr > _endPtr || isLineTerminator()) { + _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); + return false; + } + + _tokenText += _char; + scanChar(); + break; + + case '[': + // regular expression class + _tokenText += _char; + scanChar(); + + while (_codePtr <= _endPtr && ! isLineTerminator()) { + if (_char == QLatin1Char(']')) + break; + else if (_char == QLatin1Char('\\')) { + // regular expression backslash sequence + _tokenText += _char; + scanChar(); + + if (_codePtr > _endPtr || isLineTerminator()) { + _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); + return false; + } + + _tokenText += _char; + scanChar(); + } else { + _tokenText += _char; + scanChar(); + } + } + + if (_char != QLatin1Char(']')) { + _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression class"); + return false; + } + + _tokenText += _char; + scanChar(); // skip ] + break; + + default: + if (_codePtr > _endPtr || isLineTerminator()) { + _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression literal"); + return false; + } else { + _tokenText += _char; + scanChar(); + } + } // switch + } // while + + return false; +} + +bool Lexer::isLineTerminator() const +{ + 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) +{ + // ASCII-biased, since all reserved words are ASCII, aand hence the + // bulk of content to be parsed. + if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) + || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) + || ch == QLatin1Char('$') + || ch == QLatin1Char('_')) + return true; + if (ch.unicode() < 128) + return false; + return ch.isLetterOrNumber(); +} + +bool Lexer::isDecimalDigit(ushort c) +{ + return (c >= '0' && c <= '9'); +} + +bool Lexer::isHexDigit(QChar c) +{ + return ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) + || (c >= QLatin1Char('a') && c <= QLatin1Char('f')) + || (c >= QLatin1Char('A') && c <= QLatin1Char('F'))); +} + +bool Lexer::isOctalDigit(ushort c) +{ + return (c >= '0' && c <= '7'); +} + +int Lexer::tokenEndLine() const +{ + return _currentLineNumber; +} + +int Lexer::tokenEndColumn() const +{ + return _codePtr - _lastLinePtr; +} + +QString Lexer::tokenText() const +{ + if (_validTokenText) + return _tokenText; + + if (_tokenKind == T_STRING_LITERAL) + return QString(_tokenStartPtr + 1, _tokenLength - 2); + + return QString(_tokenStartPtr, _tokenLength); +} + +Lexer::Error Lexer::errorCode() const +{ + return _errorCode; +} + +QString Lexer::errorMessage() const +{ + return _errorMessage; +} + +void Lexer::syncProhibitAutomaticSemicolon() +{ + if (_parenthesesState == BalancedParentheses) { + // we have seen something like "if (foo)", which means we should + // never insert an automatic semicolon at this point, since it would + // then be expanded into an empty statement (ECMA-262 7.9.1) + _prohibitAutomaticSemicolon = true; + _parenthesesState = IgnoreParentheses; + } else { + _prohibitAutomaticSemicolon = false; + } +} + +bool Lexer::prevTerminator() const +{ + return _terminator; +} + +bool Lexer::followsClosingBrace() const +{ + return _followsClosingBrace; +} + +bool Lexer::canInsertAutomaticSemicolon(int token) const +{ + return token == T_RBRACE + || token == EOF_SYMBOL + || _terminator + || _followsClosingBrace; +} + +bool Lexer::scanDirectives(Directives *directives) +{ + if (_qmlMode) { + // the directives are a Javascript-only extension. + return false; + } + + lex(); // fetch the first token + + if (_tokenKind != T_DOT) + return true; + + do { + lex(); // skip T_DOT + + const int lineNumber = tokenStartLine(); + + if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) + return false; // expected a valid QML/JS directive + + const QString directiveName = tokenText(); + + if (! (directiveName == QLatin1String("pragma") || + directiveName == QLatin1String("import"))) + return false; // not a valid directive name + + // it must be a pragma or an import directive. + if (directiveName == QLatin1String("pragma")) { + // .pragma library + if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) + return false; // expected `library + + // we found a .pragma library directive + directives->pragmaLibrary(); + + } else { + Q_ASSERT(directiveName == QLatin1String("import")); + lex(); // skip .import + + QString pathOrUri; + QString version; + bool fileImport = false; // file or uri import + + if (_tokenKind == T_STRING_LITERAL) { + // .import T_STRING_LITERAL as T_IDENTIFIER + + fileImport = true; + pathOrUri = tokenText(); + + } else if (_tokenKind == T_IDENTIFIER) { + // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER + + pathOrUri = tokenText(); + + lex(); // skip the first T_IDENTIFIER + for (; _tokenKind == T_DOT; lex()) { + if (lex() != T_IDENTIFIER) + return false; + + pathOrUri += QLatin1Char('.'); + pathOrUri += tokenText(); + } + + if (_tokenKind != T_NUMERIC_LITERAL) + return false; // expected the module version number + + version = tokenText(); + } + + // + // recognize the mandatory `as' followed by the module name + // + if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as"))) + return false; // expected `as' + + if (lex() != T_IDENTIFIER) + return false; // expected module name + + const QString module = tokenText(); + + if (fileImport) + directives->importFile(pathOrUri, module); + else + directives->importModule(pathOrUri, version, module); + } + + if (tokenStartLine() != lineNumber) + return false; // the directives cannot span over multiple lines + + // fetch the first token after the .pragma/.import directive + lex(); + } while (_tokenKind == T_DOT); + + return true; +} diff --git a/src/qml/parser/qqmljslexer_p.h b/src/qml/parser/qqmljslexer_p.h new file mode 100644 index 0000000000..23af61d650 --- /dev/null +++ b/src/qml/parser/qqmljslexer_p.h @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSLEXER_P_H +#define QQMLJSLEXER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsglobal_p.h" +#include "qqmljsgrammar_p.h" + +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Engine; + +class QML_PARSER_EXPORT Directives { +public: + virtual ~Directives() {} + + virtual void pragmaLibrary() + { + } + + virtual void importFile(const QString &jsfile, const QString &module) + { + Q_UNUSED(jsfile); + Q_UNUSED(module); + } + + virtual void importModule(const QString &uri, const QString &version, const QString &module) + { + Q_UNUSED(uri); + Q_UNUSED(version); + Q_UNUSED(module); + } +}; + +class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar +{ +public: + enum { + T_ABSTRACT = T_RESERVED_WORD, + T_BOOLEAN = T_RESERVED_WORD, + T_BYTE = T_RESERVED_WORD, + T_CHAR = T_RESERVED_WORD, + T_CLASS = T_RESERVED_WORD, + T_DOUBLE = T_RESERVED_WORD, + T_ENUM = T_RESERVED_WORD, + T_EXPORT = T_RESERVED_WORD, + T_EXTENDS = T_RESERVED_WORD, + T_FINAL = T_RESERVED_WORD, + T_FLOAT = T_RESERVED_WORD, + T_GOTO = T_RESERVED_WORD, + T_IMPLEMENTS = T_RESERVED_WORD, + T_INT = T_RESERVED_WORD, + T_INTERFACE = T_RESERVED_WORD, + T_LONG = T_RESERVED_WORD, + T_NATIVE = T_RESERVED_WORD, + T_PACKAGE = T_RESERVED_WORD, + T_PRIVATE = T_RESERVED_WORD, + T_PROTECTED = T_RESERVED_WORD, + T_SHORT = T_RESERVED_WORD, + T_STATIC = T_RESERVED_WORD, + T_SUPER = T_RESERVED_WORD, + T_SYNCHRONIZED = T_RESERVED_WORD, + T_THROWS = T_RESERVED_WORD, + T_TRANSIENT = T_RESERVED_WORD, + T_VOLATILE = T_RESERVED_WORD + }; + + enum Error { + NoError, + IllegalCharacter, + IllegalHexNumber, + UnclosedStringLiteral, + IllegalEscapeSequence, + IllegalUnicodeEscapeSequence, + UnclosedComment, + IllegalExponentIndicator, + IllegalIdentifier, + IllegalHexadecimalEscapeSequence + }; + + enum RegExpBodyPrefix { + NoPrefix, + EqualPrefix + }; + + enum RegExpFlag { + RegExp_Global = 0x01, + RegExp_IgnoreCase = 0x02, + RegExp_Multiline = 0x04 + }; + +public: + Lexer(Engine *engine); + + bool qmlMode() const; + + QString code() const; + void setCode(const QString &code, int lineno, bool qmlMode = true); + + int lex(); + + bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); + bool scanDirectives(Directives *directives); + + int regExpFlags() const { return _patternFlags; } + QString regExpPattern() const { return _tokenText; } + + int tokenKind() const { return _tokenKind; } + int tokenOffset() const { return _tokenStartPtr - _code.unicode(); } + int tokenLength() const { return _tokenLength; } + + int tokenStartLine() const { return _tokenLine; } + int tokenStartColumn() const { return _tokenStartPtr - _tokenLinePtr + 1; } + + int tokenEndLine() const; + int tokenEndColumn() const; + + inline QStringRef tokenSpell() const { return _tokenSpell; } + double tokenValue() const { return _tokenValue; } + QString tokenText() const; + + Error errorCode() const; + QString errorMessage() const; + + bool prevTerminator() const; + bool followsClosingBrace() const; + bool canInsertAutomaticSemicolon(int token) const; + + enum ParenthesesState { + IgnoreParentheses, + CountParentheses, + BalancedParentheses + }; + +protected: + int classify(const QChar *s, int n, bool qmlMode); + +private: + inline void scanChar(); + int scanToken(); + int scanNumber(QChar ch); + + bool isLineTerminator() const; + unsigned isLineTerminatorSequence() const; + static bool isIdentLetter(QChar c); + static bool isDecimalDigit(ushort c); + static bool isHexDigit(QChar c); + static bool isOctalDigit(ushort c); + static bool isUnicodeEscapeSequence(const QChar *chars); + + void syncProhibitAutomaticSemicolon(); + QChar decodeUnicodeEscapeCharacter(bool *ok); + QChar decodeHexEscapeCharacter(bool *ok); + +private: + Engine *_engine; + + QString _code; + QString _tokenText; + QString _errorMessage; + QStringRef _tokenSpell; + + const QChar *_codePtr; + const QChar *_endPtr; + const QChar *_lastLinePtr; + const QChar *_tokenLinePtr; + const QChar *_tokenStartPtr; + + QChar _char; + Error _errorCode; + + int _currentLineNumber; + double _tokenValue; + + // parentheses state + ParenthesesState _parenthesesState; + int _parenthesesCount; + + int _stackToken; + + int _patternFlags; + int _tokenKind; + int _tokenLength; + int _tokenLine; + + bool _validTokenText; + bool _prohibitAutomaticSemicolon; + bool _restrictedKeyword; + bool _terminator; + bool _followsClosingBrace; + bool _delimited; + bool _qmlMode; +}; + +} // end of namespace QQmlJS + +QT_QML_END_NAMESPACE + +#endif // LEXER_H diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h new file mode 100644 index 0000000000..820ae8ed71 --- /dev/null +++ b/src/qml/parser/qqmljsmemorypool_p.h @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLJSMEMORYPOOL_P_H +#define QQMLJSMEMORYPOOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsglobal_p.h" + +#include +#include +#include + +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +class QML_PARSER_EXPORT MemoryPool : public QSharedData +{ + MemoryPool(const MemoryPool &other); + void operator =(const MemoryPool &other); + +public: + MemoryPool() + : _blocks(0), + _allocatedBlocks(0), + _blockCount(-1), + _ptr(0), + _end(0) + { } + + ~MemoryPool() + { + if (_blocks) { + for (int i = 0; i < _allocatedBlocks; ++i) { + if (char *b = _blocks[i]) + free(b); + } + + free(_blocks); + } + } + + inline void *allocate(size_t size) + { + size = (size + 7) & ~7; + if (_ptr && (_ptr + size < _end)) { + void *addr = _ptr; + _ptr += size; + return addr; + } + return allocate_helper(size); + } + + void reset() + { + _blockCount = -1; + _ptr = _end = 0; + } + +private: + void *allocate_helper(size_t size) + { + Q_ASSERT(size < BLOCK_SIZE); + + if (++_blockCount == _allocatedBlocks) { + if (! _allocatedBlocks) + _allocatedBlocks = DEFAULT_BLOCK_COUNT; + else + _allocatedBlocks *= 2; + + _blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks); + + for (int index = _blockCount; index < _allocatedBlocks; ++index) + _blocks[index] = 0; + } + + char *&block = _blocks[_blockCount]; + + if (! block) + block = (char *) malloc(BLOCK_SIZE); + + _ptr = block; + _end = _ptr + BLOCK_SIZE; + + void *addr = _ptr; + _ptr += size; + return addr; + } + +private: + char **_blocks; + int _allocatedBlocks; + int _blockCount; + char *_ptr; + char *_end; + + enum + { + BLOCK_SIZE = 8 * 1024, + DEFAULT_BLOCK_COUNT = 8 + }; +}; + +class QML_PARSER_EXPORT Managed +{ + Managed(const Managed &other); + void operator = (const Managed &other); + +public: + Managed() {} + ~Managed() {} + + void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } + void operator delete(void *) {} + void operator delete(void *, MemoryPool *) {} +}; + +} // namespace QQmlJS + +QT_QML_END_NAMESPACE + +#endif diff --git a/src/qml/parser/qqmljsparser.cpp b/src/qml/parser/qqmljsparser.cpp new file mode 100644 index 0000000000..46b5c041d4 --- /dev/null +++ b/src/qml/parser/qqmljsparser.cpp @@ -0,0 +1,1844 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmljsengine_p.h" +#include "qqmljslexer_p.h" +#include "qqmljsast_p.h" +#include "qqmljsmemorypool_p.h" + +#include +#include + +#include + + +#include "qqmljsparser_p.h" + +#include + +// +// W A R N I N G +// ------------- +// +// 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; + +QT_QML_BEGIN_NAMESPACE + +void Parser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); +} + +Parser::Parser(Engine *engine): + driver(engine), + pool(engine->pool()), + tos(0), + stack_size(0), + sym_stack(0), + state_stack(0), + location_stack(0), + string_stack(0), + program(0), + first_token(0), + last_token(0) +{ +} + +Parser::~Parser() +{ + if (stack_size) { + free(sym_stack); + free(state_stack); + free(location_stack); + free(string_stack); + } +} + +static inline AST::SourceLocation location(Lexer *lexer) +{ + AST::SourceLocation loc; + loc.offset = lexer->tokenOffset(); + loc.length = lexer->tokenLength(); + loc.startLine = lexer->tokenStartLine(); + loc.startColumn = lexer->tokenStartColumn(); + return loc; +} + +AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) +{ + QVarLengthArray nameIds; + QVarLengthArray locations; + + AST::ExpressionNode *it = expr; + while (AST::FieldMemberExpression *m = AST::cast(it)) { + nameIds.append(m->name); + locations.append(m->identifierToken); + it = m->base; + } + + if (AST::IdentifierExpression *idExpr = AST::cast(it)) { + AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); + q->identifierToken = idExpr->identifierToken; + + AST::UiQualifiedId *currentId = q; + for (int i = nameIds.size() - 1; i != -1; --i) { + currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); + currentId->identifierToken = locations[i]; + } + + return currentId->finish(); + } + + return 0; +} + +bool Parser::parse(int startToken) +{ + Lexer *lexer = driver->lexer(); + bool hadErrors = false; + int yytoken = -1; + int action = 0; + + token_buffer[0].token = startToken; + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + tos = -1; + program = 0; + + do { + if (++tos == stack_size) + reallocateStack(); + + state_stack[tos] = action; + + _Lcheck_token: + if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + + if (first_token == last_token) { + yytoken = lexer->lex(); + yylval = lexer->tokenValue(); + yytokenspell = lexer->tokenSpell(); + yylloc = location(lexer); + } else { + yytoken = first_token->token; + yylval = first_token->dval; + yytokenspell = first_token->spell; + yylloc = first_token->loc; + ++first_token; + } + } + + action = t_action(action, yytoken); + if (action > 0) { + if (action != ACCEPT_STATE) { + yytoken = -1; + sym(1).dval = yylval; + stringRef(1) = yytokenspell; + loc(1) = yylloc; + } else { + --tos; + return ! hadErrors; + } + } else if (action < 0) { + const int r = -action - 1; + tos -= rhs[r]; + + switch (r) { + +case 0: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 1: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 2: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 3: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 4: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 5: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 6: { + sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, + sym(2).UiObjectMemberList->finish()); +} break; + +case 8: { + sym(1).Node = sym(1).UiImportList->finish(); +} break; + +case 9: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); +} break; + +case 10: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); +} break; + +case 13: { + sym(1).UiImport->semicolonToken = loc(2); +} break; + +case 15: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->semicolonToken = loc(3); +} break; + +case 17: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->asToken = loc(3); + sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = stringRef(4); + sym(1).UiImport->semicolonToken = loc(5); +} break; + +case 19: { + sym(1).UiImport->asToken = loc(2); + sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = stringRef(3); + sym(1).UiImport->semicolonToken = loc(4); +} break; + +case 20: { + AST::UiImport *node = 0; + + if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { + node = new (pool) AST::UiImport(importIdLiteral->value); + node->fileNameToken = loc(2); + } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { + node = new (pool) AST::UiImport(qualifiedId); + node->fileNameToken = loc(2); + } + + sym(1).Node = node; + + if (node) { + node->importToken = loc(1); + } else { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id or a string literal"))); + + return false; // ### remove me + } +} break; + +case 21: { + sym(1).Node = 0; +} break; + +case 22: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; + +case 23: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; + +case 24: { + AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( + sym(1).UiObjectMemberList, sym(2).UiObjectMember); + sym(1).Node = node; +} break; + +case 25: { + sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); +} break; + +case 26: { + AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( + sym(1).UiArrayMemberList, sym(3).UiObjectMember); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 27: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); + node->lbraceToken = loc(1); + node->rbraceToken = loc(2); + sym(1).Node = node; +} break; + +case 28: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 29: { + AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, + sym(2).UiObjectInitializer); + sym(1).Node = node; +} break; + +case 31: { + AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( + sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); + node->colonToken = loc(2); + node->lbracketToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; + +case 32: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 33: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + node->hasOnToken = true; + sym(1).Node = node; +} break; + +case 41: +{ + AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( + sym(1).UiQualifiedId, sym(3).Statement); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 45: { + sym(1).Node = 0; +} break; + +case 46: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; + +case 47: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + node->propertyTypeToken = loc(1); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; + +case 48: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); + node->propertyTypeToken = loc(3); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; + +case 50: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->parameters = sym(4).UiParameterList; + node->semicolonToken = loc(6); + sym(1).Node = node; +} break; + +case 52: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 54: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; + +case 56: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); + sym(1).Node = node; +} break; + +case 58: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; + +case 59: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), + sym(5).Statement); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 60: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; + +case 61: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; + +case 62: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); + propertyName->identifierToken = loc(6); + propertyName->next = 0; + + AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( + propertyName, sym(9).UiArrayMemberList->finish()); + binding->colonToken = loc(7); + binding->lbracketToken = loc(8); + binding->rbracketToken = loc(10); + + node->binding = binding; + + sym(1).Node = node; +} break; + +case 63: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); + propertyName->identifierToken = loc(3); + propertyName->next = 0; + + AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( + propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); + binding->colonToken = loc(4); + + node->binding = binding; + + sym(1).Node = node; +} break; + +case 64: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; + +case 65: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; + +case 73: { + AST::ThisExpression *node = new (pool) AST::ThisExpression(); + node->thisToken = loc(1); + sym(1).Node = node; +} break; + +case 74: { + AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 75: { + AST::NullExpression *node = new (pool) AST::NullExpression(); + node->nullToken = loc(1); + sym(1).Node = node; +} break; + +case 76: { + AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); + node->trueToken = loc(1); + sym(1).Node = node; +} break; + +case 77: { + AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); + node->falseToken = loc(1); + sym(1).Node = node; +} break; + +case 78: { + AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +case 79: +case 80: { + AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 81: { + bool rx = lexer->scanRegExp(Lexer::NoPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; // ### remove me + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 82: { + bool rx = lexer->scanRegExp(Lexer::EqualPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 83: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); + node->lbracketToken = loc(1); + node->rbracketToken = loc(2); + sym(1).Node = node; +} break; + +case 84: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; + +case 85: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; + +case 86: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + (AST::Elision *) 0); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 87: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + sym(4).Elision->finish()); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; + +case 88: { + AST::ObjectLiteral *node = 0; + if (sym(2).Node) + node = new (pool) AST::ObjectLiteral( + sym(2).PropertyAssignmentList->finish ()); + else + node = new (pool) AST::ObjectLiteral(); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 89: { + AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( + sym(2).PropertyAssignmentList->finish ()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(4); + sym(1).Node = node; +} break; + +case 90: { + AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); + node->lparenToken = loc(1); + node->rparenToken = loc(3); + sym(1).Node = node; +} break; + +case 91: { + if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, + QLatin1String("Ignored annotation"))); + + sym(1).Expression = mem->base; + } + + if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { + sym(1).UiQualifiedId = qualifiedId; + } else { + sym(1).UiQualifiedId = 0; + + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id"))); + + return false; // ### recover + } +} break; + +case 92: { + sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); +} break; + +case 93: { + sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); +} break; + +case 94: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, + (AST::Elision *) 0, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 95: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), + sym(4).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 96: { + AST::Elision *node = new (pool) AST::Elision(); + node->commaToken = loc(1); + sym(1).Node = node; +} break; + +case 97: { + AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 98: { + AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( + sym(1).PropertyName, sym(3).Expression); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 99: { + AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( + 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; + +case 100: { + 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; + +case 101: { + sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment); +} break; + +case 102: { + AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList( + sym(1).PropertyAssignmentList, sym(3).PropertyAssignment); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 103: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 104: { + AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 105: { + AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 106: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 142: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 143: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 144: { + AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); + node->newToken = loc(1); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + sym(1).Node = node; +} break; + +case 146: { + AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); + node->newToken = loc(1); + sym(1).Node = node; +} break; + +case 147: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 148: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 149: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 150: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 151: { + sym(1).Node = 0; +} break; + +case 152: { + sym(1).Node = sym(1).ArgumentList->finish(); +} break; + +case 153: { + sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); +} break; + +case 154: { + AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 158: { + AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); + node->incrementToken = loc(2); + sym(1).Node = node; +} break; + +case 159: { + AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); + node->decrementToken = loc(2); + sym(1).Node = node; +} break; + +case 161: { + AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); + node->deleteToken = loc(1); + sym(1).Node = node; +} break; + +case 162: { + AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); + node->voidToken = loc(1); + sym(1).Node = node; +} break; + +case 163: { + AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); + node->typeofToken = loc(1); + sym(1).Node = node; +} break; + +case 164: { + AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); + node->incrementToken = loc(1); + sym(1).Node = node; +} break; + +case 165: { + AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); + node->decrementToken = loc(1); + sym(1).Node = node; +} break; + +case 166: { + AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); + node->plusToken = loc(1); + sym(1).Node = node; +} break; + +case 167: { + AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); + node->minusToken = loc(1); + sym(1).Node = node; +} break; + +case 168: { + AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); + node->tildeToken = loc(1); + sym(1).Node = node; +} break; + +case 169: { + AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); + node->notToken = loc(1); + sym(1).Node = node; +} break; + +case 171: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mul, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 172: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Div, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 173: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mod, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 175: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Add, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 176: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Sub, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 178: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::LShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 179: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::RShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 180: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::URShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 182: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 183: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 184: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 185: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 186: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 187: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::In, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 189: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 190: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 191: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 192: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 193: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 195: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 196: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 197: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 198: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 200: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 201: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 202: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 203: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 205: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 207: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 209: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 211: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 213: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 215: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 217: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 219: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 221: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 223: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 225: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 227: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 229: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 231: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 232: { + sym(1).ival = QSOperator::Assign; +} break; + +case 233: { + sym(1).ival = QSOperator::InplaceMul; +} break; + +case 234: { + sym(1).ival = QSOperator::InplaceDiv; +} break; + +case 235: { + sym(1).ival = QSOperator::InplaceMod; +} break; + +case 236: { + sym(1).ival = QSOperator::InplaceAdd; +} break; + +case 237: { + sym(1).ival = QSOperator::InplaceSub; +} break; + +case 238: { + sym(1).ival = QSOperator::InplaceLeftShift; +} break; + +case 239: { + sym(1).ival = QSOperator::InplaceRightShift; +} break; + +case 240: { + sym(1).ival = QSOperator::InplaceURightShift; +} break; + +case 241: { + sym(1).ival = QSOperator::InplaceAnd; +} break; + +case 242: { + sym(1).ival = QSOperator::InplaceXor; +} break; + +case 243: { + sym(1).ival = QSOperator::InplaceOr; +} break; + +case 245: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 246: { + sym(1).Node = 0; +} break; + +case 249: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 250: { + sym(1).Node = 0; +} break; + +case 267: { + AST::Block *node = new (pool) AST::Block(sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 268: { + sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); +} break; + +case 269: { + sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); +} break; + +case 270: { + sym(1).Node = 0; +} break; + +case 271: { + sym(1).Node = sym(1).StatementList->finish (); +} break; + +case 273: { + AST::VariableStatement *node = new (pool) AST::VariableStatement( + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + node->declarationKindToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 274: { + sym(1).ival = T_CONST; +} break; + +case 275: { + sym(1).ival = T_VAR; +} break; + +case 276: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; + +case 277: { + AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 278: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; + +case 279: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); +} break; + +case 280: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 281: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 282: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; + +case 283: { + sym(1).Node = 0; +} break; + +case 285: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; + +case 286: { + sym(1).Node = 0; +} break; + +case 288: { + AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); + node->semicolonToken = loc(1); + sym(1).Node = node; +} break; + +case 290: { + AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 291: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(6); + sym(1).Node = node; +} break; + +case 292: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 295: { + AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; + +case 296: { + AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 297: { + AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; +} break; + +case 298: { + AST::LocalForStatement *node = new (pool) AST::LocalForStatement( + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; +} break; + +case 299: { + AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; +} break; + +case 300: { + AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; +} break; + +case 302: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 304: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 306: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 308: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 310: { + AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 311: { + AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; + if (lexer->qmlMode()) { + const QString msg = qApp->translate("QQmlParser", "Deprecated JavaScript `with' statement detected in QML expression. Support for this will be removed in Qt 5.2!"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, node->withToken, msg)); + } +} break; + +case 312: { + AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 313: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 314: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; +} break; + +case 315: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); +} break; + +case 316: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); +} break; + +case 317: { + sym(1).Node = 0; +} break; + +case 318: { + sym(1).Node = sym(1).CaseClauses->finish (); +} break; + +case 319: { + AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; +} break; + +case 320: { + AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 321: { + 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; + +case 323: { + AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 324: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 325: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 326: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 327: { + AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 328: { + AST::Finally *node = new (pool) AST::Finally(sym(2).Block); + node->finallyToken = loc(1); + sym(1).Node = node; +} break; + +case 330: { + AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 332: { + AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; + +case 333: { + AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + if (! stringRef(2).isNull()) + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; + +case 334: { + 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; + +case 335: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 336: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); + node->commaToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 337: { + sym(1).Node = 0; +} break; + +case 338: { + sym(1).Node = sym(1).FormalParameterList->finish (); +} break; + +case 339: { + sym(1).Node = 0; +} break; + +case 341: { + sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); +} break; + +case 343: { + sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); +} break; + +case 344: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); +} break; + +case 345: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); +} break; + +case 346: { + sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); +} break; + +case 347: { + sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); +} break; + +case 348: { + sym(1).Node = 0; +} break; + + } // switch + action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); + } // if + } while (action != 0); + + if (first_token == last_token) { + const int errorState = state_stack[tos]; + + // automatic insertion of `;' + if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) + || t_action(errorState, T_COMPATIBILITY_SEMICOLON))) { + SavedToken &tk = token_buffer[0]; + tk.token = yytoken; + tk.dval = yylval; + tk.spell = yytokenspell; + tk.loc = yylloc; + + yylloc = yyprevlloc; + yylloc.offset += yylloc.length; + yylloc.startColumn += yylloc.length; + yylloc.length = 0; + + //const QString msg = qApp->translate("QQmlParser", "Missing `;'"); + //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); + + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + yytoken = T_SEMICOLON; + yylval = 0; + + action = errorState; + + goto _Lcheck_token; + } + + hadErrors = true; + + token_buffer[0].token = yytoken; + token_buffer[0].dval = yylval; + token_buffer[0].spell = yytokenspell; + token_buffer[0].loc = yylloc; + + token_buffer[1].token = yytoken = lexer->lex(); + token_buffer[1].dval = yylval = lexer->tokenValue(); + token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); + token_buffer[1].loc = yylloc = location(lexer); + + if (t_action(errorState, yytoken)) { + QString msg; + int token = token_buffer[0].token; + if (token < 0 || token >= TERMINAL_COUNT) + msg = qApp->translate("QQmlParser", "Syntax error"); + else + msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + action = errorState; + goto _Lcheck_token; + } + + static int tokens[] = { + T_PLUS, + T_EQ, + + T_COMMA, + T_COLON, + T_SEMICOLON, + + T_RPAREN, T_RBRACKET, T_RBRACE, + + T_NUMERIC_LITERAL, + T_IDENTIFIER, + + T_LPAREN, T_LBRACKET, T_LBRACE, + + EOF_SYMBOL + }; + + for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { + int a = t_action(errorState, *tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = *tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + first_token = &token_buffer[0]; + last_token = &token_buffer[2]; + + action = errorState; + goto _Lcheck_token; + } + } + + for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { + if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || + tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || + tk == T_FEED_JS_SOURCE_ELEMENT) + continue; + + int a = t_action(errorState, tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + action = errorState; + goto _Lcheck_token; + } + } + + const QString msg = qApp->translate("QQmlParser", "Syntax error"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + } + + return false; +} + +QT_QML_END_NAMESPACE + + diff --git a/src/qml/parser/qqmljsparser_p.h b/src/qml/parser/qqmljsparser_p.h new file mode 100644 index 0000000000..1b13690547 --- /dev/null +++ b/src/qml/parser/qqmljsparser_p.h @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// W A R N I N G +// ------------- +// +// 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 +#define QQMLJSPARSER_P_H + +#include "qqmljsglobal_p.h" +#include "qqmljsgrammar_p.h" +#include "qqmljsast_p.h" +#include "qqmljsengine_p.h" + +#include +#include + +QT_QML_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Engine; + +class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar +{ +public: + union Value { + int ival; + double dval; + AST::ArgumentList *ArgumentList; + AST::CaseBlock *CaseBlock; + AST::CaseClause *CaseClause; + AST::CaseClauses *CaseClauses; + AST::Catch *Catch; + AST::DefaultClause *DefaultClause; + AST::ElementList *ElementList; + AST::Elision *Elision; + AST::ExpressionNode *Expression; + AST::Finally *Finally; + AST::FormalParameterList *FormalParameterList; + AST::FunctionBody *FunctionBody; + AST::FunctionDeclaration *FunctionDeclaration; + AST::Node *Node; + AST::PropertyName *PropertyName; + AST::PropertyAssignment *PropertyAssignment; + AST::PropertyAssignmentList *PropertyAssignmentList; + AST::SourceElement *SourceElement; + AST::SourceElements *SourceElements; + AST::Statement *Statement; + AST::StatementList *StatementList; + AST::Block *Block; + AST::VariableDeclaration *VariableDeclaration; + AST::VariableDeclarationList *VariableDeclarationList; + + AST::UiProgram *UiProgram; + AST::UiImportList *UiImportList; + AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; + AST::UiPublicMember *UiPublicMember; + AST::UiObjectDefinition *UiObjectDefinition; + AST::UiObjectInitializer *UiObjectInitializer; + AST::UiObjectBinding *UiObjectBinding; + AST::UiScriptBinding *UiScriptBinding; + AST::UiArrayBinding *UiArrayBinding; + AST::UiObjectMember *UiObjectMember; + AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; + AST::UiQualifiedId *UiQualifiedId; + }; + +public: + Parser(Engine *engine); + ~Parser(); + + // parse a UI program + bool parse() { return parse(T_FEED_UI_PROGRAM); } + bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } + bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } + bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } + bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } + bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } + + AST::UiProgram *ast() const + { return AST::cast(program); } + + AST::Statement *statement() const + { + if (! program) + return 0; + + return program->statementCast(); + } + + AST::ExpressionNode *expression() const + { + if (! program) + return 0; + + return program->expressionCast(); + } + + AST::UiObjectMember *uiObjectMember() const + { + if (! program) + return 0; + + return program->uiObjectMemberCast(); + } + + AST::Node *rootNode() const + { return program; } + + QList diagnosticMessages() const + { return diagnostic_messages; } + + inline DiagnosticMessage diagnosticMessage() const + { + foreach (const DiagnosticMessage &d, diagnostic_messages) { + if (! d.kind == DiagnosticMessage::Warning) + return d; + } + + return DiagnosticMessage(); + } + + inline QString errorMessage() const + { return diagnosticMessage().message; } + + inline int errorLineNumber() const + { return diagnosticMessage().loc.startLine; } + + inline int errorColumnNumber() const + { return diagnosticMessage().loc.startColumn; } + +protected: + bool parse(int startToken); + + void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline QStringRef &stringRef(int index) + { return string_stack [tos + index - 1]; } + + inline AST::SourceLocation &loc(int index) + { return location_stack [tos + index - 1]; } + + AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); + +protected: + Engine *driver; + MemoryPool *pool; + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + AST::SourceLocation *location_stack; + QStringRef *string_stack; + + AST::Node *program; + + // error recovery + enum { TOKEN_BUFFER_SIZE = 3 }; + + struct SavedToken { + int token; + double dval; + AST::SourceLocation loc; + QStringRef spell; + }; + + double yylval; + QStringRef yytokenspell; + AST::SourceLocation yylloc; + AST::SourceLocation yyprevlloc; + + SavedToken token_buffer[TOKEN_BUFFER_SIZE]; + SavedToken *first_token; + SavedToken *last_token; + + QList diagnostic_messages; +}; + +} // end of namespace QQmlJS + + + +#define J_SCRIPT_REGEXPLITERAL_RULE1 81 + +#define J_SCRIPT_REGEXPLITERAL_RULE2 82 + +QT_QML_END_NAMESPACE + + + +#endif // QQMLJSPARSER_P_H diff --git a/src/qml/qml.pro b/src/qml/qml.pro index fe294aa323..6d26d9cb38 100644 --- a/src/qml/qml.pro +++ b/src/qml/qml.pro @@ -21,6 +21,7 @@ HEADERS += qtqmlglobal.h \ #modules include(util/util.pri) +include(parser/parser.pri) include(compiler/compiler.pri) include(jsapi/jsapi.pri) include(jsruntime/jsruntime.pri) diff --git a/src/qml/qml/parser/parser.pri b/src/qml/qml/parser/parser.pri deleted file mode 100644 index e5b8ae2749..0000000000 --- a/src/qml/qml/parser/parser.pri +++ /dev/null @@ -1,22 +0,0 @@ -HEADERS += \ - $$PWD/qqmljsast_p.h \ - $$PWD/qqmljsastfwd_p.h \ - $$PWD/qqmljsastvisitor_p.h \ - $$PWD/qqmljsengine_p.h \ - $$PWD/qqmljsgrammar_p.h \ - $$PWD/qqmljslexer_p.h \ - $$PWD/qqmljsmemorypool_p.h \ - $$PWD/qqmljsparser_p.h \ - $$PWD/qqmljsglobal_p.h \ - $$PWD/qqmljskeywords_p.h \ - -SOURCES += \ - $$PWD/qqmljsast.cpp \ - $$PWD/qqmljsastvisitor.cpp \ - $$PWD/qqmljsengine_p.cpp \ - $$PWD/qqmljsgrammar.cpp \ - $$PWD/qqmljslexer.cpp \ - $$PWD/qqmljsparser.cpp \ - -OTHER_FILES += \ - $$PWD/qqmljs.g diff --git a/src/qml/qml/parser/qqmljs.g b/src/qml/qml/parser/qqmljs.g deleted file mode 100644 index 5d279ef1a2..0000000000 --- a/src/qml/qml/parser/qqmljs.g +++ /dev/null @@ -1,3063 +0,0 @@ ----------------------------------------------------------------------------- --- --- Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). --- Contact: http://www.qt-project.org/legal --- --- This file is part of the QtQml module of the Qt Toolkit. --- --- $QT_BEGIN_LICENSE:LGPL-ONLY$ --- GNU Lesser General Public License Usage --- This file may be used under the terms of the GNU Lesser --- General Public License version 2.1 as published by the Free Software --- Foundation and appearing in the file LICENSE.LGPL included in the --- packaging of this file. Please review the following information to --- ensure the GNU Lesser General Public License version 2.1 requirements --- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. --- --- If you have questions regarding the use of this file, please contact --- us via http://www.qt-project.org/. --- --- $QT_END_LICENSE$ --- ----------------------------------------------------------------------------- - -%parser QQmlJSGrammar -%decl qqmljsparser_p.h -%impl qqmljsparser.cpp -%expect 5 -%expect-rr 2 - -%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" -%token T_BREAK "break" T_CASE "case" T_CATCH "catch" -%token T_COLON ":" T_COMMA "," T_CONTINUE "continue" -%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/" -%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "." -%token T_ELSE "else" T_EQ "=" T_EQ_EQ "==" -%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for" -%token T_FUNCTION "function" T_GE ">=" T_GT ">" -%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>" -%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if" -%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{" -%token T_LBRACKET "[" T_LE "<=" T_LPAREN "(" -%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<=" -%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--" -%token T_NEW "new" T_NOT "!" T_NOT_EQ "!=" -%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|" -%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+" -%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?" -%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%" -%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")" -%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*" -%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal" -%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly" -%token T_SWITCH "switch" T_THIS "this" T_THROW "throw" -%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof" -%token T_VAR "var" T_VOID "void" T_WHILE "while" -%token T_WITH "with" T_XOR "^" T_XOR_EQ "^=" -%token T_NULL "null" T_TRUE "true" T_FALSE "false" -%token T_CONST "const" -%token T_DEBUGGER "debugger" -%token T_RESERVED_WORD "reserved word" -%token T_MULTILINE_STRING_LITERAL "multiline string literal" -%token T_COMMENT "comment" -%token T_COMPATIBILITY_SEMICOLON - ---- context keywords. -%token T_PUBLIC "public" -%token T_IMPORT "import" -%token T_AS "as" -%token T_ON "on" -%token T_GET "get" -%token T_SET "set" - -%token T_ERROR - ---- feed tokens -%token T_FEED_UI_PROGRAM -%token T_FEED_UI_OBJECT_MEMBER -%token T_FEED_JS_STATEMENT -%token T_FEED_JS_EXPRESSION -%token T_FEED_JS_SOURCE_ELEMENT -%token T_FEED_JS_PROGRAM - -%nonassoc SHIFT_THERE -%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET -%nonassoc REDUCE_HERE - -%start TopLevel - -/./**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljsengine_p.h" -#include "qqmljslexer_p.h" -#include "qqmljsast_p.h" -#include "qqmljsmemorypool_p.h" - -#include -#include - -#include - -./ - -/:/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// -// W A R N I N G -// ------------- -// -// 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 -#define QQMLJSPARSER_P_H - -#include "qqmljsglobal_p.h" -#include "qqmljsgrammar_p.h" -#include "qqmljsast_p.h" -#include "qqmljsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected $table -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyAssignment *PropertyAssignment; - AST::PropertyAssignmentList *PropertyAssignmentList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QQmlJS - - -:/ - - -/. - -#include "qqmljsparser_p.h" - -#include - -// -// W A R N I N G -// ------------- -// -// 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; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - program(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { -./ - --------------------------------------------------------------------------------------------------------- --- Declarative UI --------------------------------------------------------------------------------------------------------- - -TopLevel: T_FEED_UI_PROGRAM UiProgram ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_STATEMENT Statement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_EXPRESSION Expression ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_PROGRAM Program ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -UiProgram: UiImportListOpt UiRootMember ; -/. -case $rule_number: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; -./ - -UiImportListOpt: Empty ; -UiImportListOpt: UiImportList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; -./ - -UiImportList: UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; -./ - -UiImportList: UiImportList UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; -./ - -ImportId: MemberExpression ; - -UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->semicolonToken = loc(2); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; -./ - -UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; -./ - - -UiImportHead: T_IMPORT ImportId ; -/. -case $rule_number: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; -./ - -Empty: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiRootMember: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMemberList UiObjectMember ; -/. -case $rule_number: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; -./ - -UiArrayMemberList: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; -./ - -UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ; -/. -case $rule_number: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectDefinition: UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiObjectDefinition ; - -UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; -./ - -UiScriptStatement: Block ; -UiScriptStatement: EmptyStatement ; -UiScriptStatement: ExpressionStatement ; -UiScriptStatement: IfStatement ; -UiScriptStatement: WithStatement ; -UiScriptStatement: SwitchStatement ; -UiScriptStatement: TryStatement ; - -UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ; -/. -case $rule_number: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiPropertyType: T_VAR ; -UiPropertyType: T_RESERVED_WORD ; -UiPropertyType: T_IDENTIFIER ; - -UiParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiParameterListOpt: UiParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; -./ - -UiParameterList: UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->propertyTypeToken = loc(3); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -UiObjectMember: VariableStatement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -JsIdentifier: T_IDENTIFIER; - -JsIdentifier: T_PROPERTY ; -JsIdentifier: T_SIGNAL ; -JsIdentifier: T_READONLY ; -JsIdentifier: T_ON ; -JsIdentifier: T_GET ; -JsIdentifier: T_SET ; - --------------------------------------------------------------------------------------------------------- --- Expressions --------------------------------------------------------------------------------------------------------- - -PrimaryExpression: T_THIS ; -/. -case $rule_number: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: JsIdentifier ; -/. -case $rule_number: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NULL ; -/. -case $rule_number: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_TRUE ; -/. -case $rule_number: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_FALSE ; -/. -case $rule_number: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_MULTILINE_STRING_LITERAL ; -/.case $rule_number:./ - -PrimaryExpression: T_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_EQ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - --- PrimaryExpression: T_LBRACE T_RBRACE ; --- /. --- case $rule_number: { --- sym(1).Node = new (pool) AST::ObjectLiteral(); --- } break; --- ./ - -PrimaryExpression: T_LBRACE PropertyAssignmentListOpt T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyAssignmentList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACE PropertyAssignmentList T_COMMA T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyAssignmentList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LPAREN Expression T_RPAREN ; -/. -case $rule_number: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiQualifiedId: MemberExpression ; -/. -case $rule_number: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; -./ - -ElementList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; -./ - -ElementList: Elision AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; -./ - -ElementList: ElementList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ElementList: ElementList T_COMMA Elision AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -Elision: T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; -./ - -Elision: Elision T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyAssignment: PropertyName T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyAssignment: T_GET PropertyName T_LPAREN T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( - 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); - sym(1).Node = node; -} break; -./ - -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_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: ReservedIdentifier ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -ReservedIdentifier: T_BREAK ; -ReservedIdentifier: T_CASE ; -ReservedIdentifier: T_CATCH ; -ReservedIdentifier: T_CONTINUE ; -ReservedIdentifier: T_DEFAULT ; -ReservedIdentifier: T_DELETE ; -ReservedIdentifier: T_DO ; -ReservedIdentifier: T_ELSE ; -ReservedIdentifier: T_FALSE ; -ReservedIdentifier: T_FINALLY ; -ReservedIdentifier: T_FOR ; -ReservedIdentifier: T_FUNCTION ; -ReservedIdentifier: T_IF ; -ReservedIdentifier: T_IN ; -ReservedIdentifier: T_INSTANCEOF ; -ReservedIdentifier: T_NEW ; -ReservedIdentifier: T_NULL ; -ReservedIdentifier: T_RETURN ; -ReservedIdentifier: T_SWITCH ; -ReservedIdentifier: T_THIS ; -ReservedIdentifier: T_THROW ; -ReservedIdentifier: T_TRUE ; -ReservedIdentifier: T_TRY ; -ReservedIdentifier: T_TYPEOF ; -ReservedIdentifier: T_VAR ; -ReservedIdentifier: T_VOID ; -ReservedIdentifier: T_WHILE ; -ReservedIdentifier: T_CONST ; -ReservedIdentifier: T_DEBUGGER ; -ReservedIdentifier: T_RESERVED_WORD ; -ReservedIdentifier: T_WITH ; - -PropertyIdentifier: JsIdentifier ; -PropertyIdentifier: ReservedIdentifier ; - -MemberExpression: PrimaryExpression ; -MemberExpression: FunctionExpression ; - -MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -MemberExpression: MemberExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; -./ - -NewExpression: MemberExpression ; - -NewExpression: T_NEW NewExpression ; -/. -case $rule_number: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; -./ - -CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -ArgumentListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ArgumentListOpt: ArgumentList ; -/. -case $rule_number: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; -./ - -ArgumentList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; -./ - -ArgumentList: ArgumentList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -LeftHandSideExpression: NewExpression ; -LeftHandSideExpression: CallExpression ; -PostfixExpression: LeftHandSideExpression ; - -PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; -/. -case $rule_number: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; -/. -case $rule_number: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -UnaryExpression: PostfixExpression ; - -UnaryExpression: T_DELETE UnaryExpression ; -/. -case $rule_number: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_VOID UnaryExpression ; -/. -case $rule_number: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TYPEOF UnaryExpression ; -/. -case $rule_number: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TILDE UnaryExpression ; -/. -case $rule_number: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_NOT UnaryExpression ; -/. -case $rule_number: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: UnaryExpression ; - -MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: MultiplicativeExpression ; - -AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: AdditiveExpression ; - -ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: ShiftExpression ; - -RelationalExpression: RelationalExpression T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_IN ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: ShiftExpression ; - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: RelationalExpression ; - -EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: RelationalExpressionNotIn ; - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpression: EqualityExpression ; - -BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; - -BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpression: BitwiseANDExpression ; - -BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; - -BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpression: BitwiseXORExpression ; - -BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; - -BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpression: BitwiseORExpression ; - -LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; - -LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpression: LogicalANDExpression ; - -LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; - -LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ConditionalExpression: LogicalORExpression ; - -ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -ConditionalExpressionNotIn: LogicalORExpressionNotIn ; - -ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -AssignmentExpression: ConditionalExpression ; - -AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentExpressionNotIn: ConditionalExpressionNotIn ; - -AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentOperator: T_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::Assign; -} break; -./ - -AssignmentOperator: T_STAR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMul; -} break; -./ - -AssignmentOperator: T_DIVIDE_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceDiv; -} break; -./ - -AssignmentOperator: T_REMAINDER_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMod; -} break; -./ - -AssignmentOperator: T_PLUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAdd; -} break; -./ - -AssignmentOperator: T_MINUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceSub; -} break; -./ - -AssignmentOperator: T_LT_LT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; -./ - -AssignmentOperator: T_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; -./ - -AssignmentOperator: T_GT_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; -./ - -AssignmentOperator: T_AND_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAnd; -} break; -./ - -AssignmentOperator: T_XOR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceXor; -} break; -./ - -AssignmentOperator: T_OR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceOr; -} break; -./ - -Expression: AssignmentExpression ; - -Expression: Expression T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionOpt: Expression ; - -ExpressionNotIn: AssignmentExpressionNotIn ; - -ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionNotInOpt: ExpressionNotIn ; - -Statement: Block ; -Statement: VariableStatement ; -Statement: EmptyStatement ; -Statement: ExpressionStatement ; -Statement: IfStatement ; -Statement: IterationStatement ; -Statement: ContinueStatement ; -Statement: BreakStatement ; -Statement: ReturnStatement ; -Statement: WithStatement ; -Statement: LabelledStatement ; -Statement: SwitchStatement ; -Statement: ThrowStatement ; -Statement: TryStatement ; -Statement: DebuggerStatement ; - - -Block: T_LBRACE StatementListOpt T_RBRACE ; -/. -case $rule_number: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -StatementList: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; -./ - -StatementList: StatementList Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; -./ - -StatementListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -StatementListOpt: StatementList ; -/. -case $rule_number: { - sym(1).Node = sym(1).StatementList->finish (); -} break; -./ - -VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; -/. -case $rule_number: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -VariableDeclarationKind: T_CONST ; -/. -case $rule_number: { - sym(1).ival = T_CONST; -} break; -./ - -VariableDeclarationKind: T_VAR ; -/. -case $rule_number: { - sym(1).ival = T_VAR; -} break; -./ - -VariableDeclarationList: VariableDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; -/. -case $rule_number: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; -./ - -VariableDeclaration: JsIdentifier InitialiserOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -Initialiser: T_EQ AssignmentExpression ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserOpt: Initialiser ; - -InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserNotInOpt: InitialiserNotIn ; - -EmptyStatement: T_SEMICOLON ; -/. -case $rule_number: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; -./ - -ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ExpressionStatement: Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - - -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 ; -/. -case $rule_number: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; -/. -case $rule_number: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; - if (lexer->qmlMode()) { - const QString msg = qApp->translate("QQmlParser", "Deprecated JavaScript `with' statement detected in QML expression. Support for this will be removed in Qt 5.2!"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, node->withToken, msg)); - } -} break; -./ - -SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; -/. -case $rule_number: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; -./ - -CaseClauses: CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; -./ - -CaseClauses: CaseClauses CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; -./ - -CaseClausesOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -CaseClausesOpt: CaseClauses ; -/. -case $rule_number: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; -./ - -CaseClause: T_CASE Expression T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; -./ - -DefaultClause: T_DEFAULT T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -LabelledStatement: JsIdentifier 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; -./ - -ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ThrowStatement: T_THROW Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ; -/. -case $rule_number: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -Finally: T_FINALLY Block ; -/. -case $rule_number: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; -./ - -DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -DebuggerStatement: T_DEBUGGER T_SEMICOLON ; -/. -case $rule_number: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - --- 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: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; -./ - -FunctionExpression: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} 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 ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -FormalParameterList: FormalParameterList T_COMMA JsIdentifier ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -FormalParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FormalParameterListOpt: FormalParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; -./ - -FunctionBodyOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FunctionBodyOpt: FunctionBody ; - -FunctionBody: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; -./ - -Program: Empty ; - -Program: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; -./ - -SourceElements: SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; -./ - -SourceElements: SourceElements SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; -./ - -SourceElement: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; -./ - -SourceElement: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; -./ - -PropertyAssignmentListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -PropertyAssignmentListOpt: PropertyAssignmentList ; - -/. - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) - || t_action(errorState, T_COMPATIBILITY_SEMICOLON))) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QQmlParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QQmlParser", "Syntax error"); - else - msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QQmlParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - -./ -/: -QT_QML_END_NAMESPACE - - - -#endif // QQMLJSPARSER_P_H -:/ diff --git a/src/qml/qml/parser/qqmljsast.cpp b/src/qml/qml/parser/qqmljsast.cpp deleted file mode 100644 index ea0df4a537..0000000000 --- a/src/qml/qml/parser/qqmljsast.cpp +++ /dev/null @@ -1,958 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljsast_p.h" - -#include "qqmljsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -void Node::accept(Visitor *visitor) -{ - if (visitor->preVisit(this)) { - accept0(visitor); - } - visitor->postVisit(this); -} - -void Node::accept(Node *node, Visitor *visitor) -{ - if (node) - node->accept(visitor); -} - -ExpressionNode *Node::expressionCast() -{ - return 0; -} - -BinaryExpression *Node::binaryExpressionCast() -{ - return 0; -} - -Statement *Node::statementCast() -{ - return 0; -} - -UiObjectMember *Node::uiObjectMemberCast() -{ - return 0; -} - -ExpressionNode *ExpressionNode::expressionCast() -{ - return this; -} - -BinaryExpression *BinaryExpression::binaryExpressionCast() -{ - return this; -} - -Statement *Statement::statementCast() -{ - return this; -} - -UiObjectMember *UiObjectMember::uiObjectMemberCast() -{ - return this; -} - -void NestedExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - visitor->endVisit(this); -} - -void ThisExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void IdentifierExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NullExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void TrueLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void FalseLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void RegExpLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - accept(elision, visitor); - } - - visitor->endVisit(this); -} - -void ObjectLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(properties, visitor); - } - - visitor->endVisit(this); -} - -void ElementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ElementList *it = this; it; it = it->next) { - accept(it->elision, visitor); - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void Elision::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void PropertyNameAndValue::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(name, visitor); - accept(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); - } - } - - visitor->endVisit(this); -} - -void IdentifierPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void FieldMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void NewMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void NewExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void CallExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void ArgumentList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ArgumentList *it = this; it; it = it->next) { - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void PostIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void PostDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void DeleteExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void VoidExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TypeOfExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryPlusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryMinusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TildeExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void NotExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void BinaryExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void ConditionalExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void Expression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void Block::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void StatementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (StatementList *it = this; it; it = it->next) { - accept(it->statement, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - } - - visitor->endVisit(this); -} - -void VariableDeclarationList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (VariableDeclarationList *it = this; it; it = it->next) { - accept(it->declaration, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void EmptyStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ExpressionStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void IfStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void DoWhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ContinueStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void BreakStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ReturnStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WithStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void SwitchStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(block, visitor); - } - - visitor->endVisit(this); -} - -void CaseBlock::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(clauses, visitor); - accept(defaultClause, visitor); - accept(moreClauses, visitor); - } - - visitor->endVisit(this); -} - -void CaseClauses::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (CaseClauses *it = this; it; it = it->next) { - accept(it->clause, visitor); - } - } - - visitor->endVisit(this); -} - -void CaseClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void DefaultClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void LabelledStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ThrowStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TryStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(catchExpression, visitor); - accept(finallyExpression, visitor); - } - - visitor->endVisit(this); -} - -void Catch::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void Finally::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void FunctionDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FunctionExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FormalParameterList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void FunctionBody::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void Program::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void SourceElements::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (SourceElements *it = this; it; it = it->next) { - accept(it->element, visitor); - } - } - - visitor->endVisit(this); -} - -void FunctionSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - } - - visitor->endVisit(this); -} - -void StatementSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void DebuggerStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiProgram::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(imports, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiPublicMember::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(binding, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectDefinition::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectInitializer::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiParameterList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - visitor->endVisit(this); -} - -void UiObjectBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiScriptBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiObjectMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiArrayMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiQualifiedId::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiImport::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(importUri, visitor); - } - - visitor->endVisit(this); -} - -void UiImportList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(import, visitor); - accept(next, visitor); - } - - visitor->endVisit(this); -} - -void UiSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(sourceElement, visitor); - } - - visitor->endVisit(this); -} - -} } // namespace QQmlJS::AST - -QT_QML_END_NAMESPACE - - diff --git a/src/qml/qml/parser/qqmljsast_p.h b/src/qml/qml/parser/qqmljsast_p.h deleted file mode 100644 index 01a872f1e8..0000000000 --- a/src/qml/qml/parser/qqmljsast_p.h +++ /dev/null @@ -1,2705 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSAST_P_H -#define QQMLJSAST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljsastvisitor_p.h" -#include "qqmljsglobal_p.h" -#include "qqmljsmemorypool_p.h" - -#include - -QT_QML_BEGIN_NAMESPACE - -#define QQMLJS_DECLARE_AST_NODE(name) \ - enum { K = Kind_##name }; - -namespace QSOperator // ### rename -{ - -enum Op { - Add, - And, - InplaceAnd, - Assign, - BitAnd, - BitOr, - BitXor, - InplaceSub, - Div, - InplaceDiv, - Equal, - Ge, - Gt, - In, - InplaceAdd, - InstanceOf, - Le, - LShift, - InplaceLeftShift, - Lt, - Mod, - InplaceMod, - Mul, - InplaceMul, - NotEqual, - Or, - InplaceOr, - RShift, - InplaceRightShift, - StrictEqual, - StrictNotEqual, - Sub, - URShift, - InplaceURightShift, - InplaceXor -}; - -} // namespace QSOperator - -namespace QQmlJS { - -namespace AST { - -template -_T1 cast(_T2 *ast) -{ - if (ast && ast->kind == static_cast<_T1>(0)->K) - return static_cast<_T1>(ast); - - return 0; -} - -class QML_PARSER_EXPORT Node: public Managed -{ -public: - enum Kind { - Kind_Undefined, - - Kind_ArgumentList, - Kind_ArrayLiteral, - Kind_ArrayMemberExpression, - Kind_BinaryExpression, - Kind_Block, - Kind_BreakStatement, - Kind_CallExpression, - Kind_CaseBlock, - Kind_CaseClause, - Kind_CaseClauses, - Kind_Catch, - Kind_ConditionalExpression, - Kind_ContinueStatement, - Kind_DebuggerStatement, - Kind_DefaultClause, - Kind_DeleteExpression, - Kind_DoWhileStatement, - Kind_ElementList, - Kind_Elision, - Kind_EmptyStatement, - Kind_Expression, - Kind_ExpressionStatement, - Kind_FalseLiteral, - Kind_FieldMemberExpression, - Kind_Finally, - Kind_ForEachStatement, - Kind_ForStatement, - Kind_FormalParameterList, - Kind_FunctionBody, - Kind_FunctionDeclaration, - Kind_FunctionExpression, - Kind_FunctionSourceElement, - Kind_IdentifierExpression, - Kind_IdentifierPropertyName, - Kind_IfStatement, - Kind_LabelledStatement, - Kind_LocalForEachStatement, - Kind_LocalForStatement, - Kind_NewExpression, - Kind_NewMemberExpression, - Kind_NotExpression, - Kind_NullExpression, - Kind_NumericLiteral, - Kind_NumericLiteralPropertyName, - Kind_ObjectLiteral, - Kind_PostDecrementExpression, - Kind_PostIncrementExpression, - Kind_PreDecrementExpression, - Kind_PreIncrementExpression, - Kind_Program, - Kind_PropertyAssignmentList, - Kind_PropertyGetterSetter, - Kind_PropertyName, - Kind_PropertyNameAndValue, - Kind_RegExpLiteral, - Kind_ReturnStatement, - Kind_SourceElement, - Kind_SourceElements, - Kind_StatementList, - Kind_StatementSourceElement, - Kind_StringLiteral, - Kind_StringLiteralPropertyName, - Kind_SwitchStatement, - Kind_ThisExpression, - Kind_ThrowStatement, - Kind_TildeExpression, - Kind_TrueLiteral, - Kind_TryStatement, - Kind_TypeOfExpression, - Kind_UnaryMinusExpression, - Kind_UnaryPlusExpression, - Kind_VariableDeclaration, - Kind_VariableDeclarationList, - Kind_VariableStatement, - Kind_VoidExpression, - Kind_WhileStatement, - Kind_WithStatement, - Kind_NestedExpression, - - Kind_UiArrayBinding, - Kind_UiImport, - Kind_UiImportList, - Kind_UiObjectBinding, - Kind_UiObjectDefinition, - Kind_UiObjectInitializer, - Kind_UiObjectMemberList, - Kind_UiArrayMemberList, - Kind_UiProgram, - Kind_UiParameterList, - Kind_UiPublicMember, - Kind_UiQualifiedId, - Kind_UiScriptBinding, - Kind_UiSourceElement - }; - - inline Node() - : kind(Kind_Undefined) {} - - // NOTE: node destructors are never called, - // instead we block free the memory - // (see the NodePool class) - virtual ~Node() {} - - virtual ExpressionNode *expressionCast(); - virtual BinaryExpression *binaryExpressionCast(); - virtual Statement *statementCast(); - virtual UiObjectMember *uiObjectMemberCast(); - - void accept(Visitor *visitor); - static void accept(Node *node, Visitor *visitor); - - inline static void acceptChild(Node *node, Visitor *visitor) - { return accept(node, visitor); } // ### remove - - virtual void accept0(Visitor *visitor) = 0; - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - -// attributes - int kind; -}; - -class QML_PARSER_EXPORT ExpressionNode: public Node -{ -public: - ExpressionNode() {} - - virtual ExpressionNode *expressionCast(); -}; - -class QML_PARSER_EXPORT Statement: public Node -{ -public: - Statement() {} - - virtual Statement *statementCast(); -}; - -class QML_PARSER_EXPORT NestedExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NestedExpression) - - NestedExpression(ExpressionNode *expression) - : expression(expression) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lparenToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *expression; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ThisExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(ThisExpression) - - ThisExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return thisToken; } - - virtual SourceLocation lastSourceLocation() const - { return thisToken; } - -// attributes - SourceLocation thisToken; -}; - -class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(IdentifierExpression) - - IdentifierExpression(const QStringRef &n): - name (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - -// attributes - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NullExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NullExpression) - - NullExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return nullToken; } - - virtual SourceLocation lastSourceLocation() const - { return nullToken; } - -// attributes - SourceLocation nullToken; -}; - -class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(TrueLiteral) - - TrueLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return trueToken; } - - virtual SourceLocation lastSourceLocation() const - { return trueToken; } - -// attributes - SourceLocation trueToken; -}; - -class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(FalseLiteral) - - FalseLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return falseToken; } - - virtual SourceLocation lastSourceLocation() const - { return falseToken; } - -// attributes - SourceLocation falseToken; -}; - -class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NumericLiteral) - - NumericLiteral(double v): - value(v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - double value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT StringLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(StringLiteral) - - StringLiteral(const QStringRef &v): - value (v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(RegExpLiteral) - - RegExpLiteral(const QStringRef &p, int f): - pattern (p), flags (f) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef pattern; - int flags; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(ArrayLiteral) - - ArrayLiteral(Elision *e): - elements (0), elision (e) - { kind = K; } - - ArrayLiteral(ElementList *elts): - elements (elts), elision (0) - { kind = K; } - - ArrayLiteral(ElementList *elts, Elision *e): - elements (elts), elision (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbracketToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ElementList *elements; - Elision *elision; - SourceLocation lbracketToken; - SourceLocation commaToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(ObjectLiteral) - - ObjectLiteral(): - properties (0) { kind = K; } - - ObjectLiteral(PropertyAssignmentList *plist): - properties (plist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - PropertyAssignmentList *properties; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT Elision: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(Elision) - - Elision(): - next (this) { kind = K; } - - Elision(Elision *previous) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return commaToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : commaToken; } - - inline Elision *finish () - { - Elision *front = next; - next = 0; - return front; - } - -// attributes - Elision *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT ElementList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(ElementList) - - ElementList(Elision *e, ExpressionNode *expr): - elision (e), expression (expr), next (this) - { kind = K; } - - ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): - elision (e), expression (expr) - { - kind = K; - next = previous->next; - previous->next = this; - } - - inline ElementList *finish () - { - ElementList *front = next; - next = 0; - return front; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (elision) - return elision->firstSourceLocation(); - return expression->firstSourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - -// attributes - Elision *elision; - ExpressionNode *expression; - ElementList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PropertyName: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(PropertyName) - - PropertyName() { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return propertyNameToken; } - - virtual SourceLocation lastSourceLocation() const - { return propertyNameToken; } - -// attributes - SourceLocation propertyNameToken; -}; - -class QML_PARSER_EXPORT PropertyAssignment: public Node -{ -public: - PropertyAssignment() {} -}; - -class QML_PARSER_EXPORT PropertyAssignmentList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(PropertyAssignmentList) - - PropertyAssignmentList(PropertyAssignment *assignment) - : assignment(assignment) - , next(this) - { kind = K; } - - PropertyAssignmentList(PropertyAssignmentList *previous, PropertyAssignment *assignment) - : assignment(assignment) - { - kind = K; - next = previous->next; - 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 SourceLocation firstSourceLocation() const - { return name->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return value->lastSourceLocation(); } - -// attributes - PropertyName *name; - SourceLocation colonToken; - ExpressionNode *value; - 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 -{ -public: - QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName) - - IdentifierPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName -{ -public: - QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName) - - StringLiteralPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName -{ -public: - QQMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName) - - NumericLiteralPropertyName(double n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - double id; -}; - -class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(ArrayMemberExpression) - - ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): - base (b), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ExpressionNode *base; - ExpressionNode *expression; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(FieldMemberExpression) - - FieldMemberExpression(ExpressionNode *b, const QStringRef &n): - base (b), name (n) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - - // attributes - ExpressionNode *base; - QStringRef name; - SourceLocation dotToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NewMemberExpression) - - NewMemberExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - - // attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation newToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT NewExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NewExpression) - - NewExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation newToken; -}; - -class QML_PARSER_EXPORT CallExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(CallExpression) - - CallExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ArgumentList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(ArgumentList) - - ArgumentList(ExpressionNode *e): - expression (e), next (this) - { kind = K; } - - ArgumentList(ArgumentList *previous, ExpressionNode *e): - expression (e) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - - inline ArgumentList *finish () - { - ArgumentList *front = next; - next = 0; - return front; - } - -// attributes - ExpressionNode *expression; - ArgumentList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(PostIncrementExpression) - - PostIncrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return incrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(PostDecrementExpression) - - PostDecrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return decrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(DeleteExpression) - - DeleteExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return deleteToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation deleteToken; -}; - -class QML_PARSER_EXPORT VoidExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(VoidExpression) - - VoidExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return voidToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation voidToken; -}; - -class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(TypeOfExpression) - - TypeOfExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return typeofToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation typeofToken; -}; - -class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(PreIncrementExpression) - - PreIncrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return incrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(PreDecrementExpression) - - PreDecrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return decrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(UnaryPlusExpression) - - UnaryPlusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return plusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation plusToken; -}; - -class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(UnaryMinusExpression) - - UnaryMinusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return minusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation minusToken; -}; - -class QML_PARSER_EXPORT TildeExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(TildeExpression) - - TildeExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tildeToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation tildeToken; -}; - -class QML_PARSER_EXPORT NotExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(NotExpression) - - NotExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return notToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation notToken; -}; - -class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(BinaryExpression) - - BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): - left (l), op (o), right (r) - { kind = K; } - - virtual BinaryExpression *binaryExpressionCast(); - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - int op; - ExpressionNode *right; - SourceLocation operatorToken; -}; - -class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(ConditionalExpression) - - ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return ko->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - ExpressionNode *ok; - ExpressionNode *ko; - SourceLocation questionToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename -{ -public: - QQMLJS_DECLARE_AST_NODE(Expression) - - Expression(ExpressionNode *l, ExpressionNode *r): - left (l), right (r) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - ExpressionNode *right; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT Block: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(Block) - - Block(StatementList *slist): - statements (slist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - - // attributes - StatementList *statements; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT StatementList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(StatementList) - - StatementList(Statement *stmt): - statement (stmt), next (this) - { kind = K; } - - StatementList(StatementList *previous, Statement *stmt): - statement (stmt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); } - - inline StatementList *finish () - { - StatementList *front = next; - next = 0; - return front; - } - -// attributes - Statement *statement; - StatementList *next; -}; - -class QML_PARSER_EXPORT VariableStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(VariableStatement) - - VariableStatement(VariableDeclarationList *vlist): - declarations (vlist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declarationKindToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - VariableDeclarationList *declarations; - SourceLocation declarationKindToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT VariableDeclaration: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(VariableDeclaration) - - VariableDeclaration(const QStringRef &n, ExpressionNode *e): - name (n), expression (e), readOnly(false) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression ? expression->lastSourceLocation() : identifierToken; } - -// attributes - QStringRef name; - ExpressionNode *expression; - bool readOnly; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT VariableDeclarationList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(VariableDeclarationList) - - VariableDeclarationList(VariableDeclaration *decl): - declaration (decl), next (this) - { kind = K; } - - VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): - declaration (decl) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return declaration->lastSourceLocation(); - } - - inline VariableDeclarationList *finish (bool readOnly) - { - VariableDeclarationList *front = next; - next = 0; - if (readOnly) { - VariableDeclarationList *vdl; - for (vdl = front; vdl != 0; vdl = vdl->next) - vdl->declaration->readOnly = true; - } - return front; - } - -// attributes - VariableDeclaration *declaration; - VariableDeclarationList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT EmptyStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(EmptyStatement) - - EmptyStatement() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return semicolonToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ExpressionStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ExpressionStatement) - - ExpressionStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT IfStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(IfStatement) - - IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return ifToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (ko) - return ko->lastSourceLocation(); - - return ok->lastSourceLocation(); - } - -// attributes - ExpressionNode *expression; - Statement *ok; - Statement *ko; - SourceLocation ifToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation elseToken; -}; - -class QML_PARSER_EXPORT DoWhileStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(DoWhileStatement) - - DoWhileStatement(Statement *stmt, ExpressionNode *e): - statement (stmt), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return doToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - Statement *statement; - ExpressionNode *expression; - SourceLocation doToken; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WhileStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(WhileStatement) - - WhileStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return whileToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ForStatement) - - ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - initialiser (i), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(LocalForStatement) - - LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - declarations (vlist), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclarationList *declarations; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForEachStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ForEachStatement) - - ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): - initialiser (i), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForEachStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(LocalForEachStatement) - - LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): - declaration (v), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclaration *declaration; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ContinueStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ContinueStatement) - - ContinueStatement(const QStringRef &l = QStringRef()): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return continueToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef label; - SourceLocation continueToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT BreakStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(BreakStatement) - - BreakStatement(const QStringRef &l): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return breakToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - QStringRef label; - SourceLocation breakToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ReturnStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ReturnStatement) - - ReturnStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return returnToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation returnToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WithStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(WithStatement) - - WithStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return withToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation withToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseBlock: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(CaseBlock) - - CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): - clauses (c), defaultClause (d), moreClauses (r) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - CaseClauses *clauses; - DefaultClause *defaultClause; - CaseClauses *moreClauses; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT SwitchStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(SwitchStatement) - - SwitchStatement(ExpressionNode *e, CaseBlock *b): - expression (e), block (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return switchToken; } - - virtual SourceLocation lastSourceLocation() const - { return block->rbraceToken; } - -// attributes - ExpressionNode *expression; - CaseBlock *block; - SourceLocation switchToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseClause: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(CaseClause) - - CaseClause(ExpressionNode *e, StatementList *slist): - expression (e), statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return caseToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - ExpressionNode *expression; - StatementList *statements; - SourceLocation caseToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT CaseClauses: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(CaseClauses) - - CaseClauses(CaseClause *c): - clause (c), next (this) - { kind = K; } - - CaseClauses(CaseClauses *previous, CaseClause *c): - clause (c) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return clause->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); } - - inline CaseClauses *finish () - { - CaseClauses *front = next; - next = 0; - return front; - } - -//attributes - CaseClause *clause; - CaseClauses *next; -}; - -class QML_PARSER_EXPORT DefaultClause: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(DefaultClause) - - DefaultClause(StatementList *slist): - statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return defaultToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - StatementList *statements; - SourceLocation defaultToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT LabelledStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(LabelledStatement) - - LabelledStatement(const QStringRef &l, Statement *stmt): - label (l), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef label; - Statement *statement; - SourceLocation identifierToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT ThrowStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(ThrowStatement) - - ThrowStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return throwToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - ExpressionNode *expression; - SourceLocation throwToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT Catch: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(Catch) - - Catch(const QStringRef &n, Block *stmt): - name (n), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return catchToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef name; - Block *statement; - SourceLocation catchToken; - SourceLocation lparenToken; - SourceLocation identifierToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT Finally: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(Finally) - - Finally(Block *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return finallyToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement ? statement->lastSourceLocation() : finallyToken; } - -// attributes - Block *statement; - SourceLocation finallyToken; -}; - -class QML_PARSER_EXPORT TryStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(TryStatement) - - TryStatement(Statement *stmt, Catch *c, Finally *f): - statement (stmt), catchExpression (c), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Finally *f): - statement (stmt), catchExpression (0), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Catch *c): - statement (stmt), catchExpression (c), finallyExpression (0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tryToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (finallyExpression) - return finallyExpression->statement->rbraceToken; - else if (catchExpression) - return catchExpression->statement->rbraceToken; - - return statement->lastSourceLocation(); - } - -// attributes - Statement *statement; - Catch *catchExpression; - Finally *finallyExpression; - SourceLocation tryToken; -}; - -class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode -{ -public: - QQMLJS_DECLARE_AST_NODE(FunctionExpression) - - FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - name (n), formals (f), body (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return functionToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - QStringRef name; - FormalParameterList *formals; - FunctionBody *body; - SourceLocation functionToken; - SourceLocation identifierToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression -{ -public: - QQMLJS_DECLARE_AST_NODE(FunctionDeclaration) - - FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - FunctionExpression(n, f, b) - { kind = K; } - - virtual void accept0(Visitor *visitor); -}; - -class QML_PARSER_EXPORT FormalParameterList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(FormalParameterList) - - FormalParameterList(const QStringRef &n): - name (n), next (this) - { kind = K; } - - FormalParameterList(FormalParameterList *previous, const QStringRef &n): - name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline FormalParameterList *finish () - { - FormalParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef name; - FormalParameterList *next; - SourceLocation commaToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT SourceElement: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(SourceElement) - - inline SourceElement() - { kind = K; } -}; - -class QML_PARSER_EXPORT SourceElements: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(SourceElements) - - SourceElements(SourceElement *elt): - element (elt), next (this) - { kind = K; } - - SourceElements(SourceElements *previous, SourceElement *elt): - element (elt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return element->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : element->lastSourceLocation(); } - - inline SourceElements *finish () - { - SourceElements *front = next; - next = 0; - return front; - } - -// attributes - SourceElement *element; - SourceElements *next; -}; - -class QML_PARSER_EXPORT FunctionBody: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(FunctionBody) - - FunctionBody(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT Program: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(Program) - - Program(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement -{ -public: - QQMLJS_DECLARE_AST_NODE(FunctionSourceElement) - - FunctionSourceElement(FunctionDeclaration *f): - declaration (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return declaration->lastSourceLocation(); } - -// attributes - FunctionDeclaration *declaration; -}; - -class QML_PARSER_EXPORT StatementSourceElement: public SourceElement -{ -public: - QQMLJS_DECLARE_AST_NODE(StatementSourceElement) - - StatementSourceElement(Statement *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - Statement *statement; -}; - -class QML_PARSER_EXPORT DebuggerStatement: public Statement -{ -public: - QQMLJS_DECLARE_AST_NODE(DebuggerStatement) - - DebuggerStatement() - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return debuggerToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation debuggerToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiQualifiedId: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiQualifiedId) - - UiQualifiedId(const QStringRef &name) - : next(this), name(name) - { kind = K; } - - UiQualifiedId(UiQualifiedId *previous, const QStringRef &name) - : name(name) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiQualifiedId *finish() - { - UiQualifiedId *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - -// attributes - UiQualifiedId *next; - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiImport: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiImport) - - UiImport(const QStringRef &fileName) - : fileName(fileName), importUri(0) - { kind = K; } - - UiImport(UiQualifiedId *uri) - : importUri(uri) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return importToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef fileName; - UiQualifiedId *importUri; - QStringRef importId; - SourceLocation importToken; - SourceLocation fileNameToken; - SourceLocation versionToken; - SourceLocation asToken; - SourceLocation importIdToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiImportList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiImportList) - - UiImportList(UiImport *import) - : import(import), - next(this) - { kind = K; } - - UiImportList(UiImportList *previous, UiImport *import) - : import(import) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiImportList *finish() - { - UiImportList *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return import->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : import->lastSourceLocation(); } - -// attributes - UiImport *import; - UiImportList *next; -}; - -class QML_PARSER_EXPORT UiObjectMember: public Node -{ -public: - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - - virtual UiObjectMember *uiObjectMemberCast(); -}; - -class QML_PARSER_EXPORT UiObjectMemberList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiObjectMemberList) - - UiObjectMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiObjectMemberList *finish() - { - UiObjectMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiObjectMemberList *next; - UiObjectMember *member; -}; - -class QML_PARSER_EXPORT UiProgram: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiProgram) - - UiProgram(UiImportList *imports, UiObjectMemberList *members) - : imports(imports), members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (imports) - return imports->firstSourceLocation(); - else if (members) - return members->firstSourceLocation(); - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (members) - return members->lastSourceLocation(); - else if (imports) - return imports->lastSourceLocation(); - return SourceLocation(); - } - -// attributes - UiImportList *imports; - UiObjectMemberList *members; -}; - -class QML_PARSER_EXPORT UiArrayMemberList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiArrayMemberList) - - UiArrayMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiArrayMemberList *finish() - { - UiArrayMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiArrayMemberList *next; - UiObjectMember *member; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT UiObjectInitializer: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiObjectInitializer) - - UiObjectInitializer(UiObjectMemberList *members) - : members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - SourceLocation lbraceToken; - UiObjectMemberList *members; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT UiParameterList: public Node -{ -public: - QQMLJS_DECLARE_AST_NODE(UiParameterList) - - UiParameterList(const QStringRef &t, const QStringRef &n): - type (t), name (n), next (this) - { kind = K; } - - UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): - type (t), name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *); - - virtual SourceLocation firstSourceLocation() const - { return propertyTypeToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline UiParameterList *finish () - { - UiParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef type; - QStringRef name; - UiParameterList *next; - SourceLocation commaToken; - SourceLocation propertyTypeToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiPublicMember) - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name) - : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name, - Statement *statement) - : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (defaultToken.isValid()) - return defaultToken; - else if (readonlyToken.isValid()) - return readonlyToken; - - return propertyToken; - } - - virtual SourceLocation lastSourceLocation() const - { - if (binding) - return binding->lastSourceLocation(); - if (statement) - return statement->lastSourceLocation(); - - return semicolonToken; - } - -// attributes - enum { Signal, Property } type; - QStringRef typeModifier; - QStringRef memberType; - QStringRef name; - Statement *statement; // initialized with a JS expression - UiObjectMember *binding; // initialized with a QML object or array. - bool isDefaultMember; - bool isReadonlyMember; - UiParameterList *parameters; - SourceLocation defaultToken; - SourceLocation readonlyToken; - SourceLocation propertyToken; - SourceLocation typeModifierToken; - SourceLocation typeToken; - SourceLocation identifierToken; - SourceLocation colonToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiObjectDefinition) - - UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return qualifiedTypeNameId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - -// attributes - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; -}; - -class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiSourceElement) - - UiSourceElement(Node *sourceElement) - : sourceElement(sourceElement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->firstSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->firstSourceLocation(); - - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->lastSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->lastSourceLocation(); - - return SourceLocation(); - } - - virtual void accept0(Visitor *visitor); - - -// attributes - Node *sourceElement; -}; - -class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiObjectBinding) - - UiObjectBinding(UiQualifiedId *qualifiedId, - UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedId(qualifiedId), - qualifiedTypeNameId(qualifiedTypeNameId), - initializer(initializer), - hasOnToken(false) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (hasOnToken && qualifiedTypeNameId) - return qualifiedTypeNameId->identifierToken; - - return qualifiedId->identifierToken; - } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - - virtual void accept0(Visitor *visitor); - - -// attributes - UiQualifiedId *qualifiedId; - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; - SourceLocation colonToken; - bool hasOnToken; -}; - -class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiScriptBinding) - - UiScriptBinding(UiQualifiedId *qualifiedId, - Statement *statement) - : qualifiedId(qualifiedId), - statement(statement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - Statement *statement; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember -{ -public: - QQMLJS_DECLARE_AST_NODE(UiArrayBinding) - - UiArrayBinding(UiQualifiedId *qualifiedId, - UiArrayMemberList *members) - : qualifiedId(qualifiedId), - members(members) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - UiArrayMemberList *members; - SourceLocation colonToken; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -} } // namespace AST - - - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/qml/qml/parser/qqmljsastfwd_p.h b/src/qml/qml/parser/qqmljsastfwd_p.h deleted file mode 100644 index fe5572c4b2..0000000000 --- a/src/qml/qml/parser/qqmljsastfwd_p.h +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSAST_FWD_P_H -#define QQMLJSAST_FWD_P_H - -#include "qqmljsglobal_p.h" - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -class SourceLocation -{ -public: - SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) - : offset(offset), length(length), - startLine(line), startColumn(column) - { } - - bool isValid() const { return length != 0; } - - quint32 begin() const { return offset; } - quint32 end() const { return offset + length; } - -// attributes - // ### encode - quint32 offset; - quint32 length; - quint32 startLine; - quint32 startColumn; -}; - -class Visitor; -class Node; -class ExpressionNode; -class Statement; -class ThisExpression; -class IdentifierExpression; -class NullExpression; -class TrueLiteral; -class FalseLiteral; -class NumericLiteral; -class StringLiteral; -class RegExpLiteral; -class ArrayLiteral; -class ObjectLiteral; -class ElementList; -class Elision; -class PropertyAssignmentList; -class PropertyGetterSetter; -class PropertyNameAndValue; -class PropertyName; -class IdentifierPropertyName; -class StringLiteralPropertyName; -class NumericLiteralPropertyName; -class ArrayMemberExpression; -class FieldMemberExpression; -class NewMemberExpression; -class NewExpression; -class CallExpression; -class ArgumentList; -class PostIncrementExpression; -class PostDecrementExpression; -class DeleteExpression; -class VoidExpression; -class TypeOfExpression; -class PreIncrementExpression; -class PreDecrementExpression; -class UnaryPlusExpression; -class UnaryMinusExpression; -class TildeExpression; -class NotExpression; -class BinaryExpression; -class ConditionalExpression; -class Expression; // ### rename -class Block; -class StatementList; -class VariableStatement; -class VariableDeclarationList; -class VariableDeclaration; -class EmptyStatement; -class ExpressionStatement; -class IfStatement; -class DoWhileStatement; -class WhileStatement; -class ForStatement; -class LocalForStatement; -class ForEachStatement; -class LocalForEachStatement; -class ContinueStatement; -class BreakStatement; -class ReturnStatement; -class WithStatement; -class SwitchStatement; -class CaseBlock; -class CaseClauses; -class CaseClause; -class DefaultClause; -class LabelledStatement; -class ThrowStatement; -class TryStatement; -class Catch; -class Finally; -class FunctionDeclaration; -class FunctionExpression; -class FormalParameterList; -class FunctionBody; -class Program; -class SourceElements; -class SourceElement; -class FunctionSourceElement; -class StatementSourceElement; -class DebuggerStatement; -class NestedExpression; - -// ui elements -class UiProgram; -class UiImportList; -class UiImport; -class UiPublicMember; -class UiParameterList; -class UiObjectDefinition; -class UiObjectInitializer; -class UiObjectBinding; -class UiScriptBinding; -class UiSourceElement; -class UiArrayBinding; -class UiObjectMember; -class UiObjectMemberList; -class UiArrayMemberList; -class UiQualifiedId; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/qml/qml/parser/qqmljsastvisitor.cpp b/src/qml/qml/parser/qqmljsastvisitor.cpp deleted file mode 100644 index be2a082f43..0000000000 --- a/src/qml/qml/parser/qqmljsastvisitor.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -Visitor::Visitor() -{ -} - -Visitor::~Visitor() -{ -} - -} } // namespace QQmlJS::AST - -QT_QML_END_NAMESPACE diff --git a/src/qml/qml/parser/qqmljsastvisitor_p.h b/src/qml/qml/parser/qqmljsastvisitor_p.h deleted file mode 100644 index ef022f617c..0000000000 --- a/src/qml/qml/parser/qqmljsastvisitor_p.h +++ /dev/null @@ -1,337 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSASTVISITOR_P_H -#define QQMLJSASTVISITOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljsastfwd_p.h" -#include "qqmljsglobal_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -class QML_PARSER_EXPORT Visitor -{ -public: - Visitor(); - virtual ~Visitor(); - - virtual bool preVisit(Node *) { return true; } - virtual void postVisit(Node *) {} - - // Ui - virtual bool visit(UiProgram *) { return true; } - virtual bool visit(UiImportList *) { return true; } - virtual bool visit(UiImport *) { return true; } - virtual bool visit(UiPublicMember *) { return true; } - virtual bool visit(UiSourceElement *) { return true; } - virtual bool visit(UiObjectDefinition *) { return true; } - virtual bool visit(UiObjectInitializer *) { return true; } - virtual bool visit(UiObjectBinding *) { return true; } - virtual bool visit(UiScriptBinding *) { return true; } - virtual bool visit(UiArrayBinding *) { return true; } - virtual bool visit(UiParameterList *) { return true; } - virtual bool visit(UiObjectMemberList *) { return true; } - virtual bool visit(UiArrayMemberList *) { return true; } - virtual bool visit(UiQualifiedId *) { return true; } - - virtual void endVisit(UiProgram *) {} - virtual void endVisit(UiImportList *) {} - virtual void endVisit(UiImport *) {} - virtual void endVisit(UiPublicMember *) {} - virtual void endVisit(UiSourceElement *) {} - virtual void endVisit(UiObjectDefinition *) {} - virtual void endVisit(UiObjectInitializer *) {} - virtual void endVisit(UiObjectBinding *) {} - virtual void endVisit(UiScriptBinding *) {} - virtual void endVisit(UiArrayBinding *) {} - virtual void endVisit(UiParameterList *) {} - virtual void endVisit(UiObjectMemberList *) {} - virtual void endVisit(UiArrayMemberList *) {} - virtual void endVisit(UiQualifiedId *) {} - - // QQmlJS - virtual bool visit(ThisExpression *) { return true; } - virtual void endVisit(ThisExpression *) {} - - virtual bool visit(IdentifierExpression *) { return true; } - virtual void endVisit(IdentifierExpression *) {} - - virtual bool visit(NullExpression *) { return true; } - virtual void endVisit(NullExpression *) {} - - virtual bool visit(TrueLiteral *) { return true; } - virtual void endVisit(TrueLiteral *) {} - - virtual bool visit(FalseLiteral *) { return true; } - virtual void endVisit(FalseLiteral *) {} - - virtual bool visit(StringLiteral *) { return true; } - virtual void endVisit(StringLiteral *) {} - - virtual bool visit(NumericLiteral *) { return true; } - virtual void endVisit(NumericLiteral *) {} - - virtual bool visit(RegExpLiteral *) { return true; } - virtual void endVisit(RegExpLiteral *) {} - - virtual bool visit(ArrayLiteral *) { return true; } - virtual void endVisit(ArrayLiteral *) {} - - virtual bool visit(ObjectLiteral *) { return true; } - virtual void endVisit(ObjectLiteral *) {} - - virtual bool visit(ElementList *) { return true; } - virtual void endVisit(ElementList *) {} - - virtual bool visit(Elision *) { return true; } - virtual void endVisit(Elision *) {} - - virtual bool visit(PropertyAssignmentList *) { return true; } - 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 void endVisit(NestedExpression *) {} - - virtual bool visit(IdentifierPropertyName *) { return true; } - virtual void endVisit(IdentifierPropertyName *) {} - - virtual bool visit(StringLiteralPropertyName *) { return true; } - virtual void endVisit(StringLiteralPropertyName *) {} - - virtual bool visit(NumericLiteralPropertyName *) { return true; } - virtual void endVisit(NumericLiteralPropertyName *) {} - - virtual bool visit(ArrayMemberExpression *) { return true; } - virtual void endVisit(ArrayMemberExpression *) {} - - virtual bool visit(FieldMemberExpression *) { return true; } - virtual void endVisit(FieldMemberExpression *) {} - - virtual bool visit(NewMemberExpression *) { return true; } - virtual void endVisit(NewMemberExpression *) {} - - virtual bool visit(NewExpression *) { return true; } - virtual void endVisit(NewExpression *) {} - - virtual bool visit(CallExpression *) { return true; } - virtual void endVisit(CallExpression *) {} - - virtual bool visit(ArgumentList *) { return true; } - virtual void endVisit(ArgumentList *) {} - - virtual bool visit(PostIncrementExpression *) { return true; } - virtual void endVisit(PostIncrementExpression *) {} - - virtual bool visit(PostDecrementExpression *) { return true; } - virtual void endVisit(PostDecrementExpression *) {} - - virtual bool visit(DeleteExpression *) { return true; } - virtual void endVisit(DeleteExpression *) {} - - virtual bool visit(VoidExpression *) { return true; } - virtual void endVisit(VoidExpression *) {} - - virtual bool visit(TypeOfExpression *) { return true; } - virtual void endVisit(TypeOfExpression *) {} - - virtual bool visit(PreIncrementExpression *) { return true; } - virtual void endVisit(PreIncrementExpression *) {} - - virtual bool visit(PreDecrementExpression *) { return true; } - virtual void endVisit(PreDecrementExpression *) {} - - virtual bool visit(UnaryPlusExpression *) { return true; } - virtual void endVisit(UnaryPlusExpression *) {} - - virtual bool visit(UnaryMinusExpression *) { return true; } - virtual void endVisit(UnaryMinusExpression *) {} - - virtual bool visit(TildeExpression *) { return true; } - virtual void endVisit(TildeExpression *) {} - - virtual bool visit(NotExpression *) { return true; } - virtual void endVisit(NotExpression *) {} - - virtual bool visit(BinaryExpression *) { return true; } - virtual void endVisit(BinaryExpression *) {} - - virtual bool visit(ConditionalExpression *) { return true; } - virtual void endVisit(ConditionalExpression *) {} - - virtual bool visit(Expression *) { return true; } - virtual void endVisit(Expression *) {} - - virtual bool visit(Block *) { return true; } - virtual void endVisit(Block *) {} - - virtual bool visit(StatementList *) { return true; } - virtual void endVisit(StatementList *) {} - - virtual bool visit(VariableStatement *) { return true; } - virtual void endVisit(VariableStatement *) {} - - virtual bool visit(VariableDeclarationList *) { return true; } - virtual void endVisit(VariableDeclarationList *) {} - - virtual bool visit(VariableDeclaration *) { return true; } - virtual void endVisit(VariableDeclaration *) {} - - virtual bool visit(EmptyStatement *) { return true; } - virtual void endVisit(EmptyStatement *) {} - - virtual bool visit(ExpressionStatement *) { return true; } - virtual void endVisit(ExpressionStatement *) {} - - virtual bool visit(IfStatement *) { return true; } - virtual void endVisit(IfStatement *) {} - - virtual bool visit(DoWhileStatement *) { return true; } - virtual void endVisit(DoWhileStatement *) {} - - virtual bool visit(WhileStatement *) { return true; } - virtual void endVisit(WhileStatement *) {} - - virtual bool visit(ForStatement *) { return true; } - virtual void endVisit(ForStatement *) {} - - virtual bool visit(LocalForStatement *) { return true; } - virtual void endVisit(LocalForStatement *) {} - - virtual bool visit(ForEachStatement *) { return true; } - virtual void endVisit(ForEachStatement *) {} - - virtual bool visit(LocalForEachStatement *) { return true; } - virtual void endVisit(LocalForEachStatement *) {} - - virtual bool visit(ContinueStatement *) { return true; } - virtual void endVisit(ContinueStatement *) {} - - virtual bool visit(BreakStatement *) { return true; } - virtual void endVisit(BreakStatement *) {} - - virtual bool visit(ReturnStatement *) { return true; } - virtual void endVisit(ReturnStatement *) {} - - virtual bool visit(WithStatement *) { return true; } - virtual void endVisit(WithStatement *) {} - - virtual bool visit(SwitchStatement *) { return true; } - virtual void endVisit(SwitchStatement *) {} - - virtual bool visit(CaseBlock *) { return true; } - virtual void endVisit(CaseBlock *) {} - - virtual bool visit(CaseClauses *) { return true; } - virtual void endVisit(CaseClauses *) {} - - virtual bool visit(CaseClause *) { return true; } - virtual void endVisit(CaseClause *) {} - - virtual bool visit(DefaultClause *) { return true; } - virtual void endVisit(DefaultClause *) {} - - virtual bool visit(LabelledStatement *) { return true; } - virtual void endVisit(LabelledStatement *) {} - - virtual bool visit(ThrowStatement *) { return true; } - virtual void endVisit(ThrowStatement *) {} - - virtual bool visit(TryStatement *) { return true; } - virtual void endVisit(TryStatement *) {} - - virtual bool visit(Catch *) { return true; } - virtual void endVisit(Catch *) {} - - virtual bool visit(Finally *) { return true; } - virtual void endVisit(Finally *) {} - - virtual bool visit(FunctionDeclaration *) { return true; } - virtual void endVisit(FunctionDeclaration *) {} - - virtual bool visit(FunctionExpression *) { return true; } - virtual void endVisit(FunctionExpression *) {} - - virtual bool visit(FormalParameterList *) { return true; } - virtual void endVisit(FormalParameterList *) {} - - virtual bool visit(FunctionBody *) { return true; } - virtual void endVisit(FunctionBody *) {} - - virtual bool visit(Program *) { return true; } - virtual void endVisit(Program *) {} - - virtual bool visit(SourceElements *) { return true; } - virtual void endVisit(SourceElements *) {} - - virtual bool visit(FunctionSourceElement *) { return true; } - virtual void endVisit(FunctionSourceElement *) {} - - virtual bool visit(StatementSourceElement *) { return true; } - virtual void endVisit(StatementSourceElement *) {} - - virtual bool visit(DebuggerStatement *) { return true; } - virtual void endVisit(DebuggerStatement *) {} -}; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif // QQMLJSASTVISITOR_P_H diff --git a/src/qml/qml/parser/qqmljsengine_p.cpp b/src/qml/qml/parser/qqmljsengine_p.cpp deleted file mode 100644 index 7dc3b6f6cb..0000000000 --- a/src/qml/qml/parser/qqmljsengine_p.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljsengine_p.h" -#include "qqmljsglobal_p.h" - -#include -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -static inline int toDigit(char c) -{ - if ((c >= '0') && (c <= '9')) - return c - '0'; - else if ((c >= 'a') && (c <= 'z')) - return 10 + c - 'a'; - else if ((c >= 'A') && (c <= 'Z')) - return 10 + c - 'A'; - return -1; -} - -double integerFromString(const char *buf, int size, int radix) -{ - if (size == 0) - return qSNaN(); - - double sign = 1.0; - int i = 0; - if (buf[0] == '+') { - ++i; - } else if (buf[0] == '-') { - sign = -1.0; - ++i; - } - - if (((size-i) >= 2) && (buf[i] == '0')) { - if (((buf[i+1] == 'x') || (buf[i+1] == 'X')) - && (radix < 34)) { - if ((radix != 0) && (radix != 16)) - return 0; - radix = 16; - i += 2; - } else { - if (radix == 0) { - radix = 8; - ++i; - } - } - } else if (radix == 0) { - radix = 10; - } - - int j = i; - for ( ; i < size; ++i) { - int d = toDigit(buf[i]); - if ((d == -1) || (d >= radix)) - break; - } - double result; - if (j == i) { - if (!qstrcmp(buf, "Infinity")) - result = qInf(); - else - result = qSNaN(); - } else { - result = 0; - double multiplier = 1; - for (--i ; i >= j; --i, multiplier *= radix) - result += toDigit(buf[i]) * multiplier; - } - result *= sign; - return result; -} - -double integerFromString(const QString &str, int radix) -{ - QByteArray ba = str.trimmed().toLatin1(); - return integerFromString(ba.constData(), ba.size(), radix); -} - - -Engine::Engine() - : _lexer(0) -{ } - -Engine::~Engine() -{ } - -void Engine::setCode(const QString &code) -{ _code = code; } - -void Engine::addComment(int pos, int len, int line, int col) -{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); } - -QList Engine::comments() const -{ return _comments; } - -Lexer *Engine::lexer() const -{ return _lexer; } - -void Engine::setLexer(Lexer *lexer) -{ _lexer = lexer; } - -MemoryPool *Engine::pool() -{ return &_pool; } - -QStringRef Engine::newStringRef(const QString &text) -{ - const int pos = _extraCode.length(); - _extraCode += text; - return _extraCode.midRef(pos, text.length()); -} - -QStringRef Engine::newStringRef(const QChar *chars, int size) -{ return newStringRef(QString(chars, size)); } - -} // end of namespace QQmlJS - -QT_QML_END_NAMESPACE diff --git a/src/qml/qml/parser/qqmljsengine_p.h b/src/qml/qml/parser/qqmljsengine_p.h deleted file mode 100644 index 4f58e7f8ea..0000000000 --- a/src/qml/qml/parser/qqmljsengine_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSENGINE_P_H -#define QQMLJSENGINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljsglobal_p.h" -#include "qqmljsastfwd_p.h" -#include "qqmljsmemorypool_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -class Lexer; -class MemoryPool; - -class QML_PARSER_EXPORT DiagnosticMessage -{ -public: - enum Kind { Warning, Error }; - - DiagnosticMessage() - : kind(Error) {} - - DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) - : kind(kind), loc(loc), message(message) {} - - bool isWarning() const - { return kind == Warning; } - - bool isError() const - { return kind == Error; } - - Kind kind; - AST::SourceLocation loc; - QString message; -}; - -class QML_PARSER_EXPORT Engine -{ - Lexer *_lexer; - MemoryPool _pool; - QList _comments; - QString _extraCode; - QString _code; - -public: - Engine(); - ~Engine(); - - void setCode(const QString &code); - - void addComment(int pos, int len, int line, int col); - QList comments() const; - - Lexer *lexer() const; - void setLexer(Lexer *lexer); - - MemoryPool *pool(); - - inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } - - QStringRef newStringRef(const QString &s); - QStringRef newStringRef(const QChar *chars, int size); -}; - -double integerFromString(const char *buf, int size, int radix); - -} // end of namespace QQmlJS - -QT_QML_END_NAMESPACE - -#endif // QQMLJSENGINE_P_H diff --git a/src/qml/qml/parser/qqmljsglobal_p.h b/src/qml/qml/parser/qqmljsglobal_p.h deleted file mode 100644 index c53e12ea56..0000000000 --- a/src/qml/qml/parser/qqmljsglobal_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QQMLJSGLOBAL_P_H -#define QQMLJSGLOBAL_P_H - -#include - -#ifdef QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE - -# ifdef QDECLARATIVEJS_BUILD_DIR -# define QML_PARSER_EXPORT Q_DECL_EXPORT -# elif QML_BUILD_STATIC_LIB -# define QML_PARSER_EXPORT -# else -# define QML_PARSER_EXPORT Q_DECL_IMPORT -# endif // QQMLJS_BUILD_DIR - -#else // !QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE QT_END_NAMESPACE -# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) - // QmlDevTools is a static library -# define QML_PARSER_EXPORT -# elif defined(QT_BUILD_QML_LIB) -# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT -# else -# define QML_PARSER_EXPORT -# endif -#endif // QT_CREATOR - -#endif // QQMLJSGLOBAL_P_H diff --git a/src/qml/qml/parser/qqmljsgrammar.cpp b/src/qml/qml/parser/qqmljsgrammar.cpp deleted file mode 100644 index 4a5672a796..0000000000 --- a/src/qml/qml/parser/qqmljsgrammar.cpp +++ /dev/null @@ -1,1068 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file was generated by qlalr - DO NOT EDIT! -#include "qqmljsgrammar_p.h" - -QT_BEGIN_NAMESPACE - -const char *const QQmlJSGrammar::spell [] = { - "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue", - "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", - "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", - "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=", - "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=", - "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", - ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch", - "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", - "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", 0, - "public", "import", "as", "on", "get", "set", 0, 0, 0, 0, - 0, 0, 0, 0, 0}; - -const short QQmlJSGrammar::lhs [] = { - 105, 105, 105, 105, 105, 105, 106, 112, 112, 115, - 115, 117, 116, 116, 116, 116, 116, 116, 116, 116, - 119, 114, 113, 122, 122, 123, 123, 124, 124, 121, - 110, 110, 110, 110, 126, 126, 126, 126, 126, 126, - 126, 110, 134, 134, 134, 135, 135, 136, 136, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, - 120, 120, 120, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 125, 141, 141, 141, 141, 140, 140, 145, 145, - 145, 143, 143, 146, 146, 146, 146, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 150, 150, - 118, 118, 118, 118, 118, 153, 153, 154, 154, 154, - 154, 152, 152, 155, 155, 156, 156, 157, 157, 157, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 159, 159, 159, 159, 160, 160, 160, 161, 161, 161, - 161, 162, 162, 162, 162, 162, 162, 162, 163, 163, - 163, 163, 163, 163, 164, 164, 164, 164, 164, 165, - 165, 165, 165, 165, 166, 166, 167, 167, 168, 168, - 169, 169, 170, 170, 171, 171, 172, 172, 173, 173, - 174, 174, 175, 175, 176, 176, 177, 177, 144, 144, - 178, 178, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 179, 108, 108, 180, 180, 181, 181, - 182, 182, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 127, 191, 191, - 190, 190, 138, 138, 192, 192, 193, 193, 195, 195, - 194, 196, 199, 197, 197, 200, 198, 198, 128, 129, - 129, 130, 130, 183, 183, 183, 183, 183, 183, 183, - 183, 184, 184, 184, 184, 185, 185, 185, 185, 186, - 186, 131, 132, 201, 201, 204, 204, 202, 202, 205, - 203, 187, 188, 188, 133, 133, 133, 206, 207, 189, - 189, 208, 137, 151, 151, 209, 209, 148, 148, 147, - 147, 210, 111, 111, 211, 211, 109, 109, 142, 142, - 212}; - -const short QQmlJSGrammar::rhs [] = { - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 2, 1, 2, 2, 3, 3, 5, 5, 4, 4, - 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, - 1, 5, 4, 4, 1, 1, 1, 1, 1, 1, - 1, 3, 1, 1, 1, 0, 1, 2, 4, 6, - 6, 3, 3, 7, 7, 4, 4, 5, 5, 5, - 6, 6, 10, 6, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 3, 3, 4, 5, 3, 4, - 3, 1, 1, 2, 3, 4, 1, 2, 3, 7, - 8, 1, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 4, 3, 5, 1, 2, 4, 4, 4, - 3, 0, 1, 1, 3, 1, 1, 1, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, - 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, - 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, - 3, 3, 3, 3, 1, 3, 1, 3, 1, 3, - 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, - 1, 3, 1, 3, 1, 5, 1, 5, 1, 3, - 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 0, 1, 1, 3, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, - 0, 1, 3, 3, 1, 1, 1, 3, 1, 3, - 2, 2, 2, 0, 1, 2, 0, 1, 1, 2, - 2, 7, 5, 7, 7, 7, 5, 9, 10, 7, - 8, 2, 2, 3, 3, 2, 2, 3, 3, 3, - 3, 5, 5, 3, 5, 1, 2, 0, 1, 4, - 3, 3, 3, 3, 3, 3, 4, 5, 2, 2, - 2, 1, 8, 8, 7, 1, 3, 0, 1, 0, - 1, 1, 1, 1, 1, 2, 1, 1, 0, 1, - 2}; - -const short QQmlJSGrammar::action_default [] = { - 0, 0, 22, 0, 0, 0, 22, 0, 178, 245, - 209, 217, 213, 157, 229, 205, 3, 142, 75, 158, - 221, 225, 146, 175, 156, 161, 141, 195, 182, 0, - 82, 83, 78, 0, 72, 67, 349, 0, 0, 0, - 0, 80, 0, 0, 76, 79, 71, 0, 0, 68, - 70, 73, 69, 81, 74, 0, 77, 0, 0, 171, - 0, 0, 158, 177, 160, 159, 0, 0, 0, 173, - 174, 172, 176, 0, 206, 0, 0, 0, 0, 196, - 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, - 180, 181, 179, 184, 188, 187, 185, 183, 198, 197, - 199, 0, 214, 0, 210, 0, 0, 152, 139, 151, - 140, 108, 109, 110, 135, 111, 136, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 137, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 138, 0, 0, 150, 246, 153, 0, 154, 0, - 155, 149, 0, 242, 235, 233, 240, 241, 239, 238, - 244, 237, 236, 234, 243, 230, 0, 218, 0, 0, - 222, 0, 0, 226, 0, 0, 152, 144, 0, 143, - 0, 148, 162, 0, 338, 338, 339, 0, 336, 0, - 337, 0, 340, 253, 260, 259, 267, 255, 0, 256, - 0, 341, 0, 348, 257, 258, 75, 263, 261, 345, - 342, 347, 264, 0, 275, 0, 0, 0, 0, 332, - 0, 349, 247, 289, 0, 0, 0, 276, 0, 0, - 265, 266, 0, 254, 262, 290, 291, 0, 338, 0, - 0, 340, 0, 333, 334, 0, 322, 346, 0, 306, - 307, 308, 309, 0, 302, 303, 304, 305, 330, 331, - 0, 0, 0, 0, 0, 294, 295, 296, 251, 249, - 211, 219, 215, 231, 207, 252, 0, 158, 223, 227, - 200, 189, 0, 0, 208, 0, 0, 0, 0, 201, - 0, 0, 0, 0, 0, 193, 191, 194, 192, 190, - 203, 202, 204, 0, 216, 0, 212, 0, 250, 158, - 0, 232, 247, 248, 0, 247, 0, 0, 298, 0, - 0, 0, 300, 0, 220, 0, 0, 224, 0, 0, - 228, 287, 0, 279, 288, 282, 0, 286, 0, 247, - 280, 0, 247, 0, 0, 299, 0, 0, 0, 301, - 0, 0, 0, 293, 0, 292, 75, 102, 350, 0, - 0, 107, 269, 272, 0, 108, 275, 111, 136, 113, - 114, 78, 118, 119, 72, 120, 123, 76, 79, 247, - 73, 81, 126, 74, 128, 77, 130, 131, 276, 133, - 134, 138, 0, 104, 103, 106, 90, 105, 89, 0, - 99, 270, 268, 0, 0, 0, 340, 0, 100, 146, - 147, 152, 0, 145, 0, 310, 311, 0, 338, 0, - 0, 340, 0, 101, 0, 0, 0, 313, 318, 316, - 319, 0, 0, 317, 318, 0, 314, 0, 315, 271, - 321, 0, 271, 320, 0, 323, 324, 0, 271, 325, - 326, 0, 0, 327, 0, 0, 0, 328, 329, 164, - 163, 0, 0, 0, 297, 0, 0, 0, 312, 284, - 277, 0, 285, 281, 0, 283, 273, 0, 274, 278, - 0, 0, 340, 0, 335, 93, 0, 0, 97, 84, - 0, 86, 95, 0, 87, 96, 98, 88, 94, 85, - 0, 91, 168, 166, 170, 167, 165, 169, 343, 6, - 344, 4, 2, 65, 92, 0, 0, 68, 70, 69, - 31, 5, 0, 66, 0, 45, 44, 43, 0, 0, - 58, 0, 59, 35, 36, 37, 38, 40, 41, 62, - 39, 0, 45, 0, 0, 0, 0, 0, 54, 0, - 55, 0, 0, 26, 0, 0, 63, 27, 0, 30, - 28, 24, 0, 29, 25, 0, 56, 0, 57, 146, - 0, 60, 64, 0, 0, 0, 0, 61, 0, 52, - 46, 53, 47, 0, 0, 0, 0, 49, 0, 50, - 51, 48, 0, 0, 146, 271, 0, 0, 42, 75, - 108, 275, 111, 136, 113, 114, 78, 118, 119, 120, - 123, 76, 79, 247, 81, 126, 74, 128, 77, 130, - 131, 276, 133, 134, 138, 0, 32, 33, 0, 34, - 8, 0, 10, 0, 9, 0, 1, 21, 12, 0, - 13, 0, 14, 0, 19, 20, 0, 15, 16, 0, - 17, 18, 11, 23, 7, 351}; - -const short QQmlJSGrammar::goto_default [] = { - 7, 636, 211, 198, 209, 521, 509, 635, 654, 508, - 634, 632, 637, 22, 633, 18, 520, 562, 552, 559, - 554, 539, 193, 197, 199, 204, 234, 212, 231, 543, - 583, 582, 203, 233, 26, 487, 486, 359, 358, 9, - 357, 360, 202, 480, 361, 109, 17, 147, 24, 13, - 146, 19, 25, 59, 23, 8, 28, 27, 280, 15, - 274, 10, 270, 12, 272, 11, 271, 20, 278, 21, - 279, 14, 273, 269, 310, 414, 275, 276, 205, 195, - 194, 208, 207, 230, 196, 364, 363, 232, 471, 470, - 332, 333, 473, 335, 472, 334, 427, 431, 434, 430, - 429, 449, 450, 200, 186, 201, 210, 0}; - -const short QQmlJSGrammar::action_index [] = { - 235, 1289, 2663, 2663, 2562, 1005, 64, 90, 103, -105, - 88, 94, 79, 173, -105, 302, 69, -105, -105, 724, - 65, 135, 195, 239, -105, -105, -105, 367, 278, 1289, - -105, -105, -105, 485, -105, -105, 2360, 1772, 1289, 1289, - 1289, -105, 817, 1289, -105, -105, -105, 1289, 1289, -105, - -105, -105, -105, -105, -105, 1289, -105, 1289, 1289, -105, - 1289, 1289, 95, 207, -105, -105, 1289, 1289, 1289, -105, - -105, -105, 202, 1289, 300, 1289, 1289, 1289, 1289, 377, - 1289, 1289, 1289, 1289, 1289, 1289, 253, 1289, 1289, 1289, - 151, 147, 129, 196, 170, 199, 279, 270, 470, 470, - 387, 1289, 53, 1289, 80, 2158, 1289, 1289, -105, -105, - -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, - -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, - -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, - -105, -105, 128, 1289, -105, -105, 74, 52, -105, 1289, - -105, -105, 1289, -105, -105, -105, -105, -105, -105, -105, - -105, -105, -105, -105, -105, -105, 1289, 51, 1289, 1289, - 77, 66, 1289, -105, 2158, 1289, 1289, -105, 125, -105, - 48, -105, -105, 47, 451, 374, 83, 87, -105, 397, - -105, 62, 2663, -105, -105, -105, -105, -105, 205, -105, - 415, -105, 68, -105, -105, -105, 86, -105, -105, -105, - 2663, -105, -105, 622, -105, 576, 102, 2562, 75, 89, - 81, 2865, 1289, -105, 70, 1289, 63, -105, 92, 93, - -105, -105, 546, -105, -105, -105, -105, 91, 546, 40, - 45, 2663, 49, -105, -105, 2562, -105, -105, 106, -105, - -105, -105, -105, 121, -105, -105, -105, -105, -105, -105, - 42, 44, 1289, 114, 222, -105, -105, -105, 1481, -105, - 84, 57, 56, -105, 388, 78, 54, 682, 82, 99, - 357, 247, 546, 1289, 295, 1289, 1289, 1289, 1289, 334, - 1289, 1289, 1289, 1289, 1289, 203, 217, 244, 263, 211, - 341, 319, 351, 1289, 56, 1289, 73, 1289, -105, 724, - 1289, -105, 1289, 67, 46, 1289, 61, 2562, -105, 1289, - 136, 2562, -105, 1289, 76, 1289, 1289, 85, 59, 1289, - -105, 71, 133, 72, -105, -105, 1289, -105, 546, 1289, - -105, -53, 1289, -60, 2562, -105, 1289, 143, 2562, -105, - 1289, 132, 2562, 8, 2562, -105, 7, -105, 12, -37, - 107, -105, -105, 2562, -33, 622, 22, 555, 115, 1289, - 2562, 23, -13, 502, 2259, -10, 817, 18, 6, 1387, - 2259, 0, 9, -6, 1289, -4, -23, 1289, 5, 1289, - -25, -27, 2461, -105, -105, -105, -105, -105, -105, 1289, - -105, -105, -105, -3, -1, 21, 2663, 1, -105, 218, - -105, 1289, 4, -105, 111, -105, -105, 26, 466, 16, - 38, 2663, 39, -105, 1289, 110, 37, -105, 55, -105, - 60, 116, 1289, -105, 58, 43, -105, -15, -105, 2562, - -105, 123, 2562, -105, 154, -105, -105, 96, 2562, 32, - -105, 3, 14, -105, 546, -11, 13, -105, -105, -105, - -105, 1289, 126, 2562, -105, 1289, 130, 2562, -105, 15, - -105, 301, -105, -105, 1289, -105, -105, 546, -105, -105, - -45, -12, 2663, -24, -105, -105, 204, 1578, -105, -105, - 1869, -105, -105, 1675, -105, -105, -105, -105, -105, -105, - 101, -105, -105, -105, -105, -105, -105, -105, -105, -105, - 2663, -105, -105, -105, 105, 2, 910, 206, -47, -2, - -105, -105, 246, -105, 214, -105, -105, -105, 364, 232, - -105, 1963, -105, -105, -105, -105, -105, -105, -105, -105, - -105, 191, 24, 394, 172, -18, 384, 215, -105, -30, - -105, 910, 149, -105, -16, 910, -105, -105, 1100, -105, - -105, -105, 1195, -105, -105, 225, -105, 1963, -105, 316, - -17, -105, -105, 269, 418, -5, 1963, -105, 184, -105, - 175, -105, 20, -9, 546, 182, 469, -105, 104, -105, - -105, -105, 2057, 910, 292, 2764, 1772, 10, -105, 35, - 622, 34, 525, 98, 1289, 2562, 50, 17, 536, 19, - 817, 31, 27, 1387, 28, 9, 29, 1289, 30, 11, - 1289, 41, 1289, 33, 36, 137, -105, -105, 25, -105, - -105, 910, -105, 268, -86, 910, -105, -105, 141, 546, - -105, 156, -105, 117, -105, -105, 546, -105, -105, 138, - -105, -105, -105, -105, -105, -105, - - -108, 0, 79, 128, 132, 301, 2, -108, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -47, - -108, -108, -108, -108, -108, -108, -108, -108, -108, 51, - -108, -108, -108, -3, -108, -108, 8, -23, 12, 78, - 106, -108, 69, 74, -108, -108, -108, 195, 204, -108, - -108, -108, -108, -108, -108, 188, -108, 201, 200, -108, - 127, 129, -108, -108, -108, -108, 140, 137, 133, -108, - -108, -108, -108, 146, -108, 177, 168, 170, 167, -108, - 144, 152, 166, 158, 160, 131, -108, 194, 187, 207, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, 88, -108, 112, -108, 121, 90, -38, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, 32, -108, -108, -108, -108, -108, 26, - -108, -108, 27, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, -108, -108, -108, 102, -108, 103, 41, - -108, -108, 37, -108, 250, 38, 83, -108, -108, -108, - -108, -108, -108, -108, 42, 126, -108, -108, -108, 40, - -108, -108, 43, -108, -108, -108, -108, -108, -108, -108, - 39, -108, -108, -108, -108, -108, -108, -108, -108, -108, - 225, -108, -108, 30, -108, 24, -108, 211, -108, 55, - -108, 77, 60, -108, -108, 66, 34, -108, -108, -108, - -108, -108, -8, -108, -108, -108, -108, -108, 153, -108, - -108, 164, -108, -108, -108, 241, -108, -108, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, 11, -108, -108, -108, -108, -108, 179, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, 19, 259, -108, 255, 228, 240, 246, -108, - 52, 63, 67, 65, 50, -108, -108, -108, -108, -108, - -108, -108, -108, 210, -108, 256, -108, 226, -108, -108, - 252, -108, 161, -108, -108, 268, -108, 197, -108, 5, - -108, 218, -108, 222, -108, 213, 249, -108, -108, 236, - -108, -108, -108, -108, -108, -108, 212, -108, 80, 87, - -108, -108, 86, -108, 98, -108, 61, -108, 245, -108, - 59, -108, 208, -108, 192, -108, -108, -108, -108, -108, - -108, -108, -108, 257, -108, 33, -108, 28, -108, 73, - 71, -108, -108, 36, 57, -108, 62, -108, -108, 46, - 70, -108, -108, -108, 49, -108, 45, 99, -108, 84, - -108, -108, 100, -108, -108, -108, -108, -108, -108, 21, - -108, -108, -108, -108, -108, -108, 118, -108, -108, -108, - -108, 81, -108, -108, -108, -108, -108, -108, 123, -108, - -108, 134, -108, -108, 56, -108, -108, -108, -108, -108, - -58, -108, 47, -108, -57, -108, -108, -108, -108, 265, - -108, -108, 374, -108, -108, -108, -108, -108, 94, -66, - -108, -108, 25, -108, 22, -108, 31, -108, -108, -108, - -108, 58, -108, 229, -108, 35, -108, 235, -108, -108, - -108, -108, -108, -108, 29, -108, -108, 186, -108, -108, - -108, -108, 162, -108, -108, -108, -108, 48, -108, -108, - 163, -108, -108, 44, -108, -108, -108, -108, -108, -108, - -108, -108, -108, -108, -108, -108, -108, -108, -108, -108, - 141, -108, -108, -108, -108, -108, -7, -108, -108, -108, - -108, -108, -108, -108, -19, -108, -108, -108, -6, -108, - -108, 334, -108, -108, -108, -108, -108, -108, -108, -108, - -108, -108, -108, -15, -27, -108, -10, -108, -108, -108, - -108, 159, -108, -108, -108, 176, -108, -108, 319, -108, - -108, -108, 322, -108, -108, -108, -108, 469, -108, -108, - 10, -108, -108, 6, 16, -108, 342, -108, -108, -108, - 17, -108, -108, -108, 15, 3, 9, -108, -108, -108, - -108, -108, 358, 68, -108, 82, 310, 1, -108, -108, - -2, -108, 7, -108, 54, 76, -108, -108, 4, -108, - 64, -108, -108, 23, -108, -108, -108, 18, -108, -5, - 95, -108, 91, -108, -108, -108, -108, -108, -1, -108, - -108, 20, -108, -108, 14, 142, -108, -108, -108, 13, - -108, -108, -108, -108, -108, -108, -11, -108, -108, -108, - -108, -108, -108, -108, -108, -108}; - -const short QQmlJSGrammar::action_info [] = { - 344, -127, 576, -129, 551, 631, 546, -105, 342, 465, - 448, 461, -132, -106, 245, 481, 558, 558, 398, 573, - 392, 482, 402, 268, 354, -124, 350, 578, 585, -135, - -116, 484, 474, 404, -106, -105, -127, -129, -124, 454, - 438, -135, 245, 558, 448, 424, 448, 448, -132, 456, - 439, 588, 452, 268, 406, 350, 408, -116, 558, 405, - 432, 544, 418, 432, 413, 432, 329, 166, 524, 461, - 428, 421, 465, 172, 283, 143, 420, 143, 241, 166, - 262, 73, 149, 185, 323, 283, 307, 323, 336, 73, - 655, 189, 0, 245, 423, 192, 448, 0, 0, 101, - 240, 0, 451, 346, 243, 303, 424, 315, 181, 143, - 0, 268, 151, 0, 399, 312, 452, 350, 143, 261, - 174, 317, 143, 244, 303, 184, 435, 238, 461, 465, - 442, 143, 103, 143, 143, 305, 143, 64, 143, 175, - 143, 338, 101, 60, 143, 555, 0, 191, 65, 325, - 0, 143, 0, 326, 61, 631, 174, 555, 103, 259, - 258, 501, 143, 259, 258, 590, 589, 252, 251, 60, - 426, 436, 416, 415, 264, 175, 259, 258, 645, 644, - 61, 179, 257, 256, 144, 168, 463, 60, 105, 169, - 467, 60, 352, 626, 339, 87, 321, 88, 61, 651, - 650, 525, 61, 348, 525, 556, 174, 106, 89, 107, - 174, 525, 490, 143, 66, 446, 445, 648, 647, 66, - 580, 87, 549, 88, 87, 175, 88, 411, 87, 175, - 88, 176, 567, 174, 89, 542, 87, 89, 88, 531, - 0, 89, 87, 525, 88, 581, 579, 527, 646, 89, - 527, 66, 175, 592, 411, 89, 0, 527, 526, 67, - 491, 526, 0, 0, 67, 68, 236, 235, 526, 87, - 68, 88, 87, 0, 88, 0, 550, 548, 87, 558, - 88, 527, 89, 267, 265, 89, 568, 566, 87, 527, - 88, 89, 526, 532, 530, 87, 67, 88, 525, 0, - 526, 89, 68, 87, 87, 88, 88, 174, 89, 477, - 0, 266, 0, 285, 286, 641, 89, 89, 75, 76, - 75, 76, 0, 0, 0, -92, 175, 0, 176, 642, - 640, 174, 6, 5, 4, 1, 3, 2, 0, 593, - 287, 288, 290, 291, 527, 77, 78, 77, 78, -92, - 175, 292, 176, 0, 293, 526, 294, 290, 291, 0, - 639, 0, 478, 476, 290, 291, 292, 0, 0, 293, - 0, 294, 0, 292, 290, 291, 293, 0, 294, 0, - 290, 291, 0, 292, 0, 0, 293, 0, 294, 292, - 80, 81, 293, 35, 294, 0, 0, 0, 82, 83, - 80, 81, 84, 35, 85, 0, 285, 286, 82, 83, - 80, 81, 84, 35, 85, 0, 0, 0, 82, 83, - 0, 0, 84, 35, 85, 0, 35, 0, 0, 0, - 49, 52, 50, 287, 288, 0, 0, 0, 0, 0, - 49, 52, 50, 0, 35, 0, 0, 35, 0, 0, - 49, 52, 50, 0, 0, 0, 0, 46, 34, 51, - 49, 52, 50, 49, 52, 50, 0, 46, 34, 51, - 0, 0, 0, 0, 0, 0, 0, 46, 34, 51, - 35, 49, 52, 50, 49, 52, 50, 46, 34, 51, - 46, 34, 51, 80, 81, 35, 0, 0, 35, 0, - 0, 82, 83, 0, 0, 84, 0, 85, 46, 34, - 51, 46, 34, 51, 35, 0, 0, 49, 52, 50, - 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 35, 49, 52, 50, 49, 52, 50, 184, 0, - 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, - 0, 49, 52, 50, 35, 0, 0, 0, 0, 46, - 34, 51, 46, 34, 51, 35, 0, 0, 49, 52, - 50, 0, 184, 0, 0, 35, 0, 0, 46, 34, - 51, 0, 0, 0, 35, 0, 255, 254, 0, 0, - 0, 49, 52, 50, 0, 46, 34, 51, 0, 0, - 0, 0, 49, 52, 50, 35, 0, 0, 0, 0, - 0, 0, 49, 52, 50, 0, 255, 254, 46, 34, - 51, 49, 52, 50, 0, 0, 0, 0, 0, 46, - 34, 51, 0, 0, 0, 0, 0, 255, 254, 46, - 34, 51, 49, 52, 50, 0, 0, 0, 46, 34, - 51, 35, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 250, 249, 153, 0, 0, 49, 52, - 50, 0, 0, 0, 0, 154, 0, 0, 0, 155, - 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, - 157, 0, 0, 319, 0, 46, 34, 51, 0, 0, - 0, 158, 0, 159, 64, 0, 0, 153, 0, 0, - 0, 160, 0, 0, 161, 65, 0, 154, 0, 0, - 162, 155, 0, 0, 0, 0, 163, 0, 0, 0, - 156, 0, 157, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 164, 158, 0, 159, 64, 0, 0, 0, - 0, 0, 0, 160, 0, 0, 161, 65, 0, 0, - 0, 0, 162, 0, 0, 0, 0, 0, 163, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, - 36, 37, 0, 38, 0, 0, 0, 0, 0, 0, - 42, 0, 0, 0, 45, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 53, 49, 52, 50, 0, 54, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 44, 56, - 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, - 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, - 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, - 0, 0, 0, 516, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 53, 49, 52, 50, 0, - 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, - 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 515, 0, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, - 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, - 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 517, 519, 518, 0, 54, 0, 0, 0, 0, - 227, 0, 0, 0, 0, 0, 44, 56, 32, 214, - 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, - 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 515, 0, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 219, 0, 0, 0, 0, 0, 0, 35, - 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, - 0, 0, 0, 516, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 560, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 53, 517, 519, 518, 0, - 54, 0, 0, 0, 0, 227, 0, 0, 0, 0, - 0, 44, 56, 32, 214, 0, 0, 41, 0, 0, - 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 515, 0, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, - 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, - 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 517, 519, 518, 0, 54, 0, 0, 0, 0, - 227, 0, 0, 0, 0, 0, 44, 56, 32, 214, - 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, - 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, - 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, - 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, - 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, - 0, 55, 0, 57, 0, 58, 0, 0, 0, 0, - 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, - 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -125, 0, 0, 0, 29, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, - 36, 37, 0, 38, 0, 0, 0, 39, 0, 40, - 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 53, 49, 52, 50, 0, 54, 0, 55, - 0, 57, 0, 58, 0, 0, 0, 0, 44, 56, - 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, - 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 36, 37, 0, 38, 0, 0, - 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, - 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 53, 49, 52, 50, - 0, 54, 0, 55, 0, 57, 282, 58, 0, 0, - 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, - 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 496, 0, 0, 29, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, - 0, 36, 37, 0, 38, 0, 0, 0, 39, 0, - 40, 42, 43, 0, 0, 45, 0, 0, 0, 47, - 0, 48, 0, 0, 499, 0, 0, 0, 0, 0, - 0, 0, 0, 53, 49, 52, 50, 0, 54, 0, - 55, 0, 57, 0, 58, 0, 0, 0, 0, 44, - 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 496, 0, 0, 29, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, - 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, - 0, 0, 45, 0, 0, 0, 47, 0, 48, 0, - 0, 497, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 49, 52, 50, 0, 54, 0, 55, 0, 57, - 0, 58, 0, 0, 0, 0, 44, 56, 32, 0, - 0, 0, 41, 0, 0, 0, 0, 0, 46, 34, - 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 488, 0, 0, 29, 30, 31, 0, 0, 0, 0, - 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, - 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, - 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, - 0, 0, 0, 47, 0, 48, 0, 0, 489, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, - 50, 0, 54, 0, 55, 0, 57, 0, 58, 0, - 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, - 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 488, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, - 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, - 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, - 47, 0, 48, 0, 0, 494, 0, 0, 0, 0, - 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, - 0, 55, 0, 57, 0, 58, 0, 0, 0, 0, - 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, - 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, - 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, - 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, - 0, 0, 0, 0, 223, 0, 0, 0, 53, 49, - 52, 50, 224, 54, 0, 55, 226, 57, 0, 58, - 0, 229, 0, 0, 44, 56, 32, 0, 0, 0, - 41, 0, 0, 0, 0, 0, 46, 34, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 0, 0, 35, 220, 0, 0, - 595, 596, 0, 38, 0, 0, 0, 39, 0, 40, - 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, - 48, 0, 0, 0, 0, 0, 0, 0, 223, 0, - 0, 0, 53, 49, 52, 50, 224, 54, 0, 55, - 226, 57, 0, 58, 0, 229, 0, 0, 44, 56, - 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, - 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 111, 112, 113, 0, 0, 115, 117, 118, - 0, 0, 119, 0, 120, 0, 0, 0, 122, 123, - 124, 0, 0, 0, 0, 0, 0, 35, 125, 126, - 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 0, 49, 52, 50, 132, 133, 134, - 0, 136, 137, 138, 139, 140, 141, 0, 0, 129, - 135, 121, 114, 116, 130, 0, 0, 0, 0, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 111, 112, 113, 0, 0, 115, 117, - 118, 0, 0, 119, 0, 120, 0, 0, 0, 122, - 123, 124, 0, 0, 0, 0, 0, 0, 35, 125, - 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 128, 0, 0, 0, 395, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, - 0, 0, 0, 0, 397, 49, 52, 50, 132, 133, - 134, 0, 136, 137, 138, 139, 140, 141, 0, 0, - 129, 135, 121, 114, 116, 130, 0, 0, 0, 0, - 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 111, 112, 113, 0, 0, 115, - 117, 118, 0, 0, 119, 0, 120, 0, 0, 0, - 122, 123, 124, 0, 0, 0, 0, 0, 0, 35, - 125, 126, 127, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 128, 0, 0, 0, 395, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, - 0, 0, 0, 0, 0, 397, 49, 52, 50, 132, - 133, 134, 0, 136, 137, 138, 139, 140, 141, 0, - 0, 129, 135, 121, 114, 116, 130, 0, 0, 0, - 0, 0, 0, 46, 374, 380, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 111, 112, 113, 0, 0, - 115, 117, 118, 0, 0, 119, 0, 120, 0, 0, - 0, 122, 123, 124, 0, 0, 0, 0, 0, 0, - 35, 125, 126, 127, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 0, 0, 0, 395, 0, - 0, 0, 0, 0, 0, 0, 396, 0, 0, 0, - 131, 0, 0, 0, 0, 0, 397, 49, 52, 50, - 132, 133, 134, 0, 136, 137, 138, 139, 140, 141, - 0, 0, 129, 135, 121, 114, 116, 130, 0, 0, - 0, 0, 0, 0, 46, 374, 380, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 213, 0, 0, 0, - 0, 215, 0, 29, 30, 31, 217, 0, 0, 0, - 0, 0, 0, 218, 33, 0, 0, 0, 0, 0, - 0, 35, 220, 0, 0, 221, 37, 0, 38, 0, - 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, - 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, - 0, 222, 0, 223, 0, 0, 0, 53, 49, 52, - 50, 224, 54, 225, 55, 226, 57, 227, 58, 228, - 229, 0, 0, 44, 56, 32, 214, 216, 0, 41, - 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 213, 0, 0, - 0, 0, 215, 0, 29, 30, 31, 217, 0, 0, - 0, 0, 0, 0, 218, 219, 0, 0, 0, 0, - 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, - 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, - 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, - 0, 0, 222, 0, 223, 0, 0, 0, 53, 49, - 52, 50, 224, 54, 225, 55, 226, 57, 227, 58, - 228, 229, 0, 0, 44, 56, 32, 214, 216, 0, - 41, 0, 0, 0, 0, 0, 46, 34, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 600, 112, - 113, 0, 0, 602, 117, 604, 30, 31, 605, 0, - 120, 0, 0, 0, 122, 607, 608, 0, 0, 0, - 0, 0, 0, 35, 609, 126, 127, 221, 37, 0, - 38, 0, 0, 0, 39, 0, 40, 610, 43, 0, - 0, 612, 0, 0, 0, 47, 0, 48, 0, 0, - 0, 0, 0, 613, 0, 223, 0, 0, 0, 614, - 49, 52, 50, 615, 616, 617, 55, 619, 620, 621, - 622, 623, 624, 0, 0, 611, 618, 606, 601, 603, - 130, 41, 0, 0, 0, 0, 0, 46, 374, 380, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, - 112, 113, 0, 0, 367, 117, 369, 30, 31, 370, - 0, 120, 0, 0, 0, 122, 372, 373, 0, 0, - 0, 0, 0, 0, 35, 375, 126, 127, 221, 37, - 0, 38, 0, 0, 0, 39, 0, 40, 376, 43, - 0, 0, 378, 0, 0, 0, 47, 0, 48, 0, - -271, 0, 0, 0, 379, 0, 223, 0, 0, 0, - 381, 49, 52, 50, 382, 383, 384, 55, 386, 387, - 388, 389, 390, 391, 0, 0, 377, 385, 371, 366, - 368, 130, 41, 0, 0, 0, 0, 0, 46, 374, - 380, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 565, 148, 545, 16, 649, 547, 541, 469, 320, 529, - 528, 630, 183, 248, 263, 500, 485, 447, 629, 183, - 627, 444, 253, 393, 587, 652, 313, 152, 643, 572, - 591, 575, 586, 638, 331, 574, 453, 455, 466, 253, - 437, 178, 433, 253, 0, 248, 584, 458, 248, 313, - 441, 183, 444, 457, 237, 190, 447, 188, 206, 425, - 400, 462, 351, 313, 347, 150, 165, 447, 475, 444, - 183, 145, 393, 260, 0, 409, 173, 409, 260, 362, - 171, 514, 409, 495, 362, 393, 206, 498, 628, 313, - 313, 206, 356, 142, 206, 331, 362, 599, 403, 0, - 345, 62, 62, 62, 182, 62, 299, 182, 295, 206, - 410, 417, 410, 206, 62, 393, 62, 410, 62, 296, - 148, 298, 148, 297, 62, 62, 182, 504, 412, 62, - 180, 502, 511, 206, 512, 62, 108, 460, 188, 62, - 394, 188, 62, 206, 460, 247, 62, 206, 459, 206, - 62, 102, 459, 62, 62, 514, 206, 62, 653, 503, - 407, 343, 341, 62, 313, 110, 419, 167, 188, 187, - 170, 340, 514, 104, 0, 553, 422, 206, 62, 206, - 62, 63, 62, 72, 62, 510, 71, 97, 62, 514, - 70, 62, 557, 69, 355, 62, 239, 62, 493, 318, - 86, 469, 492, 62, 483, 74, 242, 206, 93, 62, - 353, 62, 206, 260, 95, 0, 96, 62, 62, 62, - 322, 62, 94, 206, 100, 98, 206, 99, 62, 247, - 277, 464, 0, 206, 79, 281, 314, 468, 62, 62, - 206, 507, 91, 246, 206, 62, 62, 349, 505, 90, - 206, 62, 62, 460, 459, 62, 206, 506, 62, 401, - 206, 62, 92, 309, 62, 108, 281, 362, 281, 281, - 0, 313, 206, 62, 304, 479, 0, 309, 281, 62, - 206, 327, 281, 0, 281, 337, 300, 309, 324, 0, - 0, 62, 281, 0, 110, 177, 281, 62, 301, 308, - 309, 0, 281, 309, 302, 281, 62, 62, 281, 330, - 62, 281, 281, 289, 514, 281, 0, 0, 306, 284, - 0, 522, 328, 569, 561, 311, 553, 564, 625, 0, - 0, 0, 514, 513, 523, 514, 0, 0, 0, 522, - 0, 0, 522, 316, 0, 0, 0, 0, 0, 485, - 440, 513, 523, 0, 513, 523, 533, 534, 535, 536, - 540, 537, 538, 577, 533, 534, 535, 536, 540, 537, - 538, 594, 0, 0, 0, 0, 362, 0, 597, 598, - 533, 534, 535, 536, 540, 537, 538, 0, 0, 206, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 443, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 569, 0, 0, 0, 0, 0, 0, 570, - 571, 533, 534, 535, 536, 540, 537, 538, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0}; - -const short QQmlJSGrammar::action_check [] = { - 60, 7, 7, 7, 34, 91, 24, 7, 61, 36, - 33, 36, 7, 7, 7, 60, 33, 33, 55, 66, - 8, 33, 55, 36, 16, 7, 36, 29, 8, 7, - 7, 55, 17, 36, 7, 7, 7, 7, 7, 36, - 55, 7, 7, 33, 33, 36, 33, 33, 7, 60, - 7, 60, 20, 36, 33, 36, 55, 7, 33, 60, - 5, 37, 36, 5, 60, 5, 7, 2, 66, 36, - 33, 33, 36, 7, 1, 8, 60, 8, 33, 2, - 36, 1, 8, 36, 2, 1, 8, 2, 17, 1, - 0, 8, -1, 7, 55, 33, 33, -1, -1, 48, - 60, -1, 6, 31, 55, 48, 36, 61, 60, 8, - -1, 36, 60, -1, 7, 61, 20, 36, 8, 77, - 15, 60, 8, 55, 48, 36, 10, 36, 36, 36, - 7, 8, 79, 8, 8, 79, 8, 42, 8, 34, - 8, 8, 48, 40, 8, 8, -1, 60, 53, 50, - -1, 8, -1, 54, 51, 91, 15, 8, 79, 61, - 62, 60, 8, 61, 62, 61, 62, 61, 62, 40, - 60, 55, 61, 62, 60, 34, 61, 62, 61, 62, - 51, 56, 61, 62, 56, 50, 60, 40, 15, 54, - 60, 40, 60, 56, 61, 25, 60, 27, 51, 61, - 62, 29, 51, 60, 29, 56, 15, 34, 38, 36, - 15, 29, 8, 8, 12, 61, 62, 61, 62, 12, - 36, 25, 7, 27, 25, 34, 27, 36, 25, 34, - 27, 36, 7, 15, 38, 29, 25, 38, 27, 7, - -1, 38, 25, 29, 27, 61, 62, 75, 92, 38, - 75, 12, 34, 7, 36, 38, -1, 75, 86, 57, - 56, 86, -1, -1, 57, 63, 61, 62, 86, 25, - 63, 27, 25, -1, 27, -1, 61, 62, 25, 33, - 27, 75, 38, 61, 62, 38, 61, 62, 25, 75, - 27, 38, 86, 61, 62, 25, 57, 27, 29, -1, - 86, 38, 63, 25, 25, 27, 27, 15, 38, 8, - -1, 89, -1, 18, 19, 47, 38, 38, 18, 19, - 18, 19, -1, -1, -1, 33, 34, -1, 36, 61, - 62, 15, 97, 98, 99, 100, 101, 102, -1, 93, - 45, 46, 23, 24, 75, 45, 46, 45, 46, 33, - 34, 32, 36, -1, 35, 86, 37, 23, 24, -1, - 92, -1, 61, 62, 23, 24, 32, -1, -1, 35, - -1, 37, -1, 32, 23, 24, 35, -1, 37, -1, - 23, 24, -1, 32, -1, -1, 35, -1, 37, 32, - 23, 24, 35, 29, 37, -1, -1, -1, 31, 32, - 23, 24, 35, 29, 37, -1, 18, 19, 31, 32, - 23, 24, 35, 29, 37, -1, -1, -1, 31, 32, - -1, -1, 35, 29, 37, -1, 29, -1, -1, -1, - 66, 67, 68, 45, 46, -1, -1, -1, -1, -1, - 66, 67, 68, -1, 29, -1, -1, 29, -1, -1, - 66, 67, 68, -1, -1, -1, -1, 93, 94, 95, - 66, 67, 68, 66, 67, 68, -1, 93, 94, 95, - -1, -1, -1, -1, -1, -1, -1, 93, 94, 95, - 29, 66, 67, 68, 66, 67, 68, 93, 94, 95, - 93, 94, 95, 23, 24, 29, -1, -1, 29, -1, - -1, 31, 32, -1, -1, 35, -1, 37, 93, 94, - 95, 93, 94, 95, 29, -1, -1, 66, 67, 68, - -1, 36, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 29, 66, 67, 68, 66, 67, 68, 36, -1, - -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, - -1, 66, 67, 68, 29, -1, -1, -1, -1, 93, - 94, 95, 93, 94, 95, 29, -1, -1, 66, 67, - 68, -1, 36, -1, -1, 29, -1, -1, 93, 94, - 95, -1, -1, -1, 29, -1, 61, 62, -1, -1, - -1, 66, 67, 68, -1, 93, 94, 95, -1, -1, - -1, -1, 66, 67, 68, 29, -1, -1, -1, -1, - -1, -1, 66, 67, 68, -1, 61, 62, 93, 94, - 95, 66, 67, 68, -1, -1, -1, -1, -1, 93, - 94, 95, -1, -1, -1, -1, -1, 61, 62, 93, - 94, 95, 66, 67, 68, -1, -1, -1, 93, 94, - 95, 29, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, - 94, 95, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 61, 62, 3, -1, -1, 66, 67, - 68, -1, -1, -1, -1, 13, -1, -1, -1, 17, - -1, -1, -1, -1, -1, -1, -1, -1, 26, -1, - 28, -1, -1, 31, -1, 93, 94, 95, -1, -1, - -1, 39, -1, 41, 42, -1, -1, 3, -1, -1, - -1, 49, -1, -1, 52, 53, -1, 13, -1, -1, - 58, 17, -1, -1, -1, -1, 64, -1, -1, -1, - 26, -1, 28, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 80, 39, -1, 41, 42, -1, -1, -1, - -1, -1, -1, 49, -1, -1, 52, 53, -1, -1, - -1, -1, 58, -1, -1, -1, -1, -1, 64, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 80, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, 68, -1, 70, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, - 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 10, -1, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, - 75, -1, -1, -1, -1, -1, 81, 82, 83, 84, - -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 10, -1, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, - -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, -1, -1, -1, 75, -1, -1, -1, -1, - -1, 81, 82, 83, 84, -1, -1, 87, -1, -1, - -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 10, -1, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, - 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, - 75, -1, -1, -1, -1, -1, 81, 82, 83, 84, - -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, - -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 7, -1, -1, -1, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, - -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, - 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, - -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, - 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, - -1, 70, -1, 72, -1, 74, 75, 76, -1, -1, - -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, - -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, -1, -1, 11, - 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, - 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, - -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, - -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, - 72, -1, 74, -1, 76, -1, -1, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, - -1, 93, 94, 95, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, - -1, -1, 87, -1, -1, -1, -1, -1, 93, 94, - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, 56, -1, - -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, - 68, -1, 70, -1, 72, -1, 74, -1, 76, -1, - -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, - -1, -1, -1, -1, -1, 93, 94, 95, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, - -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, - -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, -1, -1, 61, -1, -1, -1, 65, 66, - 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, - -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, - 87, -1, -1, -1, -1, -1, 93, 94, 95, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, 30, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, -1, -1, 61, -1, - -1, -1, 65, 66, 67, 68, 69, 70, -1, 72, - 73, 74, -1, 76, -1, 78, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, - 93, 94, 95, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, - -1, -1, 14, -1, 16, -1, -1, -1, 20, 21, - 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, - 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 43, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, - -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, - -1, 73, 74, 75, 76, 77, 78, -1, -1, 81, - 82, 83, 84, 85, 86, -1, -1, -1, -1, -1, - -1, 93, 94, 95, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, - 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 43, -1, -1, -1, 47, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, - -1, -1, -1, -1, 65, 66, 67, 68, 69, 70, - 71, -1, 73, 74, 75, 76, 77, 78, -1, -1, - 81, 82, 83, 84, 85, 86, -1, -1, -1, -1, - -1, -1, 93, 94, 95, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, - 10, 11, -1, -1, 14, -1, 16, -1, -1, -1, - 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, - 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - -1, -1, -1, -1, -1, 65, 66, 67, 68, 69, - 70, 71, -1, 73, 74, 75, 76, 77, 78, -1, - -1, 81, 82, 83, 84, 85, 86, -1, -1, -1, - -1, -1, -1, 93, 94, 95, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, - 9, 10, 11, -1, -1, 14, -1, 16, -1, -1, - -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, - 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 43, -1, -1, -1, 47, -1, - -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, - 59, -1, -1, -1, -1, -1, 65, 66, 67, 68, - 69, 70, 71, -1, 73, 74, 75, 76, 77, 78, - -1, -1, 81, 82, 83, 84, 85, 86, -1, -1, - -1, -1, -1, -1, 93, 94, 95, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, - -1, 9, -1, 11, 12, 13, 14, -1, -1, -1, - -1, -1, -1, 21, 22, -1, -1, -1, -1, -1, - -1, 29, 30, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, - -1, 59, -1, 61, -1, -1, -1, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, -1, -1, 81, 82, 83, 84, 85, -1, 87, - -1, -1, -1, -1, -1, 93, 94, 95, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, - -1, -1, 9, -1, 11, 12, 13, 14, -1, -1, - -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, - -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, 59, -1, 61, -1, -1, -1, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, -1, -1, 81, 82, 83, 84, 85, -1, - 87, -1, -1, -1, -1, -1, 93, 94, 95, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 4, 5, - 6, -1, -1, 9, 10, 11, 12, 13, 14, -1, - 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, - -1, -1, -1, 29, 30, 31, 32, 33, 34, -1, - 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, - -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, - -1, -1, -1, 59, -1, 61, -1, -1, -1, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, -1, -1, 81, 82, 83, 84, 85, - 86, 87, -1, -1, -1, -1, -1, 93, 94, 95, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - 55, -1, -1, -1, 59, -1, 61, -1, -1, -1, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, 87, -1, -1, -1, -1, -1, 93, 94, - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, - - 15, 39, 29, 3, 15, 15, 13, 15, 3, 15, - 29, 9, 15, 15, 3, 3, 39, 22, 19, 15, - 19, 3, 15, 15, 15, 11, 3, 74, 15, 19, - 15, 15, 29, 13, 15, 29, 102, 15, 3, 15, - 97, 3, 100, 15, -1, 15, 29, 22, 15, 3, - 3, 15, 3, 22, 15, 15, 22, 15, 15, 3, - 39, 3, 3, 3, 3, 39, 39, 22, 39, 3, - 15, 39, 15, 2, -1, 13, 39, 13, 2, 2, - 39, 13, 13, 39, 2, 15, 15, 39, 20, 3, - 3, 15, 15, 3, 15, 15, 2, 15, 41, -1, - 2, 51, 51, 51, 53, 51, 56, 53, 56, 15, - 48, 41, 48, 15, 51, 15, 51, 48, 51, 56, - 39, 56, 39, 56, 51, 51, 53, 53, 47, 51, - 47, 53, 4, 15, 2, 51, 15, 53, 15, 51, - 40, 15, 51, 15, 53, 4, 51, 15, 53, 15, - 51, 63, 53, 51, 51, 13, 15, 51, 16, 53, - 42, 75, 75, 51, 3, 44, 43, 65, 15, 43, - 67, 91, 13, 61, -1, 16, 42, 15, 51, 15, - 51, 54, 51, 54, 51, 106, 53, 56, 51, 13, - 53, 51, 16, 53, 2, 51, 43, 51, 35, 2, - 56, 15, 39, 51, 42, 59, 42, 15, 56, 51, - 2, 51, 15, 2, 56, -1, 56, 51, 51, 51, - 2, 51, 56, 15, 57, 57, 15, 57, 51, 4, - 51, 2, -1, 15, 57, 56, 75, 2, 51, 51, - 15, 53, 55, 2, 15, 51, 51, 2, 53, 55, - 15, 51, 51, 53, 53, 51, 15, 53, 51, 2, - 15, 51, 55, 51, 51, 15, 56, 2, 56, 56, - -1, 3, 15, 51, 64, 89, -1, 51, 56, 51, - 15, 68, 56, -1, 56, 73, 58, 51, 66, -1, - -1, 51, 56, -1, 44, 45, 56, 51, 58, 73, - 51, -1, 56, 51, 58, 56, 51, 51, 56, 73, - 51, 56, 56, 58, 13, 56, -1, -1, 62, 60, - -1, 20, 73, 13, 5, 73, 16, 5, 18, -1, - -1, -1, 13, 32, 33, 13, -1, -1, -1, 20, - -1, -1, 20, 75, -1, -1, -1, -1, -1, 39, - 85, 32, 33, -1, 32, 33, 22, 23, 24, 25, - 26, 27, 28, 21, 22, 23, 24, 25, 26, 27, - 28, 13, -1, -1, -1, -1, 2, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, -1, -1, 15, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 13, -1, -1, -1, -1, -1, -1, 20, - 21, 22, 23, 24, 25, 26, 27, 28, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1}; - -QT_END_NAMESPACE diff --git a/src/qml/qml/parser/qqmljsgrammar_p.h b/src/qml/qml/parser/qqmljsgrammar_p.h deleted file mode 100644 index 9ef4695d69..0000000000 --- a/src/qml/qml/parser/qqmljsgrammar_p.h +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// This file was generated by qlalr - DO NOT EDIT! -#ifndef QQMLJSGRAMMAR_P_H -#define QQMLJSGRAMMAR_P_H - -#include - -QT_BEGIN_NAMESPACE - -class QQmlJSGrammar -{ -public: - enum VariousConstants { - EOF_SYMBOL = 0, - REDUCE_HERE = 104, - SHIFT_THERE = 103, - T_AND = 1, - T_AND_AND = 2, - T_AND_EQ = 3, - T_AS = 92, - T_AUTOMATIC_SEMICOLON = 62, - T_BREAK = 4, - T_CASE = 5, - T_CATCH = 6, - T_COLON = 7, - T_COMMA = 8, - T_COMMENT = 88, - T_COMPATIBILITY_SEMICOLON = 89, - T_CONST = 84, - T_CONTINUE = 9, - T_DEBUGGER = 85, - T_DEFAULT = 10, - T_DELETE = 11, - T_DIVIDE_ = 12, - T_DIVIDE_EQ = 13, - T_DO = 14, - T_DOT = 15, - T_ELSE = 16, - T_EQ = 17, - T_EQ_EQ = 18, - T_EQ_EQ_EQ = 19, - T_ERROR = 96, - T_FALSE = 83, - T_FEED_JS_EXPRESSION = 100, - T_FEED_JS_PROGRAM = 102, - T_FEED_JS_SOURCE_ELEMENT = 101, - T_FEED_JS_STATEMENT = 99, - T_FEED_UI_OBJECT_MEMBER = 98, - T_FEED_UI_PROGRAM = 97, - T_FINALLY = 20, - T_FOR = 21, - T_FUNCTION = 22, - T_GE = 23, - T_GET = 94, - T_GT = 24, - T_GT_GT = 25, - T_GT_GT_EQ = 26, - T_GT_GT_GT = 27, - T_GT_GT_GT_EQ = 28, - T_IDENTIFIER = 29, - T_IF = 30, - T_IMPORT = 91, - T_IN = 31, - T_INSTANCEOF = 32, - T_LBRACE = 33, - T_LBRACKET = 34, - T_LE = 35, - T_LPAREN = 36, - T_LT = 37, - T_LT_LT = 38, - T_LT_LT_EQ = 39, - T_MINUS = 40, - T_MINUS_EQ = 41, - T_MINUS_MINUS = 42, - T_MULTILINE_STRING_LITERAL = 87, - T_NEW = 43, - T_NOT = 44, - T_NOT_EQ = 45, - T_NOT_EQ_EQ = 46, - T_NULL = 81, - T_NUMERIC_LITERAL = 47, - T_ON = 93, - T_OR = 48, - T_OR_EQ = 49, - T_OR_OR = 50, - T_PLUS = 51, - T_PLUS_EQ = 52, - T_PLUS_PLUS = 53, - T_PROPERTY = 66, - T_PUBLIC = 90, - T_QUESTION = 54, - T_RBRACE = 55, - T_RBRACKET = 56, - T_READONLY = 68, - T_REMAINDER = 57, - T_REMAINDER_EQ = 58, - T_RESERVED_WORD = 86, - T_RETURN = 59, - T_RPAREN = 60, - T_SEMICOLON = 61, - T_SET = 95, - T_SIGNAL = 67, - T_STAR = 63, - T_STAR_EQ = 64, - T_STRING_LITERAL = 65, - T_SWITCH = 69, - T_THIS = 70, - T_THROW = 71, - T_TILDE = 72, - T_TRUE = 82, - T_TRY = 73, - T_TYPEOF = 74, - T_VAR = 75, - T_VOID = 76, - T_WHILE = 77, - T_WITH = 78, - T_XOR = 79, - T_XOR_EQ = 80, - - ACCEPT_STATE = 655, - RULE_COUNT = 351, - STATE_COUNT = 656, - TERMINAL_COUNT = 105, - NON_TERMINAL_COUNT = 108, - - GOTO_INDEX_OFFSET = 656, - GOTO_INFO_OFFSET = 2970, - GOTO_CHECK_OFFSET = 2970 - }; - - static const char *const spell []; - static const short lhs []; - static const short rhs []; - static const short goto_default []; - static const short action_default []; - static const short action_index []; - static const short action_info []; - static const short action_check []; - - static inline int nt_action (int state, int nt) - { - const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; - if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) - return goto_default [nt]; - - return action_info [GOTO_INFO_OFFSET + yyn]; - } - - static inline int t_action (int state, int token) - { - const int yyn = action_index [state] + token; - - if (yyn < 0 || action_check [yyn] != token) - return - action_default [state]; - - return action_info [yyn]; - } -}; - - -QT_END_NAMESPACE -#endif // QQMLJSGRAMMAR_P_H - diff --git a/src/qml/qml/parser/qqmljskeywords_p.h b/src/qml/qml/parser/qqmljskeywords_p.h deleted file mode 100644 index 7fcf001303..0000000000 --- a/src/qml/qml/parser/qqmljskeywords_p.h +++ /dev/null @@ -1,884 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSKEYWORDS_P_H -#define QQMLJSKEYWORDS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljslexer_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -static inline int classify2(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 's') { - return qmlMode ? Lexer::T_AS : Lexer::T_IDENTIFIER; - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'o') { - return Lexer::T_DO; - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'f') { - return Lexer::T_IF; - } - else if (s[1].unicode() == 'n') { - return Lexer::T_IN; - } - } - else if (qmlMode && s[0].unicode() == 'o') { - if (s[1].unicode() == 'n') { - return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER; - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify3(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'r') { - return Lexer::T_FOR; - } - } - } - else if (s[0].unicode() == 'g') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 't') { - return Lexer::T_GET; - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - return qmlMode ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER); - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'w') { - return Lexer::T_NEW; - } - } - } - else if (s[0].unicode() == 's') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 't') { - return Lexer::T_SET; - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'y') { - return Lexer::T_TRY; - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'r') { - return Lexer::T_VAR; - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify4(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - return qmlMode ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_CASE; - } - } - } - else if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'r') { - return qmlMode ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'l') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_ELSE; - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'm') { - return Lexer::T_ENUM; - } - } - } - } - else if (s[0].unicode() == 'g') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'o') { - return qmlMode ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[0].unicode() == 'l') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'g') { - return qmlMode ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'l') { - return Lexer::T_NULL; - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 's') { - return Lexer::T_THIS; - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'e') { - return Lexer::T_TRUE; - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'd') { - return Lexer::T_VOID; - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'h') { - return Lexer::T_WITH; - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify5(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'e') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'k') { - return Lexer::T_BREAK; - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - return Lexer::T_CATCH; - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 's') { - return Lexer::T_CLASS; - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 't') { - return qmlMode ? int(Lexer::T_CONST) : int(Lexer::T_RESERVED_WORD); - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 'e') { - return Lexer::T_FALSE; - } - } - } - } - else if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - return qmlMode ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - return qmlMode ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'r') { - if (s[4].unicode() == 't') { - return qmlMode ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER); - } - } - } - } - else if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - return qmlMode ? int(Lexer::T_SUPER) : int(Lexer::T_RESERVED_WORD); - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - return Lexer::T_THROW; - } - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - return Lexer::T_WHILE; - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify6(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'e') { - return Lexer::T_DELETE; - } - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'b') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'e') { - return qmlMode ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return Lexer::T_EXPORT; - } - } - } - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return qmlMode ? int(Lexer::T_IMPORT) : int(Lexer::T_RESERVED_WORD); - } - } - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'i') { - if (s[4].unicode() == 'v') { - if (s[5].unicode() == 'e') { - return qmlMode ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER; - } - } - } - } - } - } - else if (s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'n') { - return Lexer::T_RETURN; - } - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (qmlMode && s[1].unicode() == 'i') { - if (s[2].unicode() == 'g') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'l') { - return Lexer::T_SIGNAL; - } - } - } - } - } - else if (s[1].unicode() == 't') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return qmlMode ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - else if (s[1].unicode() == 'w') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'c') { - if (s[5].unicode() == 'h') { - return Lexer::T_SWITCH; - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - if (s[5].unicode() == 's') { - return qmlMode ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - else if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'f') { - return Lexer::T_TYPEOF; - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify7(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'n') { - return qmlMode ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'f') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'u') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 't') { - return Lexer::T_DEFAULT; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'n') { - if (s[5].unicode() == 'd') { - if (s[6].unicode() == 's') { - return Lexer::T_EXTENDS; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 'y') { - return Lexer::T_FINALLY; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'c') { - if (s[3].unicode() == 'k') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - return qmlMode ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'v') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 't') { - if (s[6].unicode() == 'e') { - return qmlMode ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify8(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 'b') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 't') { - return qmlMode ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'u') { - if (s[7].unicode() == 'e') { - return Lexer::T_CONTINUE; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'g') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'r') { - return Lexer::T_DEBUGGER; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - return Lexer::T_FUNCTION; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'p') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'y') { - return qmlMode ? Lexer::T_PROPERTY : Lexer::T_IDENTIFIER; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'd') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'y') { - return Lexer::T_READONLY; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'e') { - return qmlMode ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify9(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'f') { - if (s[6].unicode() == 'a') { - if (s[7].unicode() == 'c') { - if (s[8].unicode() == 'e') { - return qmlMode ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'c') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'd') { - return qmlMode ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 's') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - return qmlMode ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify10(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'm') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - if (s[9].unicode() == 's') { - return qmlMode ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'o') { - if (s[9].unicode() == 'f') { - return Lexer::T_INSTANCEOF; - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify12(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 's') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 'i') { - if (s[9].unicode() == 'z') { - if (s[10].unicode() == 'e') { - if (s[11].unicode() == 'd') { - return qmlMode ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER); - } - } - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -int Lexer::classify(const QChar *s, int n, bool qmlMode) { - switch (n) { - case 2: return classify2(s, qmlMode); - case 3: return classify3(s, qmlMode); - case 4: return classify4(s, qmlMode); - case 5: return classify5(s, qmlMode); - case 6: return classify6(s, qmlMode); - case 7: return classify7(s, qmlMode); - case 8: return classify8(s, qmlMode); - case 9: return classify9(s, qmlMode); - case 10: return classify10(s, qmlMode); - case 12: return classify12(s, qmlMode); - default: return Lexer::T_IDENTIFIER; - } // switch -} - -} // namespace QQmlJS - -QT_QML_END_NAMESPACE - -#endif // QQMLJSKEYWORDS_P_H diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp deleted file mode 100644 index 5d9ca1036f..0000000000 --- a/src/qml/qml/parser/qqmljslexer.cpp +++ /dev/null @@ -1,1329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljslexer_p.h" -#include "qqmljsengine_p.h" -#include "qqmljsmemorypool_p.h" -#include "qqmljskeywords_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); -QT_END_NAMESPACE - -using namespace QQmlJS; - -static inline int regExpFlagFromChar(const QChar &ch) -{ - switch (ch.unicode()) { - case 'g': return Lexer::RegExp_Global; - case 'i': return Lexer::RegExp_IgnoreCase; - case 'm': return Lexer::RegExp_Multiline; - } - return 0; -} - -static inline unsigned char convertHex(ushort c) -{ - if (c >= '0' && c <= '9') - return (c - '0'); - else if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - else - return (c - 'A' + 10); -} - -static inline QChar convertHex(QChar c1, QChar c2) -{ - return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -static inline QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4) -{ - return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()), - (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -Lexer::Lexer(Engine *engine) - : _engine(engine) - , _codePtr(0) - , _lastLinePtr(0) - , _tokenLinePtr(0) - , _tokenStartPtr(0) - , _char(QLatin1Char('\n')) - , _errorCode(NoError) - , _currentLineNumber(0) - , _tokenValue(0) - , _parenthesesState(IgnoreParentheses) - , _parenthesesCount(0) - , _stackToken(-1) - , _patternFlags(0) - , _tokenKind(0) - , _tokenLength(0) - , _tokenLine(0) - , _validTokenText(false) - , _prohibitAutomaticSemicolon(false) - , _restrictedKeyword(false) - , _terminator(false) - , _followsClosingBrace(false) - , _delimited(true) - , _qmlMode(true) -{ - if (engine) - engine->setLexer(this); -} - -bool Lexer::qmlMode() const -{ - return _qmlMode; -} - -QString Lexer::code() const -{ - return _code; -} - -void Lexer::setCode(const QString &code, int lineno, bool qmlMode) -{ - if (_engine) - _engine->setCode(code); - - _qmlMode = qmlMode; - _code = code; - _tokenText.clear(); - _tokenText.reserve(1024); - _errorMessage.clear(); - _tokenSpell = QStringRef(); - - _codePtr = code.unicode(); - _endPtr = _codePtr + code.length(); - _lastLinePtr = _codePtr; - _tokenLinePtr = _codePtr; - _tokenStartPtr = _codePtr; - - _char = QLatin1Char('\n'); - _errorCode = NoError; - - _currentLineNumber = lineno; - _tokenValue = 0; - - // parentheses state - _parenthesesState = IgnoreParentheses; - _parenthesesCount = 0; - - _stackToken = -1; - - _patternFlags = 0; - _tokenLength = 0; - _tokenLine = lineno; - - _validTokenText = false; - _prohibitAutomaticSemicolon = false; - _restrictedKeyword = false; - _terminator = false; - _followsClosingBrace = false; - _delimited = true; -} - -void Lexer::scanChar() -{ - unsigned sequenceLength = isLineTerminatorSequence(); - _char = *_codePtr++; - if (sequenceLength == 2) - _char = *_codePtr++; - - if (unsigned sequenceLength = isLineTerminatorSequence()) { - _lastLinePtr = _codePtr + sequenceLength - 1; // points to the first character after the newline - ++_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() -{ - const int previousTokenKind = _tokenKind; - - _tokenSpell = QStringRef(); - _tokenKind = scanToken(); - _tokenLength = _codePtr - _tokenStartPtr - 1; - - _delimited = false; - _restrictedKeyword = false; - _followsClosingBrace = (previousTokenKind == T_RBRACE); - - // update the flags - switch (_tokenKind) { - case T_LBRACE: - case T_SEMICOLON: - case T_QUESTION: - case T_COLON: - case T_TILDE: - _delimited = true; - break; - default: - if (isBinop(_tokenKind)) - _delimited = true; - break; - - case T_IF: - case T_FOR: - case T_WHILE: - case T_WITH: - _parenthesesState = CountParentheses; - _parenthesesCount = 0; - break; - - case T_DO: - _parenthesesState = BalancedParentheses; - break; - - case T_CONTINUE: - case T_BREAK: - case T_RETURN: - case T_THROW: - _restrictedKeyword = true; - break; - } // switch - - // update the parentheses state - switch (_parenthesesState) { - case IgnoreParentheses: - break; - - case CountParentheses: - if (_tokenKind == T_RPAREN) { - --_parenthesesCount; - if (_parenthesesCount == 0) - _parenthesesState = BalancedParentheses; - } else if (_tokenKind == T_LPAREN) { - ++_parenthesesCount; - } - break; - - case BalancedParentheses: - if (_tokenKind != T_DO) - _parenthesesState = IgnoreParentheses; - break; - } // switch - - return _tokenKind; -} - -bool Lexer::isUnicodeEscapeSequence(const QChar *chars) -{ - if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3])) - return true; - - return false; -} - -QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) -{ - if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) { - scanChar(); // skip u - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - const QChar c3 = _char; - scanChar(); - - const QChar c4 = _char; - scanChar(); - - if (ok) - *ok = true; - - return convertUnicode(c1, c2, c3, c4); - } - - *ok = false; - return QChar(); -} - -QChar Lexer::decodeHexEscapeCharacter(bool *ok) -{ - if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { - scanChar(); - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - if (ok) - *ok = true; - - return convertHex(c1, c2); - } - - *ok = false; - 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() -{ - if (_stackToken != -1) { - int tk = _stackToken; - _stackToken = -1; - return tk; - } - - _terminator = false; - -again: - _validTokenText = false; - _tokenLinePtr = _lastLinePtr; - - while (_char.isSpace()) { - if (unsigned sequenceLength = isLineTerminatorSequence()) { - _tokenLinePtr = _codePtr + sequenceLength - 1; - - if (_restrictedKeyword) { - // automatic semicolon insertion - _tokenLine = _currentLineNumber; - _tokenStartPtr = _codePtr - 1; - return T_SEMICOLON; - } else { - _terminator = true; - syncProhibitAutomaticSemicolon(); - } - } - - scanChar(); - } - - _tokenStartPtr = _codePtr - 1; - _tokenLine = _currentLineNumber; - - if (_codePtr > _endPtr) - return EOF_SYMBOL; - - const QChar ch = _char; - scanChar(); - - switch (ch.unicode()) { - case '~': return T_TILDE; - case '}': return T_RBRACE; - - case '|': - if (_char == QLatin1Char('|')) { - scanChar(); - return T_OR_OR; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_OR_EQ; - } - return T_OR; - - case '{': return T_LBRACE; - - case '^': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_XOR_EQ; - } - return T_XOR; - - case ']': return T_RBRACKET; - case '[': return T_LBRACKET; - case '?': return T_QUESTION; - - case '>': - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_GT_EQ; - } - return T_GT_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_EQ; - } - return T_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GE; - } - return T_GT; - - case '=': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_EQ_EQ_EQ; - } - return T_EQ_EQ; - } - return T_EQ; - - case '<': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LE; - } else if (_char == QLatin1Char('<')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LT_LT_EQ; - } - return T_LT_LT; - } - return T_LT; - - case ';': return T_SEMICOLON; - case ':': return T_COLON; - - case '/': - if (_char == QLatin1Char('*')) { - scanChar(); - while (_codePtr <= _endPtr) { - if (_char == QLatin1Char('*')) { - scanChar(); - if (_char == QLatin1Char('/')) { - scanChar(); - - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4, - tokenStartLine(), tokenStartColumn() + 2); - } - - goto again; - } - } else { - scanChar(); - } - } - } else if (_char == QLatin1Char('/')) { - while (_codePtr <= _endPtr && !isLineTerminator()) { - scanChar(); - } - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2, - tokenStartLine(), tokenStartColumn() + 2); - } - goto again; - } if (_char == QLatin1Char('=')) { - scanChar(); - return T_DIVIDE_EQ; - } - return T_DIVIDE_; - - case '.': - if (_char.isDigit()) { - QVarLengthArray chars; - - chars.append(ch.unicode()); // append the `.' - - 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(); - } - } - } - - 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; - } - return T_DOT; - - case '-': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_MINUS_EQ; - } else if (_char == QLatin1Char('-')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_MINUS_MINUS; - return T_SEMICOLON; - } - - return T_MINUS_MINUS; - } - return T_MINUS; - - case ',': return T_COMMA; - - case '+': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_PLUS_EQ; - } else if (_char == QLatin1Char('+')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_PLUS_PLUS; - return T_SEMICOLON; - } - - return T_PLUS_PLUS; - } - return T_PLUS; - - case '*': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_STAR_EQ; - } - return T_STAR; - - case ')': return T_RPAREN; - case '(': return T_LPAREN; - - case '&': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_AND_EQ; - } else if (_char == QLatin1Char('&')) { - scanChar(); - return T_AND_AND; - } - return T_AND; - - case '%': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_REMAINDER_EQ; - } - return T_REMAINDER; - - case '!': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_NOT_EQ_EQ; - } - return T_NOT_EQ; - } - return T_NOT; - - case '\'': - case '"': { - const QChar quote = ch; - bool multilineStringLiteral = false; - - const QChar *startCode = _codePtr; - - if (_engine) { - while (_codePtr <= _endPtr) { - if (isLineTerminator()) { - if (qmlMode()) - break; - _errorCode = IllegalCharacter; - _errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal"); - return T_ERROR; - } else if (_char == QLatin1Char('\\')) { - break; - } else if (_char == quote) { - _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode); - scanChar(); - - return T_STRING_LITERAL; - } - scanChar(); - } - } - - _validTokenText = true; - _tokenText.resize(0); - startCode--; - while (startCode != _codePtr - 1) - _tokenText += *startCode++; - - while (_codePtr <= _endPtr) { - if (unsigned sequenceLength = isLineTerminatorSequence()) { - multilineStringLiteral = true; - _tokenText += _char; - if (sequenceLength == 2) - _tokenText += *_codePtr; - scanChar(); - } else if (_char == quote) { - scanChar(); - - if (_engine) - _tokenSpell = _engine->newStringRef(_tokenText); - - return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL; - } else if (_char == QLatin1Char('\\')) { - scanChar(); - - QChar u; - - switch (_char.unicode()) { - // unicode escape sequence - case 'u': { - bool ok = false; - u = decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - } break; - - // hex escape sequence - case 'x': { - bool ok = false; - u = decodeHexEscapeCharacter(&ok); - if (!ok) { - _errorCode = IllegalHexadecimalEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal hexadecimal escape sequence"); - return T_ERROR; - } - } break; - - // single character escape sequence - case '\\': u = QLatin1Char('\\'); scanChar(); break; - case '\'': u = QLatin1Char('\''); scanChar(); break; - case '\"': u = QLatin1Char('\"'); scanChar(); break; - case 'b': u = QLatin1Char('\b'); scanChar(); break; - case 'f': u = QLatin1Char('\f'); scanChar(); break; - case 'n': u = QLatin1Char('\n'); scanChar(); break; - case 'r': u = QLatin1Char('\r'); scanChar(); break; - case 't': u = QLatin1Char('\t'); scanChar(); break; - case 'v': u = QLatin1Char('\v'); scanChar(); break; - - case '0': - if (! _codePtr->isDigit()) { - scanChar(); - u = QLatin1Char('\0'); - 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 '\n': - case 0x2028u: - case 0x2029u: - scanChar(); - continue; - - default: - // non escape character - u = _char; - scanChar(); - } - - _tokenText += u; - } else { - _tokenText += _char; - scanChar(); - } - } - - _errorCode = UnclosedStringLiteral; - _errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line"); - 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: { - QChar c = ch; - bool identifierWithEscapeChars = false; - if (c == QLatin1Char('\\') && _char == QLatin1Char('u')) { - 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 += c; - _validTokenText = true; - } - while (true) { - c = _char; - if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) { - if (! identifierWithEscapeChars) { - identifierWithEscapeChars = true; - _tokenText.resize(0); - _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1); - _validTokenText = true; - } - - scanChar(); // skip '\\' - bool ok = false; - c = decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - if (isIdentifierPart(c)) - _tokenText += c; - continue; - } else if (isIdentifierPart(c)) { - if (identifierWithEscapeChars) - _tokenText += c; - - scanChar(); - continue; - } - - _tokenLength = _codePtr - _tokenStartPtr - 1; - - 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; - } - } - } - - break; - } - - 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 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) -{ - _tokenText.resize(0); - _validTokenText = true; - _patternFlags = 0; - - if (prefix == EqualPrefix) - _tokenText += QLatin1Char('='); - - while (true) { - switch (_char.unicode()) { - case '/': - scanChar(); - - // scan the flags - _patternFlags = 0; - while (isIdentLetter(_char)) { - int flag = regExpFlagFromChar(_char); - if (flag == 0 || _patternFlags & flag) { - _errorMessage = QCoreApplication::translate("QQmlParser", "Invalid regular expression flag '%0'") - .arg(QChar(_char)); - return false; - } - _patternFlags |= flag; - scanChar(); - } - - _tokenLength = _codePtr - _tokenStartPtr - 1; - return true; - - case '\\': - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_codePtr > _endPtr || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - break; - - case '[': - // regular expression class - _tokenText += _char; - scanChar(); - - while (_codePtr <= _endPtr && ! isLineTerminator()) { - if (_char == QLatin1Char(']')) - break; - else if (_char == QLatin1Char('\\')) { - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_codePtr > _endPtr || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - } else { - _tokenText += _char; - scanChar(); - } - } - - if (_char != QLatin1Char(']')) { - _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression class"); - return false; - } - - _tokenText += _char; - scanChar(); // skip ] - break; - - default: - if (_codePtr > _endPtr || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression literal"); - return false; - } else { - _tokenText += _char; - scanChar(); - } - } // switch - } // while - - return false; -} - -bool Lexer::isLineTerminator() const -{ - 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) -{ - // ASCII-biased, since all reserved words are ASCII, aand hence the - // bulk of content to be parsed. - if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) - || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) - || ch == QLatin1Char('$') - || ch == QLatin1Char('_')) - return true; - if (ch.unicode() < 128) - return false; - return ch.isLetterOrNumber(); -} - -bool Lexer::isDecimalDigit(ushort c) -{ - return (c >= '0' && c <= '9'); -} - -bool Lexer::isHexDigit(QChar c) -{ - return ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) - || (c >= QLatin1Char('a') && c <= QLatin1Char('f')) - || (c >= QLatin1Char('A') && c <= QLatin1Char('F'))); -} - -bool Lexer::isOctalDigit(ushort c) -{ - return (c >= '0' && c <= '7'); -} - -int Lexer::tokenEndLine() const -{ - return _currentLineNumber; -} - -int Lexer::tokenEndColumn() const -{ - return _codePtr - _lastLinePtr; -} - -QString Lexer::tokenText() const -{ - if (_validTokenText) - return _tokenText; - - if (_tokenKind == T_STRING_LITERAL) - return QString(_tokenStartPtr + 1, _tokenLength - 2); - - return QString(_tokenStartPtr, _tokenLength); -} - -Lexer::Error Lexer::errorCode() const -{ - return _errorCode; -} - -QString Lexer::errorMessage() const -{ - return _errorMessage; -} - -void Lexer::syncProhibitAutomaticSemicolon() -{ - if (_parenthesesState == BalancedParentheses) { - // we have seen something like "if (foo)", which means we should - // never insert an automatic semicolon at this point, since it would - // then be expanded into an empty statement (ECMA-262 7.9.1) - _prohibitAutomaticSemicolon = true; - _parenthesesState = IgnoreParentheses; - } else { - _prohibitAutomaticSemicolon = false; - } -} - -bool Lexer::prevTerminator() const -{ - return _terminator; -} - -bool Lexer::followsClosingBrace() const -{ - return _followsClosingBrace; -} - -bool Lexer::canInsertAutomaticSemicolon(int token) const -{ - return token == T_RBRACE - || token == EOF_SYMBOL - || _terminator - || _followsClosingBrace; -} - -bool Lexer::scanDirectives(Directives *directives) -{ - if (_qmlMode) { - // the directives are a Javascript-only extension. - return false; - } - - lex(); // fetch the first token - - if (_tokenKind != T_DOT) - return true; - - do { - lex(); // skip T_DOT - - const int lineNumber = tokenStartLine(); - - if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) - return false; // expected a valid QML/JS directive - - const QString directiveName = tokenText(); - - if (! (directiveName == QLatin1String("pragma") || - directiveName == QLatin1String("import"))) - return false; // not a valid directive name - - // it must be a pragma or an import directive. - if (directiveName == QLatin1String("pragma")) { - // .pragma library - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) - return false; // expected `library - - // we found a .pragma library directive - directives->pragmaLibrary(); - - } else { - Q_ASSERT(directiveName == QLatin1String("import")); - lex(); // skip .import - - QString pathOrUri; - QString version; - bool fileImport = false; // file or uri import - - if (_tokenKind == T_STRING_LITERAL) { - // .import T_STRING_LITERAL as T_IDENTIFIER - - fileImport = true; - pathOrUri = tokenText(); - - } else if (_tokenKind == T_IDENTIFIER) { - // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER - - pathOrUri = tokenText(); - - lex(); // skip the first T_IDENTIFIER - for (; _tokenKind == T_DOT; lex()) { - if (lex() != T_IDENTIFIER) - return false; - - pathOrUri += QLatin1Char('.'); - pathOrUri += tokenText(); - } - - if (_tokenKind != T_NUMERIC_LITERAL) - return false; // expected the module version number - - version = tokenText(); - } - - // - // recognize the mandatory `as' followed by the module name - // - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as"))) - return false; // expected `as' - - if (lex() != T_IDENTIFIER) - return false; // expected module name - - const QString module = tokenText(); - - if (fileImport) - directives->importFile(pathOrUri, module); - else - directives->importModule(pathOrUri, version, module); - } - - if (tokenStartLine() != lineNumber) - return false; // the directives cannot span over multiple lines - - // fetch the first token after the .pragma/.import directive - lex(); - } while (_tokenKind == T_DOT); - - return true; -} diff --git a/src/qml/qml/parser/qqmljslexer_p.h b/src/qml/qml/parser/qqmljslexer_p.h deleted file mode 100644 index 23af61d650..0000000000 --- a/src/qml/qml/parser/qqmljslexer_p.h +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSLEXER_P_H -#define QQMLJSLEXER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljsglobal_p.h" -#include "qqmljsgrammar_p.h" - -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -class Engine; - -class QML_PARSER_EXPORT Directives { -public: - virtual ~Directives() {} - - virtual void pragmaLibrary() - { - } - - virtual void importFile(const QString &jsfile, const QString &module) - { - Q_UNUSED(jsfile); - Q_UNUSED(module); - } - - virtual void importModule(const QString &uri, const QString &version, const QString &module) - { - Q_UNUSED(uri); - Q_UNUSED(version); - Q_UNUSED(module); - } -}; - -class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar -{ -public: - enum { - T_ABSTRACT = T_RESERVED_WORD, - T_BOOLEAN = T_RESERVED_WORD, - T_BYTE = T_RESERVED_WORD, - T_CHAR = T_RESERVED_WORD, - T_CLASS = T_RESERVED_WORD, - T_DOUBLE = T_RESERVED_WORD, - T_ENUM = T_RESERVED_WORD, - T_EXPORT = T_RESERVED_WORD, - T_EXTENDS = T_RESERVED_WORD, - T_FINAL = T_RESERVED_WORD, - T_FLOAT = T_RESERVED_WORD, - T_GOTO = T_RESERVED_WORD, - T_IMPLEMENTS = T_RESERVED_WORD, - T_INT = T_RESERVED_WORD, - T_INTERFACE = T_RESERVED_WORD, - T_LONG = T_RESERVED_WORD, - T_NATIVE = T_RESERVED_WORD, - T_PACKAGE = T_RESERVED_WORD, - T_PRIVATE = T_RESERVED_WORD, - T_PROTECTED = T_RESERVED_WORD, - T_SHORT = T_RESERVED_WORD, - T_STATIC = T_RESERVED_WORD, - T_SUPER = T_RESERVED_WORD, - T_SYNCHRONIZED = T_RESERVED_WORD, - T_THROWS = T_RESERVED_WORD, - T_TRANSIENT = T_RESERVED_WORD, - T_VOLATILE = T_RESERVED_WORD - }; - - enum Error { - NoError, - IllegalCharacter, - IllegalHexNumber, - UnclosedStringLiteral, - IllegalEscapeSequence, - IllegalUnicodeEscapeSequence, - UnclosedComment, - IllegalExponentIndicator, - IllegalIdentifier, - IllegalHexadecimalEscapeSequence - }; - - enum RegExpBodyPrefix { - NoPrefix, - EqualPrefix - }; - - enum RegExpFlag { - RegExp_Global = 0x01, - RegExp_IgnoreCase = 0x02, - RegExp_Multiline = 0x04 - }; - -public: - Lexer(Engine *engine); - - bool qmlMode() const; - - QString code() const; - void setCode(const QString &code, int lineno, bool qmlMode = true); - - int lex(); - - bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); - bool scanDirectives(Directives *directives); - - int regExpFlags() const { return _patternFlags; } - QString regExpPattern() const { return _tokenText; } - - int tokenKind() const { return _tokenKind; } - int tokenOffset() const { return _tokenStartPtr - _code.unicode(); } - int tokenLength() const { return _tokenLength; } - - int tokenStartLine() const { return _tokenLine; } - int tokenStartColumn() const { return _tokenStartPtr - _tokenLinePtr + 1; } - - int tokenEndLine() const; - int tokenEndColumn() const; - - inline QStringRef tokenSpell() const { return _tokenSpell; } - double tokenValue() const { return _tokenValue; } - QString tokenText() const; - - Error errorCode() const; - QString errorMessage() const; - - bool prevTerminator() const; - bool followsClosingBrace() const; - bool canInsertAutomaticSemicolon(int token) const; - - enum ParenthesesState { - IgnoreParentheses, - CountParentheses, - BalancedParentheses - }; - -protected: - int classify(const QChar *s, int n, bool qmlMode); - -private: - inline void scanChar(); - int scanToken(); - int scanNumber(QChar ch); - - bool isLineTerminator() const; - unsigned isLineTerminatorSequence() const; - static bool isIdentLetter(QChar c); - static bool isDecimalDigit(ushort c); - static bool isHexDigit(QChar c); - static bool isOctalDigit(ushort c); - static bool isUnicodeEscapeSequence(const QChar *chars); - - void syncProhibitAutomaticSemicolon(); - QChar decodeUnicodeEscapeCharacter(bool *ok); - QChar decodeHexEscapeCharacter(bool *ok); - -private: - Engine *_engine; - - QString _code; - QString _tokenText; - QString _errorMessage; - QStringRef _tokenSpell; - - const QChar *_codePtr; - const QChar *_endPtr; - const QChar *_lastLinePtr; - const QChar *_tokenLinePtr; - const QChar *_tokenStartPtr; - - QChar _char; - Error _errorCode; - - int _currentLineNumber; - double _tokenValue; - - // parentheses state - ParenthesesState _parenthesesState; - int _parenthesesCount; - - int _stackToken; - - int _patternFlags; - int _tokenKind; - int _tokenLength; - int _tokenLine; - - bool _validTokenText; - bool _prohibitAutomaticSemicolon; - bool _restrictedKeyword; - bool _terminator; - bool _followsClosingBrace; - bool _delimited; - bool _qmlMode; -}; - -} // end of namespace QQmlJS - -QT_QML_END_NAMESPACE - -#endif // LEXER_H diff --git a/src/qml/qml/parser/qqmljsmemorypool_p.h b/src/qml/qml/parser/qqmljsmemorypool_p.h deleted file mode 100644 index 820ae8ed71..0000000000 --- a/src/qml/qml/parser/qqmljsmemorypool_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSMEMORYPOOL_P_H -#define QQMLJSMEMORYPOOL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmljsglobal_p.h" - -#include -#include -#include - -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -class QML_PARSER_EXPORT MemoryPool : public QSharedData -{ - MemoryPool(const MemoryPool &other); - void operator =(const MemoryPool &other); - -public: - MemoryPool() - : _blocks(0), - _allocatedBlocks(0), - _blockCount(-1), - _ptr(0), - _end(0) - { } - - ~MemoryPool() - { - if (_blocks) { - for (int i = 0; i < _allocatedBlocks; ++i) { - if (char *b = _blocks[i]) - free(b); - } - - free(_blocks); - } - } - - inline void *allocate(size_t size) - { - size = (size + 7) & ~7; - if (_ptr && (_ptr + size < _end)) { - void *addr = _ptr; - _ptr += size; - return addr; - } - return allocate_helper(size); - } - - void reset() - { - _blockCount = -1; - _ptr = _end = 0; - } - -private: - void *allocate_helper(size_t size) - { - Q_ASSERT(size < BLOCK_SIZE); - - if (++_blockCount == _allocatedBlocks) { - if (! _allocatedBlocks) - _allocatedBlocks = DEFAULT_BLOCK_COUNT; - else - _allocatedBlocks *= 2; - - _blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks); - - for (int index = _blockCount; index < _allocatedBlocks; ++index) - _blocks[index] = 0; - } - - char *&block = _blocks[_blockCount]; - - if (! block) - block = (char *) malloc(BLOCK_SIZE); - - _ptr = block; - _end = _ptr + BLOCK_SIZE; - - void *addr = _ptr; - _ptr += size; - return addr; - } - -private: - char **_blocks; - int _allocatedBlocks; - int _blockCount; - char *_ptr; - char *_end; - - enum - { - BLOCK_SIZE = 8 * 1024, - DEFAULT_BLOCK_COUNT = 8 - }; -}; - -class QML_PARSER_EXPORT Managed -{ - Managed(const Managed &other); - void operator = (const Managed &other); - -public: - Managed() {} - ~Managed() {} - - void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } - void operator delete(void *) {} - void operator delete(void *, MemoryPool *) {} -}; - -} // namespace QQmlJS - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/qml/qml/parser/qqmljsparser.cpp b/src/qml/qml/parser/qqmljsparser.cpp deleted file mode 100644 index 46b5c041d4..0000000000 --- a/src/qml/qml/parser/qqmljsparser.cpp +++ /dev/null @@ -1,1844 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmljsengine_p.h" -#include "qqmljslexer_p.h" -#include "qqmljsast_p.h" -#include "qqmljsmemorypool_p.h" - -#include -#include - -#include - - -#include "qqmljsparser_p.h" - -#include - -// -// W A R N I N G -// ------------- -// -// 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; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - program(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { - -case 0: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 1: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 2: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 3: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 4: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 5: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 6: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; - -case 8: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; - -case 9: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; - -case 10: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; - -case 13: { - sym(1).UiImport->semicolonToken = loc(2); -} break; - -case 15: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; - -case 17: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; - -case 19: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; - -case 20: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; - -case 21: { - sym(1).Node = 0; -} break; - -case 22: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 23: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 24: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; - -case 25: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; - -case 26: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 27: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; - -case 28: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 29: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; - -case 31: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 32: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 33: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; - -case 41: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 45: { - sym(1).Node = 0; -} break; - -case 46: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; - -case 47: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; - -case 48: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->propertyTypeToken = loc(3); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; - -case 50: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; - -case 52: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 54: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 56: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; - -case 58: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; - -case 59: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 60: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 61: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 62: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 63: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 64: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 65: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 73: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; - -case 74: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 75: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; - -case 76: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; - -case 77: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; - -case 78: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -case 79: -case 80: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 81: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 82: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 83: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; - -case 84: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 85: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 86: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 87: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 88: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyAssignmentList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 89: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyAssignmentList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; - -case 90: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; - -case 91: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; - -case 92: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; - -case 93: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; - -case 94: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 95: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 96: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; - -case 97: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 98: { - AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 99: { - AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( - 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; - -case 100: { - 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; - -case 101: { - sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment); -} break; - -case 102: { - AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList( - sym(1).PropertyAssignmentList, sym(3).PropertyAssignment); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 103: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 104: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 105: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 106: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 142: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 143: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 144: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; - -case 146: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; - -case 147: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 148: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 149: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 150: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 151: { - sym(1).Node = 0; -} break; - -case 152: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; - -case 153: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; - -case 154: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 158: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; - -case 159: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; - -case 161: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; - -case 162: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; - -case 163: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; - -case 164: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; - -case 165: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; - -case 166: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; - -case 167: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; - -case 168: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; - -case 169: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; - -case 171: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 172: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 173: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 175: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 176: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 178: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 179: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 180: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 182: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 183: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 184: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 185: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 186: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 187: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 189: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 190: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 191: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 192: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 193: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 195: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 196: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 197: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 198: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 200: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 201: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 202: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 203: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 205: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 207: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 209: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 211: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 213: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 215: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 217: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 219: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 221: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 223: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 225: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 227: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 229: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 231: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 232: { - sym(1).ival = QSOperator::Assign; -} break; - -case 233: { - sym(1).ival = QSOperator::InplaceMul; -} break; - -case 234: { - sym(1).ival = QSOperator::InplaceDiv; -} break; - -case 235: { - sym(1).ival = QSOperator::InplaceMod; -} break; - -case 236: { - sym(1).ival = QSOperator::InplaceAdd; -} break; - -case 237: { - sym(1).ival = QSOperator::InplaceSub; -} break; - -case 238: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; - -case 239: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; - -case 240: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; - -case 241: { - sym(1).ival = QSOperator::InplaceAnd; -} break; - -case 242: { - sym(1).ival = QSOperator::InplaceXor; -} break; - -case 243: { - sym(1).ival = QSOperator::InplaceOr; -} break; - -case 245: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 246: { - sym(1).Node = 0; -} break; - -case 249: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 250: { - sym(1).Node = 0; -} break; - -case 267: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 268: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; - -case 269: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; - -case 270: { - sym(1).Node = 0; -} break; - -case 271: { - sym(1).Node = sym(1).StatementList->finish (); -} break; - -case 273: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 274: { - sym(1).ival = T_CONST; -} break; - -case 275: { - sym(1).ival = T_VAR; -} break; - -case 276: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 277: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 278: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 279: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; - -case 280: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 281: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 282: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 283: { - sym(1).Node = 0; -} break; - -case 285: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 286: { - sym(1).Node = 0; -} break; - -case 288: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; - -case 290: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 291: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; - -case 292: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 295: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 296: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 297: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; - -case 298: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; - -case 299: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; - -case 300: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; - -case 302: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 304: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 306: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 308: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 310: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 311: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; - if (lexer->qmlMode()) { - const QString msg = qApp->translate("QQmlParser", "Deprecated JavaScript `with' statement detected in QML expression. Support for this will be removed in Qt 5.2!"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, node->withToken, msg)); - } -} break; - -case 312: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 313: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 314: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; - -case 315: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; - -case 316: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; - -case 317: { - sym(1).Node = 0; -} break; - -case 318: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; - -case 319: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; - -case 320: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 321: { - 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; - -case 323: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 324: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 325: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 326: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 327: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 328: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; - -case 330: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 332: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 333: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 334: { - 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; - -case 335: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 336: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 337: { - sym(1).Node = 0; -} break; - -case 338: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; - -case 339: { - sym(1).Node = 0; -} break; - -case 341: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; - -case 343: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; - -case 344: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; - -case 345: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; - -case 346: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; - -case 347: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; - -case 348: { - sym(1).Node = 0; -} break; - - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) - || t_action(errorState, T_COMPATIBILITY_SEMICOLON))) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QQmlParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QQmlParser", "Syntax error"); - else - msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QQmlParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - diff --git a/src/qml/qml/parser/qqmljsparser_p.h b/src/qml/qml/parser/qqmljsparser_p.h deleted file mode 100644 index 1b13690547..0000000000 --- a/src/qml/qml/parser/qqmljsparser_p.h +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// -// W A R N I N G -// ------------- -// -// 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 -#define QQMLJSPARSER_P_H - -#include "qqmljsglobal_p.h" -#include "qqmljsgrammar_p.h" -#include "qqmljsast_p.h" -#include "qqmljsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QQmlJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyAssignment *PropertyAssignment; - AST::PropertyAssignmentList *PropertyAssignmentList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QQmlJS - - - -#define J_SCRIPT_REGEXPLITERAL_RULE1 81 - -#define J_SCRIPT_REGEXPLITERAL_RULE2 82 - -QT_QML_END_NAMESPACE - - - -#endif // QQMLJSPARSER_P_H diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri index 4601f8ca00..dae76ede32 100644 --- a/src/qml/qml/qml.pri +++ b/src/qml/qml/qml.pri @@ -132,6 +132,5 @@ HEADERS += \ $$PWD/qqmlvaluetypewrapper_p.h \ $$PWD/qqmltypewrapper_p.h -include(parser/parser.pri) include(ftw/ftw.pri) include(v8/v8.pri) diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro index 10e1ce0275..963fb1be5a 100644 --- a/src/qmldevtools/qmldevtools.pro +++ b/src/qmldevtools/qmldevtools.pro @@ -12,4 +12,4 @@ MODULE_PRIVATE_INCLUDES = \ load(qt_module) -include(../qml/qml/parser/parser.pri) +include(../qml/parser/parser.pri) -- cgit v1.2.3