Commit d72bddc7 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Update to new QmlJS parser.

UiPublicMember is now initialized with a statement.
parent f8bcd6c6
#!/usr/bin/python
import sys
import os
if not len(sys.argv) >= 3:
print("Usage: %s license files..." % os.path.basename(sys.argv[0]))
sys.exit()
licenseFileName = sys.argv[1]
licenseText = ""
with open(licenseFileName, 'r') as f:
licenseText = f.read()
licenseText = licenseText[0:licenseText.find('*/')]
files = sys.argv[2:]
for fileName in files:
with open(fileName, 'r') as f:
text = f.read()
oldEnd = text.find('*/')
if oldEnd == -1:
oldEnd = 0
text = licenseText + text[oldEnd:]
with open(fileName, 'w') as f:
f.write(text)
......@@ -12,3 +12,7 @@ done
# export QmlDirParser
perl -p -0777 -i -e 's/QT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlDirParser/#include "qmljsglobal_p.h"\n\nQT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QML_PARSER_EXPORT QmlDirParser/' qmldirparser_p.h
./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h}
echo "Fix licenses in qmljs.g!"
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -132,7 +133,7 @@ bool QmlDirParser::parse()
} else if (sections[0] == QLatin1String("plugin")) {
if (sectionCount < 2) {
reportError(lineNumber, -1,
QString::fromUtf8("plugin directive requires 2 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;
}
......@@ -144,12 +145,22 @@ bool QmlDirParser::parse()
} else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) {
reportError(lineNumber, -1,
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;
}
Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.append(entry);
} else if (sections[0] == QLatin1String("typeinfo")) {
if (sectionCount != 2) {
reportError(lineNumber, -1,
QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
continue;
}
#ifdef QT_CREATOR
TypeInfo typeInfo(sections[1]);
_typeInfos.append(typeInfo);
#endif
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
......@@ -179,7 +190,7 @@ bool QmlDirParser::parse()
}
} else {
reportError(lineNumber, -1,
QString::fromUtf8("a component declaration requires 3 arguments, but %1 were provided").arg(sectionCount + 1));
QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
}
}
......@@ -219,4 +230,11 @@ QList<QmlDirParser::Component> QmlDirParser::components() const
return _components;
}
#ifdef QT_CREATOR
QList<QmlDirParser::TypeInfo> QmlDirParser::typeInfos() const
{
return _typeInfos;
}
#endif
QT_END_NAMESPACE
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -101,6 +102,19 @@ public:
QList<Component> components() const;
QList<Plugin> plugins() const;
#ifdef QT_CREATOR
struct TypeInfo
{
TypeInfo() {}
TypeInfo(const QString &fileName)
: fileName(fileName) {}
QString fileName;
};
QList<TypeInfo> typeInfos() const;
#endif
private:
void reportError(int line, int column, const QString &message);
......@@ -110,6 +124,9 @@ private:
QString _source;
QList<Component> _components;
QList<Plugin> _plugins;
#ifdef QT_CREATOR
QList<TypeInfo> _typeInfos;
#endif
unsigned _isParsed: 1;
};
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
--
-- Contact: Nokia Corporation (info@qt.nokia.com)
--
--
-- GNU Lesser General Public License Usage
--
-- This file may be used under the terms of the GNU Lesser General Public
......@@ -97,6 +98,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -120,7 +122,6 @@
**
**************************************************************************/
#include <QtCore/QtDebug>
#include <QtGui/QApplication>
......@@ -141,6 +142,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -165,7 +167,6 @@
**************************************************************************/
//
// W A R N I N G
// -------------
......@@ -772,19 +773,14 @@ case $rule_number: {
} break;
./
UiObjectMember: UiQualifiedId T_COLON Block ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
UiScriptStatement: Block ;
UiScriptStatement: EmptyStatement ;
UiScriptStatement: ExpressionStatement ;
UiScriptStatement: IfStatement ; --- ### do we really want if statement in a binding?
UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
/.
case $rule_number:
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId, sym(3).Statement);
......@@ -912,51 +908,45 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
sym(5).Expression);
sym(5).Statement);
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->colonToken = loc(4);
node->semicolonToken = loc(6);
sym(1).Node = node;
} break;
./
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).Expression);
sym(6).Statement);
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
node->semicolonToken = loc(7);
sym(1).Node = node;
} break;
./
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).Expression);
sym(6).Statement);
node->isDefaultMember = true;
node->defaultToken = loc(1);
node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
node->semicolonToken = loc(7);
sym(1).Node = node;
} break;
./
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -826,7 +827,7 @@ void UiFormal::accept0(Visitor *visitor)
void UiPublicMember::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
accept(statement, visitor);
accept(binding, visitor);
}
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -2332,13 +2333,13 @@ public:
UiPublicMember(NameId *memberType,
NameId *name)
: type(Property), typeModifier(0), memberType(memberType), name(name), expression(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
: type(Property), typeModifier(0), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
UiPublicMember(NameId *memberType,
NameId *name,
ExpressionNode *expression)
: type(Property), typeModifier(0), memberType(memberType), name(name), expression(expression), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
Statement *statement)
: type(Property), typeModifier(0), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
......@@ -2366,7 +2367,7 @@ public:
NameId *typeModifier;
NameId *memberType;
NameId *name;
ExpressionNode *expression; // initialized with a JS expression
Statement *statement; // initialized with a JS expression
UiObjectMember *binding; // initialized with a QML object or array.
bool isDefaultMember;
bool isReadonlyMember;
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -78,12 +79,6 @@ uint qHash(const QmlJS::NameId &id);
} // end of namespace QmlJS
#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
//this ensures that code outside QmlJS can use the hash function
//it also a workaround for some compilers
inline uint qHash(const QmlJS::NameId &nameId) { return QmlJS::qHash(nameId); }
#endif
namespace QmlJS {
class Lexer;
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -28,7 +29,6 @@
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef QMLJSGLOBAL_P_H
#define QMLJSGLOBAL_P_H
......@@ -49,7 +49,7 @@
#else // !QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
# define QML_PARSER_EXPORT
# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT
#endif // QT_CREATOR
#endif // QMLJSGLOBAL_P_H
This diff is collapsed.
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -154,15 +155,15 @@ public:
T_XOR = 79,
T_XOR_EQ = 80,
ACCEPT_STATE = 645,
RULE_COUNT = 347,
STATE_COUNT = 646,
ACCEPT_STATE = 640,
RULE_COUNT = 345,
STATE_COUNT = 641,
TERMINAL_COUNT = 101,
NON_TERMINAL_COUNT = 106,
NON_TERMINAL_COUNT = 107,
GOTO_INDEX_OFFSET = 646,
GOTO_INFO_OFFSET = 2714,
GOTO_CHECK_OFFSET = 2714
GOTO_INDEX_OFFSET = 641,
GOTO_INFO_OFFSET = 2787,
GOTO_CHECK_OFFSET = 2787
};
static const char *const spell [];
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment