| 1 | ----------------------------------------------------------------------------
|
|---|
| 2 | --
|
|---|
| 3 | -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | -- Contact: Qt Software Information ([email protected])
|
|---|
| 5 | --
|
|---|
| 6 | -- This file is part of the QtScript module of the Qt Toolkit.
|
|---|
| 7 | --
|
|---|
| 8 | -- $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | -- Commercial Usage
|
|---|
| 10 | -- Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | -- accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | -- Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | -- a written agreement between you and Nokia.
|
|---|
| 14 | --
|
|---|
| 15 | -- GNU Lesser General Public License Usage
|
|---|
| 16 | -- Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | -- General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | -- Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | -- packaging of this file. Please review the following information to
|
|---|
| 20 | -- ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | -- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | --
|
|---|
| 23 | -- In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | -- additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | -- Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | -- package.
|
|---|
| 27 | --
|
|---|
| 28 | -- GNU General Public License Usage
|
|---|
| 29 | -- Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | -- General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | -- Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | -- packaging of this file. Please review the following information to
|
|---|
| 33 | -- ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | -- met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | --
|
|---|
| 36 | -- If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | -- contact the sales department at [email protected].
|
|---|
| 38 | -- $QT_END_LICENSE$
|
|---|
| 39 | --
|
|---|
| 40 | -- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 41 | -- WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 42 | --
|
|---|
| 43 | ----------------------------------------------------------------------------
|
|---|
| 44 |
|
|---|
| 45 | %parser QScriptGrammar
|
|---|
| 46 | %decl qscriptparser_p.h
|
|---|
| 47 | %impl qscriptparser.cpp
|
|---|
| 48 | %expect 3
|
|---|
| 49 | %expect-rr 1
|
|---|
| 50 |
|
|---|
| 51 | %token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
|
|---|
| 52 | %token T_BREAK "break" T_CASE "case" T_CATCH "catch"
|
|---|
| 53 | %token T_COLON ":" T_COMMA ";" T_CONTINUE "continue"
|
|---|
| 54 | %token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/"
|
|---|
| 55 | %token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
|
|---|
| 56 | %token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
|
|---|
| 57 | %token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
|
|---|
| 58 | %token T_FUNCTION "function" T_GE ">=" T_GT ">"
|
|---|
| 59 | %token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
|
|---|
| 60 | %token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
|
|---|
| 61 | %token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{"
|
|---|
| 62 | %token T_LBRACKET "[" T_LE "<=" T_LPAREN "("
|
|---|
| 63 | %token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<="
|
|---|
| 64 | %token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--"
|
|---|
| 65 | %token T_NEW "new" T_NOT "!" T_NOT_EQ "!="
|
|---|
| 66 | %token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|"
|
|---|
| 67 | %token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+"
|
|---|
| 68 | %token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?"
|
|---|
| 69 | %token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
|
|---|
| 70 | %token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
|
|---|
| 71 | %token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
|
|---|
| 72 | %token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
|
|---|
| 73 | %token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
|
|---|
| 74 | %token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
|
|---|
| 75 | %token T_VAR "var" T_VOID "void" T_WHILE "while"
|
|---|
| 76 | %token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
|
|---|
| 77 | %token T_NULL "null" T_TRUE "true" T_FALSE "false"
|
|---|
| 78 | %token T_CONST "const"
|
|---|
| 79 | %token T_DEBUGGER "debugger"
|
|---|
| 80 | %token T_RESERVED_WORD "reserved word"
|
|---|
| 81 |
|
|---|
| 82 | %start Program
|
|---|
| 83 |
|
|---|
| 84 | /.
|
|---|
| 85 | /****************************************************************************
|
|---|
| 86 | **
|
|---|
| 87 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 88 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 89 | **
|
|---|
| 90 | ** This file is part of the QtScript module of the Qt Toolkit.
|
|---|
| 91 | **
|
|---|
| 92 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 93 | ** Commercial Usage
|
|---|
| 94 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 95 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 96 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 97 | ** a written agreement between you and Nokia.
|
|---|
| 98 | **
|
|---|
| 99 | ** GNU Lesser General Public License Usage
|
|---|
| 100 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 101 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 102 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 103 | ** packaging of this file. Please review the following information to
|
|---|
| 104 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 105 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 106 | **
|
|---|
| 107 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 108 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 109 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 110 | ** package.
|
|---|
| 111 | **
|
|---|
| 112 | ** GNU General Public License Usage
|
|---|
| 113 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 114 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 115 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 116 | ** packaging of this file. Please review the following information to
|
|---|
| 117 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 118 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 119 | **
|
|---|
| 120 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 121 | ** contact the sales department at [email protected].
|
|---|
| 122 | ** $QT_END_LICENSE$
|
|---|
| 123 | **
|
|---|
| 124 | ****************************************************************************/
|
|---|
| 125 |
|
|---|
| 126 | #include <QtCore/QtDebug>
|
|---|
| 127 |
|
|---|
| 128 | #ifndef QT_NO_SCRIPT
|
|---|
| 129 |
|
|---|
| 130 | #include <string.h>
|
|---|
| 131 |
|
|---|
| 132 | #include "qscriptengine.h"
|
|---|
| 133 | #include "qscriptengine_p.h"
|
|---|
| 134 | #include "qscriptvalueimpl_p.h"
|
|---|
| 135 | #include "qscriptcontext_p.h"
|
|---|
| 136 | #include "qscriptmember_p.h"
|
|---|
| 137 | #include "qscriptobject_p.h"
|
|---|
| 138 | #include "qscriptlexer_p.h"
|
|---|
| 139 | #include "qscriptast_p.h"
|
|---|
| 140 | #include "qscriptnodepool_p.h"
|
|---|
| 141 |
|
|---|
| 142 | #define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc) do { \
|
|---|
| 143 | node->startLine = startloc.startLine; \
|
|---|
| 144 | node->startColumn = startloc.startColumn; \
|
|---|
| 145 | node->endLine = endloc.endLine; \
|
|---|
| 146 | node->endColumn = endloc.endColumn; \
|
|---|
| 147 | } while (0)
|
|---|
| 148 |
|
|---|
| 149 | ./
|
|---|
| 150 |
|
|---|
| 151 | /:
|
|---|
| 152 | /****************************************************************************
|
|---|
| 153 | **
|
|---|
| 154 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 155 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 156 | **
|
|---|
| 157 | ** This file is part of the QtScript module of the Qt Toolkit.
|
|---|
| 158 | **
|
|---|
| 159 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 160 | ** Commercial Usage
|
|---|
| 161 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 162 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 163 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 164 | ** a written agreement between you and Nokia.
|
|---|
| 165 | **
|
|---|
| 166 | ** GNU Lesser General Public License Usage
|
|---|
| 167 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 168 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 169 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 170 | ** packaging of this file. Please review the following information to
|
|---|
| 171 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 172 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 173 | **
|
|---|
| 174 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 175 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 176 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 177 | ** package.
|
|---|
| 178 | **
|
|---|
| 179 | ** GNU General Public License Usage
|
|---|
| 180 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 181 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 182 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 183 | ** packaging of this file. Please review the following information to
|
|---|
| 184 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 185 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 186 | **
|
|---|
| 187 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 188 | ** contact the sales department at [email protected].
|
|---|
| 189 | ** $QT_END_LICENSE$
|
|---|
| 190 | **
|
|---|
| 191 | ****************************************************************************/
|
|---|
| 192 |
|
|---|
| 193 | //
|
|---|
| 194 | // W A R N I N G
|
|---|
| 195 | // -------------
|
|---|
| 196 | //
|
|---|
| 197 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 198 | // implementation detail. This header file may change from version to
|
|---|
| 199 | // version without notice, or even be removed.
|
|---|
| 200 | //
|
|---|
| 201 | // We mean it.
|
|---|
| 202 | //
|
|---|
| 203 |
|
|---|
| 204 | //
|
|---|
| 205 | // This file is automatically generated from qscript.g.
|
|---|
| 206 | // Changes will be lost.
|
|---|
| 207 | //
|
|---|
| 208 |
|
|---|
| 209 | #ifndef QSCRIPTPARSER_P_H
|
|---|
| 210 | #define QSCRIPTPARSER_P_H
|
|---|
| 211 |
|
|---|
| 212 | #include "qscriptgrammar_p.h"
|
|---|
| 213 |
|
|---|
| 214 | #ifndef QT_NO_SCRIPT
|
|---|
| 215 |
|
|---|
| 216 | #include "qscriptastfwd_p.h"
|
|---|
| 217 |
|
|---|
| 218 | QT_BEGIN_NAMESPACE
|
|---|
| 219 |
|
|---|
| 220 | class QString;
|
|---|
| 221 | class QScriptEnginePrivate;
|
|---|
| 222 | class QScriptNameIdImpl;
|
|---|
| 223 |
|
|---|
| 224 | class QScriptParser: protected $table
|
|---|
| 225 | {
|
|---|
| 226 | public:
|
|---|
| 227 | union Value {
|
|---|
| 228 | int ival;
|
|---|
| 229 | double dval;
|
|---|
| 230 | QScriptNameIdImpl *sval;
|
|---|
| 231 | QScript::AST::ArgumentList *ArgumentList;
|
|---|
| 232 | QScript::AST::CaseBlock *CaseBlock;
|
|---|
| 233 | QScript::AST::CaseClause *CaseClause;
|
|---|
| 234 | QScript::AST::CaseClauses *CaseClauses;
|
|---|
| 235 | QScript::AST::Catch *Catch;
|
|---|
| 236 | QScript::AST::DefaultClause *DefaultClause;
|
|---|
| 237 | QScript::AST::ElementList *ElementList;
|
|---|
| 238 | QScript::AST::Elision *Elision;
|
|---|
| 239 | QScript::AST::ExpressionNode *Expression;
|
|---|
| 240 | QScript::AST::Finally *Finally;
|
|---|
| 241 | QScript::AST::FormalParameterList *FormalParameterList;
|
|---|
| 242 | QScript::AST::FunctionBody *FunctionBody;
|
|---|
| 243 | QScript::AST::FunctionDeclaration *FunctionDeclaration;
|
|---|
| 244 | QScript::AST::Node *Node;
|
|---|
| 245 | QScript::AST::PropertyName *PropertyName;
|
|---|
| 246 | QScript::AST::PropertyNameAndValueList *PropertyNameAndValueList;
|
|---|
| 247 | QScript::AST::SourceElement *SourceElement;
|
|---|
| 248 | QScript::AST::SourceElements *SourceElements;
|
|---|
| 249 | QScript::AST::Statement *Statement;
|
|---|
| 250 | QScript::AST::StatementList *StatementList;
|
|---|
| 251 | QScript::AST::VariableDeclaration *VariableDeclaration;
|
|---|
| 252 | QScript::AST::VariableDeclarationList *VariableDeclarationList;
|
|---|
| 253 | };
|
|---|
| 254 |
|
|---|
| 255 | struct Location {
|
|---|
| 256 | int startLine;
|
|---|
| 257 | int startColumn;
|
|---|
| 258 | int endLine;
|
|---|
| 259 | int endColumn;
|
|---|
| 260 | };
|
|---|
| 261 |
|
|---|
| 262 | public:
|
|---|
| 263 | QScriptParser();
|
|---|
| 264 | ~QScriptParser();
|
|---|
| 265 |
|
|---|
| 266 | bool parse(QScriptEnginePrivate *driver);
|
|---|
| 267 |
|
|---|
| 268 | inline QString errorMessage() const
|
|---|
| 269 | { return error_message; }
|
|---|
| 270 | inline int errorLineNumber() const
|
|---|
| 271 | { return error_lineno; }
|
|---|
| 272 | inline int errorColumnNumber() const
|
|---|
| 273 | { return error_column; }
|
|---|
| 274 |
|
|---|
| 275 | protected:
|
|---|
| 276 | inline void reallocateStack();
|
|---|
| 277 |
|
|---|
| 278 | inline Value &sym(int index)
|
|---|
| 279 | { return sym_stack [tos + index - 1]; }
|
|---|
| 280 |
|
|---|
| 281 | inline Location &loc(int index)
|
|---|
| 282 | { return location_stack [tos + index - 2]; }
|
|---|
| 283 |
|
|---|
| 284 | protected:
|
|---|
| 285 | int tos;
|
|---|
| 286 | int stack_size;
|
|---|
| 287 | Value *sym_stack;
|
|---|
| 288 | int *state_stack;
|
|---|
| 289 | Location *location_stack;
|
|---|
| 290 | QString error_message;
|
|---|
| 291 | int error_lineno;
|
|---|
| 292 | int error_column;
|
|---|
| 293 | };
|
|---|
| 294 |
|
|---|
| 295 | inline void QScriptParser::reallocateStack()
|
|---|
| 296 | {
|
|---|
| 297 | if (! stack_size)
|
|---|
| 298 | stack_size = 128;
|
|---|
| 299 | else
|
|---|
| 300 | stack_size <<= 1;
|
|---|
| 301 |
|
|---|
| 302 | sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
|---|
| 303 | state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
|---|
| 304 | location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | :/
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | /.
|
|---|
| 311 |
|
|---|
| 312 | #include "qscriptparser_p.h"
|
|---|
| 313 |
|
|---|
| 314 | //
|
|---|
| 315 | // This file is automatically generated from qscript.g.
|
|---|
| 316 | // Changes will be lost.
|
|---|
| 317 | //
|
|---|
| 318 |
|
|---|
| 319 | QT_BEGIN_NAMESPACE
|
|---|
| 320 |
|
|---|
| 321 | inline static bool automatic(QScriptEnginePrivate *driver, int token)
|
|---|
| 322 | {
|
|---|
| 323 | return token == $table::T_RBRACE
|
|---|
| 324 | || token == 0
|
|---|
| 325 | || driver->lexer()->prevTerminator();
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | QScriptParser::QScriptParser():
|
|---|
| 330 | tos(0),
|
|---|
| 331 | stack_size(0),
|
|---|
| 332 | sym_stack(0),
|
|---|
| 333 | state_stack(0),
|
|---|
| 334 | location_stack(0),
|
|---|
| 335 | error_lineno(0),
|
|---|
| 336 | error_column(0)
|
|---|
| 337 | {
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | QScriptParser::~QScriptParser()
|
|---|
| 341 | {
|
|---|
| 342 | if (stack_size) {
|
|---|
| 343 | qFree(sym_stack);
|
|---|
| 344 | qFree(state_stack);
|
|---|
| 345 | qFree(location_stack);
|
|---|
| 346 | }
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 | static inline QScriptParser::Location location(QScript::Lexer *lexer)
|
|---|
| 350 | {
|
|---|
| 351 | QScriptParser::Location loc;
|
|---|
| 352 | loc.startLine = lexer->startLineNo();
|
|---|
| 353 | loc.startColumn = lexer->startColumnNo();
|
|---|
| 354 | loc.endLine = lexer->endLineNo();
|
|---|
| 355 | loc.endColumn = lexer->endColumnNo();
|
|---|
| 356 | return loc;
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | bool QScriptParser::parse(QScriptEnginePrivate *driver)
|
|---|
| 360 | {
|
|---|
| 361 | const int INITIAL_STATE = 0;
|
|---|
| 362 | QScript::Lexer *lexer = driver->lexer();
|
|---|
| 363 |
|
|---|
| 364 | int yytoken = -1;
|
|---|
| 365 | int saved_yytoken = -1;
|
|---|
| 366 |
|
|---|
| 367 | reallocateStack();
|
|---|
| 368 |
|
|---|
| 369 | tos = 0;
|
|---|
| 370 | state_stack[++tos] = INITIAL_STATE;
|
|---|
| 371 |
|
|---|
| 372 | while (true)
|
|---|
| 373 | {
|
|---|
| 374 | const int state = state_stack [tos];
|
|---|
| 375 | if (yytoken == -1 && - TERMINAL_COUNT != action_index [state])
|
|---|
| 376 | {
|
|---|
| 377 | if (saved_yytoken == -1)
|
|---|
| 378 | {
|
|---|
| 379 | yytoken = lexer->lex();
|
|---|
| 380 | location_stack [tos] = location(lexer);
|
|---|
| 381 | }
|
|---|
| 382 | else
|
|---|
| 383 | {
|
|---|
| 384 | yytoken = saved_yytoken;
|
|---|
| 385 | saved_yytoken = -1;
|
|---|
| 386 | }
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | int act = t_action (state, yytoken);
|
|---|
| 390 |
|
|---|
| 391 | if (act == ACCEPT_STATE)
|
|---|
| 392 | return true;
|
|---|
| 393 |
|
|---|
| 394 | else if (act > 0)
|
|---|
| 395 | {
|
|---|
| 396 | if (++tos == stack_size)
|
|---|
| 397 | reallocateStack();
|
|---|
| 398 |
|
|---|
| 399 | sym_stack [tos].dval = lexer->dval ();
|
|---|
| 400 | state_stack [tos] = act;
|
|---|
| 401 | location_stack [tos] = location(lexer);
|
|---|
| 402 | yytoken = -1;
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | else if (act < 0)
|
|---|
| 406 | {
|
|---|
| 407 | int r = - act - 1;
|
|---|
| 408 |
|
|---|
| 409 | tos -= rhs [r];
|
|---|
| 410 | act = state_stack [tos++];
|
|---|
| 411 |
|
|---|
| 412 | switch (r) {
|
|---|
| 413 | ./
|
|---|
| 414 |
|
|---|
| 415 | PrimaryExpression: T_THIS ;
|
|---|
| 416 | /.
|
|---|
| 417 | case $rule_number: {
|
|---|
| 418 | sym(1).Node = QScript::makeAstNode<QScript::AST::ThisExpression> (driver->nodePool());
|
|---|
| 419 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 420 | } break;
|
|---|
| 421 | ./
|
|---|
| 422 |
|
|---|
| 423 | PrimaryExpression: T_IDENTIFIER ;
|
|---|
| 424 | /.
|
|---|
| 425 | case $rule_number: {
|
|---|
| 426 | sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
|
|---|
| 427 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 428 | } break;
|
|---|
| 429 | ./
|
|---|
| 430 |
|
|---|
| 431 | PrimaryExpression: T_NULL ;
|
|---|
| 432 | /.
|
|---|
| 433 | case $rule_number: {
|
|---|
| 434 | sym(1).Node = QScript::makeAstNode<QScript::AST::NullExpression> (driver->nodePool());
|
|---|
| 435 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 436 | } break;
|
|---|
| 437 | ./
|
|---|
| 438 |
|
|---|
| 439 | PrimaryExpression: T_TRUE ;
|
|---|
| 440 | /.
|
|---|
| 441 | case $rule_number: {
|
|---|
| 442 | sym(1).Node = QScript::makeAstNode<QScript::AST::TrueLiteral> (driver->nodePool());
|
|---|
| 443 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 444 | } break;
|
|---|
| 445 | ./
|
|---|
| 446 |
|
|---|
| 447 | PrimaryExpression: T_FALSE ;
|
|---|
| 448 | /.
|
|---|
| 449 | case $rule_number: {
|
|---|
| 450 | sym(1).Node = QScript::makeAstNode<QScript::AST::FalseLiteral> (driver->nodePool());
|
|---|
| 451 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 452 | } break;
|
|---|
| 453 | ./
|
|---|
| 454 |
|
|---|
| 455 | PrimaryExpression: T_NUMERIC_LITERAL ;
|
|---|
| 456 | /.
|
|---|
| 457 | case $rule_number: {
|
|---|
| 458 | sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
|
|---|
| 459 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 460 | } break;
|
|---|
| 461 | ./
|
|---|
| 462 |
|
|---|
| 463 | PrimaryExpression: T_STRING_LITERAL ;
|
|---|
| 464 | /.
|
|---|
| 465 | case $rule_number: {
|
|---|
| 466 | sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteral> (driver->nodePool(), sym(1).sval);
|
|---|
| 467 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 468 | } break;
|
|---|
| 469 | ./
|
|---|
| 470 |
|
|---|
| 471 | PrimaryExpression: T_DIVIDE_ ;
|
|---|
| 472 | /:
|
|---|
| 473 | #define Q_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
|
|---|
| 474 | :/
|
|---|
| 475 | /.
|
|---|
| 476 | case $rule_number: {
|
|---|
| 477 | bool rx = lexer->scanRegExp(QScript::Lexer::NoPrefix);
|
|---|
| 478 | if (!rx) {
|
|---|
| 479 | error_message = lexer->errorMessage();
|
|---|
| 480 | error_lineno = lexer->startLineNo();
|
|---|
| 481 | error_column = lexer->startColumnNo();
|
|---|
| 482 | return false;
|
|---|
| 483 | }
|
|---|
| 484 | sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
|
|---|
| 485 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 486 | } break;
|
|---|
| 487 | ./
|
|---|
| 488 |
|
|---|
| 489 | PrimaryExpression: T_DIVIDE_EQ ;
|
|---|
| 490 | /:
|
|---|
| 491 | #define Q_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
|
|---|
| 492 | :/
|
|---|
| 493 | /.
|
|---|
| 494 | case $rule_number: {
|
|---|
| 495 | bool rx = lexer->scanRegExp(QScript::Lexer::EqualPrefix);
|
|---|
| 496 | if (!rx) {
|
|---|
| 497 | error_message = lexer->errorMessage();
|
|---|
| 498 | error_lineno = lexer->startLineNo();
|
|---|
| 499 | error_column = lexer->startColumnNo();
|
|---|
| 500 | return false;
|
|---|
| 501 | }
|
|---|
| 502 | sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
|
|---|
| 503 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 504 | } break;
|
|---|
| 505 | ./
|
|---|
| 506 |
|
|---|
| 507 | PrimaryExpression: T_LBRACKET ElisionOpt T_RBRACKET ;
|
|---|
| 508 | /.
|
|---|
| 509 | case $rule_number: {
|
|---|
| 510 | sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision);
|
|---|
| 511 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
|
|---|
| 512 | } break;
|
|---|
| 513 | ./
|
|---|
| 514 |
|
|---|
| 515 | PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
|
|---|
| 516 | /.
|
|---|
| 517 | case $rule_number: {
|
|---|
| 518 | sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
|
|---|
| 519 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
|
|---|
| 520 | } break;
|
|---|
| 521 | ./
|
|---|
| 522 |
|
|---|
| 523 | PrimaryExpression: T_LBRACKET ElementList T_COMMA ElisionOpt T_RBRACKET ;
|
|---|
| 524 | /.
|
|---|
| 525 | case $rule_number: {
|
|---|
| 526 | sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), sym(4).Elision);
|
|---|
| 527 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5));
|
|---|
| 528 | } break;
|
|---|
| 529 | ./
|
|---|
| 530 |
|
|---|
| 531 | -- PrimaryExpression: T_LBRACE T_RBRACE ;
|
|---|
| 532 | -- /.
|
|---|
| 533 | -- case $rule_number: {
|
|---|
| 534 | -- sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool());
|
|---|
| 535 | -- Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2));
|
|---|
| 536 | -- } break;
|
|---|
| 537 | -- ./
|
|---|
| 538 |
|
|---|
| 539 | PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
|
|---|
| 540 | /.
|
|---|
| 541 | case $rule_number: {
|
|---|
| 542 | if (sym(2).Node)
|
|---|
| 543 | sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ());
|
|---|
| 544 | else
|
|---|
| 545 | sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool());
|
|---|
| 546 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
|
|---|
| 547 | } break;
|
|---|
| 548 | ./
|
|---|
| 549 |
|
|---|
| 550 | PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
|
|---|
| 551 | /.
|
|---|
| 552 | case $rule_number: {
|
|---|
| 553 | sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ());
|
|---|
| 554 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4));
|
|---|
| 555 | } break;
|
|---|
| 556 | ./
|
|---|
| 557 |
|
|---|
| 558 | PrimaryExpression: T_LPAREN Expression T_RPAREN ;
|
|---|
| 559 | /.
|
|---|
| 560 | case $rule_number: {
|
|---|
| 561 | sym(1) = sym(2);
|
|---|
| 562 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
|
|---|
| 563 | } break;
|
|---|
| 564 | ./
|
|---|
| 565 |
|
|---|
| 566 | ElementList: ElisionOpt AssignmentExpression ;
|
|---|
| 567 | /.
|
|---|
| 568 | case $rule_number: {
|
|---|
| 569 | sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).Elision, sym(2).Expression);
|
|---|
| 570 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2));
|
|---|
| 571 | } break;
|
|---|
| 572 | ./
|
|---|
| 573 |
|
|---|
| 574 | ElementList: ElementList T_COMMA ElisionOpt AssignmentExpression ;
|
|---|
| 575 | /.
|
|---|
| 576 | case $rule_number: {
|
|---|
| 577 | sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision, sym(4).Expression);
|
|---|
| 578 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4));
|
|---|
| 579 | } break;
|
|---|
| 580 | ./
|
|---|
| 581 |
|
|---|
| 582 | Elision: T_COMMA ;
|
|---|
| 583 | /.
|
|---|
| 584 | case $rule_number: {
|
|---|
| 585 | sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool());
|
|---|
| 586 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 587 | } break;
|
|---|
| 588 | ./
|
|---|
| 589 |
|
|---|
| 590 | Elision: Elision T_COMMA ;
|
|---|
| 591 | /.
|
|---|
| 592 | case $rule_number: {
|
|---|
| 593 | sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool(), sym(1).Elision);
|
|---|
| 594 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2));
|
|---|
| 595 | } break;
|
|---|
| 596 | ./
|
|---|
| 597 |
|
|---|
| 598 | ElisionOpt: ;
|
|---|
| 599 | /.
|
|---|
| 600 | case $rule_number: {
|
|---|
| 601 | sym(1).Node = 0;
|
|---|
| 602 | } break;
|
|---|
| 603 | ./
|
|---|
| 604 |
|
|---|
| 605 | ElisionOpt: Elision ;
|
|---|
| 606 | /.
|
|---|
| 607 | case $rule_number: {
|
|---|
| 608 | sym(1).Elision = sym(1).Elision->finish ();
|
|---|
| 609 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 610 | } break;
|
|---|
| 611 | ./
|
|---|
| 612 |
|
|---|
| 613 | PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
|
|---|
| 614 | /.
|
|---|
| 615 | case $rule_number: {
|
|---|
| 616 | sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyName, sym(3).Expression);
|
|---|
| 617 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
|
|---|
| 618 | } break;
|
|---|
| 619 | ./
|
|---|
| 620 |
|
|---|
| 621 | PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
|
|---|
| 622 | /.
|
|---|
| 623 | case $rule_number: {
|
|---|
| 624 | sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
|
|---|
| 625 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(5));
|
|---|
| 626 | } break;
|
|---|
| 627 | ./
|
|---|
| 628 |
|
|---|
| 629 | PropertyName: T_IDENTIFIER ;
|
|---|
| 630 | /.
|
|---|
| 631 | case $rule_number: {
|
|---|
| 632 | sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
|
|---|
| 633 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 634 | } break;
|
|---|
| 635 | ./
|
|---|
| 636 |
|
|---|
| 637 | PropertyName: T_STRING_LITERAL ;
|
|---|
| 638 | /.
|
|---|
| 639 | case $rule_number: {
|
|---|
| 640 | sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
|
|---|
| 641 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 642 | } break;
|
|---|
| 643 | ./
|
|---|
| 644 |
|
|---|
| 645 | PropertyName: T_NUMERIC_LITERAL ;
|
|---|
| 646 | /.
|
|---|
| 647 | case $rule_number: {
|
|---|
| 648 | sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
|
|---|
| 649 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 650 | } break;
|
|---|
| 651 | ./
|
|---|
| 652 |
|
|---|
| 653 | PropertyName: ReservedIdentifier ;
|
|---|
| 654 | /.
|
|---|
| 655 | case $rule_number: {
|
|---|
| 656 | sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
|
|---|
| 657 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
|
|---|
| 658 | } break;
|
|---|
| 659 | ./
|
|---|
| 660 |
|
|---|
| 661 | ReservedIdentifier: T_BREAK ;
|
|---|
| 662 | /.
|
|---|
| 663 | case $rule_number:
|
|---|
| 664 | ./
|
|---|
| 665 | ReservedIdentifier: T_CASE ;
|
|---|
| 666 | /.
|
|---|
| 667 | case $rule_number:
|
|---|
| 668 | ./
|
|---|
| 669 | ReservedIdentifier: T_CATCH ;
|
|---|
| 670 | /.
|
|---|
| 671 | case $rule_number:
|
|---|
| 672 | ./
|
|---|
| 673 | ReservedIdentifier: T_CONTINUE ;
|
|---|
| 674 | /.
|
|---|
| 675 | case $rule_number:
|
|---|
| 676 | ./
|
|---|
| 677 | ReservedIdentifier: T_DEFAULT ;
|
|---|
| 678 | /.
|
|---|
| 679 | case $rule_number:
|
|---|
| 680 | ./
|
|---|
| 681 | ReservedIdentifier: T_DELETE ;
|
|---|
| 682 | /.
|
|---|
| 683 | case $rule_number:
|
|---|
| 684 | ./
|
|---|
| 685 | ReservedIdentifier: T_DO ;
|
|---|
| 686 | /.
|
|---|
| 687 | case $rule_number:
|
|---|
| 688 | ./
|
|---|
| 689 | ReservedIdentifier: T_ELSE ;
|
|---|
| 690 | /.
|
|---|
| 691 | case $rule_number:
|
|---|
| 692 | ./
|
|---|
| 693 | ReservedIdentifier: T_FALSE ;
|
|---|
| 694 | /.
|
|---|
| 695 | case $rule_number:
|
|---|
| 696 | ./
|
|---|
| 697 | ReservedIdentifier: T_FINALLY ;
|
|---|
| 698 | /.
|
|---|
| 699 | case $rule_number:
|
|---|
| 700 | ./
|
|---|
| 701 | ReservedIdentifier: T_FOR ;
|
|---|
| 702 | /.
|
|---|
| 703 | case $rule_number:
|
|---|
| 704 | ./
|
|---|
| 705 | ReservedIdentifier: T_FUNCTION ;
|
|---|
| 706 | /.
|
|---|
| 707 | case $rule_number:
|
|---|
| 708 | ./
|
|---|
| 709 | ReservedIdentifier: T_IF ;
|
|---|
| 710 | /.
|
|---|
| 711 | case $rule_number:
|
|---|
| 712 | ./
|
|---|
| 713 | ReservedIdentifier: T_IN ;
|
|---|
| 714 | /.
|
|---|
| 715 | case $rule_number:
|
|---|
| 716 | ./
|
|---|
| 717 | ReservedIdentifier: T_INSTANCEOF ;
|
|---|
| 718 | /.
|
|---|
| 719 | case $rule_number:
|
|---|
| 720 | ./
|
|---|
| 721 | ReservedIdentifier: T_NEW ;
|
|---|
| 722 | /.
|
|---|
| 723 | case $rule_number:
|
|---|
| 724 | ./
|
|---|
| 725 | ReservedIdentifier: T_NULL ;
|
|---|
| 726 | /.
|
|---|
| 727 | case $rule_number:
|
|---|
| 728 | ./
|
|---|
| 729 | ReservedIdentifier: T_RETURN ;
|
|---|
| 730 | /.
|
|---|
| 731 | case $rule_number:
|
|---|
| 732 | ./
|
|---|
| 733 | ReservedIdentifier: T_SWITCH ;
|
|---|
| 734 | /.
|
|---|
| 735 | case $rule_number:
|
|---|
| 736 | ./
|
|---|
| 737 | ReservedIdentifier: T_THIS ;
|
|---|
| 738 | /.
|
|---|
| 739 | case $rule_number:
|
|---|
| 740 | ./
|
|---|
| 741 | ReservedIdentifier: T_THROW ;
|
|---|
| 742 | /.
|
|---|
| 743 | case $rule_number:
|
|---|
| 744 | ./
|
|---|
| 745 | ReservedIdentifier: T_TRUE ;
|
|---|
| 746 | /.
|
|---|
| 747 | case $rule_number:
|
|---|
| 748 | ./
|
|---|
| 749 | ReservedIdentifier: T_TRY ;
|
|---|
| 750 | /.
|
|---|
| 751 | case $rule_number:
|
|---|
| 752 | ./
|
|---|
| 753 | ReservedIdentifier: T_TYPEOF ;
|
|---|
| 754 | /.
|
|---|
| 755 | case $rule_number:
|
|---|
| 756 | ./
|
|---|
| 757 | ReservedIdentifier: T_VAR ;
|
|---|
| 758 | /.
|
|---|
| 759 | case $rule_number:
|
|---|
| 760 | ./
|
|---|
| 761 | ReservedIdentifier: T_VOID ;
|
|---|
| 762 | /.
|
|---|
| 763 | case $rule_number:
|
|---|
| 764 | ./
|
|---|
| 765 | ReservedIdentifier: T_WHILE ;
|
|---|
| 766 | /.
|
|---|
| 767 | case $rule_number:
|
|---|
| 768 | ./
|
|---|
| 769 | ReservedIdentifier: T_CONST ;
|
|---|
| 770 | /.
|
|---|
| 771 | case $rule_number:
|
|---|
| 772 | ./
|
|---|
| 773 | ReservedIdentifier: T_DEBUGGER ;
|
|---|
| 774 | /.
|
|---|
| 775 | case $rule_number:
|
|---|
| 776 | ./
|
|---|
| 777 | ReservedIdentifier: T_RESERVED_WORD ;
|
|---|
| 778 | /.
|
|---|
| 779 | case $rule_number:
|
|---|
| 780 | ./
|
|---|
| 781 | ReservedIdentifier: T_WITH ;
|
|---|
| 782 | /.
|
|---|
| 783 | case $rule_number:
|
|---|
| 784 | {
|
|---|
| 785 | sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
|
|---|
| 786 | } break;
|
|---|
| 787 | ./
|
|---|
| 788 |
|
|---|
| 789 | PropertyIdentifier: T_IDENTIFIER ;
|
|---|
| 790 | PropertyIdentifier: ReservedIdentifier ;
|
|---|
| 791 |
|
|---|
| 792 | MemberExpression: PrimaryExpression ;
|
|---|
| 793 | MemberExpression: FunctionExpression ;
|
|---|
| 794 |
|
|---|
| 795 | MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
|
|---|
| 796 | /.
|
|---|
| 797 | case $rule_number: {
|
|---|
| 798 | sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
|
|---|
| 799 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4));
|
|---|
| 800 | } break;
|
|---|
| 801 | ./
|
|---|
| 802 |
|
|---|
| 803 | MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
|
|---|
| 804 | /.
|
|---|
| 805 | case $rule_number: {
|
|---|
| 806 | sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
|
|---|
| 807 | Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(4));
|
|---|
| 808 | } break;
|
|---|
|
|---|