qmljs/parser: update to latest qt5 parser

fix error semicolon insertion of loops, strict mode
Change-Id: I311733ffb34269d1cee7e576d05af78893b2bcbb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Fawzi Mohamed
2013-01-22 11:15:23 +01:00
committed by Erik Verbruggen
parent 111872591e
commit f0e4df5826
14 changed files with 1141 additions and 1016 deletions

View File

@@ -1,17 +1,17 @@
diff --git a/src/libs/qmljs/parser/qmljs.g b/src/libs/qmljs/parser/qmljs.g diff --git a/src/libs/qmljs/parser/qmljsengine_p.cpp b/src/libs/qmljs/parser/qmljsengine_p.cpp
index 069be3c..9cbdc23 100644 index 73850bb..d7d2189 100644
--- a/src/libs/qmljs/parser/qmljs.g --- a/src/libs/qmljs/parser/qmljsengine_p.cpp
+++ b/src/libs/qmljs/parser/qmljs.g +++ b/src/libs/qmljs/parser/qmljsengine_p.cpp
@@ -111,7 +111,7 @@ double integerFromString(const QString &str, int radix) @@ -110,7 +110,7 @@ double integerFromString(const QString &str, int radix)
Engine::Engine() Engine::Engine()
- : _lexer(0) - : _lexer(0)
+ : _lexer(0), _directives(0) + : _lexer(0), directives(0)
{ } { }
Engine::~Engine() Engine::~Engine()
@@ -132,6 +132,12 @@ Lexer *Engine::lexer() const @@ -131,6 +131,12 @@ Lexer *Engine::lexer() const
void Engine::setLexer(Lexer *lexer) void Engine::setLexer(Lexer *lexer)
{ _lexer = lexer; } { _lexer = lexer; }
@@ -24,11 +24,11 @@ index 069be3c..9cbdc23 100644
MemoryPool *Engine::pool() MemoryPool *Engine::pool()
{ return &_pool; } { return &_pool; }
diff --git b/src/libs/qmljs/parser/qmljsengine_p.h a/src/libs/qmljs/parser/qmljsengine_p.h diff --git a/src/libs/qmljs/parser/qmljsengine_p.h b/src/libs/qmljs/parser/qmljsengine_p.h
index 5057ea0..487619e 100644 index d4ed4b37..4908e02 100644
--- b/src/libs/qmljs/parser/qmljsengine_p.h --- a/src/libs/qmljs/parser/qmljsengine_p.h
+++ a/src/libs/qmljs/parser/qmljsengine_p.h +++ b/src/libs/qmljs/parser/qmljsengine_p.h
@@ -54,6 +54,7 @@ QT_QML_BEGIN_NAMESPACE @@ -53,6 +53,7 @@ QT_QML_BEGIN_NAMESPACE
namespace QmlJS { namespace QmlJS {
class Lexer; class Lexer;
@@ -36,7 +36,7 @@ index 5057ea0..487619e 100644
class MemoryPool; class MemoryPool;
class QML_PARSER_EXPORT DiagnosticMessage class QML_PARSER_EXPORT DiagnosticMessage
@@ -81,6 +82,7 @@ public: @@ -80,6 +81,7 @@ public:
class QML_PARSER_EXPORT Engine class QML_PARSER_EXPORT Engine
{ {
Lexer *_lexer; Lexer *_lexer;
@@ -44,7 +44,7 @@ index 5057ea0..487619e 100644
MemoryPool _pool; MemoryPool _pool;
QList<AST::SourceLocation> _comments; QList<AST::SourceLocation> _comments;
QString _extraCode; QString _extraCode;
@@ -98,6 +100,9 @@ public: @@ -97,6 +99,9 @@ public:
Lexer *lexer() const; Lexer *lexer() const;
void setLexer(Lexer *lexer); void setLexer(Lexer *lexer);
@@ -54,11 +54,11 @@ index 5057ea0..487619e 100644
MemoryPool *pool(); MemoryPool *pool();
inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
diff --git b/src/libs/qmljs/parser/qmljsparser.cpp a/src/libs/qmljs/parser/qmljsparser.cpp diff --git a/src/libs/qmljs/parser/qmljsparser.cpp b/src/libs/qmljs/parser/qmljsparser.cpp
index a731c1a..e986534 100644 index d53960b..71e994f 100644
--- b/src/libs/qmljs/parser/qmljsparser.cpp --- a/src/libs/qmljs/parser/qmljsparser.cpp
+++ a/src/libs/qmljs/parser/qmljsparser.cpp +++ b/src/libs/qmljs/parser/qmljsparser.cpp
@@ -137,7 +137,20 @@ bool Parser::parse(int startToken) @@ -143,7 +143,20 @@ bool Parser::parse(int startToken)
token_buffer[0].token = startToken; token_buffer[0].token = startToken;
first_token = &token_buffer[0]; first_token = &token_buffer[0];

View File

@@ -21,3 +21,6 @@ SOURCES += \
$$PWD/qmljsparser.cpp \ $$PWD/qmljsparser.cpp \
$$PWD/qmldirparser.cpp \ $$PWD/qmldirparser.cpp \
$$PWD/qmlerror.cpp \ $$PWD/qmlerror.cpp \
OTHER_FILES += \
$$PWD/qmljs.g

View File

@@ -32,7 +32,7 @@
#include <QtCore/QDebug> #include <QtCore/QtDebug>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -86,7 +86,7 @@ bool QmlDirParser::parse(const QString &source)
_components.clear(); _components.clear();
_scripts.clear(); _scripts.clear();
int lineNumber = 0; quint16 lineNumber = 0;
bool firstLine = true; bool firstLine = true;
const QChar *ch = source.constData(); const QChar *ch = source.constData();
@@ -129,7 +129,7 @@ bool QmlDirParser::parse(const QString &source)
++ch; ++ch;
if (invalidLine) { if (invalidLine) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("invalid qmldir directive contains too many tokens")); QString::fromUtf8("invalid qmldir directive contains too many tokens"));
continue; continue;
} else if (sectionCount == 0) { } else if (sectionCount == 0) {
@@ -137,18 +137,18 @@ bool QmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("module")) { } else if (sections[0] == QLatin1String("module")) {
if (sectionCount != 2) { if (sectionCount != 2) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("module directive requires one argument, but %1 were provided").arg(sectionCount - 1)); QString::fromUtf8("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1));
continue; continue;
} }
if (!_typeNamespace.isEmpty()) { if (!_typeNamespace.isEmpty()) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("only one module directive may be defined in a qmldir file")); QString::fromUtf8("only one module identifier directive may be defined in a qmldir file"));
continue; continue;
} }
if (!firstLine) { if (!firstLine) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("module directive must be the first directive in a qmldir file")); QString::fromUtf8("module identifier directive must be the first command in a qmldir file"));
continue; continue;
} }
@@ -156,7 +156,7 @@ bool QmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("plugin")) { } else if (sections[0] == QLatin1String("plugin")) {
if (sectionCount < 2) { if (sectionCount < 2) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));
continue; continue;
@@ -168,7 +168,7 @@ bool QmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("internal")) { } else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) { if (sectionCount != 3) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue; continue;
} }
@@ -177,7 +177,7 @@ bool QmlDirParser::parse(const QString &source)
_components.insertMulti(entry.typeName, entry); _components.insertMulti(entry.typeName, entry);
} else if (sections[0] == QLatin1String("typeinfo")) { } else if (sections[0] == QLatin1String("typeinfo")) {
if (sectionCount != 2) { if (sectionCount != 2) {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
continue; continue;
} }
@@ -195,9 +195,9 @@ bool QmlDirParser::parse(const QString &source)
const int dotIndex = version.indexOf(QLatin1Char('.')); const int dotIndex = version.indexOf(QLatin1Char('.'));
if (dotIndex == -1) { if (dotIndex == -1) {
reportError(lineNumber, -1, QLatin1String("expected '.'")); reportError(lineNumber, 0, QLatin1String("expected '.'"));
} else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
reportError(lineNumber, -1, QLatin1String("unexpected '.'")); reportError(lineNumber, 0, QLatin1String("unexpected '.'"));
} else { } else {
bool validVersionNumber = false; bool validVersionNumber = false;
const int majorVersion = parseInt(QStringRef(&version, 0, dotIndex), &validVersionNumber); const int majorVersion = parseInt(QStringRef(&version, 0, dotIndex), &validVersionNumber);
@@ -220,7 +220,7 @@ bool QmlDirParser::parse(const QString &source)
} }
} }
} else { } else {
reportError(lineNumber, -1, reportError(lineNumber, 0,
QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
} }
@@ -230,7 +230,7 @@ bool QmlDirParser::parse(const QString &source)
return hasError(); return hasError();
} }
void QmlDirParser::reportError(int line, int column, const QString &description) void QmlDirParser::reportError(quint16 line, quint16 column, const QString &description)
{ {
QmlError error; QmlError error;
error.setLine(line); error.setLine(line);

View File

@@ -128,7 +128,7 @@ public:
#endif #endif
private: private:
void reportError(int line, int column, const QString &message); void reportError(quint16 line, quint16 column, const QString &message);
private: private:
QList<QmlError> _errors; QList<QmlError> _errors;

View File

@@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include "qmlerror.h" #include "qmlerror.h"
#include "qmlglobal_p.h"
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QtCore/qfile.h> #include <QtCore/qfile.h>
@@ -69,12 +70,12 @@ public:
QUrl url; QUrl url;
QString description; QString description;
int line; quint16 line;
int column; quint16 column;
}; };
QmlErrorPrivate::QmlErrorPrivate() QmlErrorPrivate::QmlErrorPrivate()
: line(-1), column(-1) : line(0), column(0)
{ {
} }
@@ -114,7 +115,7 @@ QmlError &QmlError::operator=(const QmlError &other)
} }
/*! /*!
\internal \internal
*/ */
QmlError::~QmlError() QmlError::~QmlError()
{ {
@@ -170,7 +171,7 @@ void QmlError::setDescription(const QString &description)
*/ */
int QmlError::line() const int QmlError::line() const
{ {
if (d) return d->line; if (d) return qmlSourceCoordinate(d->line);
else return -1; else return -1;
} }
@@ -180,7 +181,7 @@ int QmlError::line() const
void QmlError::setLine(int line) void QmlError::setLine(int line)
{ {
if (!d) d = new QmlErrorPrivate; if (!d) d = new QmlErrorPrivate;
d->line = line; d->line = qmlSourceCoordinate(line);
} }
/*! /*!
@@ -188,7 +189,7 @@ void QmlError::setLine(int line)
*/ */
int QmlError::column() const int QmlError::column() const
{ {
if (d) return d->column; if (d) return qmlSourceCoordinate(d->column);
else return -1; else return -1;
} }
@@ -198,7 +199,7 @@ int QmlError::column() const
void QmlError::setColumn(int column) void QmlError::setColumn(int column)
{ {
if (!d) d = new QmlErrorPrivate; if (!d) d = new QmlErrorPrivate;
d->column = column; d->column = qmlSourceCoordinate(column);
} }
/*! /*!
@@ -207,14 +208,20 @@ void QmlError::setColumn(int column)
QString QmlError::toString() const QString QmlError::toString() const
{ {
QString rv; QString rv;
if (url().isEmpty()) {
QUrl u(url());
int l(line());
if (u.isEmpty()) {
rv = QLatin1String("<Unknown File>"); rv = QLatin1String("<Unknown File>");
} else if (line() != -1) { } else if (l != -1) {
rv = url().toString() + QLatin1Char(':') + QString::number(line()); rv = u.toString() + QLatin1Char(':') + QString::number(l);
if (column() != -1)
rv += QLatin1Char(':') + QString::number(column()); int c(column());
if (c != -1)
rv += QLatin1Char(':') + QString::number(c);
} else { } else {
rv = url().toString(); rv = u.toString();
} }
rv += QLatin1String(": ") + description(); rv += QLatin1String(": ") + description();
@@ -251,9 +258,9 @@ QDebug operator<<(QDebug debug, const QmlError &error)
const QString &line = lines.at(error.line() - 1); const QString &line = lines.at(error.line() - 1);
debug << "\n " << qPrintable(line); debug << "\n " << qPrintable(line);
if (error.column() > 0) { if(error.column() > 0) {
int column = qMax(0, error.column() - 1); int column = qMax(0, error.column() - 1);
column = qMin(column, line.length()); column = qMin(column, line.length());
QByteArray ind; QByteArray ind;
ind.reserve(column); ind.reserve(column);

View File

@@ -1,37 +1,29 @@
----------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
-- Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -- Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-- Contact: http://www.qt-project.org/legal -- Contact: http://www.qt-project.org/legal
-- --
-- This file is part of Qt Creator. -- This file is part of the QtQml module of the Qt Toolkit.
--
-- Commercial License Usage
-- Licensees holding valid commercial Qt licenses may use this file in
-- accordance with the commercial license agreement provided with the
-- Software or, alternatively, in accordance with the terms contained in
-- a written agreement between you and Digia. For licensing terms and
-- conditions see http://qt.digia.com/licensing. For further information
-- use the contact form at http://qt.digia.com/contact-us.
-- --
-- $QT_BEGIN_LICENSE:LGPL-ONLY$
-- GNU Lesser General Public License Usage -- GNU Lesser General Public License Usage
-- Alternatively, this file may be used under the terms of the GNU Lesser -- This file may be used under the terms of the GNU Lesser
-- General Public License version 2.1 as published by the Free Software -- General Public License version 2.1 as published by the Free Software
-- Foundation and appearing in the file LICENSE.LGPL included in the -- Foundation and appearing in the file LICENSE.LGPL included in the
-- packaging of this file. Please review the following information to -- packaging of this file. Please review the following information to
-- ensure the GNU Lesser General Public License version 2.1 requirements -- 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. -- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-- --
-- In addition, as a special exception, Digia gives you certain additional -- If you have questions regarding the use of this file, please contact
-- rights. These rights are described in the Digia Qt LGPL Exception -- us via http://www.qt-project.org/.
-- version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-- --
----------------------------------------------------------------------------- -- $QT_END_LICENSE$
--
----------------------------------------------------------------------------
%parser QmlJSGrammar %parser QmlJSGrammar
%decl qmljsparser_p.h %decl qmljsparser_p.h
%impl qdeclarativejsparser.cpp %impl qmljsparser.cpp
%expect 2 %expect 2
%expect-rr 2 %expect-rr 2
@@ -68,6 +60,7 @@
%token T_RESERVED_WORD "reserved word" %token T_RESERVED_WORD "reserved word"
%token T_MULTILINE_STRING_LITERAL "multiline string literal" %token T_MULTILINE_STRING_LITERAL "multiline string literal"
%token T_COMMENT "comment" %token T_COMMENT "comment"
%token T_COMPATIBILITY_SEMICOLON
--- context keywords. --- context keywords.
%token T_PUBLIC "public" %token T_PUBLIC "public"
@@ -96,8 +89,9 @@
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of the QtQml module of the Qt Toolkit.
** **
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage ** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in ** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the ** accordance with the commercial license agreement provided with the
@@ -118,10 +112,20 @@
** rights. These rights are described in the Digia Qt LGPL Exception ** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** **
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/ ****************************************************************************/
#include <QtCore/QtDebug>
#include <QtCore/QDebug>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <string.h> #include <string.h>
@@ -138,8 +142,9 @@
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of the QtQml module of the Qt Toolkit.
** **
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage ** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in ** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the ** accordance with the commercial license agreement provided with the
@@ -160,10 +165,20 @@
** rights. These rights are described in the Digia Qt LGPL Exception ** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** **
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/ ****************************************************************************/
// //
// W A R N I N G // W A R N I N G
// ------------- // -------------
@@ -175,9 +190,16 @@
// We mean it. // We mean it.
// //
//
// W A R N I N G
// -------------
// //
// This file is automatically generated from qmljs.g. // This file is automatically generated from qmljs.g.
// Changes will be lost. // Changes should be made to that file, not here. Any change to this file will
// be lost!
//
// To regenerate this file, run:
// qlalr --no-debug --no-lines --qt qmljs.g
// //
#ifndef QMLJSPARSER_P_H #ifndef QMLJSPARSER_P_H
@@ -368,9 +390,16 @@ protected:
#include "qmljsparser_p.h" #include "qmljsparser_p.h"
#include <QVarLengthArray> #include <QVarLengthArray>
//
// W A R N I N G
// -------------
// //
// This file is automatically generated from qmljs.g. // This file is automatically generated from qmljs.g.
// Changes will be lost. // Changes should be made to that file, not here. Any change to this file will
// be lost!
//
// To regenerate this file, run:
// qlalr --no-debug --no-lines --qt qmljs.g
// //
using namespace QmlJS; using namespace QmlJS;
@@ -2411,6 +2440,7 @@ case $rule_number: {
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_COMPATIBILITY_SEMICOLON ; -- for JSC/V8 compatibility
IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ; IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
/. /.
case $rule_number: { case $rule_number: {
@@ -2875,7 +2905,8 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
const int errorState = state_stack[tos]; const int errorState = state_stack[tos];
// automatic insertion of `;' // automatic insertion of `;'
if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken))
|| t_action(errorState, T_COMPATIBILITY_SEMICOLON))) {
SavedToken &tk = token_buffer[0]; SavedToken &tk = token_buffer[0];
tk.token = yytoken; tk.token = yytoken;
tk.dval = yylval; tk.dval = yylval;
@@ -2887,7 +2918,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
yylloc.startColumn += yylloc.length; yylloc.startColumn += yylloc.length;
yylloc.length = 0; yylloc.length = 0;
//const QString msg = qApp->translate("QQmlParser", "Missing `;'"); //const QString msg = qApp->translate("QmlParser", "Missing `;'");
//diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
first_token = &token_buffer[0]; first_token = &token_buffer[0];
@@ -2917,9 +2948,9 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
QString msg; QString msg;
int token = token_buffer[0].token; int token = token_buffer[0].token;
if (token < 0 || token >= TERMINAL_COUNT) if (token < 0 || token >= TERMINAL_COUNT)
msg = qApp->translate("QQmlParser", "Syntax error"); msg = qApp->translate("QmlParser", "Syntax error");
else else
msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
action = errorState; action = errorState;
@@ -2947,7 +2978,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
int a = t_action(errorState, *tk); int a = t_action(errorState, *tk);
if (a > 0 && t_action(a, yytoken)) { if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = *tk; yytoken = *tk;
@@ -2971,7 +3002,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
int a = t_action(errorState, tk); int a = t_action(errorState, tk);
if (a > 0 && t_action(a, yytoken)) { if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = tk; yytoken = tk;
@@ -2984,7 +3015,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
} }
} }
const QString msg = qApp->translate("QQmlParser", "Syntax error"); const QString msg = qApp->translate("QmlParser", "Syntax error");
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
} }

View File

@@ -110,7 +110,7 @@ double integerFromString(const QString &str, int radix)
Engine::Engine() Engine::Engine()
: _lexer(0), _directives(0) : _lexer(0), directives(0)
{ } { }
Engine::~Engine() Engine::~Engine()

File diff suppressed because it is too large Load Diff

View File

@@ -52,12 +52,12 @@ class QML_PARSER_EXPORT QmlJSGrammar
public: public:
enum VariousConstants { enum VariousConstants {
EOF_SYMBOL = 0, EOF_SYMBOL = 0,
REDUCE_HERE = 101, REDUCE_HERE = 102,
SHIFT_THERE = 100, SHIFT_THERE = 101,
T_AND = 1, T_AND = 1,
T_AND_AND = 2, T_AND_AND = 2,
T_AND_EQ = 3, T_AND_EQ = 3,
T_AS = 91, T_AS = 92,
T_AUTOMATIC_SEMICOLON = 62, T_AUTOMATIC_SEMICOLON = 62,
T_BREAK = 4, T_BREAK = 4,
T_CASE = 5, T_CASE = 5,
@@ -65,6 +65,7 @@ public:
T_COLON = 7, T_COLON = 7,
T_COMMA = 8, T_COMMA = 8,
T_COMMENT = 88, T_COMMENT = 88,
T_COMPATIBILITY_SEMICOLON = 89,
T_CONST = 84, T_CONST = 84,
T_CONTINUE = 9, T_CONTINUE = 9,
T_DEBUGGER = 85, T_DEBUGGER = 85,
@@ -78,14 +79,14 @@ public:
T_EQ = 17, T_EQ = 17,
T_EQ_EQ = 18, T_EQ_EQ = 18,
T_EQ_EQ_EQ = 19, T_EQ_EQ_EQ = 19,
T_ERROR = 93, T_ERROR = 94,
T_FALSE = 83, T_FALSE = 83,
T_FEED_JS_EXPRESSION = 97, T_FEED_JS_EXPRESSION = 98,
T_FEED_JS_PROGRAM = 99, T_FEED_JS_PROGRAM = 100,
T_FEED_JS_SOURCE_ELEMENT = 98, T_FEED_JS_SOURCE_ELEMENT = 99,
T_FEED_JS_STATEMENT = 96, T_FEED_JS_STATEMENT = 97,
T_FEED_UI_OBJECT_MEMBER = 95, T_FEED_UI_OBJECT_MEMBER = 96,
T_FEED_UI_PROGRAM = 94, T_FEED_UI_PROGRAM = 95,
T_FINALLY = 20, T_FINALLY = 20,
T_FOR = 21, T_FOR = 21,
T_FUNCTION = 22, T_FUNCTION = 22,
@@ -97,7 +98,7 @@ public:
T_GT_GT_GT_EQ = 28, T_GT_GT_GT_EQ = 28,
T_IDENTIFIER = 29, T_IDENTIFIER = 29,
T_IF = 30, T_IF = 30,
T_IMPORT = 90, T_IMPORT = 91,
T_IN = 31, T_IN = 31,
T_INSTANCEOF = 32, T_INSTANCEOF = 32,
T_LBRACE = 33, T_LBRACE = 33,
@@ -117,7 +118,7 @@ public:
T_NOT_EQ_EQ = 46, T_NOT_EQ_EQ = 46,
T_NULL = 81, T_NULL = 81,
T_NUMERIC_LITERAL = 47, T_NUMERIC_LITERAL = 47,
T_ON = 92, T_ON = 93,
T_OR = 48, T_OR = 48,
T_OR_EQ = 49, T_OR_EQ = 49,
T_OR_OR = 50, T_OR_OR = 50,
@@ -125,7 +126,7 @@ public:
T_PLUS_EQ = 52, T_PLUS_EQ = 52,
T_PLUS_PLUS = 53, T_PLUS_PLUS = 53,
T_PROPERTY = 66, T_PROPERTY = 66,
T_PUBLIC = 89, T_PUBLIC = 90,
T_QUESTION = 54, T_QUESTION = 54,
T_RBRACE = 55, T_RBRACE = 55,
T_RBRACKET = 56, T_RBRACKET = 56,
@@ -154,15 +155,15 @@ public:
T_XOR = 79, T_XOR = 79,
T_XOR_EQ = 80, T_XOR_EQ = 80,
ACCEPT_STATE = 644, ACCEPT_STATE = 645,
RULE_COUNT = 349, RULE_COUNT = 350,
STATE_COUNT = 645, STATE_COUNT = 646,
TERMINAL_COUNT = 102, TERMINAL_COUNT = 103,
NON_TERMINAL_COUNT = 107, NON_TERMINAL_COUNT = 107,
GOTO_INDEX_OFFSET = 645, GOTO_INDEX_OFFSET = 646,
GOTO_INFO_OFFSET = 2807, GOTO_INFO_OFFSET = 3019,
GOTO_CHECK_OFFSET = 2807 GOTO_CHECK_OFFSET = 3019
}; };
static const char *const spell []; static const char *const spell [];

View File

@@ -44,7 +44,7 @@
static inline int classify2(const QChar *s, bool qmlMode) { static inline int classify2(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'a') { if (s[0].unicode() == 'a') {
if (s[1].unicode() == 's') { if (s[1].unicode() == 's') {
return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD; return qmlMode ? Lexer::T_AS : Lexer::T_IDENTIFIER;
} }
} }
else if (s[0].unicode() == 'd') { else if (s[0].unicode() == 'd') {
@@ -62,13 +62,13 @@ static inline int classify2(const QChar *s, bool qmlMode) {
} }
else if (qmlMode && s[0].unicode() == 'o') { else if (qmlMode && s[0].unicode() == 'o') {
if (s[1].unicode() == 'n') { if (s[1].unicode() == 'n') {
return Lexer::T_ON; return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER;
} }
} }
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify3(const QChar *s, bool /*qmlMode*/) { static inline int classify3(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'f') { if (s[0].unicode() == 'f') {
if (s[1].unicode() == 'o') { if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'r') { if (s[2].unicode() == 'r') {
@@ -79,7 +79,7 @@ static inline int classify3(const QChar *s, bool /*qmlMode*/) {
else if (s[0].unicode() == 'i') { else if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') { if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') { if (s[2].unicode() == 't') {
return Lexer::T_INT; return qmlMode ? Lexer::T_INT : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -107,12 +107,12 @@ static inline int classify3(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify4(const QChar *s, bool /*qmlMode*/) { static inline int classify4(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') { if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'y') { if (s[1].unicode() == 'y') {
if (s[2].unicode() == 't') { if (s[2].unicode() == 't') {
if (s[3].unicode() == 'e') { if (s[3].unicode() == 'e') {
return Lexer::T_BYTE; return qmlMode ? Lexer::T_BYTE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -128,7 +128,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
else if (s[1].unicode() == 'h') { else if (s[1].unicode() == 'h') {
if (s[2].unicode() == 'a') { if (s[2].unicode() == 'a') {
if (s[3].unicode() == 'r') { if (s[3].unicode() == 'r') {
return Lexer::T_CHAR; return qmlMode ? Lexer::T_CHAR : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -153,7 +153,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
if (s[1].unicode() == 'o') { if (s[1].unicode() == 'o') {
if (s[2].unicode() == 't') { if (s[2].unicode() == 't') {
if (s[3].unicode() == 'o') { if (s[3].unicode() == 'o') {
return Lexer::T_GOTO; return qmlMode ? Lexer::T_GOTO : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -162,7 +162,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
if (s[1].unicode() == 'o') { if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'n') { if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'g') { if (s[3].unicode() == 'g') {
return Lexer::T_LONG; return qmlMode ? Lexer::T_LONG : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -213,7 +213,7 @@ static inline int classify4(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify5(const QChar *s, bool /*qmlMode*/) { static inline int classify5(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') { if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'r') { if (s[1].unicode() == 'r') {
if (s[2].unicode() == 'e') { if (s[2].unicode() == 'e') {
@@ -248,7 +248,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'n') { if (s[2].unicode() == 'n') {
if (s[3].unicode() == 's') { if (s[3].unicode() == 's') {
if (s[4].unicode() == 't') { if (s[4].unicode() == 't') {
return Lexer::T_CONST; return qmlMode ? Lexer::T_CONST : Lexer::T_RESERVED_WORD;
} }
} }
} }
@@ -268,7 +268,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'n') { if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'a') { if (s[3].unicode() == 'a') {
if (s[4].unicode() == 'l') { if (s[4].unicode() == 'l') {
return Lexer::T_FINAL; return qmlMode ? Lexer::T_FINAL : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -277,7 +277,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'o') { if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'a') { if (s[3].unicode() == 'a') {
if (s[4].unicode() == 't') { if (s[4].unicode() == 't') {
return Lexer::T_FLOAT; return qmlMode ? Lexer::T_FLOAT : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -288,7 +288,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'o') { if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'r') { if (s[3].unicode() == 'r') {
if (s[4].unicode() == 't') { if (s[4].unicode() == 't') {
return Lexer::T_SHORT; return qmlMode ? Lexer::T_SHORT : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -297,7 +297,7 @@ static inline int classify5(const QChar *s, bool /*qmlMode*/) {
if (s[2].unicode() == 'p') { if (s[2].unicode() == 'p') {
if (s[3].unicode() == 'e') { if (s[3].unicode() == 'e') {
if (s[4].unicode() == 'r') { if (s[4].unicode() == 'r') {
return Lexer::T_SUPER; return qmlMode ? Lexer::T_SUPER : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -346,7 +346,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'b') { if (s[3].unicode() == 'b') {
if (s[4].unicode() == 'l') { if (s[4].unicode() == 'l') {
if (s[5].unicode() == 'e') { if (s[5].unicode() == 'e') {
return Lexer::T_DOUBLE; return qmlMode ? Lexer::T_DOUBLE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -385,7 +385,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'i') { if (s[3].unicode() == 'i') {
if (s[4].unicode() == 'v') { if (s[4].unicode() == 'v') {
if (s[5].unicode() == 'e') { if (s[5].unicode() == 'e') {
return Lexer::T_NATIVE; return qmlMode ? Lexer::T_NATIVE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -398,7 +398,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'l') { if (s[3].unicode() == 'l') {
if (s[4].unicode() == 'i') { if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') { if (s[5].unicode() == 'c') {
return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD; return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -435,7 +435,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 't') { if (s[3].unicode() == 't') {
if (s[4].unicode() == 'i') { if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') { if (s[5].unicode() == 'c') {
return Lexer::T_STATIC; return qmlMode ? Lexer::T_STATIC : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -459,7 +459,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'o') { if (s[3].unicode() == 'o') {
if (s[4].unicode() == 'w') { if (s[4].unicode() == 'w') {
if (s[5].unicode() == 's') { if (s[5].unicode() == 's') {
return Lexer::T_THROWS; return qmlMode ? Lexer::T_THROWS : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -480,7 +480,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify7(const QChar *s, bool /*qmlMode*/) { static inline int classify7(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'b') { if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'o') { if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'o') { if (s[2].unicode() == 'o') {
@@ -488,7 +488,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'e') { if (s[4].unicode() == 'e') {
if (s[5].unicode() == 'a') { if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'n') { if (s[6].unicode() == 'n') {
return Lexer::T_BOOLEAN; return qmlMode ? Lexer::T_BOOLEAN : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -548,7 +548,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'a') { if (s[4].unicode() == 'a') {
if (s[5].unicode() == 'g') { if (s[5].unicode() == 'g') {
if (s[6].unicode() == 'e') { if (s[6].unicode() == 'e') {
return Lexer::T_PACKAGE; return qmlMode ? Lexer::T_PACKAGE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -561,7 +561,7 @@ static inline int classify7(const QChar *s, bool /*qmlMode*/) {
if (s[4].unicode() == 'a') { if (s[4].unicode() == 'a') {
if (s[5].unicode() == 't') { if (s[5].unicode() == 't') {
if (s[6].unicode() == 'e') { if (s[6].unicode() == 'e') {
return Lexer::T_PRIVATE; return qmlMode ? Lexer::T_PRIVATE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -581,7 +581,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'a') { if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'c') { if (s[6].unicode() == 'c') {
if (s[7].unicode() == 't') { if (s[7].unicode() == 't') {
return Lexer::T_ABSTRACT; return qmlMode ? Lexer::T_ABSTRACT : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -649,7 +649,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'r') { if (s[5].unicode() == 'r') {
if (s[6].unicode() == 't') { if (s[6].unicode() == 't') {
if (s[7].unicode() == 'y') { if (s[7].unicode() == 'y') {
return Lexer::T_PROPERTY; return qmlMode ? Lexer::T_PROPERTY : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -683,7 +683,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'i') { if (s[5].unicode() == 'i') {
if (s[6].unicode() == 'l') { if (s[6].unicode() == 'l') {
if (s[7].unicode() == 'e') { if (s[7].unicode() == 'e') {
return Lexer::T_VOLATILE; return qmlMode ? Lexer::T_VOLATILE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -695,7 +695,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify9(const QChar *s, bool /*qmlMode*/) { static inline int classify9(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'i') { if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') { if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') { if (s[2].unicode() == 't') {
@@ -705,7 +705,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 'a') { if (s[6].unicode() == 'a') {
if (s[7].unicode() == 'c') { if (s[7].unicode() == 'c') {
if (s[8].unicode() == 'e') { if (s[8].unicode() == 'e') {
return Lexer::T_INTERFACE; return qmlMode ? Lexer::T_INTERFACE : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -724,7 +724,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 't') { if (s[6].unicode() == 't') {
if (s[7].unicode() == 'e') { if (s[7].unicode() == 'e') {
if (s[8].unicode() == 'd') { if (s[8].unicode() == 'd') {
return Lexer::T_PROTECTED; return qmlMode ? Lexer::T_PROTECTED : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -743,7 +743,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
if (s[6].unicode() == 'e') { if (s[6].unicode() == 'e') {
if (s[7].unicode() == 'n') { if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') { if (s[8].unicode() == 't') {
return Lexer::T_TRANSIENT; return qmlMode ? Lexer::T_TRANSIENT : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -756,7 +756,7 @@ static inline int classify9(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify10(const QChar *s, bool /*qmlMode*/) { static inline int classify10(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 'i') { if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'm') { if (s[1].unicode() == 'm') {
if (s[2].unicode() == 'p') { if (s[2].unicode() == 'p') {
@@ -767,7 +767,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
if (s[7].unicode() == 'n') { if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') { if (s[8].unicode() == 't') {
if (s[9].unicode() == 's') { if (s[9].unicode() == 's') {
return Lexer::T_IMPLEMENTS; return qmlMode ? Lexer::T_IMPLEMENTS : Lexer::T_IDENTIFIER;
} }
} }
} }
@@ -800,7 +800,7 @@ static inline int classify10(const QChar *s, bool /*qmlMode*/) {
return Lexer::T_IDENTIFIER; return Lexer::T_IDENTIFIER;
} }
static inline int classify12(const QChar *s, bool /*qmlMode*/) { static inline int classify12(const QChar *s, bool qmlMode) {
if (s[0].unicode() == 's') { if (s[0].unicode() == 's') {
if (s[1].unicode() == 'y') { if (s[1].unicode() == 'y') {
if (s[2].unicode() == 'n') { if (s[2].unicode() == 'n') {
@@ -813,7 +813,7 @@ static inline int classify12(const QChar *s, bool /*qmlMode*/) {
if (s[9].unicode() == 'z') { if (s[9].unicode() == 'z') {
if (s[10].unicode() == 'e') { if (s[10].unicode() == 'e') {
if (s[11].unicode() == 'd') { if (s[11].unicode() == 'd') {
return Lexer::T_SYNCHRONIZED; return qmlMode ? Lexer::T_SYNCHRONIZED : Lexer::T_IDENTIFIER;
} }
} }
} }

View File

@@ -154,10 +154,13 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
void Lexer::scanChar() void Lexer::scanChar()
{ {
unsigned sequenceLength = isLineTerminatorSequence();
_char = *_codePtr++; _char = *_codePtr++;
if (sequenceLength == 2)
_char = *_codePtr++;
if (_char == QLatin1Char('\n')) { if (unsigned sequenceLength = isLineTerminatorSequence()) {
_lastLinePtr = _codePtr; // points to the first character after the newline _lastLinePtr = _codePtr + sequenceLength - 1; // points to the first character after the newline
++_currentLineNumber; ++_currentLineNumber;
} }
} }
@@ -275,13 +278,13 @@ again:
_tokenLinePtr = _lastLinePtr; _tokenLinePtr = _lastLinePtr;
while (_char.isSpace()) { while (_char.isSpace()) {
if (_char == QLatin1Char('\n')) { if (unsigned sequenceLength = isLineTerminatorSequence()) {
_tokenLinePtr = _codePtr; _tokenLinePtr = _codePtr + sequenceLength - 1;
if (_restrictedKeyword) { if (_restrictedKeyword) {
// automatic semicolon insertion // automatic semicolon insertion
_tokenLine = _currentLineNumber; _tokenLine = _currentLineNumber;
_tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence. _tokenStartPtr = _codePtr - 1;
return T_SEMICOLON; return T_SEMICOLON;
} else { } else {
_terminator = true; _terminator = true;
@@ -398,7 +401,7 @@ again:
} }
} }
} else if (_char == QLatin1Char('/')) { } else if (_char == QLatin1Char('/')) {
while (!_char.isNull() && _char != QLatin1Char('\n')) { while (!_char.isNull() && !isLineTerminator()) {
scanChar(); scanChar();
} }
if (_engine) { if (_engine) {
@@ -541,7 +544,7 @@ again:
if (_engine) { if (_engine) {
while (!_char.isNull()) { while (!_char.isNull()) {
if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) { if (isLineTerminator() || _char == QLatin1Char('\\')) {
break; break;
} else if (_char == quote) { } else if (_char == quote) {
_tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode); _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
@@ -556,13 +559,15 @@ again:
_validTokenText = true; _validTokenText = true;
_tokenText.resize(0); _tokenText.resize(0);
startCode--; startCode--;
while (startCode != _codePtr - 1) while (startCode != _codePtr - 1)
_tokenText += *startCode++; _tokenText += *startCode++;
while (! _char.isNull()) { while (! _char.isNull()) {
if (_char == QLatin1Char('\n')) { if (unsigned sequenceLength = isLineTerminatorSequence()) {
multilineStringLiteral = true; multilineStringLiteral = true;
_tokenText += _char; _tokenText += _char;
if (sequenceLength == 2)
_tokenText += *_codePtr;
scanChar(); scanChar();
} else if (_char == quote) { } else if (_char == quote) {
scanChar(); scanChar();
@@ -587,7 +592,6 @@ again:
// hex escape sequence // hex escape sequence
case 'x': case 'x':
case 'X':
if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) {
scanChar(); scanChar();
@@ -625,23 +629,23 @@ again:
break; break;
case '\r': case '\r':
while (_char == QLatin1Char('\r')) if (isLineTerminatorSequence() == 2) {
scanChar(); _tokenText += QLatin1Char('\r');
if (_char == QLatin1Char('\n')) {
u = _char;
scanChar();
} else {
u = QLatin1Char('\n'); u = QLatin1Char('\n');
} else {
u = QLatin1Char('\r');
} }
scanChar();
break; break;
case '\n': case '\n':
case 0x2028u:
case 0x2029u:
u = _char; u = _char;
scanChar(); scanChar();
break; break;
default: default:
// non escape character // non escape character
u = _char; u = _char;
@@ -860,11 +864,6 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (true) { while (true) {
switch (_char.unicode()) { switch (_char.unicode()) {
case 0: // eof
case '\n': case '\r': // line terminator
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal");
return false;
case '/': case '/':
scanChar(); scanChar();
@@ -934,8 +933,13 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
break; break;
default: default:
_tokenText += _char; if (_char.isNull() || isLineTerminator()) {
scanChar(); _errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal");
return false;
} else {
_tokenText += _char;
scanChar();
}
} // switch } // switch
} // while } // while
@@ -944,7 +948,28 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
bool Lexer::isLineTerminator() const bool Lexer::isLineTerminator() const
{ {
return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r')); const ushort unicode = _char.unicode();
return unicode == 0x000Au
|| unicode == 0x000Du
|| unicode == 0x2028u
|| unicode == 0x2029u;
}
unsigned Lexer::isLineTerminatorSequence() const
{
switch (_char.unicode()) {
case 0x000Au:
case 0x2028u:
case 0x2029u:
return 1;
case 0x000Du:
if (_codePtr->unicode() == 0x000Au)
return 2;
else
return 1;
default:
return 0;
}
} }
bool Lexer::isIdentLetter(QChar ch) bool Lexer::isIdentLetter(QChar ch)
@@ -1112,7 +1137,7 @@ bool Lexer::scanDirectives(Directives *directives)
// //
// recognize the mandatory `as' followed by the module name // recognize the mandatory `as' followed by the module name
// //
if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as"))) if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as")))
return false; // expected `as' return false; // expected `as'
if (lex() != T_IDENTIFIER) if (lex() != T_IDENTIFIER)

View File

@@ -92,7 +92,6 @@ public:
T_IMPLEMENTS = T_RESERVED_WORD, T_IMPLEMENTS = T_RESERVED_WORD,
T_INT = T_RESERVED_WORD, T_INT = T_RESERVED_WORD,
T_INTERFACE = T_RESERVED_WORD, T_INTERFACE = T_RESERVED_WORD,
T_LET = T_RESERVED_WORD,
T_LONG = T_RESERVED_WORD, T_LONG = T_RESERVED_WORD,
T_NATIVE = T_RESERVED_WORD, T_NATIVE = T_RESERVED_WORD,
T_PACKAGE = T_RESERVED_WORD, T_PACKAGE = T_RESERVED_WORD,
@@ -104,8 +103,7 @@ public:
T_SYNCHRONIZED = T_RESERVED_WORD, T_SYNCHRONIZED = T_RESERVED_WORD,
T_THROWS = T_RESERVED_WORD, T_THROWS = T_RESERVED_WORD,
T_TRANSIENT = T_RESERVED_WORD, T_TRANSIENT = T_RESERVED_WORD,
T_VOLATILE = T_RESERVED_WORD, T_VOLATILE = T_RESERVED_WORD
T_YIELD = T_RESERVED_WORD
}; };
enum Error { enum Error {
@@ -182,6 +180,7 @@ private:
int scanNumber(QChar ch); int scanNumber(QChar ch);
bool isLineTerminator() const; bool isLineTerminator() const;
unsigned isLineTerminatorSequence() const;
static bool isIdentLetter(QChar c); static bool isIdentLetter(QChar c);
static bool isDecimalDigit(ushort c); static bool isDecimalDigit(ushort c);
static bool isHexDigit(QChar c); static bool isHexDigit(QChar c);

View File

@@ -27,7 +27,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtCore/QDebug> #include <QtCore/QtDebug>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <string.h> #include <string.h>
@@ -42,9 +42,16 @@
#include "qmljsparser_p.h" #include "qmljsparser_p.h"
#include <QVarLengthArray> #include <QVarLengthArray>
//
// W A R N I N G
// -------------
// //
// This file is automatically generated from qmljs.g. // This file is automatically generated from qmljs.g.
// Changes will be lost. // Changes should be made to that file, not here. Any change to this file will
// be lost!
//
// To regenerate this file, run:
// qlalr --no-debug --no-lines --qt qmljs.g
// //
using namespace QmlJS; using namespace QmlJS;
@@ -1384,7 +1391,7 @@ case 289: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 291: { case 292: {
AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
node->doToken = loc(1); node->doToken = loc(1);
node->whileToken = loc(3); node->whileToken = loc(3);
@@ -1394,7 +1401,7 @@ case 291: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 292: { case 293: {
AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
node->whileToken = loc(1); node->whileToken = loc(1);
node->lparenToken = loc(2); node->lparenToken = loc(2);
@@ -1402,7 +1409,7 @@ case 292: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 293: { case 294: {
AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
sym(5).Expression, sym(7).Expression, sym(9).Statement); sym(5).Expression, sym(7).Expression, sym(9).Statement);
node->forToken = loc(1); node->forToken = loc(1);
@@ -1413,7 +1420,7 @@ case 293: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 294: { case 295: {
AST::LocalForStatement *node = new (pool) AST::LocalForStatement( AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
sym(8).Expression, sym(10).Statement); sym(8).Expression, sym(10).Statement);
@@ -1426,7 +1433,7 @@ case 294: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 295: { case 296: {
AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
sym(5).Expression, sym(7).Statement); sym(5).Expression, sym(7).Statement);
node->forToken = loc(1); node->forToken = loc(1);
@@ -1436,7 +1443,7 @@ case 295: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 296: { case 297: {
AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
node->forToken = loc(1); node->forToken = loc(1);
@@ -1447,14 +1454,14 @@ case 296: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 298: { case 299: {
AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
node->continueToken = loc(1); node->continueToken = loc(1);
node->semicolonToken = loc(2); node->semicolonToken = loc(2);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 300: { case 301: {
AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
node->continueToken = loc(1); node->continueToken = loc(1);
node->identifierToken = loc(2); node->identifierToken = loc(2);
@@ -1462,14 +1469,14 @@ case 300: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 302: { case 303: {
AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
node->breakToken = loc(1); node->breakToken = loc(1);
node->semicolonToken = loc(2); node->semicolonToken = loc(2);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 304: { case 305: {
AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
node->breakToken = loc(1); node->breakToken = loc(1);
node->identifierToken = loc(2); node->identifierToken = loc(2);
@@ -1477,14 +1484,14 @@ case 304: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 306: { case 307: {
AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
node->returnToken = loc(1); node->returnToken = loc(1);
node->semicolonToken = loc(3); node->semicolonToken = loc(3);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 307: { case 308: {
AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
node->withToken = loc(1); node->withToken = loc(1);
node->lparenToken = loc(2); node->lparenToken = loc(2);
@@ -1492,7 +1499,7 @@ case 307: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 308: { case 309: {
AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
node->switchToken = loc(1); node->switchToken = loc(1);
node->lparenToken = loc(2); node->lparenToken = loc(2);
@@ -1500,57 +1507,50 @@ case 308: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 309: { case 310: {
AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
node->lbraceToken = loc(1); node->lbraceToken = loc(1);
node->rbraceToken = loc(3); node->rbraceToken = loc(3);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 310: { case 311: {
AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
node->lbraceToken = loc(1); node->lbraceToken = loc(1);
node->rbraceToken = loc(5); node->rbraceToken = loc(5);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 311: { case 312: {
sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
} break; } break;
case 312: { case 313: {
sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
} break; } break;
case 313: { case 314: {
sym(1).Node = 0; sym(1).Node = 0;
} break; } break;
case 314: { case 315: {
sym(1).Node = sym(1).CaseClauses->finish (); sym(1).Node = sym(1).CaseClauses->finish ();
} break; } break;
case 315: { case 316: {
AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
node->caseToken = loc(1); node->caseToken = loc(1);
node->colonToken = loc(3); node->colonToken = loc(3);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 316: { case 317: {
AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
node->defaultToken = loc(1); node->defaultToken = loc(1);
node->colonToken = loc(2); node->colonToken = loc(2);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 317: case 318:
case 318: {
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
node->identifierToken = loc(1);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
case 319: { case 319: {
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
node->identifierToken = loc(1); node->identifierToken = loc(1);
@@ -1558,32 +1558,39 @@ case 319: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 321: { case 320: {
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
node->identifierToken = loc(1);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
case 322: {
AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
node->throwToken = loc(1); node->throwToken = loc(1);
node->semicolonToken = loc(3); node->semicolonToken = loc(3);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 322: { case 323: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
node->tryToken = loc(1); node->tryToken = loc(1);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 323: { case 324: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
node->tryToken = loc(1); node->tryToken = loc(1);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 324: { case 325: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
node->tryToken = loc(1); node->tryToken = loc(1);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 325: { case 326: {
AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
node->catchToken = loc(1); node->catchToken = loc(1);
node->lparenToken = loc(2); node->lparenToken = loc(2);
@@ -1592,20 +1599,20 @@ case 325: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 326: { case 327: {
AST::Finally *node = new (pool) AST::Finally(sym(2).Block); AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
node->finallyToken = loc(1); node->finallyToken = loc(1);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 328: { case 329: {
AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
node->debuggerToken = loc(1); node->debuggerToken = loc(1);
node->semicolonToken = loc(2); node->semicolonToken = loc(2);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 329: { case 330: {
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
node->functionToken = loc(1); node->functionToken = loc(1);
node->identifierToken = loc(2); node->identifierToken = loc(2);
@@ -1616,7 +1623,7 @@ case 329: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 330: { case 331: {
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
node->functionToken = loc(1); node->functionToken = loc(1);
if (! stringRef(2).isNull()) if (! stringRef(2).isNull())
@@ -1628,60 +1635,60 @@ case 330: {
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 331: { case 332: {
AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
node->identifierToken = loc(1); node->identifierToken = loc(1);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 332: { case 333: {
AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
node->commaToken = loc(2); node->commaToken = loc(2);
node->identifierToken = loc(3); node->identifierToken = loc(3);
sym(1).Node = node; sym(1).Node = node;
} break; } break;
case 333: {
sym(1).Node = 0;
} break;
case 334: { case 334: {
sym(1).Node = sym(1).FormalParameterList->finish (); sym(1).Node = 0;
} break; } break;
case 335: { case 335: {
sym(1).Node = sym(1).FormalParameterList->finish ();
} break;
case 336: {
sym(1).Node = 0; sym(1).Node = 0;
} break; } break;
case 337: { case 338: {
sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
} break; } break;
case 339: { case 340: {
sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
} break; } break;
case 340: { case 341: {
sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
} break; } break;
case 341: { case 342: {
sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
} break; } break;
case 342: { case 343: {
sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
} break; } break;
case 343: { case 344: {
sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
} break; } break;
case 344: { case 345: {
stringRef(1) = QStringRef(); stringRef(1) = QStringRef();
} break; } break;
case 346: { case 347: {
sym(1).Node = 0; sym(1).Node = 0;
} break; } break;
@@ -1694,7 +1701,8 @@ case 346: {
const int errorState = state_stack[tos]; const int errorState = state_stack[tos];
// automatic insertion of `;' // automatic insertion of `;'
if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken))
|| t_action(errorState, T_COMPATIBILITY_SEMICOLON))) {
SavedToken &tk = token_buffer[0]; SavedToken &tk = token_buffer[0];
tk.token = yytoken; tk.token = yytoken;
tk.dval = yylval; tk.dval = yylval;

View File

@@ -39,9 +39,16 @@
// We mean it. // We mean it.
// //
//
// W A R N I N G
// -------------
// //
// This file is automatically generated from qmljs.g. // This file is automatically generated from qmljs.g.
// Changes will be lost. // Changes should be made to that file, not here. Any change to this file will
// be lost!
//
// To regenerate this file, run:
// qlalr --no-debug --no-lines --qt qmljs.g
// //
#ifndef QMLJSPARSER_P_H #ifndef QMLJSPARSER_P_H