diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-21 12:00:07 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-21 12:00:07 (GMT) |
commit | 8d00a0a21f245d15962191e0690d3619735d118b (patch) | |
tree | 7aaa66528f0ee40d0d2d885f94835d0f09ea4a68 /src/script/parser | |
parent | 97cec103793a4b9aae8337ffc2ce9a2bd98fb5fc (diff) | |
parent | 508b447075fb852e61ddf88c92c9099dad292747 (diff) | |
download | Qt-8d00a0a21f245d15962191e0690d3619735d118b.zip Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.gz Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.bz2 |
Merge commit 'qt/master' into kinetic-graphicseffect
Conflicts:
src/gui/graphicsview/graphicsview.pri
Diffstat (limited to 'src/script/parser')
-rw-r--r-- | src/script/parser/parser.pri | 19 | ||||
-rw-r--r-- | src/script/parser/qscript.g | 2070 | ||||
-rw-r--r-- | src/script/parser/qscriptast.cpp | 785 | ||||
-rw-r--r-- | src/script/parser/qscriptast_p.h | 1498 | ||||
-rw-r--r-- | src/script/parser/qscriptastfwd_p.h | 146 | ||||
-rw-r--r-- | src/script/parser/qscriptastvisitor.cpp | 58 | ||||
-rw-r--r-- | src/script/parser/qscriptastvisitor_p.h | 295 | ||||
-rw-r--r-- | src/script/parser/qscriptgrammar.cpp | 971 | ||||
-rw-r--r-- | src/script/parser/qscriptgrammar_p.h | 204 | ||||
-rw-r--r-- | src/script/parser/qscriptlexer.cpp | 1111 | ||||
-rw-r--r-- | src/script/parser/qscriptlexer_p.h | 242 | ||||
-rw-r--r-- | src/script/parser/qscriptparser.cpp | 1158 | ||||
-rw-r--r-- | src/script/parser/qscriptparser_p.h | 163 | ||||
-rw-r--r-- | src/script/parser/qscriptsyntaxchecker.cpp | 214 | ||||
-rw-r--r-- | src/script/parser/qscriptsyntaxchecker_p.h | 114 |
15 files changed, 9048 insertions, 0 deletions
diff --git a/src/script/parser/parser.pri b/src/script/parser/parser.pri new file mode 100644 index 0000000..4839ed2 --- /dev/null +++ b/src/script/parser/parser.pri @@ -0,0 +1,19 @@ +SOURCES += \ + $$PWD/qscriptast.cpp \ + $$PWD/qscriptastvisitor.cpp \ + $$PWD/qscriptgrammar.cpp \ + $$PWD/qscriptsyntaxchecker.cpp \ + $$PWD/qscriptlexer.cpp \ + #$$PWD/qscriptparser.cpp + +HEADERS += \ + $$PWD/qscriptastfwd_p.h \ + $$PWD/qscriptast_p.h \ + $$PWD/qscriptastvisitor_p.h \ + $$PWD/qscriptgrammar_p.h \ + $$PWD/qscriptsyntaxchecker_p.h \ + $$PWD/qscriptlexer_p.h \ + #$$PWD/qscriptparser_p.h + +INCLUDEPATH += \ + $$PWD diff --git a/src/script/parser/qscript.g b/src/script/parser/qscript.g new file mode 100644 index 0000000..39900a8 --- /dev/null +++ b/src/script/parser/qscript.g @@ -0,0 +1,2070 @@ +---------------------------------------------------------------------------- +-- +-- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +-- Contact: Nokia Corporation (qt-info@nokia.com) +-- +-- This file is part of the QtScript module of the Qt Toolkit. +-- +-- $QT_BEGIN_LICENSE:LGPL$ +-- No Commercial Usage +-- This file contains pre-release code and may not be distributed. +-- You may use this file in accordance with the terms and conditions +-- contained in the either Technology Preview License Agreement or the +-- Beta Release License Agreement. +-- +-- 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, Nokia gives you certain +-- additional rights. These rights are described in the Nokia Qt LGPL +-- Exception version 1.0, 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. +-- +-- If you are unsure which license is appropriate for your use, please +-- contact the sales department at http://qt.nokia.com/contact. +-- $QT_END_LICENSE$ +-- +-- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +-- WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +-- +---------------------------------------------------------------------------- + +%parser QScriptGrammar +%decl qscriptparser_p.h +%impl qscriptparser.cpp +%expect 3 +%expect-rr 1 + +%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_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" + +%start Program + +/. +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QtDebug> + +#include <string.h> + +#include "qscriptengine.h" +#include "qscriptengine_p.h" +#include "qscriptvalueimpl_p.h" +#include "qscriptcontext_p.h" +#include "qscriptmember_p.h" +#include "qscriptobject_p.h" +#include "qscriptlexer_p.h" +#include "qscriptast_p.h" +#include "qscriptnodepool_p.h" + +#define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc) do { \ + node->startLine = startloc.startLine; \ + node->startColumn = startloc.startColumn; \ + node->endLine = endloc.endLine; \ + node->endColumn = endloc.endColumn; \ +} while (0) + +./ + +/: +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $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. +// + +// +// This file is automatically generated from qscript.g. +// Changes will be lost. +// + +#ifndef QSCRIPTPARSER_P_H +#define QSCRIPTPARSER_P_H + +#include "qscriptgrammar_p.h" + +#include "qscriptastfwd_p.h" + +QT_BEGIN_NAMESPACE + +class QString; +class QScriptEnginePrivate; +class QScriptNameIdImpl; + +class QScriptParser: protected $table +{ +public: + union Value { + int ival; + double dval; + QScriptNameIdImpl *sval; + QScript::AST::ArgumentList *ArgumentList; + QScript::AST::CaseBlock *CaseBlock; + QScript::AST::CaseClause *CaseClause; + QScript::AST::CaseClauses *CaseClauses; + QScript::AST::Catch *Catch; + QScript::AST::DefaultClause *DefaultClause; + QScript::AST::ElementList *ElementList; + QScript::AST::Elision *Elision; + QScript::AST::ExpressionNode *Expression; + QScript::AST::Finally *Finally; + QScript::AST::FormalParameterList *FormalParameterList; + QScript::AST::FunctionBody *FunctionBody; + QScript::AST::FunctionDeclaration *FunctionDeclaration; + QScript::AST::Node *Node; + QScript::AST::PropertyName *PropertyName; + QScript::AST::PropertyNameAndValueList *PropertyNameAndValueList; + QScript::AST::SourceElement *SourceElement; + QScript::AST::SourceElements *SourceElements; + QScript::AST::Statement *Statement; + QScript::AST::StatementList *StatementList; + QScript::AST::VariableDeclaration *VariableDeclaration; + QScript::AST::VariableDeclarationList *VariableDeclarationList; + }; + + struct Location { + int startLine; + int startColumn; + int endLine; + int endColumn; + }; + +public: + QScriptParser(); + ~QScriptParser(); + + bool parse(QScriptEnginePrivate *driver); + + inline QString errorMessage() const + { return error_message; } + inline int errorLineNumber() const + { return error_lineno; } + inline int errorColumnNumber() const + { return error_column; } + +protected: + inline void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline Location &loc(int index) + { return location_stack [tos + index - 2]; } + +protected: + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + Location *location_stack; + QString error_message; + int error_lineno; + int error_column; +}; + +inline void QScriptParser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location))); +} + +:/ + + +/. + +#include "qscriptparser_p.h" + +// +// This file is automatically generated from qscript.g. +// Changes will be lost. +// + +QT_BEGIN_NAMESPACE + +inline static bool automatic(QScriptEnginePrivate *driver, int token) +{ + return token == $table::T_RBRACE + || token == 0 + || driver->lexer()->prevTerminator(); +} + + +QScriptParser::QScriptParser(): + tos(0), + stack_size(0), + sym_stack(0), + state_stack(0), + location_stack(0) +{ +} + +QScriptParser::~QScriptParser() +{ + if (stack_size) { + qFree(sym_stack); + qFree(state_stack); + qFree(location_stack); + } +} + +static inline QScriptParser::Location location(QScript::Lexer *lexer) +{ + QScriptParser::Location loc; + loc.startLine = lexer->startLineNo(); + loc.startColumn = lexer->startColumnNo(); + loc.endLine = lexer->endLineNo(); + loc.endColumn = lexer->endColumnNo(); + return loc; +} + +bool QScriptParser::parse(QScriptEnginePrivate *driver) +{ + const int INITIAL_STATE = 0; + QScript::Lexer *lexer = driver->lexer(); + + int yytoken = -1; + int saved_yytoken = -1; + + reallocateStack(); + + tos = 0; + state_stack[++tos] = INITIAL_STATE; + + while (true) + { + const int state = state_stack [tos]; + if (yytoken == -1 && - TERMINAL_COUNT != action_index [state]) + { + if (saved_yytoken == -1) + { + yytoken = lexer->lex(); + location_stack [tos] = location(lexer); + } + else + { + yytoken = saved_yytoken; + saved_yytoken = -1; + } + } + + int act = t_action (state, yytoken); + + if (act == ACCEPT_STATE) + return true; + + else if (act > 0) + { + if (++tos == stack_size) + reallocateStack(); + + sym_stack [tos].dval = lexer->dval (); + state_stack [tos] = act; + location_stack [tos] = location(lexer); + yytoken = -1; + } + + else if (act < 0) + { + int r = - act - 1; + + tos -= rhs [r]; + act = state_stack [tos++]; + + switch (r) { +./ + +PrimaryExpression: T_THIS ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ThisExpression> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_IDENTIFIER ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierExpression> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_NULL ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NullExpression> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_TRUE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TrueLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_FALSE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FalseLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteral> (driver->nodePool(), sym(1).dval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_STRING_LITERAL ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteral> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_DIVIDE_ ; +/: +#define Q_SCRIPT_REGEXPLITERAL_RULE1 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(QScript::Lexer::NoPrefix); + if (!rx) { + error_message = lexer->errorMessage(); + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + return false; + } + sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_DIVIDE_EQ ; +/: +#define Q_SCRIPT_REGEXPLITERAL_RULE2 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(QScript::Lexer::EqualPrefix); + if (!rx) { + error_message = lexer->errorMessage(); + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + return false; + } + sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PrimaryExpression: T_LBRACKET ElisionOpt T_RBRACKET ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_COMMA ElisionOpt T_RBRACKET ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), sym(4).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +-- PrimaryExpression: T_LBRACE T_RBRACE ; +-- /. +-- case $rule_number: { +-- sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool()); +-- Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +-- } break; +-- ./ + +PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ; +/. +case $rule_number: { + if (sym(2).Node) + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ()); + else + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +PrimaryExpression: T_LPAREN Expression T_RPAREN ; +/. +case $rule_number: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ElementList: ElisionOpt AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).Elision, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +ElementList: ElementList T_COMMA ElisionOpt AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision, sym(4).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +Elision: T_COMMA ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +Elision: Elision T_COMMA ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool(), sym(1).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +ElisionOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ElisionOpt: Elision ; +/. +case $rule_number: { + sym(1).Elision = sym(1).Elision->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyName, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +PropertyName: T_IDENTIFIER ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PropertyName: T_STRING_LITERAL ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PropertyName: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +PropertyName: ReservedIdentifier ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +ReservedIdentifier: T_BREAK ; +/. +case $rule_number: +./ +ReservedIdentifier: T_CASE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_CATCH ; +/. +case $rule_number: +./ +ReservedIdentifier: T_CONTINUE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_DEFAULT ; +/. +case $rule_number: +./ +ReservedIdentifier: T_DELETE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_DO ; +/. +case $rule_number: +./ +ReservedIdentifier: T_ELSE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_FALSE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_FINALLY ; +/. +case $rule_number: +./ +ReservedIdentifier: T_FOR ; +/. +case $rule_number: +./ +ReservedIdentifier: T_FUNCTION ; +/. +case $rule_number: +./ +ReservedIdentifier: T_IF ; +/. +case $rule_number: +./ +ReservedIdentifier: T_IN ; +/. +case $rule_number: +./ +ReservedIdentifier: T_INSTANCEOF ; +/. +case $rule_number: +./ +ReservedIdentifier: T_NEW ; +/. +case $rule_number: +./ +ReservedIdentifier: T_NULL ; +/. +case $rule_number: +./ +ReservedIdentifier: T_RETURN ; +/. +case $rule_number: +./ +ReservedIdentifier: T_SWITCH ; +/. +case $rule_number: +./ +ReservedIdentifier: T_THIS ; +/. +case $rule_number: +./ +ReservedIdentifier: T_THROW ; +/. +case $rule_number: +./ +ReservedIdentifier: T_TRUE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_TRY ; +/. +case $rule_number: +./ +ReservedIdentifier: T_TYPEOF ; +/. +case $rule_number: +./ +ReservedIdentifier: T_VAR ; +/. +case $rule_number: +./ +ReservedIdentifier: T_VOID ; +/. +case $rule_number: +./ +ReservedIdentifier: T_WHILE ; +/. +case $rule_number: +./ +ReservedIdentifier: T_CONST ; +/. +case $rule_number: +./ +ReservedIdentifier: T_DEBUGGER ; +/. +case $rule_number: +./ +ReservedIdentifier: T_RESERVED_WORD ; +/. +case $rule_number: +./ +ReservedIdentifier: T_WITH ; +/. +case $rule_number: +{ + sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount()); +} break; +./ + +PropertyIdentifier: T_IDENTIFIER ; +PropertyIdentifier: ReservedIdentifier ; + +MemberExpression: PrimaryExpression ; +MemberExpression: FunctionExpression ; + +MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +MemberExpression: MemberExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +MemberExpression: T_NEW MemberExpression Arguments ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(3).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +NewExpression: MemberExpression ; + +NewExpression: T_NEW NewExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NewExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +CallExpression: MemberExpression Arguments ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +CallExpression: CallExpression Arguments ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +CallExpression: CallExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +Arguments: T_LPAREN T_RPAREN ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +Arguments: T_LPAREN ArgumentList T_RPAREN ; +/. +case $rule_number: { + sym(1).Node = sym(2).ArgumentList->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ArgumentList: AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +ArgumentList: ArgumentList T_COMMA AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LeftHandSideExpression: NewExpression ; +LeftHandSideExpression: CallExpression ; +PostfixExpression: LeftHandSideExpression ; + +PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: PostfixExpression ; + +UnaryExpression: T_DELETE UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DeleteExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_VOID UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VoidExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_TYPEOF UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_PLUS_PLUS UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_MINUS_MINUS UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_PLUS UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_MINUS UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_TILDE UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TildeExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +UnaryExpression: T_NOT UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NotExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +MultiplicativeExpression: UnaryExpression ; + +MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mul, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Div, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mod, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +AdditiveExpression: MultiplicativeExpression ; + +AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Add, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Sub, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ShiftExpression: AdditiveExpression ; + +ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::LShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::RShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::URShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: ShiftExpression ; + +RelationalExpression: RelationalExpression T_LT ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: RelationalExpression T_GT ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: RelationalExpression T_LE ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: RelationalExpression T_GE ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpression: RelationalExpression T_IN ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::In, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpressionNotIn: ShiftExpression ; + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpression: RelationalExpression ; + +EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpressionNotIn: RelationalExpressionNotIn ; + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseANDExpression: EqualityExpression ; + +BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; + +BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseXORExpression: BitwiseANDExpression ; + +BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; + +BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseORExpression: BitwiseXORExpression ; + +BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; + +BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LogicalANDExpression: BitwiseORExpression ; + +LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; + +LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LogicalORExpression: LogicalANDExpression ; + +LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; + +LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ConditionalExpression: LogicalORExpression ; + +ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ConditionalExpressionNotIn: LogicalORExpressionNotIn ; + +ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +AssignmentExpression: ConditionalExpression ; + +AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +AssignmentExpressionNotIn: ConditionalExpressionNotIn ; + +AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} 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: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ExpressionOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ExpressionOpt: Expression ; + +ExpressionNotIn: AssignmentExpressionNotIn ; + +ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} 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: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Block> (driver->nodePool(), sym(2).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +StatementList: Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +StatementList: StatementList Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} 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: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} 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 = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +VariableDeclaration: T_IDENTIFIER InitialiserOpt ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +VariableDeclarationNotIn: T_IDENTIFIER InitialiserNotInOpt ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +Initialiser: T_EQ AssignmentExpression ; +/. +case $rule_number: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +InitialiserOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserOpt: Initialiser ; + +InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; +/. +case $rule_number: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +InitialiserNotInOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserNotInOpt: InitialiserNotIn ; + +EmptyStatement: T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::EmptyStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ExpressionStatement: Expression T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} 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_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; +./ + +IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(9)); +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(10)); +} break; +./ + +IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; +./ + +ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +ContinueStatement: T_CONTINUE T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE T_IDENTIFIER T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +BreakStatement: T_BREAK T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK T_IDENTIFIER T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool(), sym(2).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +CaseClauses: CaseClause ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +CaseClauses: CaseClauses CaseClause ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +CaseClausesOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +CaseClausesOpt: CaseClauses ; +/. +case $rule_number: { + sym(1).Node = sym(1).CaseClauses->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +CaseClause: T_CASE Expression T_COLON StatementListOpt ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +DefaultClause: T_DEFAULT T_COLON StatementListOpt ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +LabelledStatement: T_IDENTIFIER T_COLON Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ThrowStatement: T_THROW Expression T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +TryStatement: T_TRY Block Catch ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +TryStatement: T_TRY Block Finally ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +TryStatement: T_TRY Block Catch Finally ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; +./ + +Catch: T_CATCH T_LPAREN T_IDENTIFIER T_RPAREN Block ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; +./ + +Finally: T_FINALLY Block ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Finally> (driver->nodePool(), sym(2).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +DebuggerStatement: T_DEBUGGER T_SEMICOLON ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DebuggerStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +FunctionDeclaration: T_FUNCTION T_IDENTIFIER T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; +./ + +FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; +./ + +FormalParameterList: T_IDENTIFIER ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +FormalParameterList: FormalParameterList T_COMMA T_IDENTIFIER ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; +./ + +FormalParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FormalParameterListOpt: FormalParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).FormalParameterList->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +FunctionBodyOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FunctionBodyOpt: FunctionBody ; + +FunctionBody: SourceElements ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +Program: SourceElements ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ()); + driver->changeAbstractSyntaxTree(sym(1).Node); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +SourceElements: SourceElement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +SourceElements: SourceElements SourceElement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; +./ + +SourceElement: Statement ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +SourceElement: FunctionDeclaration ; +/. +case $rule_number: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; +./ + +IdentifierOpt: ; +/. +case $rule_number: { + sym(1).sval = 0; +} break; +./ + +IdentifierOpt: T_IDENTIFIER ; + +PropertyNameAndValueListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +PropertyNameAndValueListOpt: PropertyNameAndValueList ; + +/. + } // switch + + state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT); + + if (rhs[r] > 1) { + location_stack[tos - 1].endLine = location_stack[tos + rhs[r] - 2].endLine; + location_stack[tos - 1].endColumn = location_stack[tos + rhs[r] - 2].endColumn; + location_stack[tos] = location_stack[tos + rhs[r] - 1]; + } + } + + else + { + if (saved_yytoken == -1 && automatic (driver, yytoken) && t_action (state, T_AUTOMATIC_SEMICOLON) > 0) + { + saved_yytoken = yytoken; + yytoken = T_SEMICOLON; + continue; + } + + else if ((state == INITIAL_STATE) && (yytoken == 0)) { + // accept empty input + yytoken = T_SEMICOLON; + continue; + } + + int ers = state; + int shifts = 0; + int reduces = 0; + int expected_tokens [3]; + for (int tk = 0; tk < TERMINAL_COUNT; ++tk) + { + int k = t_action (ers, tk); + + if (! k) + continue; + else if (k < 0) + ++reduces; + else if (spell [tk]) + { + if (shifts < 3) + expected_tokens [shifts] = tk; + ++shifts; + } + } + + error_message.clear (); + if (shifts && shifts < 3) + { + bool first = true; + + for (int s = 0; s < shifts; ++s) + { + if (first) + error_message += QLatin1String ("Expected "); + else + error_message += QLatin1String (", "); + + first = false; + error_message += QLatin1String("`"); + error_message += QLatin1String (spell [expected_tokens [s]]); + error_message += QLatin1String("'"); + } + } + + if (error_message.isEmpty()) + error_message = lexer->errorMessage(); + + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + + return false; + } + } + + return false; +} + +QT_END_NAMESPACE +./ +/: +QT_END_NAMESPACE + +#endif // QSCRIPTPARSER_P_H +:/ diff --git a/src/script/parser/qscriptast.cpp b/src/script/parser/qscriptast.cpp new file mode 100644 index 0000000..b0cc171 --- /dev/null +++ b/src/script/parser/qscriptast.cpp @@ -0,0 +1,785 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptast_p.h" + +#include "qscriptastvisitor_p.h" + +QT_BEGIN_NAMESPACE + +namespace QScript { namespace AST { + +ExpressionNode *Node::expressionCast() +{ + return 0; +} + +BinaryExpression *Node::binaryExpressionCast() +{ + return 0; +} + +Statement *Node::statementCast() +{ + return 0; +} + +ExpressionNode *ExpressionNode::expressionCast() +{ + return this; +} + +BinaryExpression *BinaryExpression::binaryExpressionCast() +{ + return this; +} + +Statement *Statement::statementCast() +{ + return 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)) { + acceptChild(elements, visitor); + acceptChild(elision, visitor); + } + + visitor->endVisit(this); +} + +void ObjectLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(properties, visitor); + } + + visitor->endVisit(this); +} + +void ElementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + ElementList *it = this; + do { + acceptChild(it->elision, visitor); + acceptChild(it->expression, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void Elision::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + // ### + } + + visitor->endVisit(this); +} + +void PropertyNameAndValueList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + PropertyNameAndValueList *it = this; + do { + acceptChild(it->name, visitor); + acceptChild(it->value, visitor); + it = it->next; + } while (it); + } + + 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)) { + acceptChild(base, visitor); + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void FieldMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(base, visitor); + } + + visitor->endVisit(this); +} + +void NewMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(base, visitor); + acceptChild(arguments, visitor); + } + + visitor->endVisit(this); +} + +void NewExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void CallExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(base, visitor); + acceptChild(arguments, visitor); + } + + visitor->endVisit(this); +} + +void ArgumentList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + ArgumentList *it = this; + do { + acceptChild(it->expression, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void PostIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(base, visitor); + } + + visitor->endVisit(this); +} + +void PostDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(base, visitor); + } + + visitor->endVisit(this); +} + +void DeleteExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void VoidExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void TypeOfExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryPlusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryMinusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void TildeExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void NotExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void BinaryExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(left, visitor); + acceptChild(right, visitor); + } + + visitor->endVisit(this); +} + +void ConditionalExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(ok, visitor); + acceptChild(ko, visitor); + } + + visitor->endVisit(this); +} + +void Expression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(left, visitor); + acceptChild(right, visitor); + } + + visitor->endVisit(this); +} + +void Block::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statements, visitor); + } + + visitor->endVisit(this); +} + +void StatementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + StatementList *it = this; + do { + acceptChild(it->statement, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void VariableStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(declarations, visitor); + } + + visitor->endVisit(this); +} + +void VariableDeclarationList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + VariableDeclarationList *it = this; + do { + acceptChild(it->declaration, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void VariableDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(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)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void IfStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(ok, visitor); + acceptChild(ko, visitor); + } + + visitor->endVisit(this); +} + +void DoWhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void WhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(initialiser, visitor); + acceptChild(condition, visitor); + acceptChild(expression, visitor); + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(declarations, visitor); + acceptChild(condition, visitor); + acceptChild(expression, visitor); + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(initialiser, visitor); + acceptChild(expression, visitor); + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(declaration, visitor); + acceptChild(expression, visitor); + acceptChild(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)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void WithStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void SwitchStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(block, visitor); + } + + visitor->endVisit(this); +} + +void CaseBlock::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(clauses, visitor); + acceptChild(defaultClause, visitor); + acceptChild(moreClauses, visitor); + } + + visitor->endVisit(this); +} + +void CaseClauses::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + CaseClauses *it = this; + do { + acceptChild(it->clause, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void CaseClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + acceptChild(statements, visitor); + } + + visitor->endVisit(this); +} + +void DefaultClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statements, visitor); + } + + visitor->endVisit(this); +} + +void LabelledStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void ThrowStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(expression, visitor); + } + + visitor->endVisit(this); +} + +void TryStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + acceptChild(catchExpression, visitor); + acceptChild(finallyExpression, visitor); + } + + visitor->endVisit(this); +} + +void Catch::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void Finally::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void FunctionDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(formals, visitor); + acceptChild(body, visitor); + } + + visitor->endVisit(this); +} + +void FunctionExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(formals, visitor); + acceptChild(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)) { + acceptChild(elements, visitor); + } + + visitor->endVisit(this); +} + +void Program::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(elements, visitor); + } + + visitor->endVisit(this); +} + +void SourceElements::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + SourceElements *it = this; + do { + acceptChild(it->element, visitor); + it = it->next; + } while (it); + } + + visitor->endVisit(this); +} + +void FunctionSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(declaration, visitor); + } + + visitor->endVisit(this); +} + +void StatementSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + acceptChild(statement, visitor); + } + + visitor->endVisit(this); +} + +void DebuggerStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +} } // namespace QScript::AST + +QT_END_NAMESPACE diff --git a/src/script/parser/qscriptast_p.h b/src/script/parser/qscriptast_p.h new file mode 100644 index 0000000..d0e534a --- /dev/null +++ b/src/script/parser/qscriptast_p.h @@ -0,0 +1,1498 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTAST_P_H +#define QSCRIPTAST_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 <QtCore/QString> + +#include "qscriptastvisitor_p.h" + +QT_BEGIN_NAMESPACE + +class QScriptNameIdImpl; + +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 QScript { namespace AST { + +class Node +{ +public: + enum Kind { + Kind_Node, + Kind_ExpressionNode, + Kind_Statement, + Kind_ThisExpression, + Kind_IdentifierExpression, + Kind_NullExpression, + Kind_TrueLiteral, + Kind_FalseLiteral, + Kind_NumericLiteral, + Kind_StringLiteral, + Kind_RegExpLiteral, + Kind_ArrayLiteral, + Kind_ObjectLiteral, + Kind_ElementList, + Kind_Elision, + Kind_PropertyNameAndValueList, + Kind_PropertyName, + Kind_IdentifierPropertyName, + Kind_StringLiteralPropertyName, + Kind_NumericLiteralPropertyName, + Kind_ArrayMemberExpression, + Kind_FieldMemberExpression, + Kind_NewMemberExpression, + Kind_NewExpression, + Kind_CallExpression, + Kind_ArgumentList, + Kind_PostIncrementExpression, + Kind_PostDecrementExpression, + Kind_DeleteExpression, + Kind_VoidExpression, + Kind_TypeOfExpression, + Kind_PreIncrementExpression, + Kind_PreDecrementExpression, + Kind_UnaryPlusExpression, + Kind_UnaryMinusExpression, + Kind_TildeExpression, + Kind_NotExpression, + Kind_BinaryExpression, + Kind_ConditionalExpression, + Kind_Expression, + Kind_Block, + Kind_StatementList, + Kind_VariableStatement, + Kind_VariableDeclarationList, + Kind_VariableDeclaration, + Kind_EmptyStatement, + Kind_ExpressionStatement, + Kind_IfStatement, + Kind_DoWhileStatement, + Kind_WhileStatement, + Kind_ForStatement, + Kind_LocalForStatement, + Kind_ForEachStatement, + Kind_LocalForEachStatement, + Kind_ContinueStatement, + Kind_BreakStatement, + Kind_ReturnStatement, + Kind_WithStatement, + Kind_SwitchStatement, + Kind_CaseBlock, + Kind_CaseClauses, + Kind_CaseClause, + Kind_DefaultClause, + Kind_LabelledStatement, + Kind_ThrowStatement, + Kind_TryStatement, + Kind_Catch, + Kind_Finally, + Kind_FunctionDeclaration, + Kind_FunctionExpression, + Kind_FormalParameterList, + Kind_FunctionBody, + Kind_Program, + Kind_SourceElements, + Kind_SourceElement, + Kind_FunctionSourceElement, + Kind_StatementSourceElement, + Kind_DebuggerStatement + }; + + inline Node(): + startLine(0), startColumn(0), + endLine(0), endColumn(0), kind(Kind_Node) {} + + virtual ~Node() {} + + virtual ExpressionNode *expressionCast(); + virtual BinaryExpression *binaryExpressionCast(); + virtual Statement *statementCast(); + + inline void accept(Visitor *visitor) + { + if (visitor->preVisit(this)) { + accept0(visitor); + visitor->postVisit(this); + } + } + + static void acceptChild(Node *node, Visitor *visitor) + { + if (node) + node->accept(visitor); + } + + virtual void accept0(Visitor *visitor) = 0; + + int startLine; + int startColumn; + int endLine; + int endColumn; + Kind kind; +}; + +class ExpressionNode: public Node +{ +public: + ExpressionNode() { kind = Kind_ExpressionNode; } + virtual ~ExpressionNode() {} + + virtual ExpressionNode *expressionCast(); +}; + +class Statement: public Node +{ +public: + Statement() { kind = Kind_Statement; } + virtual ~Statement() {} + + virtual Statement *statementCast(); +}; + +class ThisExpression: public ExpressionNode +{ +public: + ThisExpression() { kind = Kind_ThisExpression; } + virtual ~ThisExpression() {} + + virtual void accept0(Visitor *visitor); +}; + +class IdentifierExpression: public ExpressionNode +{ +public: + IdentifierExpression(QScriptNameIdImpl *n): + name (n) { kind = Kind_IdentifierExpression; } + + virtual ~IdentifierExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *name; +}; + +class NullExpression: public ExpressionNode +{ +public: + NullExpression() { kind = Kind_NullExpression; } + virtual ~NullExpression() {} + + virtual void accept0(Visitor *visitor); +}; + +class TrueLiteral: public ExpressionNode +{ +public: + TrueLiteral() { kind = Kind_TrueLiteral; } + virtual ~TrueLiteral() {} + + virtual void accept0(Visitor *visitor); +}; + +class FalseLiteral: public ExpressionNode +{ +public: + FalseLiteral() { kind = Kind_FalseLiteral; } + virtual ~FalseLiteral() {} + + virtual void accept0(Visitor *visitor); +}; + +class NumericLiteral: public ExpressionNode +{ +public: + NumericLiteral(double v): + value (v) { kind = Kind_NumericLiteral; } + virtual ~NumericLiteral() {} + + virtual void accept0(Visitor *visitor); + +// attributes: + double value; +}; + +class StringLiteral: public ExpressionNode +{ +public: + StringLiteral(QScriptNameIdImpl *v): + value (v) { kind = Kind_StringLiteral; } + + virtual ~StringLiteral() {} + + virtual void accept0(Visitor *visitor); + +// attributes: + QScriptNameIdImpl *value; +}; + +class RegExpLiteral: public ExpressionNode +{ +public: + RegExpLiteral(QScriptNameIdImpl *p, int f): + pattern (p), flags (f) { kind = Kind_RegExpLiteral; } + + virtual ~RegExpLiteral() {} + + virtual void accept0(Visitor *visitor); + +// attributes: + QScriptNameIdImpl *pattern; + int flags; +}; + +class ArrayLiteral: public ExpressionNode +{ +public: + ArrayLiteral(Elision *e): + elements (0), elision (e) + { kind = Kind_ArrayLiteral; } + + ArrayLiteral(ElementList *elts): + elements (elts), elision (0) + { kind = Kind_ArrayLiteral; } + + ArrayLiteral(ElementList *elts, Elision *e): + elements (elts), elision (e) + { kind = Kind_ArrayLiteral; } + + virtual ~ArrayLiteral() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ElementList *elements; + Elision *elision; +}; + +class ObjectLiteral: public ExpressionNode +{ +public: + ObjectLiteral(): + properties (0) { kind = Kind_ObjectLiteral; } + + ObjectLiteral(PropertyNameAndValueList *plist): + properties (plist) { kind = Kind_ObjectLiteral; } + + virtual ~ObjectLiteral() {} + + virtual void accept0(Visitor *visitor); + +// attributes + PropertyNameAndValueList *properties; +}; + +class ElementList: public Node +{ +public: + ElementList(Elision *e, ExpressionNode *expr): + elision (e), expression (expr), next (this) + { kind = Kind_ElementList; } + + ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): + elision (e), expression (expr) + { + kind = Kind_ElementList; + next = previous->next; + previous->next = this; + } + + virtual ~ElementList() {} + + inline ElementList *finish () + { + ElementList *front = next; + next = 0; + return front; + } + + virtual void accept0(Visitor *visitor); + +// attributes + Elision *elision; + ExpressionNode *expression; + ElementList *next; +}; + +class Elision: public Node +{ +public: + Elision(): + next (this) { kind = Kind_Elision; } + + Elision(Elision *previous) + { + kind = Kind_Elision; + next = previous->next; + previous->next = this; + } + + virtual ~Elision() {} + + virtual void accept0(Visitor *visitor); + + inline Elision *finish () + { + Elision *front = next; + next = 0; + return front; + } + +// attributes + Elision *next; +}; + +class PropertyNameAndValueList: public Node +{ +public: + PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): + name (n), value (v), next (this) + { kind = Kind_PropertyNameAndValueList; } + + PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v): + name (n), value (v) + { + kind = Kind_PropertyNameAndValueList; + next = previous->next; + previous->next = this; + } + + virtual ~PropertyNameAndValueList() {} + + virtual void accept0(Visitor *visitor); + + inline PropertyNameAndValueList *finish () + { + PropertyNameAndValueList *front = next; + next = 0; + return front; + } + +// attributes + PropertyName *name; + ExpressionNode *value; + PropertyNameAndValueList *next; +}; + +class PropertyName: public Node +{ +public: + PropertyName() { kind = Kind_PropertyName; } + virtual ~PropertyName() {} +}; + +class IdentifierPropertyName: public PropertyName +{ +public: + IdentifierPropertyName(QScriptNameIdImpl *n): + id (n) { kind = Kind_IdentifierPropertyName; } + + virtual ~IdentifierPropertyName() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *id; +}; + +class StringLiteralPropertyName: public PropertyName +{ +public: + StringLiteralPropertyName(QScriptNameIdImpl *n): + id (n) { kind = Kind_StringLiteralPropertyName; } + virtual ~StringLiteralPropertyName() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *id; +}; + +class NumericLiteralPropertyName: public PropertyName +{ +public: + NumericLiteralPropertyName(double n): + id (n) { kind = Kind_NumericLiteralPropertyName; } + virtual ~NumericLiteralPropertyName() {} + + virtual void accept0(Visitor *visitor); + +// attributes + double id; +}; + +class ArrayMemberExpression: public ExpressionNode +{ +public: + ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): + base (b), expression (e) + { kind = Kind_ArrayMemberExpression; } + + virtual ~ArrayMemberExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; + ExpressionNode *expression; +}; + +class FieldMemberExpression: public ExpressionNode +{ +public: + FieldMemberExpression(ExpressionNode *b, QScriptNameIdImpl *n): + base (b), name (n) + { kind = Kind_FieldMemberExpression; } + + virtual ~FieldMemberExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; + QScriptNameIdImpl *name; +}; + +class NewMemberExpression: public ExpressionNode +{ +public: + NewMemberExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = Kind_NewMemberExpression; } + + virtual ~NewMemberExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; + ArgumentList *arguments; +}; + +class NewExpression: public ExpressionNode +{ +public: + NewExpression(ExpressionNode *e): + expression (e) { kind = Kind_NewExpression; } + + virtual ~NewExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class CallExpression: public ExpressionNode +{ +public: + CallExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = Kind_CallExpression; } + + virtual ~CallExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; + ArgumentList *arguments; +}; + +class ArgumentList: public Node +{ +public: + ArgumentList(ExpressionNode *e): + expression (e), next (this) + { kind = Kind_ArgumentList; } + + ArgumentList(ArgumentList *previous, ExpressionNode *e): + expression (e) + { + kind = Kind_ArgumentList; + next = previous->next; + previous->next = this; + } + + virtual ~ArgumentList() {} + + virtual void accept0(Visitor *visitor); + + inline ArgumentList *finish () + { + ArgumentList *front = next; + next = 0; + return front; + } + +// attributes + ExpressionNode *expression; + ArgumentList *next; +}; + +class PostIncrementExpression: public ExpressionNode +{ +public: + PostIncrementExpression(ExpressionNode *b): + base (b) { kind = Kind_PostIncrementExpression; } + + virtual ~PostIncrementExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; +}; + +class PostDecrementExpression: public ExpressionNode +{ +public: + PostDecrementExpression(ExpressionNode *b): + base (b) { kind = Kind_PostDecrementExpression; } + + virtual ~PostDecrementExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *base; +}; + +class DeleteExpression: public ExpressionNode +{ +public: + DeleteExpression(ExpressionNode *e): + expression (e) { kind = Kind_DeleteExpression; } + virtual ~DeleteExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class VoidExpression: public ExpressionNode +{ +public: + VoidExpression(ExpressionNode *e): + expression (e) { kind = Kind_VoidExpression; } + + virtual ~VoidExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class TypeOfExpression: public ExpressionNode +{ +public: + TypeOfExpression(ExpressionNode *e): + expression (e) { kind = Kind_TypeOfExpression; } + + virtual ~TypeOfExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class PreIncrementExpression: public ExpressionNode +{ +public: + PreIncrementExpression(ExpressionNode *e): + expression (e) { kind = Kind_PreIncrementExpression; } + + virtual ~PreIncrementExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class PreDecrementExpression: public ExpressionNode +{ +public: + PreDecrementExpression(ExpressionNode *e): + expression (e) { kind = Kind_PreDecrementExpression; } + + virtual ~PreDecrementExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class UnaryPlusExpression: public ExpressionNode +{ +public: + UnaryPlusExpression(ExpressionNode *e): + expression (e) { kind = Kind_UnaryPlusExpression; } + + virtual ~UnaryPlusExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class UnaryMinusExpression: public ExpressionNode +{ +public: + UnaryMinusExpression(ExpressionNode *e): + expression (e) { kind = Kind_UnaryMinusExpression; } + + virtual ~UnaryMinusExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class TildeExpression: public ExpressionNode +{ +public: + TildeExpression(ExpressionNode *e): + expression (e) { kind = Kind_TildeExpression; } + + virtual ~TildeExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class NotExpression: public ExpressionNode +{ +public: + NotExpression(ExpressionNode *e): + expression (e) { kind = Kind_NotExpression; } + + virtual ~NotExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class BinaryExpression: public ExpressionNode +{ +public: + BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): + left (l), op (o), right (r) + { kind = Kind_BinaryExpression; } + + virtual ~BinaryExpression() {} + + virtual BinaryExpression *binaryExpressionCast(); + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *left; + int op; + ExpressionNode *right; +}; + +class ConditionalExpression: public ExpressionNode +{ +public: + ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): + expression (e), ok (t), ko (f) + { kind = Kind_ConditionalExpression; } + + virtual ~ConditionalExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + ExpressionNode *ok; + ExpressionNode *ko; +}; + +class Expression: public ExpressionNode // ### rename +{ +public: + Expression(ExpressionNode *l, ExpressionNode *r): + left (l), right (r) { kind = Kind_Expression; } + + virtual ~Expression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *left; + ExpressionNode *right; +}; + +class Block: public Statement +{ +public: + Block(StatementList *slist): + statements (slist) { kind = Kind_Block; } + + virtual ~Block() {} + + virtual void accept0(Visitor *visitor); + +// attributes + StatementList *statements; +}; + +class StatementList: public Node +{ +public: + StatementList(Statement *stmt): + statement (stmt), next (this) + { kind = Kind_StatementList; } + + StatementList(StatementList *previous, Statement *stmt): + statement (stmt) + { + kind = Kind_StatementList; + next = previous->next; + previous->next = this; + } + + virtual ~StatementList() {} + + virtual void accept0(Visitor *visitor); + + inline StatementList *finish () + { + StatementList *front = next; + next = 0; + return front; + } + +// attributes + Statement *statement; + StatementList *next; +}; + +class VariableStatement: public Statement +{ +public: + VariableStatement(VariableDeclarationList *vlist): + declarations (vlist) + { kind = Kind_VariableStatement; } + + virtual ~VariableStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + VariableDeclarationList *declarations; +}; + +class VariableDeclaration: public Node +{ +public: + VariableDeclaration(QScriptNameIdImpl *n, ExpressionNode *e): + name (n), expression (e), readOnly(false) + { kind = Kind_VariableDeclaration; } + + virtual ~VariableDeclaration() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *name; + ExpressionNode *expression; + bool readOnly; +}; + +class VariableDeclarationList: public Node +{ +public: + VariableDeclarationList(VariableDeclaration *decl): + declaration (decl), next (this) + { kind = Kind_VariableDeclarationList; } + + VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): + declaration (decl) + { + kind = Kind_VariableDeclarationList; + next = previous->next; + previous->next = this; + } + + virtual ~VariableDeclarationList() {} + + virtual void accept0(Visitor *visitor); + + 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; +}; + +class EmptyStatement: public Statement +{ +public: + EmptyStatement() { kind = Kind_EmptyStatement; } + virtual ~EmptyStatement() {} + + virtual void accept0(Visitor *visitor); +}; + +class ExpressionStatement: public Statement +{ +public: + ExpressionStatement(ExpressionNode *e): + expression (e) { kind = Kind_ExpressionStatement; } + + virtual ~ExpressionStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class IfStatement: public Statement +{ +public: + IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): + expression (e), ok (t), ko (f) + { kind = Kind_IfStatement; } + + virtual ~IfStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + Statement *ok; + Statement *ko; +}; + +class DoWhileStatement: public Statement +{ +public: + DoWhileStatement(Statement *stmt, ExpressionNode *e): + statement (stmt), expression (e) + { kind = Kind_DoWhileStatement; } + + virtual ~DoWhileStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + Statement *statement; + ExpressionNode *expression; +}; + +class WhileStatement: public Statement +{ +public: + WhileStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = Kind_WhileStatement; } + + virtual ~WhileStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + Statement *statement; +}; + +class ForStatement: public Statement +{ +public: + ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + initialiser (i), condition (c), expression (e), statement (stmt) + { kind = Kind_ForStatement; } + + virtual ~ForStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *initialiser; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; +}; + +class LocalForStatement: public Statement +{ +public: + LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + declarations (vlist), condition (c), expression (e), statement (stmt) + { kind = Kind_LocalForStatement; } + + virtual ~LocalForStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + VariableDeclarationList *declarations; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; +}; + +class ForEachStatement: public Statement +{ +public: + ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): + initialiser (i), expression (e), statement (stmt) + { kind = Kind_ForEachStatement; } + + virtual ~ForEachStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *initialiser; + ExpressionNode *expression; + Statement *statement; +}; + +class LocalForEachStatement: public Statement +{ +public: + LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): + declaration (v), expression (e), statement (stmt) + { kind = Kind_LocalForEachStatement; } + + virtual ~LocalForEachStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + VariableDeclaration *declaration; + ExpressionNode *expression; + Statement *statement; +}; + +class ContinueStatement: public Statement +{ +public: + ContinueStatement(QScriptNameIdImpl *l = 0): + label (l) { kind = Kind_ContinueStatement; } + + virtual ~ContinueStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *label; +}; + +class BreakStatement: public Statement +{ +public: + BreakStatement(QScriptNameIdImpl *l = 0): + label (l) { kind = Kind_BreakStatement; } + + virtual ~BreakStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *label; +}; + +class ReturnStatement: public Statement +{ +public: + ReturnStatement(ExpressionNode *e): + expression (e) { kind = Kind_ReturnStatement; } + + virtual ~ReturnStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class WithStatement: public Statement +{ +public: + WithStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = Kind_WithStatement; } + + virtual ~WithStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + Statement *statement; +}; + +class SwitchStatement: public Statement +{ +public: + SwitchStatement(ExpressionNode *e, CaseBlock *b): + expression (e), block (b) + { kind = Kind_SwitchStatement; } + + virtual ~SwitchStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + CaseBlock *block; +}; + +class CaseBlock: public Node +{ +public: + CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): + clauses (c), defaultClause (d), moreClauses (r) + { kind = Kind_CaseBlock; } + + virtual ~CaseBlock() {} + + virtual void accept0(Visitor *visitor); + +// attributes + CaseClauses *clauses; + DefaultClause *defaultClause; + CaseClauses *moreClauses; +}; + +class CaseClauses: public Node +{ +public: + CaseClauses(CaseClause *c): + clause (c), next (this) + { kind = Kind_CaseClauses; } + + CaseClauses(CaseClauses *previous, CaseClause *c): + clause (c) + { + kind = Kind_CaseClauses; + next = previous->next; + previous->next = this; + } + + virtual ~CaseClauses() {} + + virtual void accept0(Visitor *visitor); + + inline CaseClauses *finish () + { + CaseClauses *front = next; + next = 0; + return front; + } + +//attributes + CaseClause *clause; + CaseClauses *next; +}; + +class CaseClause: public Node +{ +public: + CaseClause(ExpressionNode *e, StatementList *slist): + expression (e), statements (slist) + { kind = Kind_CaseClause; } + + virtual ~CaseClause() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; + StatementList *statements; +}; + +class DefaultClause: public Node +{ +public: + DefaultClause(StatementList *slist): + statements (slist) + { kind = Kind_DefaultClause; } + + virtual ~DefaultClause() {} + + virtual void accept0(Visitor *visitor); + +// attributes + StatementList *statements; +}; + +class LabelledStatement: public Statement +{ +public: + LabelledStatement(QScriptNameIdImpl *l, Statement *stmt): + label (l), statement (stmt) + { kind = Kind_LabelledStatement; } + + virtual ~LabelledStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *label; + Statement *statement; +}; + +class ThrowStatement: public Statement +{ +public: + ThrowStatement(ExpressionNode *e): + expression (e) { kind = Kind_ThrowStatement; } + + virtual ~ThrowStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + ExpressionNode *expression; +}; + +class TryStatement: public Statement +{ +public: + TryStatement(Statement *stmt, Catch *c, Finally *f): + statement (stmt), catchExpression (c), finallyExpression (f) + { kind = Kind_TryStatement; } + + TryStatement(Statement *stmt, Finally *f): + statement (stmt), catchExpression (0), finallyExpression (f) + { kind = Kind_TryStatement; } + + TryStatement(Statement *stmt, Catch *c): + statement (stmt), catchExpression (c), finallyExpression (0) + { kind = Kind_TryStatement; } + + virtual ~TryStatement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + Statement *statement; + Catch *catchExpression; + Finally *finallyExpression; +}; + +class Catch: public Node +{ +public: + Catch(QScriptNameIdImpl *n, Statement *stmt): + name (n), statement (stmt) + { kind = Kind_Catch; } + + virtual ~Catch() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *name; + Statement *statement; +}; + +class Finally: public Node +{ +public: + Finally(Statement *stmt): + statement (stmt) + { kind = Kind_Finally; } + + virtual ~Finally() {} + + virtual void accept0(Visitor *visitor); + +// attributes + Statement *statement; +}; + +class FunctionExpression: public ExpressionNode +{ +public: + FunctionExpression(QScriptNameIdImpl *n, FormalParameterList *f, FunctionBody *b): + name (n), formals (f), body (b) + { kind = Kind_FunctionExpression; } + + virtual ~FunctionExpression() {} + + virtual void accept0(Visitor *visitor); + +// attributes + QScriptNameIdImpl *name; + FormalParameterList *formals; + FunctionBody *body; +}; + +class FunctionDeclaration: public FunctionExpression +{ +public: + FunctionDeclaration(QScriptNameIdImpl *n, FormalParameterList *f, FunctionBody *b): + FunctionExpression(n, f, b) + { kind = Kind_FunctionDeclaration; } + + virtual ~FunctionDeclaration() {} + + virtual void accept0(Visitor *visitor); +}; + +class FormalParameterList: public Node +{ +public: + FormalParameterList(QScriptNameIdImpl *n): + name (n), next (this) + { kind = Kind_FormalParameterList; } + + FormalParameterList(FormalParameterList *previous, QScriptNameIdImpl *n): + name (n) + { + kind = Kind_FormalParameterList; + next = previous->next; + previous->next = this; + } + + virtual ~FormalParameterList() {} + + virtual void accept0(Visitor *visitor); + + inline FormalParameterList *finish () + { + FormalParameterList *front = next; + next = 0; + return front; + } + +// attributes + QScriptNameIdImpl *name; + FormalParameterList *next; +}; + +class FunctionBody: public Node +{ +public: + FunctionBody(SourceElements *elts): + elements (elts) + { kind = Kind_FunctionBody; } + + virtual ~FunctionBody() {} + + virtual void accept0(Visitor *visitor); + +// attributes + SourceElements *elements; +}; + +class Program: public Node +{ +public: + Program(SourceElements *elts): + elements (elts) + { kind = Kind_Program; } + + virtual ~Program() {} + + virtual void accept0(Visitor *visitor); + +// attributes + SourceElements *elements; +}; + +class SourceElements: public Node +{ +public: + SourceElements(SourceElement *elt): + element (elt), next (this) + { kind = Kind_SourceElements; } + + SourceElements(SourceElements *previous, SourceElement *elt): + element (elt) + { + kind = Kind_SourceElements; + next = previous->next; + previous->next = this; + } + + virtual ~SourceElements() {} + + virtual void accept0(Visitor *visitor); + + inline SourceElements *finish () + { + SourceElements *front = next; + next = 0; + return front; + } + +// attributes + SourceElement *element; + SourceElements *next; +}; + +class SourceElement: public Node +{ +public: + inline SourceElement() + { kind = Kind_SourceElement; } + + virtual ~SourceElement() {} +}; + +class FunctionSourceElement: public SourceElement +{ +public: + FunctionSourceElement(FunctionDeclaration *f): + declaration (f) + { kind = Kind_FunctionSourceElement; } + + virtual ~FunctionSourceElement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + FunctionDeclaration *declaration; +}; + +class StatementSourceElement: public SourceElement +{ +public: + StatementSourceElement(Statement *stmt): + statement (stmt) + { kind = Kind_StatementSourceElement; } + + virtual ~StatementSourceElement() {} + + virtual void accept0(Visitor *visitor); + +// attributes + Statement *statement; +}; + +class DebuggerStatement: public Statement +{ +public: + DebuggerStatement() + { kind = Kind_DebuggerStatement; } + + virtual ~DebuggerStatement() {} + + virtual void accept0(Visitor *visitor); +}; + +} } // namespace AST + +QT_END_NAMESPACE + +#endif diff --git a/src/script/parser/qscriptastfwd_p.h b/src/script/parser/qscriptastfwd_p.h new file mode 100644 index 0000000..84c1c24 --- /dev/null +++ b/src/script/parser/qscriptastfwd_p.h @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTAST_FWD_P_H +#define QSCRIPTAST_FWD_P_H + +#include <QtCore/qglobal.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. +// + +QT_BEGIN_NAMESPACE + +namespace QScript { namespace AST { + +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 PropertyNameAndValueList; +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; + +} } // namespace AST + +QT_END_NAMESPACE + +#endif diff --git a/src/script/parser/qscriptastvisitor.cpp b/src/script/parser/qscriptastvisitor.cpp new file mode 100644 index 0000000..196c906 --- /dev/null +++ b/src/script/parser/qscriptastvisitor.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptastvisitor_p.h" + +QT_BEGIN_NAMESPACE + +namespace QScript { namespace AST { + +Visitor::Visitor() +{ +} + +Visitor::~Visitor() +{ +} + +} } // namespace QScript::AST + +QT_END_NAMESPACE diff --git a/src/script/parser/qscriptastvisitor_p.h b/src/script/parser/qscriptastvisitor_p.h new file mode 100644 index 0000000..c199e5e --- /dev/null +++ b/src/script/parser/qscriptastvisitor_p.h @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTASTVISITOR_P_H +#define QSCRIPTASTVISITOR_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 "qscriptastfwd_p.h" + +QT_BEGIN_NAMESPACE + +namespace QScript { namespace AST { + +class Visitor +{ +public: + Visitor(); + virtual ~Visitor(); + + virtual bool preVisit(Node *) { return true; } + virtual void postVisit(Node *) {} + + 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(PropertyNameAndValueList *) { return true; } + virtual void endVisit(PropertyNameAndValueList *) {} + + 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_END_NAMESPACE + +#endif // QSCRIPTASTVISITOR_P_H diff --git a/src/script/parser/qscriptgrammar.cpp b/src/script/parser/qscriptgrammar.cpp new file mode 100644 index 0000000..a2971a0 --- /dev/null +++ b/src/script/parser/qscriptgrammar.cpp @@ -0,0 +1,971 @@ +// This file was generated by qlalr - DO NOT EDIT! +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptgrammar_p.h" + +QT_BEGIN_NAMESPACE + +const char *const QScriptGrammar::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", "switch", "this", "throw", "~", + "try", "typeof", "var", "void", "while", "with", "^", "^=", "null", "true", + "false", "const", "debugger", "reserved word", +#ifndef QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO +"Program", "PrimaryExpression", "ElisionOpt", "ElementList", "PropertyNameAndValueListOpt", "PropertyNameAndValueList", + "Expression", "AssignmentExpression", "Elision", "PropertyName", "ReservedIdentifier", "PropertyIdentifier", "MemberExpression", "FunctionExpression", "Arguments", "NewExpression", + "CallExpression", "ArgumentList", "LeftHandSideExpression", "PostfixExpression", "UnaryExpression", "MultiplicativeExpression", "AdditiveExpression", "ShiftExpression", "RelationalExpression", "RelationalExpressionNotIn", + "EqualityExpression", "EqualityExpressionNotIn", "BitwiseANDExpression", "BitwiseANDExpressionNotIn", "BitwiseXORExpression", "BitwiseXORExpressionNotIn", "BitwiseORExpression", "BitwiseORExpressionNotIn", "LogicalANDExpression", "LogicalANDExpressionNotIn", + "LogicalORExpression", "LogicalORExpressionNotIn", "ConditionalExpression", "ConditionalExpressionNotIn", "AssignmentExpressionNotIn", "AssignmentOperator", "ExpressionOpt", "ExpressionNotIn", "ExpressionNotInOpt", "Statement", + "Block", "VariableStatement", "EmptyStatement", "ExpressionStatement", "IfStatement", "IterationStatement", "ContinueStatement", "BreakStatement", "ReturnStatement", "WithStatement", + "LabelledStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "DebuggerStatement", "StatementListOpt", "StatementList", "VariableDeclarationKind", "VariableDeclarationList", "VariableDeclaration", + "VariableDeclarationListNotIn", "VariableDeclarationNotIn", "InitialiserOpt", "InitialiserNotInOpt", "Initialiser", "InitialiserNotIn", "CaseBlock", "CaseClausesOpt", "DefaultClause", "CaseClauses", + "CaseClause", "Catch", "Finally", "FunctionDeclaration", "FormalParameterListOpt", "FunctionBodyOpt", "IdentifierOpt", "FormalParameterList", "FunctionBody", "SourceElements", + "SourceElement", "$accept" +#endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO +}; + +const int QScriptGrammar::lhs [] = { + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 87, 87, 92, 92, 86, + 86, 89, 89, 93, 93, 93, 93, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 95, 95, + 96, 96, 96, 96, 96, 99, 99, 100, 100, 100, + 100, 98, 98, 101, 101, 102, 102, 103, 103, 103, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 105, 105, 105, 105, 106, 106, 106, 107, 107, 107, + 107, 108, 108, 108, 108, 108, 108, 108, 109, 109, + 109, 109, 109, 109, 110, 110, 110, 110, 110, 111, + 111, 111, 111, 111, 112, 112, 113, 113, 114, 114, + 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, + 120, 120, 121, 121, 122, 122, 123, 123, 91, 91, + 124, 124, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 90, 90, 126, 126, 127, 127, + 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 130, 146, 146, + 145, 145, 131, 131, 147, 147, 148, 148, 150, 150, + 149, 151, 154, 152, 152, 155, 153, 153, 132, 133, + 133, 134, 134, 135, 135, 135, 135, 135, 135, 135, + 136, 136, 136, 136, 137, 137, 137, 137, 138, 138, + 139, 141, 156, 156, 159, 159, 157, 157, 160, 158, + 140, 142, 142, 143, 143, 143, 161, 162, 144, 144, + 163, 97, 167, 167, 164, 164, 165, 165, 168, 84, + 169, 169, 170, 170, 166, 166, 88, 88, 171}; + +const int QScriptGrammar:: rhs[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 3, 5, 3, 4, 3, 2, 4, 1, 2, 0, + 1, 3, 5, 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, 3, 1, 2, 2, 2, 4, + 3, 2, 3, 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, 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, + 8, 8, 1, 3, 0, 1, 0, 1, 1, 1, + 1, 2, 1, 1, 0, 1, 0, 1, 2}; + + +#ifndef QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO +const int QScriptGrammar::rule_info [] = { + 85, 67 + , 85, 29 + , 85, 78 + , 85, 79 + , 85, 80 + , 85, 47 + , 85, 65 + , 85, 12 + , 85, 13 + , 85, 34, 86, 56 + , 85, 34, 87, 56 + , 85, 34, 87, 8, 86, 56 + , 85, 33, 88, 55 + , 85, 33, 89, 8, 55 + , 85, 36, 90, 60 + , 87, 86, 91 + , 87, 87, 8, 86, 91 + , 92, 8 + , 92, 92, 8 + , 86 + , 86, 92 + , 89, 93, 7, 91 + , 89, 89, 8, 93, 7, 91 + , 93, 29 + , 93, 65 + , 93, 47 + , 93, 94 + , 94, 4 + , 94, 5 + , 94, 6 + , 94, 9 + , 94, 10 + , 94, 11 + , 94, 14 + , 94, 16 + , 94, 80 + , 94, 20 + , 94, 21 + , 94, 22 + , 94, 30 + , 94, 31 + , 94, 32 + , 94, 43 + , 94, 78 + , 94, 59 + , 94, 66 + , 94, 67 + , 94, 68 + , 94, 79 + , 94, 70 + , 94, 71 + , 94, 72 + , 94, 73 + , 94, 74 + , 94, 81 + , 94, 82 + , 94, 83 + , 94, 75 + , 95, 29 + , 95, 94 + , 96, 85 + , 96, 97 + , 96, 96, 34, 90, 56 + , 96, 96, 15, 95 + , 96, 43, 96, 98 + , 99, 96 + , 99, 43, 99 + , 100, 96, 98 + , 100, 100, 98 + , 100, 100, 34, 90, 56 + , 100, 100, 15, 95 + , 98, 36, 60 + , 98, 36, 101, 60 + , 101, 91 + , 101, 101, 8, 91 + , 102, 99 + , 102, 100 + , 103, 102 + , 103, 102, 53 + , 103, 102, 42 + , 104, 103 + , 104, 11, 104 + , 104, 73, 104 + , 104, 71, 104 + , 104, 53, 104 + , 104, 42, 104 + , 104, 51, 104 + , 104, 40, 104 + , 104, 69, 104 + , 104, 44, 104 + , 105, 104 + , 105, 105, 63, 104 + , 105, 105, 12, 104 + , 105, 105, 57, 104 + , 106, 105 + , 106, 106, 51, 105 + , 106, 106, 40, 105 + , 107, 106 + , 107, 107, 38, 106 + , 107, 107, 25, 106 + , 107, 107, 27, 106 + , 108, 107 + , 108, 108, 37, 107 + , 108, 108, 24, 107 + , 108, 108, 35, 107 + , 108, 108, 23, 107 + , 108, 108, 32, 107 + , 108, 108, 31, 107 + , 109, 107 + , 109, 109, 37, 107 + , 109, 109, 24, 107 + , 109, 109, 35, 107 + , 109, 109, 23, 107 + , 109, 109, 32, 107 + , 110, 108 + , 110, 110, 18, 108 + , 110, 110, 45, 108 + , 110, 110, 19, 108 + , 110, 110, 46, 108 + , 111, 109 + , 111, 111, 18, 109 + , 111, 111, 45, 109 + , 111, 111, 19, 109 + , 111, 111, 46, 109 + , 112, 110 + , 112, 112, 1, 110 + , 113, 111 + , 113, 113, 1, 111 + , 114, 112 + , 114, 114, 76, 112 + , 115, 113 + , 115, 115, 76, 113 + , 116, 114 + , 116, 116, 48, 114 + , 117, 115 + , 117, 117, 48, 115 + , 118, 116 + , 118, 118, 2, 116 + , 119, 117 + , 119, 119, 2, 117 + , 120, 118 + , 120, 120, 50, 118 + , 121, 119 + , 121, 121, 50, 119 + , 122, 120 + , 122, 120, 54, 91, 7, 91 + , 123, 121 + , 123, 121, 54, 124, 7, 124 + , 91, 122 + , 91, 102, 125, 91 + , 124, 123 + , 124, 102, 125, 124 + , 125, 17 + , 125, 64 + , 125, 13 + , 125, 58 + , 125, 52 + , 125, 41 + , 125, 39 + , 125, 26 + , 125, 28 + , 125, 3 + , 125, 77 + , 125, 49 + , 90, 91 + , 90, 90, 8, 91 + , 126 + , 126, 90 + , 127, 124 + , 127, 127, 8, 124 + , 128 + , 128, 127 + , 129, 130 + , 129, 131 + , 129, 132 + , 129, 133 + , 129, 134 + , 129, 135 + , 129, 136 + , 129, 137 + , 129, 138 + , 129, 139 + , 129, 140 + , 129, 141 + , 129, 142 + , 129, 143 + , 129, 144 + , 130, 33, 145, 55 + , 146, 129 + , 146, 146, 129 + , 145 + , 145, 146 + , 131, 147, 148, 62 + , 131, 147, 148, 61 + , 147, 81 + , 147, 72 + , 148, 149 + , 148, 148, 8, 149 + , 150, 151 + , 150, 150, 8, 151 + , 149, 29, 152 + , 151, 29, 153 + , 154, 17, 91 + , 152 + , 152, 154 + , 155, 17, 124 + , 153 + , 153, 155 + , 132, 61 + , 133, 90, 62 + , 133, 90, 61 + , 134, 30, 36, 90, 60, 129, 16, 129 + , 134, 30, 36, 90, 60, 129 + , 135, 14, 129, 74, 36, 90, 60, 62 + , 135, 14, 129, 74, 36, 90, 60, 61 + , 135, 74, 36, 90, 60, 129 + , 135, 21, 36, 128, 61, 126, 61, 126, 60, 129 + , 135, 21, 36, 72, 150, 61, 126, 61, 126, 60, 129 + , 135, 21, 36, 102, 31, 90, 60, 129 + , 135, 21, 36, 72, 151, 31, 90, 60, 129 + , 136, 9, 62 + , 136, 9, 61 + , 136, 9, 29, 62 + , 136, 9, 29, 61 + , 137, 4, 62 + , 137, 4, 61 + , 137, 4, 29, 62 + , 137, 4, 29, 61 + , 138, 59, 126, 62 + , 138, 59, 126, 61 + , 139, 75, 36, 90, 60, 129 + , 141, 66, 36, 90, 60, 156 + , 156, 33, 157, 55 + , 156, 33, 157, 158, 157, 55 + , 159, 160 + , 159, 159, 160 + , 157 + , 157, 159 + , 160, 5, 90, 7, 145 + , 158, 10, 7, 145 + , 140, 29, 7, 129 + , 142, 68, 90, 62 + , 142, 68, 90, 61 + , 143, 70, 130, 161 + , 143, 70, 130, 162 + , 143, 70, 130, 161, 162 + , 161, 6, 36, 29, 60, 130 + , 162, 20, 130 + , 144, 82, 62 + , 144, 82, 61 + , 163, 22, 29, 36, 164, 60, 33, 165, 55 + , 97, 22, 166, 36, 164, 60, 33, 165, 55 + , 167, 29 + , 167, 167, 8, 29 + , 164 + , 164, 167 + , 165 + , 165, 168 + , 168, 169 + , 84, 169 + , 169, 170 + , 169, 169, 170 + , 170, 129 + , 170, 163 + , 166 + , 166, 29 + , 88 + , 88, 89 + , 171, 84, 0}; + +const int QScriptGrammar::rule_index [] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, + 22, 26, 32, 36, 41, 45, 48, 53, 55, 58, + 59, 61, 65, 71, 73, 75, 77, 79, 81, 83, + 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, + 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, + 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, + 145, 147, 149, 154, 158, 162, 164, 167, 170, 173, + 178, 182, 185, 189, 191, 195, 197, 199, 201, 204, + 207, 209, 212, 215, 218, 221, 224, 227, 230, 233, + 236, 238, 242, 246, 250, 252, 256, 260, 262, 266, + 270, 274, 276, 280, 284, 288, 292, 296, 300, 302, + 306, 310, 314, 318, 322, 324, 328, 332, 336, 340, + 342, 346, 350, 354, 358, 360, 364, 366, 370, 372, + 376, 378, 382, 384, 388, 390, 394, 396, 400, 402, + 406, 408, 412, 414, 418, 420, 426, 428, 434, 436, + 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, + 462, 464, 466, 468, 470, 472, 476, 477, 479, 481, + 485, 486, 488, 490, 492, 494, 496, 498, 500, 502, + 504, 506, 508, 510, 512, 514, 516, 518, 522, 524, + 527, 528, 530, 534, 538, 540, 542, 544, 548, 550, + 554, 557, 560, 563, 564, 566, 569, 570, 572, 574, + 577, 580, 588, 594, 602, 610, 616, 626, 637, 645, + 654, 657, 660, 664, 668, 671, 674, 678, 682, 686, + 690, 696, 702, 706, 712, 714, 717, 718, 720, 725, + 729, 733, 737, 741, 745, 749, 754, 760, 763, 766, + 769, 778, 787, 789, 793, 794, 796, 797, 799, 801, + 803, 805, 808, 810, 812, 813, 815, 816, 818}; +#endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO + +const int QScriptGrammar::action_default [] = { + 0, 98, 165, 129, 137, 133, 173, 180, 77, 149, + 179, 187, 175, 125, 0, 176, 264, 62, 177, 178, + 183, 78, 141, 145, 66, 95, 76, 81, 61, 0, + 115, 181, 102, 261, 260, 263, 184, 0, 195, 0, + 0, 0, 8, 9, 0, 5, 0, 265, 2, 0, + 267, 20, 0, 0, 0, 0, 0, 3, 6, 0, + 0, 167, 209, 7, 0, 1, 0, 0, 4, 0, + 0, 196, 0, 0, 0, 185, 186, 91, 0, 174, + 182, 0, 0, 78, 97, 265, 2, 267, 80, 79, + 0, 0, 0, 93, 94, 92, 0, 266, 255, 256, + 0, 253, 0, 254, 0, 257, 258, 0, 259, 252, + 262, 0, 268, 0, 27, 28, 29, 30, 55, 31, + 56, 32, 33, 34, 35, 36, 37, 38, 39, 24, + 40, 41, 42, 43, 44, 26, 57, 45, 25, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 58, 0, + 22, 0, 0, 14, 0, 23, 13, 96, 0, 126, + 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, + 0, 106, 0, 0, 0, 100, 101, 99, 104, 108, + 107, 105, 103, 118, 117, 119, 0, 134, 0, 130, + 69, 0, 0, 0, 71, 60, 59, 0, 0, 70, + 166, 0, 74, 72, 0, 73, 75, 210, 211, 0, + 162, 155, 153, 160, 161, 159, 158, 164, 157, 156, + 154, 163, 150, 0, 138, 0, 0, 142, 0, 0, + 146, 68, 0, 0, 64, 0, 63, 269, 225, 0, + 226, 227, 228, 221, 0, 222, 223, 224, 249, 250, + 82, 0, 0, 0, 0, 0, 214, 215, 171, 169, + 131, 139, 135, 151, 127, 172, 0, 78, 143, 147, + 120, 109, 0, 0, 128, 0, 0, 0, 0, 121, + 0, 0, 0, 0, 0, 113, 111, 114, 112, 110, + 123, 122, 124, 0, 136, 0, 132, 0, 170, 78, + 0, 152, 167, 168, 0, 167, 0, 0, 217, 0, + 0, 0, 219, 0, 140, 0, 0, 144, 0, 0, + 148, 207, 0, 199, 208, 202, 0, 206, 0, 167, + 200, 0, 167, 0, 0, 218, 0, 0, 0, 220, + 266, 255, 0, 0, 257, 0, 251, 0, 241, 0, + 0, 0, 213, 0, 212, 189, 192, 0, 28, 55, + 31, 56, 33, 34, 5, 38, 39, 2, 40, 43, + 3, 6, 167, 7, 46, 1, 48, 4, 50, 51, + 52, 53, 54, 58, 190, 188, 66, 67, 65, 0, + 229, 230, 0, 0, 0, 232, 237, 235, 238, 0, + 0, 236, 237, 0, 233, 0, 234, 191, 240, 0, + 191, 239, 0, 242, 243, 0, 191, 244, 245, 0, + 0, 246, 0, 0, 0, 247, 248, 84, 83, 0, + 0, 0, 216, 0, 0, 0, 231, 0, 21, 0, + 18, 20, 11, 0, 17, 12, 19, 16, 10, 0, + 15, 88, 86, 90, 87, 85, 89, 204, 197, 0, + 205, 201, 0, 203, 193, 0, 194, 198}; + +const int QScriptGrammar::goto_default [] = { + 29, 28, 439, 437, 113, 112, 14, 2, 438, 111, + 114, 194, 24, 17, 190, 26, 8, 201, 21, 27, + 77, 25, 1, 32, 30, 270, 13, 264, 3, 260, + 5, 262, 4, 261, 22, 268, 23, 269, 9, 263, + 259, 300, 389, 265, 266, 35, 6, 79, 12, 15, + 18, 19, 10, 7, 31, 80, 20, 36, 75, 76, + 11, 357, 356, 78, 459, 458, 322, 323, 461, 325, + 460, 324, 395, 399, 402, 398, 397, 417, 418, 16, + 100, 107, 96, 99, 106, 108, 33, 0}; + +const int QScriptGrammar::action_index [] = { + 1318, 79, -84, 56, 39, -17, -84, -84, 169, -84, + -84, -84, -84, 216, 149, -84, -84, -84, -84, -84, + -84, 475, 68, 100, 180, 184, -84, -84, -84, 99, + 303, -84, 193, -84, 1318, -84, -84, 160, -84, 194, + 85, 629, -84, -84, 1398, -84, -5, 32, 42, 26, + 1478, 37, 629, 629, 629, 366, 629, -84, -84, 629, + 629, 629, -84, -84, 55, -84, 629, 629, -84, 61, + 629, -84, 629, 52, 38, -84, -84, -84, 49, -84, + -84, 629, 629, 64, 182, 48, -84, 1158, -84, -84, + 629, 629, 629, -84, -84, -84, 36, -84, 44, 50, + 40, -84, 57, -84, -26, 1318, -84, -53, 1318, -84, + -84, 18, 7, 43, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, 629, + -84, 1238, 23, -84, 629, -84, -84, 189, 629, 214, + 629, 629, 629, 629, 293, 629, 629, 629, 629, 629, + 629, 143, 629, 629, 629, 65, 83, 69, 153, 152, + 144, 161, 175, 273, 283, 318, 629, 62, 629, 74, + -84, 1078, 629, 702, -84, -84, -84, 84, 629, -84, + -84, 88, -84, -84, 629, -84, -84, -84, -84, 629, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, 629, 45, 629, 629, 63, 53, 629, + -84, -84, 1078, 629, -84, 102, -84, -84, -84, 90, + -84, -84, -84, -84, 101, -84, -84, -84, -84, -84, + -84, 51, 59, 629, 89, 94, -84, -84, 775, -84, + 13, -36, -65, -84, 230, 2, -52, 556, 14, 133, + 248, 147, -12, 629, 224, 629, 629, 629, 629, 258, + 629, 629, 629, 629, 629, 199, 261, 261, 261, 181, + 242, 322, 322, 629, -55, 629, 5, 629, -84, 334, + 629, -84, 629, 15, -61, 629, -59, 1398, -84, 629, + 73, 1398, -84, 629, 20, 629, 629, 24, 41, 629, + -84, 54, 82, 19, -84, -84, 629, -84, 17, 629, + -84, -10, 629, -7, 1398, -84, 629, 77, 1398, -84, + 31, 27, -13, 10, 1318, -22, -84, 1398, -84, 629, + 76, 1398, 11, 1398, -84, -84, 1398, -15, 136, 9, + 131, 80, 629, 1398, 28, 6, 78, 47, 8, 394, + 34, 30, 925, 29, 3, 21, 629, 25, 1, 629, + 35, 629, 33, 16, -84, -84, 202, -84, -84, 67, + -84, -84, 629, 72, -4, -84, -2, -84, -1, 66, + 629, -84, 0, 12, -84, -37, -84, 1398, -84, 95, + 1398, -84, 105, -84, -84, 98, 1398, 4, -84, -14, + -25, -84, -16, -40, 22, -84, -84, -84, -84, 629, + 93, 1398, -84, 629, 104, 1398, -84, 103, 71, 848, + -84, 58, -84, 998, -84, -84, -84, -84, -84, 75, + -84, -84, -84, -84, -84, -84, -84, 46, -84, 114, + -84, -84, 629, -84, -84, 60, -84, -84, + + -50, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -28, -88, -88, -10, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -64, -88, -88, -88, -88, -88, + -88, 131, -88, -88, -22, -88, -88, -88, -88, -88, + -27, -88, 13, 94, 88, 98, 89, -88, -88, 106, + 107, -4, -88, -88, -88, -88, 68, 111, -88, -31, + 85, -88, 110, -88, -88, -88, -88, -88, -88, -88, + -88, 127, 122, -88, -88, -88, -88, -88, -88, -88, + 97, 100, 101, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -48, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, 32, + -88, 33, -88, -88, 34, -88, -88, -88, 46, -88, + 60, 74, 76, 77, -88, 73, 67, 70, 81, 58, + 79, -88, 37, 51, 65, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, 59, -88, 43, -88, + -88, 42, 48, 20, -88, -88, -88, -88, 41, -88, + -88, -88, -88, -88, 40, -88, -88, -88, -88, 49, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, 50, -88, 45, 26, -88, -88, 24, + -88, -88, 56, 22, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, 31, -88, -88, -88, -88, 57, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, 158, -88, 146, 142, 150, 154, -88, + 47, 138, 115, 135, 132, -88, -88, -88, -88, -88, + -88, -88, -88, 168, -88, 172, -88, 160, -88, -88, + 180, -88, 220, -88, -88, 117, -88, -2, -88, 38, + -88, -5, -88, 174, -88, 170, 166, -88, -88, 164, + -88, -88, -88, -88, -88, -88, 190, -88, -37, 80, + -88, -88, 105, -88, -13, -88, 28, -88, 0, -88, + -88, -44, -88, -88, -52, -88, -88, 12, -88, 52, + -88, 1, -88, 4, -88, -88, 6, -88, -88, -88, + -88, -88, 119, 8, -88, -88, -88, -88, -88, 120, + -88, -88, 44, -88, -88, -88, 68, -88, -45, 116, + -88, 124, -88, -88, -88, -88, -14, -88, -88, -88, + -88, -88, -1, -88, -88, -88, -88, -88, -55, -88, + 11, -88, -53, -88, -88, -88, -88, 109, -88, -88, + 96, -88, -88, -88, -88, -88, -19, -54, -88, -88, + -21, -88, -88, -88, -43, -88, -88, -88, -88, 10, + -88, -38, -88, 2, -88, -39, -88, -88, -88, 3, + -88, 9, -88, 7, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, 5, -88, -88, -56, -88, -88}; + +const int QScriptGrammar::action_info [] = { + 305, 307, 109, 400, 400, 400, 273, 105, 416, 302, + 297, 295, 293, 423, 273, 151, 313, 321, 406, 407, + 424, 295, 422, 198, 420, 149, 313, 353, -47, 396, + 154, 258, -49, 346, 416, -36, -25, -26, -195, 392, + 385, -44, 258, 344, 349, 440, 321, 343, 319, 347, + 336, 332, 433, 334, 347, 416, 101, 158, 102, 188, + 229, 340, 349, 462, -196, 223, 440, 341, 293, 429, + 223, 326, 98, 101, 433, 158, 403, 97, 457, 446, + 198, 198, 0, 198, 198, 198, 103, 186, 429, 457, + 328, 392, 198, 186, 416, 253, 204, 198, 156, 237, + 104, 198, 410, 198, 419, 81, 88, 97, 0, 81, + 198, 441, 198, 198, -265, 0, 82, 89, 420, 81, + 82, 404, 465, 81, 0, 252, 0, 0, 391, 390, + 82, 0, 394, 311, 82, 450, 351, 338, 188, 0, + 199, 249, 248, 329, 0, 0, 249, 248, 205, 255, + 225, 242, 241, 431, 226, 257, 256, 198, 236, 442, + 244, 0, 247, 246, 435, 239, 414, 413, 172, 172, + 173, 173, 172, 0, 173, 466, 464, 172, 172, 173, + 173, 174, 174, 315, 191, 174, 172, 316, 173, 239, + 174, 174, 245, 243, 90, 232, 90, 240, 238, 174, + 172, 90, 173, 192, 0, 193, 172, 0, 173, 0, + 208, 207, 0, 174, 233, 0, 193, 232, 172, 174, + 173, 240, 238, 244, 172, 0, 173, 0, 0, 0, + 0, 174, 160, 161, 160, 161, 233, 174, 193, 91, + 0, 91, 275, 276, 0, 92, 91, 92, 275, 276, + 0, 0, 92, 0, 0, 245, 243, 0, 0, 162, + 163, 162, 163, 0, 0, 280, 281, 0, 0, 277, + 278, 280, 281, 0, 282, 277, 278, 283, 0, 284, + 282, 280, 281, 283, 0, 284, 172, 0, 173, 0, + 282, 0, 0, 283, 0, 284, 165, 166, 0, 174, + 0, 0, 0, 0, 167, 168, 165, 166, 169, 0, + 170, 0, 0, 0, 167, 168, 165, 166, 169, 0, + 170, 0, 0, 0, 167, 168, 165, 166, 169, 0, + 170, 0, 0, 0, 167, 168, 0, 210, 169, 0, + 170, 165, 166, 0, 0, 280, 281, 211, 0, 167, + 168, 212, 0, 169, 282, 170, 0, 283, 0, 284, + 213, 0, 214, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 215, 0, 216, 88, 0, 42, 43, + 0, 0, 0, 217, 0, 0, 218, 89, 85, 0, + 0, 0, 219, 0, 0, 86, 0, 0, 220, 87, + 51, 0, 52, 0, 0, 0, 42, 43, 0, 55, + 0, 221, 0, 58, 0, 0, 85, 0, 0, 0, + 0, 0, 0, 86, 0, 0, 0, 87, 51, 0, + 52, 63, 0, 65, 0, 0, 0, 55, 0, 0, + 0, 58, 0, 0, 57, 68, 45, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, + 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 57, 68, 45, 0, 0, 0, 210, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 211, 0, + 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, + 0, 213, 0, 214, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 215, 0, 216, 88, 0, 0, + 0, 0, 0, 0, 217, 0, 0, 218, 89, 0, + 0, 0, 0, 219, 0, 0, 0, 0, 0, 220, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 221, 0, 0, 0, 0, 0, 0, 210, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 211, + 0, 0, 0, 212, 0, 0, 0, 0, 0, 0, + 0, 0, 213, 0, 214, 0, 0, 309, 0, 0, + 0, 0, 0, 0, 0, 215, 0, 216, 88, 0, + 0, 0, 0, 0, 0, 217, 0, 0, 218, 89, + 0, 0, 0, 0, 219, 0, 0, 0, 0, 0, + 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 221, 0, 0, 0, 0, 0, 0, + 41, 42, 43, 0, 0, 0, 0, 0, 0, 0, + 0, 85, 0, 0, 0, 0, 0, 0, 86, 0, + 0, 0, 87, 51, 0, 52, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 58, 0, 0, 0, + 59, 0, 60, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 63, 0, 65, 0, 67, 0, + 70, 0, 72, 0, 0, 0, 0, 57, 68, 45, + 0, 0, 0, 41, 42, 43, 0, 0, 0, 0, + 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, + 0, 86, 0, 0, 0, 87, 51, 0, 52, 0, + 0, 0, 53, 0, 54, 55, 56, 0, 0, 58, + 0, 0, 0, 59, 0, 60, 0, 0, 0, 0, + 0, 0, 203, 0, 0, 0, 0, 63, 0, 65, + 0, 67, 0, 70, 0, 72, 0, 0, 0, 0, + 57, 68, 45, 0, 0, 0, 41, 42, 43, 0, + 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, + 0, 0, 0, 0, 86, 0, 0, 0, 87, 51, + 0, 52, 0, 0, 0, 53, 0, 54, 55, 56, + 0, 0, 58, 0, 0, 0, 59, 0, 60, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 63, 0, 65, 0, 67, 0, 70, 272, 72, 0, + 0, 0, 0, 57, 68, 45, 0, 0, 0, 41, + 42, 43, 0, 0, 0, 0, 0, 0, 0, 0, + 85, 0, 0, 0, 0, 0, 0, 86, 0, 0, + 0, 87, 51, 0, 52, 0, 0, 0, 53, 0, + 54, 55, 56, 0, 0, 58, 0, 0, 0, 59, + 0, 60, 0, 0, 448, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 65, 0, 67, 0, 70, + 0, 72, 0, 0, 0, 0, 57, 68, 45, 0, + 0, 0, -45, 0, 0, 0, 41, 42, 43, 0, + 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, + 0, 0, 0, 0, 86, 0, 0, 0, 87, 51, + 0, 52, 0, 0, 0, 53, 0, 54, 55, 56, + 0, 0, 58, 0, 0, 0, 59, 0, 60, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 63, 0, 65, 0, 67, 0, 70, 0, 72, 0, + 0, 0, 0, 57, 68, 45, 0, 0, 0, 41, + 42, 43, 0, 0, 0, 0, 0, 0, 0, 0, + 85, 0, 0, 0, 0, 0, 0, 86, 0, 0, + 0, 87, 51, 0, 52, 0, 0, 0, 53, 0, + 54, 55, 56, 0, 0, 58, 0, 0, 0, 59, + 0, 60, 0, 0, 445, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 65, 0, 67, 0, 70, + 0, 72, 0, 0, 0, 0, 57, 68, 45, 0, + 0, 0, 115, 116, 117, 0, 0, 119, 121, 122, + 0, 0, 123, 0, 124, 0, 0, 0, 126, 127, + 128, 0, 0, 0, 0, 0, 0, 196, 130, 131, + 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, + 0, 0, 0, 0, 139, 140, 141, 0, 143, 144, + 145, 146, 147, 148, 0, 0, 134, 142, 125, 118, + 120, 136, 115, 116, 117, 0, 0, 119, 121, 122, + 0, 0, 123, 0, 124, 0, 0, 0, 126, 127, + 128, 0, 0, 0, 0, 0, 0, 129, 130, 131, + 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 133, 0, 0, 0, 135, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, + 0, 0, 0, 138, 139, 140, 141, 0, 143, 144, + 145, 146, 147, 148, 0, 0, 134, 142, 125, 118, + 120, 136, 115, 116, 117, 0, 0, 119, 121, 122, + 0, 0, 123, 0, 124, 0, 0, 0, 126, 127, + 128, 0, 0, 0, 0, 0, 0, 129, 130, 131, + 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 133, 0, 0, 0, 135, 0, 0, 0, 0, + 0, 0, 0, 153, 0, 0, 0, 137, 0, 0, + 0, 0, 0, 138, 139, 140, 141, 0, 143, 144, + 145, 146, 147, 148, 0, 0, 134, 142, 125, 118, + 120, 136, 37, 0, 0, 0, 0, 39, 0, 41, + 42, 43, 44, 0, 0, 0, 0, 0, 0, 46, + 47, 0, 0, 0, 0, 0, 0, 48, 49, 0, + 0, 50, 51, 0, 52, 0, 0, 0, 53, 0, + 54, 55, 56, 0, 0, 58, 0, 0, 0, 59, + 0, 60, 0, 0, 0, 0, 0, 61, 0, 62, + 0, 0, 0, 63, 64, 65, 66, 67, 69, 70, + 71, 72, 73, 74, 0, 0, 57, 68, 45, 38, + 40, 0, 37, 0, 0, 0, 0, 39, 0, 41, + 42, 43, 44, 0, 0, 0, 0, 0, 0, 46, + 85, 0, 0, 0, 0, 0, 0, 48, 49, 0, + 0, 50, 51, 0, 52, 0, 0, 0, 53, 0, + 54, 55, 56, 0, 0, 58, 0, 0, 0, 59, + 0, 60, 0, 0, 0, 0, 0, 61, 0, 62, + 0, 0, 0, 63, 64, 65, 66, 67, 69, 70, + 71, 72, 73, 74, 0, 0, 57, 68, 45, 38, + 40, 0, 358, 116, 117, 0, 0, 360, 121, 362, + 42, 43, 363, 0, 124, 0, 0, 0, 126, 365, + 366, 0, 0, 0, 0, 0, 0, 367, 368, 131, + 132, 50, 51, 0, 52, 0, 0, 0, 53, 0, + 54, 369, 56, 0, 0, 371, 0, 0, 0, 59, + 0, 60, 0, -191, 0, 0, 0, 372, 0, 62, + 0, 0, 0, 373, 374, 375, 376, 67, 378, 379, + 380, 381, 382, 383, 0, 0, 370, 377, 364, 359, + 361, 136, + + 388, 415, 303, 425, 231, 393, 436, 432, 434, 467, + 447, 443, 463, 209, 444, 415, 430, 409, 355, 449, + 405, 401, 110, 251, 421, 426, 355, 202, 235, 345, + 330, 230, 335, 228, 337, 34, 342, 254, 110, 150, + 312, 155, 152, 308, 310, 339, 352, 206, 200, 354, + 303, 384, 195, 251, 197, 83, 222, 348, 350, 175, + 0, 83, 0, 83, 83, 83, 195, 234, 83, 83, + 285, 189, 159, 176, 412, 267, 83, 83, 83, 227, + 271, 181, 224, 83, 164, 83, 303, 177, 83, 187, + 178, 83, 83, 179, 83, 83, 171, 83, 183, 83, + 184, 185, 182, 83, 180, 427, 83, 83, 452, 453, + 386, 303, 83, 387, 451, 83, 0, 93, 83, 83, + 94, 95, 331, 303, 83, 83, 454, 455, 83, 83, + 428, 456, 386, 83, 83, 387, 427, 83, 287, 250, + 83, 355, 83, 157, 428, 83, 0, 333, 84, 83, + 83, 250, 0, 83, 355, 289, 83, 411, 288, 306, + 83, 286, 0, 0, 83, 271, 0, 290, 83, 271, + 408, 279, 83, 271, 0, 291, 83, 271, 299, 292, + 0, 271, 299, 271, 299, 274, 83, 271, 83, 271, + 83, 271, 83, 271, 0, 271, 0, 271, 299, 294, + 298, 296, 0, 271, 320, 317, 318, 314, 299, 0, + 0, 0, 0, 271, 0, 0, 0, 0, 0, 0, + 301, 0, 0, 0, 0, 0, 303, 0, 0, 0, + 327, 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, 304, 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 int QScriptGrammar::action_check [] = { + 61, 60, 55, 5, 5, 5, 1, 33, 33, 61, + 8, 76, 48, 29, 1, 8, 2, 29, 55, 7, + 60, 76, 36, 8, 20, 7, 2, 16, 7, 33, + 7, 36, 7, 55, 33, 7, 7, 7, 29, 36, + 55, 7, 36, 33, 36, 8, 29, 60, 7, 7, + 31, 61, 36, 60, 7, 33, 29, 1, 8, 76, + 7, 29, 36, 17, 29, 2, 8, 36, 48, 36, + 2, 17, 36, 29, 36, 1, 10, 29, 29, 8, + 8, 8, -1, 8, 8, 8, 29, 48, 36, 29, + 8, 36, 8, 48, 33, 36, 8, 8, 55, 0, + 60, 8, 7, 8, 6, 40, 42, 29, -1, 40, + 8, 8, 8, 8, 36, -1, 51, 53, 20, 40, + 51, 55, 8, 40, -1, 74, -1, -1, 61, 62, + 51, -1, 60, 60, 51, 60, 60, 60, 76, -1, + 56, 61, 62, 61, -1, -1, 61, 62, 60, 60, + 50, 61, 62, 60, 54, 61, 62, 8, 56, 56, + 29, -1, 61, 62, 60, 29, 61, 62, 25, 25, + 27, 27, 25, -1, 27, 61, 62, 25, 25, 27, + 27, 38, 38, 50, 15, 38, 25, 54, 27, 29, + 38, 38, 61, 62, 12, 15, 12, 61, 62, 38, + 25, 12, 27, 34, -1, 36, 25, -1, 27, -1, + 61, 62, -1, 38, 34, -1, 36, 15, 25, 38, + 27, 61, 62, 29, 25, -1, 27, -1, -1, -1, + -1, 38, 18, 19, 18, 19, 34, 38, 36, 57, + -1, 57, 18, 19, -1, 63, 57, 63, 18, 19, + -1, -1, 63, -1, -1, 61, 62, -1, -1, 45, + 46, 45, 46, -1, -1, 23, 24, -1, -1, 45, + 46, 23, 24, -1, 32, 45, 46, 35, -1, 37, + 32, 23, 24, 35, -1, 37, 25, -1, 27, -1, + 32, -1, -1, 35, -1, 37, 23, 24, -1, 38, + -1, -1, -1, -1, 31, 32, 23, 24, 35, -1, + 37, -1, -1, -1, 31, 32, 23, 24, 35, -1, + 37, -1, -1, -1, 31, 32, 23, 24, 35, -1, + 37, -1, -1, -1, 31, 32, -1, 3, 35, -1, + 37, 23, 24, -1, -1, 23, 24, 13, -1, 31, + 32, 17, -1, 35, 32, 37, -1, 35, -1, 37, + 26, -1, 28, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 39, -1, 41, 42, -1, 12, 13, + -1, -1, -1, 49, -1, -1, 52, 53, 22, -1, + -1, -1, 58, -1, -1, 29, -1, -1, 64, 33, + 34, -1, 36, -1, -1, -1, 12, 13, -1, 43, + -1, 77, -1, 47, -1, -1, 22, -1, -1, -1, + -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, + 36, 65, -1, 67, -1, -1, -1, 43, -1, -1, + -1, 47, -1, -1, 78, 79, 80, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, + -1, 67, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 78, 79, 80, -1, -1, -1, 3, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, + -1, -1, 17, -1, -1, -1, -1, -1, -1, -1, + -1, 26, -1, 28, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 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, 77, -1, -1, -1, -1, -1, -1, 3, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, + -1, -1, -1, 17, -1, -1, -1, -1, -1, -1, + -1, -1, 26, -1, 28, -1, -1, 31, -1, -1, + -1, -1, -1, -1, -1, 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, 77, -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, -1, 67, -1, 69, -1, + 71, -1, 73, -1, -1, -1, -1, 78, 79, 80, + -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, 60, -1, -1, -1, -1, 65, -1, 67, + -1, 69, -1, 71, -1, 73, -1, -1, -1, -1, + 78, 79, 80, -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, -1, 67, -1, 69, -1, 71, 72, 73, -1, + -1, -1, -1, 78, 79, 80, -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, 56, -1, -1, -1, -1, -1, + -1, -1, -1, 65, -1, 67, -1, 69, -1, 71, + -1, 73, -1, -1, -1, -1, 78, 79, 80, -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, -1, 67, -1, 69, -1, 71, -1, 73, -1, + -1, -1, -1, 78, 79, 80, -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, 56, -1, -1, -1, -1, -1, + -1, -1, -1, 65, -1, 67, -1, 69, -1, 71, + -1, 73, -1, -1, -1, -1, 78, 79, 80, -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, -1, 70, 71, + 72, 73, 74, 75, -1, -1, 78, 79, 80, 81, + 82, 83, 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, -1, 70, 71, + 72, 73, 74, 75, -1, -1, 78, 79, 80, 81, + 82, 83, 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, -1, 70, 71, + 72, 73, 74, 75, -1, -1, 78, 79, 80, 81, + 82, 83, 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, -1, -1, 78, 79, 80, 81, + 82, -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, -1, -1, 78, 79, 80, 81, + 82, -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, -1, -1, 78, 79, 80, 81, + 82, 83, + + 14, 46, 6, 46, 14, 6, 45, 45, 6, 65, + 7, 2, 7, 41, 7, 46, 6, 6, 45, 6, + 73, 76, 86, 45, 78, 46, 45, 7, 6, 81, + 67, 7, 45, 7, 6, 85, 80, 6, 86, 7, + 45, 7, 9, 45, 6, 45, 45, 7, 7, 45, + 6, 45, 10, 45, 6, 18, 7, 45, 6, 22, + -1, 18, -1, 18, 18, 18, 10, 11, 18, 18, + 23, 28, 26, 22, 6, 18, 18, 18, 18, 34, + 23, 23, 32, 18, 24, 18, 6, 22, 18, 30, + 23, 18, 18, 23, 18, 18, 23, 18, 24, 18, + 24, 24, 23, 18, 23, 20, 18, 18, 20, 20, + 12, 6, 18, 15, 20, 18, -1, 20, 18, 18, + 20, 20, 42, 6, 18, 18, 20, 20, 18, 18, + 20, 20, 12, 18, 18, 15, 20, 18, 23, 20, + 18, 45, 18, 21, 20, 18, -1, 42, 21, 18, + 18, 20, -1, 18, 45, 23, 18, 61, 23, 42, + 18, 23, -1, -1, 18, 23, -1, 25, 18, 23, + 61, 25, 18, 23, -1, 25, 18, 23, 18, 25, + -1, 23, 18, 23, 18, 27, 18, 23, 18, 23, + 18, 23, 18, 23, -1, 23, -1, 23, 18, 31, + 40, 29, -1, 23, 40, 35, 40, 33, 18, -1, + -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, + 40, -1, -1, -1, -1, -1, 6, -1, -1, -1, + 40, -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, 42, -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/script/parser/qscriptgrammar_p.h b/src/script/parser/qscriptgrammar_p.h new file mode 100644 index 0000000..43e8b67 --- /dev/null +++ b/src/script/parser/qscriptgrammar_p.h @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was generated by qlalr - DO NOT EDIT! + +#ifndef QSCRIPTGRAMMAR_P_H +#define QSCRIPTGRAMMAR_P_H + +// +// 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. +// + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +class QScriptGrammar +{ +public: + enum { + EOF_SYMBOL = 0, + T_AND = 1, + T_AND_AND = 2, + T_AND_EQ = 3, + T_AUTOMATIC_SEMICOLON = 62, + T_BREAK = 4, + T_CASE = 5, + T_CATCH = 6, + T_COLON = 7, + T_COMMA = 8, + T_CONST = 81, + T_CONTINUE = 9, + T_DEBUGGER = 82, + 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_FALSE = 80, + T_FINALLY = 20, + T_FOR = 21, + T_FUNCTION = 22, + T_GE = 23, + 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_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_NEW = 43, + T_NOT = 44, + T_NOT_EQ = 45, + T_NOT_EQ_EQ = 46, + T_NULL = 78, + T_NUMERIC_LITERAL = 47, + T_OR = 48, + T_OR_EQ = 49, + T_OR_OR = 50, + T_PLUS = 51, + T_PLUS_EQ = 52, + T_PLUS_PLUS = 53, + T_QUESTION = 54, + T_RBRACE = 55, + T_RBRACKET = 56, + T_REMAINDER = 57, + T_REMAINDER_EQ = 58, + T_RESERVED_WORD = 83, + T_RETURN = 59, + T_RPAREN = 60, + T_SEMICOLON = 61, + T_STAR = 63, + T_STAR_EQ = 64, + T_STRING_LITERAL = 65, + T_SWITCH = 66, + T_THIS = 67, + T_THROW = 68, + T_TILDE = 69, + T_TRUE = 79, + T_TRY = 70, + T_TYPEOF = 71, + T_VAR = 72, + T_VOID = 73, + T_WHILE = 74, + T_WITH = 75, + T_XOR = 76, + T_XOR_EQ = 77, + + ACCEPT_STATE = 237, + RULE_COUNT = 269, + STATE_COUNT = 468, + TERMINAL_COUNT = 84, + NON_TERMINAL_COUNT = 88, + + GOTO_INDEX_OFFSET = 468, + GOTO_INFO_OFFSET = 1562, + GOTO_CHECK_OFFSET = 1562 + }; + + static const char *const spell []; + static const int lhs []; + static const int rhs []; + +#ifndef QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO + static const int rule_index []; + static const int rule_info []; +#endif // QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO + + static const int goto_default []; + static const int action_default []; + static const int action_index []; + static const int action_info []; + static const int action_check []; + + static inline int nt_action (int state, int nt) + { + const int *const goto_index = &action_index [GOTO_INDEX_OFFSET]; + const int *const goto_check = &action_check [GOTO_CHECK_OFFSET]; + + const int yyn = goto_index [state] + nt; + + if (yyn < 0 || goto_check [yyn] != nt) + return goto_default [nt]; + + const int *const goto_info = &action_info [GOTO_INFO_OFFSET]; + return goto_info [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 // QSCRIPTGRAMMAR_P_H diff --git a/src/script/parser/qscriptlexer.cpp b/src/script/parser/qscriptlexer.cpp new file mode 100644 index 0000000..ea7578f --- /dev/null +++ b/src/script/parser/qscriptlexer.cpp @@ -0,0 +1,1111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptlexer_p.h" + +#include "qscriptgrammar_p.h" +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +QT_BEGIN_NAMESPACE + +extern double qstrtod(const char *s00, char const **se, bool *ok); + +#define shiftWindowsLineBreak() \ + do { \ + if (((current == '\r') && (next1 == '\n')) \ + || ((current == '\n') && (next1 == '\r'))) { \ + shift(1); \ + } \ + } \ + while (0) + +typedef double qsreal; // ### + +namespace QScript { +extern qsreal integerFromString(const char *buf, int size, int radix); +} + +QScript::Lexer::Lexer(QScriptEnginePrivate *eng) + : driver(eng), + yylineno(0), + size8(128), size16(128), restrKeyword(false), + stackToken(-1), pos(0), + code(0), length(0), + bol(true), + current(0), next1(0), next2(0), next3(0), + err(NoError), + check_reserved(true), + parenthesesState(IgnoreParentheses), + prohibitAutomaticSemicolon(false) +{ + // allocate space for read buffers + buffer8 = new char[size8]; + buffer16 = new QChar[size16]; + pattern = 0; + flags = 0; + +} + +QScript::Lexer::~Lexer() +{ + delete [] buffer8; + delete [] buffer16; +} + +void QScript::Lexer::setCode(const QString &c, int lineno) +{ + errmsg = QString(); + yylineno = lineno; + yycolumn = 1; + restrKeyword = false; + delimited = false; + stackToken = -1; + pos = 0; + code = c.unicode(); + length = c.length(); + bol = true; + + // read first characters + current = (length > 0) ? code[0].unicode() : 0; + next1 = (length > 1) ? code[1].unicode() : 0; + next2 = (length > 2) ? code[2].unicode() : 0; + next3 = (length > 3) ? code[3].unicode() : 0; +} + +void QScript::Lexer::shift(uint p) +{ + while (p--) { + ++pos; + ++yycolumn; + current = next1; + next1 = next2; + next2 = next3; + next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0; + } +} + +void QScript::Lexer::setDone(State s) +{ + state = s; + done = true; +} + +int QScript::Lexer::findReservedWord(const QChar *c, int size) const +{ + switch (size) { + case 2: { + if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o')) + return QScriptGrammar::T_DO; + else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('f')) + return QScriptGrammar::T_IF; + else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')) + return QScriptGrammar::T_IN; + } break; + + case 3: { + if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('r')) + return QScriptGrammar::T_FOR; + else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('w')) + return QScriptGrammar::T_NEW; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('y')) + return QScriptGrammar::T_TRY; + else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('r')) + return QScriptGrammar::T_VAR; + else if (check_reserved) { + if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 4: { + if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a') + && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e')) + return QScriptGrammar::T_CASE; + else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('l') + && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e')) + return QScriptGrammar::T_ELSE; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('s')) + return QScriptGrammar::T_THIS; + else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('d')) + return QScriptGrammar::T_VOID; + else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('i') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('h')) + return QScriptGrammar::T_WITH; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') + && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('e')) + return QScriptGrammar::T_TRUE; + else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('u') + && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('l')) + return QScriptGrammar::T_NULL; + else if (check_reserved) { + if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('n') + && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('m')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('y') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('l') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('g')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('r')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('g') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('o')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 5: { + if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('r') + && c[2] == QLatin1Char('e') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('k')) + return QScriptGrammar::T_BREAK; + else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('c') + && c[4] == QLatin1Char('h')) + return QScriptGrammar::T_CATCH; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o') + && c[4] == QLatin1Char('w')) + return QScriptGrammar::T_THROW; + else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('l') + && c[4] == QLatin1Char('e')) + return QScriptGrammar::T_WHILE; + else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('s') + && c[4] == QLatin1Char('t')) + return QScriptGrammar::T_CONST; + else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('a') + && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('s') + && c[4] == QLatin1Char('e')) + return QScriptGrammar::T_FALSE; + else if (check_reserved) { + if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('r') + && c[4] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('u') + && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e') + && c[4] == QLatin1Char('r')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('l')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('l') + && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('s') + && c[4] == QLatin1Char('s')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('l') + && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 6: { + if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e') + && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('e') + && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('e')) + return QScriptGrammar::T_DELETE; + else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('u') + && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('n')) + return QScriptGrammar::T_RETURN; + else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('w') + && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('c') && c[5] == QLatin1Char('h')) + return QScriptGrammar::T_SWITCH; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('y') + && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e') + && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('f')) + return QScriptGrammar::T_TYPEOF; + else if (check_reserved) { + if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x') + && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o') + && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('t') + && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('b') + && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m') + && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o') + && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('u') + && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('l') + && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('a') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('i') + && c[4] == QLatin1Char('v') && c[5] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') + && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o') + && c[4] == QLatin1Char('w') && c[5] == QLatin1Char('s')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 7: { + if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e') + && c[2] == QLatin1Char('f') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('u') && c[5] == QLatin1Char('l') + && c[6] == QLatin1Char('t')) + return QScriptGrammar::T_DEFAULT; + else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('l') + && c[6] == QLatin1Char('y')) + return QScriptGrammar::T_FINALLY; + else if (check_reserved) { + if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('l') + && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('a') + && c[6] == QLatin1Char('n')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e') + && c[4] == QLatin1Char('n') && c[5] == QLatin1Char('d') + && c[6] == QLatin1Char('s')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('a') + && c[2] == QLatin1Char('c') && c[3] == QLatin1Char('k') + && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('g') + && c[6] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r') + && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('v') + && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('t') + && c[6] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 8: { + if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('n') + && c[6] == QLatin1Char('u') && c[7] == QLatin1Char('e')) + return QScriptGrammar::T_CONTINUE; + else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('u') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c') + && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i') + && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n')) + return QScriptGrammar::T_FUNCTION; + else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e') + && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('u') + && c[4] == QLatin1Char('g') && c[5] == QLatin1Char('g') + && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('r')) + return QScriptGrammar::T_DEBUGGER; + else if (check_reserved) { + if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('b') + && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('a') + && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o') + && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('a') + && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i') + && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 9: { + if (check_reserved) { + if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') + && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e') + && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('f') + && c[6] == QLatin1Char('a') && c[7] == QLatin1Char('c') + && c[8] == QLatin1Char('e')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') + && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('n') + && c[4] == QLatin1Char('s') && c[5] == QLatin1Char('i') + && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n') + && c[8] == QLatin1Char('t')) + return QScriptGrammar::T_RESERVED_WORD; + else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r') + && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('c') + && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('e') + && c[8] == QLatin1Char('d')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 10: { + if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') + && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t') + && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('n') + && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('e') + && c[8] == QLatin1Char('o') && c[9] == QLatin1Char('f')) + return QScriptGrammar::T_INSTANCEOF; + else if (check_reserved) { + if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m') + && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('l') + && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('m') + && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n') + && c[8] == QLatin1Char('t') && c[9] == QLatin1Char('s')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + case 12: { + if (check_reserved) { + if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('y') + && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c') + && c[4] == QLatin1Char('h') && c[5] == QLatin1Char('r') + && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n') + && c[8] == QLatin1Char('i') && c[9] == QLatin1Char('z') + && c[10] == QLatin1Char('e') && c[11] == QLatin1Char('d')) + return QScriptGrammar::T_RESERVED_WORD; + } + } break; + + } // switch + + return -1; +} + +int QScript::Lexer::lex() +{ + int token = 0; + state = Start; + ushort stringType = 0; // either single or double quotes + pos8 = pos16 = 0; + done = false; + terminator = false; + + // did we push a token on the stack previously ? + // (after an automatic semicolon insertion) + if (stackToken >= 0) { + setDone(Other); + token = stackToken; + stackToken = -1; + } + + while (!done) { + switch (state) { + case Start: + if (isWhiteSpace()) { + // do nothing + } else if (current == '/' && next1 == '/') { + recordStartPos(); + shift(1); + state = InSingleLineComment; + } else if (current == '/' && next1 == '*') { + recordStartPos(); + shift(1); + state = InMultiLineComment; + } else if (current == 0) { + syncProhibitAutomaticSemicolon(); + if (!terminator && !delimited && !prohibitAutomaticSemicolon) { + // automatic semicolon insertion if program incomplete + token = QScriptGrammar::T_SEMICOLON; + stackToken = 0; + setDone(Other); + } else { + setDone(Eof); + } + } else if (isLineTerminator()) { + shiftWindowsLineBreak(); + yylineno++; + yycolumn = 0; + bol = true; + terminator = true; + syncProhibitAutomaticSemicolon(); + if (restrKeyword) { + token = QScriptGrammar::T_SEMICOLON; + setDone(Other); + } + } else if (current == '"' || current == '\'') { + recordStartPos(); + state = InString; + stringType = current; + } else if (isIdentLetter(current)) { + recordStartPos(); + record16(current); + state = InIdentifier; + } else if (current == '0') { + recordStartPos(); + record8(current); + state = InNum0; + } else if (isDecimalDigit(current)) { + recordStartPos(); + record8(current); + state = InNum; + } else if (current == '.' && isDecimalDigit(next1)) { + recordStartPos(); + record8(current); + state = InDecimal; + } else { + recordStartPos(); + token = matchPunctuator(current, next1, next2, next3); + if (token != -1) { + if (terminator && !delimited && !prohibitAutomaticSemicolon + && (token == QScriptGrammar::T_PLUS_PLUS + || token == QScriptGrammar::T_MINUS_MINUS)) { + // automatic semicolon insertion + stackToken = token; + token = QScriptGrammar::T_SEMICOLON; + } + setDone(Other); + } + else { + setDone(Bad); + err = IllegalCharacter; + errmsg = QLatin1String("Illegal character"); + } + } + break; + case InString: + if (current == stringType) { + shift(1); + setDone(String); + } else if (current == 0 || isLineTerminator()) { + setDone(Bad); + err = UnclosedStringLiteral; + errmsg = QLatin1String("Unclosed string at end of line"); + } else if (current == '\\') { + state = InEscapeSequence; + } else { + record16(current); + } + break; + // Escape Sequences inside of strings + case InEscapeSequence: + if (isOctalDigit(current)) { + if (current >= '0' && current <= '3' && + isOctalDigit(next1) && isOctalDigit(next2)) { + record16(convertOctal(current, next1, next2)); + shift(2); + state = InString; + } else if (isOctalDigit(current) && + isOctalDigit(next1)) { + record16(convertOctal('0', current, next1)); + shift(1); + state = InString; + } else if (isOctalDigit(current)) { + record16(convertOctal('0', '0', current)); + state = InString; + } else { + setDone(Bad); + err = IllegalEscapeSequence; + errmsg = QLatin1String("Illegal escape squence"); + } + } else if (current == 'x') + state = InHexEscape; + else if (current == 'u') + state = InUnicodeEscape; + else { + if (isLineTerminator()) { + shiftWindowsLineBreak(); + yylineno++; + yycolumn = 0; + bol = true; + } else { + record16(singleEscape(current)); + } + state = InString; + } + break; + case InHexEscape: + if (isHexDigit(current) && isHexDigit(next1)) { + state = InString; + record16(QLatin1Char(convertHex(current, next1))); + shift(1); + } else if (current == stringType) { + record16(QLatin1Char('x')); + shift(1); + setDone(String); + } else { + record16(QLatin1Char('x')); + record16(current); + state = InString; + } + break; + case InUnicodeEscape: + if (isHexDigit(current) && isHexDigit(next1) && + isHexDigit(next2) && isHexDigit(next3)) { + record16(convertUnicode(current, next1, next2, next3)); + shift(3); + state = InString; + } else if (current == stringType) { + record16(QLatin1Char('u')); + shift(1); + setDone(String); + } else { + setDone(Bad); + err = IllegalUnicodeEscapeSequence; + errmsg = QLatin1String("Illegal unicode escape sequence"); + } + break; + case InSingleLineComment: + if (isLineTerminator()) { + shiftWindowsLineBreak(); + yylineno++; + yycolumn = 0; + terminator = true; + bol = true; + if (restrKeyword) { + token = QScriptGrammar::T_SEMICOLON; + setDone(Other); + } else + state = Start; + } else if (current == 0) { + setDone(Eof); + } + break; + case InMultiLineComment: + if (current == 0) { + setDone(Bad); + err = UnclosedComment; + errmsg = QLatin1String("Unclosed comment at end of file"); + } else if (isLineTerminator()) { + shiftWindowsLineBreak(); + yylineno++; + } else if (current == '*' && next1 == '/') { + state = Start; + shift(1); + } + break; + case InIdentifier: + if (isIdentLetter(current) || isDecimalDigit(current)) { + record16(current); + break; + } + setDone(Identifier); + break; + case InNum0: + if (current == 'x' || current == 'X') { + record8(current); + state = InHex; + } else if (current == '.') { + record8(current); + state = InDecimal; + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else if (isOctalDigit(current)) { + record8(current); + state = InOctal; + } else if (isDecimalDigit(current)) { + record8(current); + state = InDecimal; + } else { + setDone(Number); + } + break; + case InHex: + if (isHexDigit(current)) + record8(current); + else + setDone(Hex); + break; + case InOctal: + if (isOctalDigit(current)) { + record8(current); + } else if (isDecimalDigit(current)) { + record8(current); + state = InDecimal; + } else { + setDone(Octal); + } + break; + case InNum: + if (isDecimalDigit(current)) { + record8(current); + } else if (current == '.') { + record8(current); + state = InDecimal; + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else { + setDone(Number); + } + break; + case InDecimal: + if (isDecimalDigit(current)) { + record8(current); + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else { + setDone(Number); + } + break; + case InExponentIndicator: + if (current == '+' || current == '-') { + record8(current); + } else if (isDecimalDigit(current)) { + record8(current); + state = InExponent; + } else { + setDone(Bad); + err = IllegalExponentIndicator; + errmsg = QLatin1String("Illegal syntax for exponential number"); + } + break; + case InExponent: + if (isDecimalDigit(current)) { + record8(current); + } else { + setDone(Number); + } + break; + default: + Q_ASSERT_X(0, "Lexer::lex", "Unhandled state in switch statement"); + } + + // move on to the next character + if (!done) + shift(1); + if (state != Start && state != InSingleLineComment) + bol = false; + } + + // no identifiers allowed directly after numeric literal, e.g. "3in" is bad + if ((state == Number || state == Octal || state == Hex) + && isIdentLetter(current)) { + state = Bad; + err = IllegalIdentifier; + errmsg = QLatin1String("Identifier cannot start with numeric literal"); + } + + // terminate string + buffer8[pos8] = '\0'; + + double dval = 0; + if (state == Number) { + dval = qstrtod(buffer8, 0, 0); + } else if (state == Hex) { // scan hex numbers + dval = QScript::integerFromString(buffer8, pos8, 16); + state = Number; + } else if (state == Octal) { // scan octal number + dval = QScript::integerFromString(buffer8, pos8, 8); + state = Number; + } + + restrKeyword = false; + delimited = false; + + switch (parenthesesState) { + case IgnoreParentheses: + break; + case CountParentheses: + if (token == QScriptGrammar::T_RPAREN) { + --parenthesesCount; + if (parenthesesCount == 0) + parenthesesState = BalancedParentheses; + } else if (token == QScriptGrammar::T_LPAREN) { + ++parenthesesCount; + } + break; + case BalancedParentheses: + parenthesesState = IgnoreParentheses; + break; + } + + switch (state) { + case Eof: + return 0; + case Other: + if(token == QScriptGrammar::T_RBRACE || token == QScriptGrammar::T_SEMICOLON) + delimited = true; + return token; + case Identifier: + if ((token = findReservedWord(buffer16, pos16)) < 0) { + /* TODO: close leak on parse error. same holds true for String */ + if (driver) { + Q_ASSERT_X(false, Q_FUNC_INFO, "not implemented"); + qsyylval.ustr = 0; // driver->intern(buffer16, pos16); + } else + qsyylval.ustr = 0; + return QScriptGrammar::T_IDENTIFIER; + } + if (token == QScriptGrammar::T_CONTINUE || token == QScriptGrammar::T_BREAK + || token == QScriptGrammar::T_RETURN || token == QScriptGrammar::T_THROW) { + restrKeyword = true; + } else if (token == QScriptGrammar::T_IF || token == QScriptGrammar::T_FOR + || token == QScriptGrammar::T_WHILE || token == QScriptGrammar::T_WITH) { + parenthesesState = CountParentheses; + parenthesesCount = 0; + } else if (token == QScriptGrammar::T_DO) { + parenthesesState = BalancedParentheses; + } + return token; + case String: + if (driver) { + Q_ASSERT_X(false, Q_FUNC_INFO, "not implemented"); + qsyylval.ustr = 0; // driver->intern(buffer16, pos16); + } else + qsyylval.ustr = 0; + return QScriptGrammar::T_STRING_LITERAL; + case Number: + qsyylval.dval = dval; + return QScriptGrammar::T_NUMERIC_LITERAL; + case Bad: + return -1; + default: + Q_ASSERT(!"unhandled numeration value in switch"); + return -1; + } +} + +bool QScript::Lexer::isWhiteSpace() const +{ + return (current == ' ' || current == '\t' || + current == 0x0b || current == 0x0c); +} + +bool QScript::Lexer::isLineTerminator() const +{ + return (current == '\n' || current == '\r'); +} + +bool QScript::Lexer::isIdentLetter(ushort c) +{ + /* TODO: allow other legitimate unicode chars */ + return ((c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || c == '$' + || c == '_'); +} + +bool QScript::Lexer::isDecimalDigit(ushort c) +{ + return (c >= '0' && c <= '9'); +} + +bool QScript::Lexer::isHexDigit(ushort c) const +{ + return ((c >= '0' && c <= '9') + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F')); +} + +bool QScript::Lexer::isOctalDigit(ushort c) const +{ + return (c >= '0' && c <= '7'); +} + +int QScript::Lexer::matchPunctuator(ushort c1, ushort c2, + ushort c3, ushort c4) +{ + if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { + shift(4); + return QScriptGrammar::T_GT_GT_GT_EQ; + } else if (c1 == '=' && c2 == '=' && c3 == '=') { + shift(3); + return QScriptGrammar::T_EQ_EQ_EQ; + } else if (c1 == '!' && c2 == '=' && c3 == '=') { + shift(3); + return QScriptGrammar::T_NOT_EQ_EQ; + } else if (c1 == '>' && c2 == '>' && c3 == '>') { + shift(3); + return QScriptGrammar::T_GT_GT_GT; + } else if (c1 == '<' && c2 == '<' && c3 == '=') { + shift(3); + return QScriptGrammar::T_LT_LT_EQ; + } else if (c1 == '>' && c2 == '>' && c3 == '=') { + shift(3); + return QScriptGrammar::T_GT_GT_EQ; + } else if (c1 == '<' && c2 == '=') { + shift(2); + return QScriptGrammar::T_LE; + } else if (c1 == '>' && c2 == '=') { + shift(2); + return QScriptGrammar::T_GE; + } else if (c1 == '!' && c2 == '=') { + shift(2); + return QScriptGrammar::T_NOT_EQ; + } else if (c1 == '+' && c2 == '+') { + shift(2); + return QScriptGrammar::T_PLUS_PLUS; + } else if (c1 == '-' && c2 == '-') { + shift(2); + return QScriptGrammar::T_MINUS_MINUS; + } else if (c1 == '=' && c2 == '=') { + shift(2); + return QScriptGrammar::T_EQ_EQ; + } else if (c1 == '+' && c2 == '=') { + shift(2); + return QScriptGrammar::T_PLUS_EQ; + } else if (c1 == '-' && c2 == '=') { + shift(2); + return QScriptGrammar::T_MINUS_EQ; + } else if (c1 == '*' && c2 == '=') { + shift(2); + return QScriptGrammar::T_STAR_EQ; + } else if (c1 == '/' && c2 == '=') { + shift(2); + return QScriptGrammar::T_DIVIDE_EQ; + } else if (c1 == '&' && c2 == '=') { + shift(2); + return QScriptGrammar::T_AND_EQ; + } else if (c1 == '^' && c2 == '=') { + shift(2); + return QScriptGrammar::T_XOR_EQ; + } else if (c1 == '%' && c2 == '=') { + shift(2); + return QScriptGrammar::T_REMAINDER_EQ; + } else if (c1 == '|' && c2 == '=') { + shift(2); + return QScriptGrammar::T_OR_EQ; + } else if (c1 == '<' && c2 == '<') { + shift(2); + return QScriptGrammar::T_LT_LT; + } else if (c1 == '>' && c2 == '>') { + shift(2); + return QScriptGrammar::T_GT_GT; + } else if (c1 == '&' && c2 == '&') { + shift(2); + return QScriptGrammar::T_AND_AND; + } else if (c1 == '|' && c2 == '|') { + shift(2); + return QScriptGrammar::T_OR_OR; + } + + switch(c1) { + case '=': shift(1); return QScriptGrammar::T_EQ; + case '>': shift(1); return QScriptGrammar::T_GT; + case '<': shift(1); return QScriptGrammar::T_LT; + case ',': shift(1); return QScriptGrammar::T_COMMA; + case '!': shift(1); return QScriptGrammar::T_NOT; + case '~': shift(1); return QScriptGrammar::T_TILDE; + case '?': shift(1); return QScriptGrammar::T_QUESTION; + case ':': shift(1); return QScriptGrammar::T_COLON; + case '.': shift(1); return QScriptGrammar::T_DOT; + case '+': shift(1); return QScriptGrammar::T_PLUS; + case '-': shift(1); return QScriptGrammar::T_MINUS; + case '*': shift(1); return QScriptGrammar::T_STAR; + case '/': shift(1); return QScriptGrammar::T_DIVIDE_; + case '&': shift(1); return QScriptGrammar::T_AND; + case '|': shift(1); return QScriptGrammar::T_OR; + case '^': shift(1); return QScriptGrammar::T_XOR; + case '%': shift(1); return QScriptGrammar::T_REMAINDER; + case '(': shift(1); return QScriptGrammar::T_LPAREN; + case ')': shift(1); return QScriptGrammar::T_RPAREN; + case '{': shift(1); return QScriptGrammar::T_LBRACE; + case '}': shift(1); return QScriptGrammar::T_RBRACE; + case '[': shift(1); return QScriptGrammar::T_LBRACKET; + case ']': shift(1); return QScriptGrammar::T_RBRACKET; + case ';': shift(1); return QScriptGrammar::T_SEMICOLON; + + default: return -1; + } +} + +ushort QScript::Lexer::singleEscape(ushort c) const +{ + switch(c) { + case 'b': + return 0x08; + case 't': + return 0x09; + case 'n': + return 0x0A; + case 'v': + return 0x0B; + case 'f': + return 0x0C; + case 'r': + return 0x0D; + case '"': + return 0x22; + case '\'': + return 0x27; + case '\\': + return 0x5C; + default: + return c; + } +} + +ushort QScript::Lexer::convertOctal(ushort c1, ushort c2, + ushort c3) const +{ + return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); +} + +unsigned char QScript::Lexer::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); +} + +unsigned char QScript::Lexer::convertHex(ushort c1, ushort c2) +{ + return ((convertHex(c1) << 4) + convertHex(c2)); +} + +QChar QScript::Lexer::convertUnicode(ushort c1, ushort c2, + ushort c3, ushort c4) +{ + return QChar((convertHex(c3) << 4) + convertHex(c4), + (convertHex(c1) << 4) + convertHex(c2)); +} + +void QScript::Lexer::record8(ushort c) +{ + Q_ASSERT(c <= 0xff); + + // enlarge buffer if full + if (pos8 >= size8 - 1) { + char *tmp = new char[2 * size8]; + memcpy(tmp, buffer8, size8 * sizeof(char)); + delete [] buffer8; + buffer8 = tmp; + size8 *= 2; + } + + buffer8[pos8++] = (char) c; +} + +void QScript::Lexer::record16(QChar c) +{ + // enlarge buffer if full + if (pos16 >= size16 - 1) { + QChar *tmp = new QChar[2 * size16]; + memcpy(tmp, buffer16, size16 * sizeof(QChar)); + delete [] buffer16; + buffer16 = tmp; + size16 *= 2; + } + + buffer16[pos16++] = c; +} + +void QScript::Lexer::recordStartPos() +{ + startlineno = yylineno; + startcolumn = yycolumn; +} + +bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix) +{ + pos16 = 0; + bool lastWasEscape = false; + + if (prefix == EqualPrefix) + record16(QLatin1Char('=')); + + while (1) { + if (isLineTerminator() || current == 0) { + errmsg = QLatin1String("Unterminated regular expression literal"); + return false; + } + else if (current != '/' || lastWasEscape == true) + { + record16(current); + lastWasEscape = !lastWasEscape && (current == '\\'); + } + else { + if (driver) { + Q_ASSERT_X(false, Q_FUNC_INFO, "not implemented"); + pattern = 0; // driver->intern(buffer16, pos16); + } else + pattern = 0; + pos16 = 0; + shift(1); + break; + } + shift(1); + } + + flags = 0; + while (isIdentLetter(current)) { + // current version was remade from this line: + //int flag = QScript::Ecma::RegExp::flagFromChar(current); + //code was "inlined" because it was only one call to this function + int flag; + switch (current) { + case 'g': flag = 0x01; break; + case 'm': flag = 0x02; break; + case 'i': flag = 0x04; break; + default: flag = 0; + } + if (flag == 0) { + errmsg = QString::fromLatin1("Invalid regular expression flag '%0'") + .arg(QChar(current)); + return false; + } + flags |= flag; + record16(current); + shift(1); + } + + return true; +} + +void QScript::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; + } +} + +QT_END_NAMESPACE diff --git a/src/script/parser/qscriptlexer_p.h b/src/script/parser/qscriptlexer_p.h new file mode 100644 index 0000000..2d7d3b5 --- /dev/null +++ b/src/script/parser/qscriptlexer_p.h @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTLEXER_P_H +#define QSCRIPTLEXER_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 <QtCore/QString> + +QT_BEGIN_NAMESPACE + +class QScriptEnginePrivate; +class QScriptNameIdImpl; + +namespace QScript { + +class Lexer +{ +public: + Lexer(QScriptEnginePrivate *eng); + ~Lexer(); + + void setCode(const QString &c, int lineno); + int lex(); + + int currentLineNo() const { return yylineno; } + int currentColumnNo() const { return yycolumn; } + + int startLineNo() const { return startlineno; } + int startColumnNo() const { return startcolumn; } + + int endLineNo() const { return currentLineNo(); } + int endColumnNo() const + { int col = currentColumnNo(); return (col > 0) ? col - 1 : col; } + + bool prevTerminator() const { return terminator; } + + enum State { Start, + Identifier, + InIdentifier, + InSingleLineComment, + InMultiLineComment, + InNum, + InNum0, + InHex, + InOctal, + InDecimal, + InExponentIndicator, + InExponent, + Hex, + Octal, + Number, + String, + Eof, + InString, + InEscapeSequence, + InHexEscape, + InUnicodeEscape, + Other, + Bad }; + + enum Error { + NoError, + IllegalCharacter, + UnclosedStringLiteral, + IllegalEscapeSequence, + IllegalUnicodeEscapeSequence, + UnclosedComment, + IllegalExponentIndicator, + IllegalIdentifier + }; + + enum ParenthesesState { + IgnoreParentheses, + CountParentheses, + BalancedParentheses + }; + + enum RegExpBodyPrefix { + NoPrefix, + EqualPrefix + }; + + bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); + + QScriptNameIdImpl *pattern; + int flags; + + State lexerState() const + { return state; } + + QString errorMessage() const + { return errmsg; } + void setErrorMessage(const QString &err) + { errmsg = err; } + void setErrorMessage(const char *err) + { setErrorMessage(QString::fromLatin1(err)); } + + Error error() const + { return err; } + void clearError() + { err = NoError; } + +private: + QScriptEnginePrivate *driver; + int yylineno; + bool done; + char *buffer8; + QChar *buffer16; + uint size8, size16; + uint pos8, pos16; + bool terminator; + bool restrKeyword; + // encountered delimiter like "'" and "}" on last run + bool delimited; + int stackToken; + + State state; + void setDone(State s); + uint pos; + void shift(uint p); + int lookupKeyword(const char *); + + bool isWhiteSpace() const; + bool isLineTerminator() const; + bool isHexDigit(ushort c) const; + bool isOctalDigit(ushort c) const; + + int matchPunctuator(ushort c1, ushort c2, + ushort c3, ushort c4); + ushort singleEscape(ushort c) const; + ushort convertOctal(ushort c1, ushort c2, + ushort c3) const; +public: + static unsigned char convertHex(ushort c1); + static unsigned char convertHex(ushort c1, ushort c2); + static QChar convertUnicode(ushort c1, ushort c2, + ushort c3, ushort c4); + static bool isIdentLetter(ushort c); + static bool isDecimalDigit(ushort c); + + inline int ival() const { return qsyylval.ival; } + inline double dval() const { return qsyylval.dval; } + inline QScriptNameIdImpl *ustr() const { return qsyylval.ustr; } + + const QChar *characterBuffer() const { return buffer16; } + int characterCount() const { return pos16; } + +private: + void record8(ushort c); + void record16(QChar c); + void recordStartPos(); + + int findReservedWord(const QChar *buffer, int size) const; + + void syncProhibitAutomaticSemicolon(); + + const QChar *code; + uint length; + int yycolumn; + int startlineno; + int startcolumn; + int bol; // begin of line + + union { + int ival; + double dval; + QScriptNameIdImpl *ustr; + } qsyylval; + + // current and following unicode characters + ushort current, next1, next2, next3; + + struct keyword { + const char *name; + int token; + }; + + QString errmsg; + Error err; + + bool wantRx; + bool check_reserved; + + ParenthesesState parenthesesState; + int parenthesesCount; + bool prohibitAutomaticSemicolon; +}; + +} // namespace QScript + +QT_END_NAMESPACE + +#endif diff --git a/src/script/parser/qscriptparser.cpp b/src/script/parser/qscriptparser.cpp new file mode 100644 index 0000000..b3880af --- /dev/null +++ b/src/script/parser/qscriptparser.cpp @@ -0,0 +1,1158 @@ +// This file was generated by qlalr - DO NOT EDIT! + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QtDebug> + +#include <string.h> + +#include "qscriptast_p.h" + +#define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc) do { \ + node->startLine = startloc.startLine; \ + node->startColumn = startloc.startColumn; \ + node->endLine = endloc.endLine; \ + node->endColumn = endloc.endColumn; \ +} while (0) + + + +#include "qscriptparser_p.h" + +// +// This file is automatically generated from qscript.g. +// Changes will be lost. +// + +QT_BEGIN_NAMESPACE + +inline static bool automatic(QScriptEnginePrivate *driver, int token) +{ + return token == QScriptGrammar::T_RBRACE + || token == 0 + || driver->lexer()->prevTerminator(); +} + + +QScriptParser::QScriptParser(): + tos(0), + stack_size(0), + sym_stack(0), + state_stack(0), + location_stack(0) +{ +} + +QScriptParser::~QScriptParser() +{ + if (stack_size) { + qFree(sym_stack); + qFree(state_stack); + qFree(location_stack); + } +} + +static inline QScriptParser::Location location(QScript::Lexer *lexer) +{ + QScriptParser::Location loc; + loc.startLine = lexer->startLineNo(); + loc.startColumn = lexer->startColumnNo(); + loc.endLine = lexer->endLineNo(); + loc.endColumn = lexer->endColumnNo(); + return loc; +} + +bool QScriptParser::parse(QScriptEnginePrivate *driver) +{ + const int INITIAL_STATE = 0; + QScript::Lexer *lexer = driver->lexer(); + + int yytoken = -1; + int saved_yytoken = -1; + + reallocateStack(); + + tos = 0; + state_stack[++tos] = INITIAL_STATE; + + while (true) + { + const int state = state_stack [tos]; + if (yytoken == -1 && - TERMINAL_COUNT != action_index [state]) + { + if (saved_yytoken == -1) + { + yytoken = lexer->lex(); + location_stack [tos] = location(lexer); + } + else + { + yytoken = saved_yytoken; + saved_yytoken = -1; + } + } + + int act = t_action (state, yytoken); + + if (act == ACCEPT_STATE) + return true; + + else if (act > 0) + { + if (++tos == stack_size) + reallocateStack(); + + sym_stack [tos].dval = lexer->dval (); + state_stack [tos] = act; + location_stack [tos] = location(lexer); + yytoken = -1; + } + + else if (act < 0) + { + int r = - act - 1; + + tos -= rhs [r]; + act = state_stack [tos++]; + + switch (r) { + +case 0: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ThisExpression> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 1: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierExpression> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 2: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NullExpression> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 3: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TrueLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 4: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FalseLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 5: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteral> (driver->nodePool(), sym(1).dval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 6: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteral> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 7: { + bool rx = lexer->scanRegExp(QScript::Lexer::NoPrefix); + if (!rx) { + error_message = lexer->errorMessage(); + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + return false; + } + sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 8: { + bool rx = lexer->scanRegExp(QScript::Lexer::EqualPrefix); + if (!rx) { + error_message = lexer->errorMessage(); + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + return false; + } + sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 9: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 10: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 11: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), sym(4).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 12: { + if (sym(2).Node) + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ()); + else + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 13: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 14: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 15: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).Elision, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 16: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision, sym(4).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 17: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 18: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool(), sym(1).Elision); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 19: { + sym(1).Node = 0; +} break; + +case 20: { + sym(1).Elision = sym(1).Elision->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 21: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyName, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 22: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 23: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 24: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 25: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 26: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 27: + +case 28: + +case 29: + +case 30: + +case 31: + +case 32: + +case 33: + +case 34: + +case 35: + +case 36: + +case 37: + +case 38: + +case 39: + +case 40: + +case 41: + +case 42: + +case 43: + +case 44: + +case 45: + +case 46: + +case 47: + +case 48: + +case 49: + +case 50: + +case 51: + +case 52: + +case 53: + +case 54: + +case 55: + +case 56: + +case 57: +{ + sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount()); +} break; + +case 62: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 63: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 64: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(3).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 66: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NewExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 67: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 68: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 69: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 70: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 71: { + sym(1).Node = 0; +} break; + +case 72: { + sym(1).Node = sym(2).ArgumentList->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 73: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 74: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 78: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 79: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 81: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DeleteExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 82: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VoidExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 83: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 84: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 85: { + sym(1).Node = QScript::makeAstNode<QScript::AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 86: { + sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 87: { + sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 88: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TildeExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 89: { + sym(1).Node = QScript::makeAstNode<QScript::AST::NotExpression> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 91: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mul, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 92: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Div, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 93: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mod, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 95: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Add, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 96: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Sub, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 98: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::LShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 99: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::RShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 100: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::URShift, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 102: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 103: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 104: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 105: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 106: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 107: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::In, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 109: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 110: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 111: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 112: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 113: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 115: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 116: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 117: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 118: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 120: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 121: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 122: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 123: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 125: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 127: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 129: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 131: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 133: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 135: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 137: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 139: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 141: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 143: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 145: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 147: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 149: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 151: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 152: { + sym(1).ival = QSOperator::Assign; +} break; + +case 153: { + sym(1).ival = QSOperator::InplaceMul; +} break; + +case 154: { + sym(1).ival = QSOperator::InplaceDiv; +} break; + +case 155: { + sym(1).ival = QSOperator::InplaceMod; +} break; + +case 156: { + sym(1).ival = QSOperator::InplaceAdd; +} break; + +case 157: { + sym(1).ival = QSOperator::InplaceSub; +} break; + +case 158: { + sym(1).ival = QSOperator::InplaceLeftShift; +} break; + +case 159: { + sym(1).ival = QSOperator::InplaceRightShift; +} break; + +case 160: { + sym(1).ival = QSOperator::InplaceURightShift; +} break; + +case 161: { + sym(1).ival = QSOperator::InplaceAnd; +} break; + +case 162: { + sym(1).ival = QSOperator::InplaceXor; +} break; + +case 163: { + sym(1).ival = QSOperator::InplaceOr; +} break; + +case 165: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 166: { + sym(1).Node = 0; +} break; + +case 169: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 170: { + sym(1).Node = 0; +} break; + +case 187: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Block> (driver->nodePool(), sym(2).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 188: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 189: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 190: { + sym(1).Node = 0; +} break; + +case 191: { + sym(1).Node = sym(1).StatementList->finish (); +} break; + +case 193: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 194: { + sym(1).ival = T_CONST; +} break; + +case 195: { + sym(1).ival = T_VAR; +} break; + +case 196: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 197: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 198: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 199: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 200: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 201: { + sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 202: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 203: { + sym(1).Node = 0; +} break; + +case 205: { + sym(1) = sym(2); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 206: { + sym(1).Node = 0; +} break; + +case 208: { + sym(1).Node = QScript::makeAstNode<QScript::AST::EmptyStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 210: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 211: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; + +case 212: { + sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 214: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; + +case 215: { + sym(1).Node = QScript::makeAstNode<QScript::AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 216: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(9)); +} break; + +case 217: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(10)); +} break; + +case 218: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(7)); +} break; + +case 219: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; + +case 221: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 223: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 225: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 227: { + sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool(), sym(2).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 229: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 230: { + sym(1).Node = QScript::makeAstNode<QScript::AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 231: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 232: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 233: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 234: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 235: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 236: { + sym(1).Node = 0; +} break; + +case 237: { + sym(1).Node = sym(1).CaseClauses->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 238: { + sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 239: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 240: { + sym(1).Node = QScript::makeAstNode<QScript::AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 242: { + sym(1).Node = QScript::makeAstNode<QScript::AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 243: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 244: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 245: { + sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4)); +} break; + +case 246: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5)); +} break; + +case 247: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Finally> (driver->nodePool(), sym(2).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 249: { + sym(1).Node = QScript::makeAstNode<QScript::AST::DebuggerStatement> (driver->nodePool()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 250: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; + +case 251: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(8)); +} break; + +case 252: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 253: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3)); +} break; + +case 254: { + sym(1).Node = 0; +} break; + +case 255: { + sym(1).Node = sym(1).FormalParameterList->finish (); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 256: { + sym(1).Node = 0; +} break; + +case 258: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ()); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 259: { + sym(1).Node = QScript::makeAstNode<QScript::AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ()); + driver->changeAbstractSyntaxTree(sym(1).Node); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 260: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 261: { + sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2)); +} break; + +case 262: { + sym(1).Node = QScript::makeAstNode<QScript::AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 263: { + sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration); + Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1)); +} break; + +case 264: { + sym(1).sval = 0; +} break; + +case 266: { + sym(1).Node = 0; +} break; + + } // switch + + state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT); + + if (rhs[r] > 1) { + location_stack[tos - 1].endLine = location_stack[tos + rhs[r] - 2].endLine; + location_stack[tos - 1].endColumn = location_stack[tos + rhs[r] - 2].endColumn; + location_stack[tos] = location_stack[tos + rhs[r] - 1]; + } + } + + else + { + if (saved_yytoken == -1 && automatic (driver, yytoken) && t_action (state, T_AUTOMATIC_SEMICOLON) > 0) + { + saved_yytoken = yytoken; + yytoken = T_SEMICOLON; + continue; + } + + else if ((state == INITIAL_STATE) && (yytoken == 0)) { + // accept empty input + yytoken = T_SEMICOLON; + continue; + } + + int ers = state; + int shifts = 0; + int reduces = 0; + int expected_tokens [3]; + for (int tk = 0; tk < TERMINAL_COUNT; ++tk) + { + int k = t_action (ers, tk); + + if (! k) + continue; + else if (k < 0) + ++reduces; + else if (spell [tk]) + { + if (shifts < 3) + expected_tokens [shifts] = tk; + ++shifts; + } + } + + error_message.clear (); + if (shifts && shifts < 3) + { + bool first = true; + + for (int s = 0; s < shifts; ++s) + { + if (first) + error_message += QLatin1String ("Expected "); + else + error_message += QLatin1String (", "); + + first = false; + error_message += QLatin1Char('`'); + error_message += QLatin1String (spell [expected_tokens [s]]); + error_message += QLatin1Char('\''); + } + } + + if (error_message.isEmpty()) + error_message = lexer->errorMessage(); + + error_lineno = lexer->startLineNo(); + error_column = lexer->startColumnNo(); + + return false; + } + } + + return false; +} + +QT_END_NAMESPACE diff --git a/src/script/parser/qscriptparser_p.h b/src/script/parser/qscriptparser_p.h new file mode 100644 index 0000000..cd463aa --- /dev/null +++ b/src/script/parser/qscriptparser_p.h @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was generated by qlalr - DO NOT EDIT! + +// +// 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. +// + +// +// This file is automatically generated from qscript.g. +// Changes will be lost. +// + +#ifndef QSCRIPTPARSER_P_H +#define QSCRIPTPARSER_P_H + +#include "qscriptgrammar_p.h" + +#include "qscriptastfwd_p.h" + +QT_BEGIN_NAMESPACE + +class QString; +class QScriptEnginePrivate; +class QScriptNameIdImpl; + +class QScriptParser: protected QScriptGrammar +{ +public: + union Value { + int ival; + double dval; + QScriptNameIdImpl *sval; + QScript::AST::ArgumentList *ArgumentList; + QScript::AST::CaseBlock *CaseBlock; + QScript::AST::CaseClause *CaseClause; + QScript::AST::CaseClauses *CaseClauses; + QScript::AST::Catch *Catch; + QScript::AST::DefaultClause *DefaultClause; + QScript::AST::ElementList *ElementList; + QScript::AST::Elision *Elision; + QScript::AST::ExpressionNode *Expression; + QScript::AST::Finally *Finally; + QScript::AST::FormalParameterList *FormalParameterList; + QScript::AST::FunctionBody *FunctionBody; + QScript::AST::FunctionDeclaration *FunctionDeclaration; + QScript::AST::Node *Node; + QScript::AST::PropertyName *PropertyName; + QScript::AST::PropertyNameAndValueList *PropertyNameAndValueList; + QScript::AST::SourceElement *SourceElement; + QScript::AST::SourceElements *SourceElements; + QScript::AST::Statement *Statement; + QScript::AST::StatementList *StatementList; + QScript::AST::VariableDeclaration *VariableDeclaration; + QScript::AST::VariableDeclarationList *VariableDeclarationList; + }; + + struct Location { + int startLine; + int startColumn; + int endLine; + int endColumn; + }; + +public: + QScriptParser(); + ~QScriptParser(); + + bool parse(QScriptEnginePrivate *driver); + + inline QString errorMessage() const + { return error_message; } + inline int errorLineNumber() const + { return error_lineno; } + inline int errorColumnNumber() const + { return error_column; } + +protected: + inline void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline Location &loc(int index) + { return location_stack [tos + index - 2]; } + +protected: + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + Location *location_stack; + QString error_message; + int error_lineno; + int error_column; +}; + +inline void QScriptParser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location))); +} + + +#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 + +#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 + +QT_END_NAMESPACE + +#endif // QSCRIPTPARSER_P_H diff --git a/src/script/parser/qscriptsyntaxchecker.cpp b/src/script/parser/qscriptsyntaxchecker.cpp new file mode 100644 index 0000000..ee91c52 --- /dev/null +++ b/src/script/parser/qscriptsyntaxchecker.cpp @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptsyntaxchecker_p.h" + +#include "qscriptlexer_p.h" +#include "qscriptparser_p.h" + +QT_BEGIN_NAMESPACE + +namespace QScript { + + +SyntaxChecker::SyntaxChecker(): + tos(0), + stack_size(0), + state_stack(0) +{ +} + +SyntaxChecker::~SyntaxChecker() +{ + if (stack_size) { + qFree(state_stack); + } +} + +bool SyntaxChecker::automatic(QScript::Lexer *lexer, int token) const +{ + return token == T_RBRACE || token == 0 || lexer->prevTerminator(); +} + +SyntaxChecker::Result SyntaxChecker::checkSyntax(const QString &code) +{ + const int INITIAL_STATE = 0; + QScript::Lexer lexer (/*engine=*/ 0); + lexer.setCode(code, /*lineNo*/ 1); + + int yytoken = -1; + int saved_yytoken = -1; + QString error_message; + int error_lineno = -1; + int error_column = -1; + State checkerState = Valid; + + reallocateStack(); + + tos = 0; + state_stack[++tos] = INITIAL_STATE; + + while (true) + { + const int state = state_stack [tos]; + if (yytoken == -1 && - TERMINAL_COUNT != action_index [state]) + { + if (saved_yytoken == -1) + yytoken = lexer.lex(); + else + { + yytoken = saved_yytoken; + saved_yytoken = -1; + } + } + + int act = t_action (state, yytoken); + + if (act == ACCEPT_STATE) { + if (lexer.error() == QScript::Lexer::UnclosedComment) + checkerState = Intermediate; + else + checkerState = Valid; + break; + } else if (act > 0) { + if (++tos == stack_size) + reallocateStack(); + + state_stack [tos] = act; + yytoken = -1; + } + + else if (act < 0) + { + int r = - act - 1; + + tos -= rhs [r]; + act = state_stack [tos++]; + + if ((r == Q_SCRIPT_REGEXPLITERAL_RULE1) + || (r == Q_SCRIPT_REGEXPLITERAL_RULE2)) { + // Skip the rest of the RegExp literal + bool rx = lexer.scanRegExp(); + if (!rx) { + checkerState = Intermediate; + break; + } + } + + state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT); + } + + else + { + if (saved_yytoken == -1 && automatic (&lexer, yytoken) && t_action (state, T_AUTOMATIC_SEMICOLON) > 0) + { + saved_yytoken = yytoken; + yytoken = T_SEMICOLON; + continue; + } + + else if ((state == INITIAL_STATE) && (yytoken == 0)) { + // accept empty input + yytoken = T_SEMICOLON; + continue; + } + + int ers = state; + int shifts = 0; + int reduces = 0; + int expected_tokens [3]; + for (int tk = 0; tk < TERMINAL_COUNT; ++tk) + { + int k = t_action (ers, tk); + + if (! k) + continue; + else if (k < 0) + ++reduces; + else if (spell [tk]) + { + if (shifts < 3) + expected_tokens [shifts] = tk; + ++shifts; + } + } + + error_message.clear (); + if (shifts && shifts < 3) + { + bool first = true; + + for (int s = 0; s < shifts; ++s) + { + if (first) + error_message += QLatin1String ("Expected "); + else + error_message += QLatin1String (", "); + + first = false; + error_message += QLatin1Char('`'); + error_message += QLatin1String (spell [expected_tokens [s]]); + error_message += QLatin1Char('\''); + } + } + + if (error_message.isEmpty()) + error_message = lexer.errorMessage(); + + error_lineno = lexer.startLineNo(); + error_column = lexer.startColumnNo(); + checkerState = Error; + break; + } + } + + if (checkerState == Error) { + if (lexer.error() == QScript::Lexer::UnclosedComment) + checkerState = Intermediate; + else if (yytoken == 0) + checkerState = Intermediate; + } + return Result(checkerState, error_lineno, error_column, error_message); +} + +} // namespace QScript + +QT_END_NAMESPACE diff --git a/src/script/parser/qscriptsyntaxchecker_p.h b/src/script/parser/qscriptsyntaxchecker_p.h new file mode 100644 index 0000000..5609cc2 --- /dev/null +++ b/src/script/parser/qscriptsyntaxchecker_p.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtScript module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTSYNTAXCHECKER_H +#define QSCRIPTSYNTAXCHECKER_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 <QtCore/qstring.h> + +#include "qscriptgrammar_p.h" + +QT_BEGIN_NAMESPACE + +namespace QScript { + +class Lexer; + +class SyntaxChecker: protected QScriptGrammar +{ +public: + enum State { + Error, + Intermediate, + Valid, + }; + + struct Result { + Result(State s, int ln, int col, const QString &msg) + : state(s), errorLineNumber(ln), errorColumnNumber(col), + errorMessage(msg) {} + State state; + int errorLineNumber; + int errorColumnNumber; + QString errorMessage; + }; + + SyntaxChecker(); + ~SyntaxChecker(); + + Result checkSyntax(const QString &code); + +protected: + bool automatic(QScript::Lexer *lexer, int token) const; + inline void reallocateStack(); + +protected: + int tos; + int stack_size; + int *state_stack; +}; + +inline void SyntaxChecker::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int))); +} + +} // namespace QScript + +QT_END_NAMESPACE + +#endif |