Commit 674097b8 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Updated the QML front-end to revision 8b168b8f969c1eafaeb0276a3c81b58a388f93d2

parent 124f2e9f
......@@ -10,14 +10,12 @@ HEADERS += $$PWD/qmljsast_p.h \
$$PWD/qmljslexer_p.h \
$$PWD/qmljsmemorypool_p.h \
$$PWD/qmljsnodepool_p.h \
$$PWD/qmljsparser_p.h \
$$PWD/qmljsprettypretty_p.h
$$PWD/qmljsparser_p.h
SOURCES += $$PWD/qmljsast.cpp \
$$PWD/qmljsastvisitor.cpp \
$$PWD/qmljsengine_p.cpp \
$$PWD/qmljsgrammar.cpp \
$$PWD/qmljslexer.cpp \
$$PWD/qmljsprettypretty.cpp \
$$PWD/qmljsparser.cpp
......@@ -46,7 +46,7 @@
%decl qmljsparser_p.h
%impl qmljsparser.cpp
%expect 2
%expect-rr 3
%expect-rr 2
%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
......@@ -580,86 +580,73 @@ case $rule_number: {
} break;
./
UiImport: T_IMPORT T_STRING_LITERAL T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT T_STRING_LITERAL T_SEMICOLON;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval);
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
./
ImportId: MemberExpression ;
UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_SEMICOLON;
UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
UiImport: UiImportHead T_SEMICOLON ;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval);
node->importId = sym(4).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->asToken = loc(3);
node->importIdToken = loc(4);
node->semicolonToken = loc(5);
sym(1).Node = node;
sym(1).UiImport->semicolonToken = loc(2);
} break;
./
UiImport: T_IMPORT UiQualifiedId T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_SEMICOLON;
UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->semicolonToken = loc(3);
sym(1).Node = node;
sym(1).UiImport->versionToken = loc(2);
sym(1).UiImport->semicolonToken = loc(3);
} break;
./
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_SEMICOLON;
UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->versionToken = loc(3);
node->semicolonToken = loc(4);
sym(1).Node = node;
sym(1).UiImport->versionToken = loc(2);
sym(1).UiImport->asToken = loc(3);
sym(1).UiImport->importIdToken = loc(4);
sym(1).UiImport->semicolonToken = loc(5);
} break;
./
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON;
UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(5).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->versionToken = loc(3);
node->asToken = loc(4);
node->importIdToken = loc(5);
node->semicolonToken = loc(6);
sym(1).Node = node;
sym(1).UiImport->asToken = loc(2);
sym(1).UiImport->importIdToken = loc(3);
sym(1).UiImport->semicolonToken = loc(4);
} break;
./
UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_AUTOMATIC_SEMICOLON;
UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_SEMICOLON;
UiImportHead: T_IMPORT ImportId ;
/.
case $rule_number: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(4).sval;
node->importToken = loc(1);
node->fileNameToken = loc(2);
node->asToken = loc(3);
node->importIdToken = loc(4);
node->semicolonToken = loc(5);
AST::UiImport *node = 0;
if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
node->fileNameToken = loc(2);
} else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
QString text;
for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
text += q->name->asString();
if (q->next) text += QLatin1String(".");
}
node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
node->fileNameToken = loc(2);
}
sym(1).Node = node;
if (! node) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
QLatin1String("Expected a qualified name id or a string literal")));
return false; // ### remove me
}
} break;
./
......@@ -733,7 +720,7 @@ case $rule_number: {
UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
/.
case $rule_number: {
AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId,
sym(2).UiObjectInitializer);
sym(1).Node = node;
} break;
......@@ -745,7 +732,7 @@ UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
/.
case $rule_number: {
AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(4).UiArrayMemberList->finish());
sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
node->colonToken = loc(2);
node->lbracketToken = loc(3);
node->rbracketToken = loc(5);
......@@ -753,67 +740,16 @@ case $rule_number: {
} break;
./
UiObjectMember: UiQualifiedId T_COLON Expression UiObjectInitializer ;
UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
/.
case $rule_number: {
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(3).Expression)) {
AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), qualifiedId, sym(4).UiObjectInitializer);
sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
node->colonToken = loc(2);
sym(1).Node = node;
} else {
sym(1).Node = 0;
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(2),
QLatin1String("Expected a type name after token `:'")));
return false; // ### recover
}
} break;
./
UiObjectMember: UiQualifiedId UiSignature T_COLON Expression UiObjectInitializer ;
/.
case $rule_number: {
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(4).Expression)) {
AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), qualifiedId, sym(5).UiObjectInitializer);
node->colonToken = loc(3);
sym(1).Node = node;
} else {
sym(1).Node = 0;
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(2),
QLatin1String("Expected a type name after token `:'")));
return false; // ### recover
}
} break;
./
UiObjectMember: UiQualifiedId UiSignature T_COLON Block ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON EmptyStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON ExpressionStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
/.
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(4).Statement);
node->colonToken = loc(3);
sym(1).Node = node;
} break;
./
UiObjectMember: UiQualifiedId T_COLON Block ;
/.case $rule_number:./
......@@ -829,7 +765,7 @@ UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if
/.
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(3).Statement);
sym(1).UiQualifiedId, sym(3).Statement);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
......@@ -882,64 +818,6 @@ case $rule_number: {
} break;
./
UiFormal: JsIdentifier ;
/.
case $rule_number: {
AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).UiFormal = node;
} break;
./
UiFormal: JsIdentifier T_AS JsIdentifier ;
/.
case $rule_number: {
AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(),
sym(1).sval, sym(3).sval);
node->identifierToken = loc(1);
node->asToken = loc(2);
node->aliasToken = loc(3);
sym(1).UiFormal = node;
} break;
./
UiFormalList: UiFormal ;
/.
case $rule_number: {
sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
sym(1).UiFormal);
} break;
./
UiFormalList: UiFormalList T_COMMA UiFormal ;
/.
case $rule_number: {
sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
sym(1).UiFormalList, sym(3).UiFormal);
} break;
./
UiSignature: T_LPAREN T_RPAREN ;
/.
case $rule_number: {
AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool());
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).UiSignature = node;
} break;
./
UiSignature: T_LPAREN UiFormalList T_RPAREN ;
/.
case $rule_number: {
AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool(),
sym(2).UiFormalList->finish());
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).UiSignature = node;
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
/.
......@@ -1043,19 +921,6 @@ case $rule_number: {
} break;
./
UiQualifiedId: T_RESERVED_WORD ;
/.case $rule_number: ./
UiQualifiedId: T_RETURN ;
/.
case $rule_number:
{
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
./
JsIdentifier: T_IDENTIFIER;
JsIdentifier: T_PROPERTY ;
......@@ -1277,22 +1142,27 @@ case $rule_number: {
} break;
./
UiQualifiedId: JsIdentifier ;
UiQualifiedId: MemberExpression ;
/.
case $rule_number: {
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
./
if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
QLatin1String("Ignored annotation")));
UiQualifiedId: UiQualifiedId T_DOT JsIdentifier ;
/.
case $rule_number: {
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).UiQualifiedId, sym(3).sval);
node->identifierToken = loc(3);
sym(1).Node = node;
} break;
sym(1).Expression = mem->base;
}
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
sym(1).UiQualifiedId = qualifiedId;
} else {
sym(1).UiQualifiedId = 0;
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
QLatin1String("Expected a qualified name id")));
return false; // ### recover
}
} break;
./
ElementList: AssignmentExpression ;
......
This diff is collapsed.
......@@ -228,19 +228,11 @@ public:
virtual BinaryExpression *binaryExpressionCast();
virtual Statement *statementCast();
inline void accept(Visitor *visitor)
{
if (visitor->preVisit(this)) {
accept0(visitor);
visitor->postVisit(this);
}
}
void accept(Visitor *visitor);
static void accept(Node *node, Visitor *visitor);
static void acceptChild(Node *node, Visitor *visitor)
{
if (node)
node->accept(visitor);
}
inline static void acceptChild(Node *node, Visitor *visitor)
{ return accept(node, visitor); } // ### remove
virtual void accept0(Visitor *visitor) = 0;
......@@ -2291,6 +2283,12 @@ public:
: fileName(0), importUri(uri), importId(0)
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
{ return importToken; }
virtual SourceLocation lastSourceLocation() const
{ return semicolonToken; }
virtual void accept0(Visitor *visitor);
// attributes
......@@ -2323,6 +2321,21 @@ public:
previous->next = this;
}
virtual SourceLocation firstSourceLocation() const
{
if (import) return import->firstSourceLocation();
else return SourceLocation();
}
virtual SourceLocation lastSourceLocation() const
{
for (const UiImportList *it = this; it; it = it->next)
if (!it->next && it->import)
return it->import->lastSourceLocation();
return SourceLocation();
}
UiImportList *finish()
{
UiImportList *head = next;
......
......@@ -154,15 +154,15 @@ public:
T_XOR = 78,
T_XOR_EQ = 79,
ACCEPT_STATE = 638,
RULE_COUNT = 350,
STATE_COUNT = 639,
ACCEPT_STATE = 612,
RULE_COUNT = 334,
STATE_COUNT = 613,
TERMINAL_COUNT = 95,
NON_TERMINAL_COUNT = 106,
NON_TERMINAL_COUNT = 105,
GOTO_INDEX_OFFSET = 639,
GOTO_INFO_OFFSET = 2310,
GOTO_CHECK_OFFSET = 2310
GOTO_INDEX_OFFSET = 613,
GOTO_INFO_OFFSET = 2434,
GOTO_CHECK_OFFSET = 2434
};
static const char *const spell [];
......
......@@ -222,9 +222,9 @@ protected:
#define J_SCRIPT_REGEXPLITERAL_RULE1 81
#define J_SCRIPT_REGEXPLITERAL_RULE1 66
#define J_SCRIPT_REGEXPLITERAL_RULE2 82
#define J_SCRIPT_REGEXPLITERAL_RULE2 67
QT_END_NAMESPACE
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMLJSPRETTYPRETTY_P_H
#define QMLJSPRETTYPRETTY_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
#include "qmljsastvisitor_p.h"
QT_BEGIN_NAMESPACE
class QTextStream;
namespace QmlJS {
class PrettyPretty: protected AST::Visitor
{
public:
PrettyPretty(QTextStream &out);
virtual ~PrettyPretty();
QTextStream &operator () (AST::Node *node, int level = 0);
protected:
void accept(AST::Node *node);
virtual bool preVisit(AST::Node *node);
virtual bool visit(AST::ThisExpression *node);
virtual void endVisit(AST::ThisExpression *node);
virtual bool visit(AST::IdentifierExpression *node);
virtual void endVisit(AST::IdentifierExpression *node);
virtual bool visit(AST::NullExpression *node);
virtual void endVisit(AST::NullExpression *node);
virtual bool visit(AST::TrueLiteral *node);
virtual void endVisit(AST::TrueLiteral *node);
virtual bool visit(AST::FalseLiteral *node);
virtual void endVisit(AST::FalseLiteral *node);
virtual bool visit(AST::StringLiteral *node);
virtual void endVisit(AST::StringLiteral *node);
virtual bool visit(AST::NumericLiteral *node);
virtual void endVisit(AST::NumericLiteral *node);
virtual bool visit(AST::RegExpLiteral *node);
virtual void endVisit(AST::RegExpLiteral *node);
virtual bool visit(AST::ArrayLiteral *node);
virtual void endVisit(AST::ArrayLiteral *node);
virtual bool visit(AST::ObjectLiteral *node);
virtual void endVisit(AST::ObjectLiteral *node);
virtual bool visit(AST::ElementList *node);
virtual void endVisit(AST::ElementList *node);
virtual bool visit(AST::Elision *node);
virtual void endVisit(AST::Elision *node);
virtual bool visit(AST::PropertyNameAndValueList *node);
virtual void endVisit(AST::PropertyNameAndValueList *node);
virtual bool visit(AST::IdentifierPropertyName *node);
virtual void endVisit(AST::IdentifierPropertyName *node);
virtual bool visit(AST::StringLiteralPropertyName *node);
virtual void endVisit(AST::StringLiteralPropertyName *node);
virtual bool visit(AST::NumericLiteralPropertyName *node);
virtual void endVisit(AST::NumericLiteralPropertyName *node);
virtual bool visit(AST::ArrayMemberExpression *node);
virtual void endVisit(AST::ArrayMemberExpression *node);
virtual bool visit(AST::FieldMemberExpression *node);
virtual void endVisit(AST::FieldMemberExpression *node);
virtual bool visit(AST::NewMemberExpression *node);
virtual void endVisit(AST::NewMemberExpression *node);
virtual bool visit(AST::NewExpression *node);
virtual void endVisit(AST::NewExpression *node);
virtual bool visit(AST::CallExpression *node);
virtual void endVisit(AST::CallExpression *node);
virtual bool visit(AST::ArgumentList *node);
virtual void endVisit(AST::ArgumentList *node);
virtual bool visit(AST::PostIncrementExpression *node);
virtual void endVisit(AST::PostIncrementExpression *node);