Commit 67dd062a authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Merge new parser from Qt 5.



Change-Id: I986df52b7ddb31e3bae1148eda881acc1829b102
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 72c06cb6
......@@ -15,7 +15,7 @@ perl -p -0777 -i -e 's/QT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlDirParser
# export QmlJSGrammar
perl -p -0777 -i -e 's/#include <QtCore\/qglobal.h>\n\nQT_BEGIN_NAMESPACE\n\nclass QmlJSGrammar\n/#include "qmljsglobal_p.h"\n#include <QtCore\/qglobal.h>\n\nQT_BEGIN_NAMESPACE\n\nclass QML_PARSER_EXPORT QmlJSGrammar\n/' qmljsgrammar_p.h
# replace qmlglobal_p.h include with needed declaration
perl -p -0777 -i -e 's/#include \<qmlglobal_p.h\>/bool Qml_isFileCaseCorrect(const QString &) { return true; }/' qmldirparser.cpp
perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"/bool Qml_isFileCaseCorrect(const QString &) { return true; }/' qmldirparser.cpp
./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h}
......
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qmljsast_p.h \
$$PWD/qmljsastfwd_p.h \
......
......@@ -177,7 +177,7 @@ bool QmlDirParser::parse()
QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
Component entry(sections[1].toUtf8(), sections[2], -1, -1);
Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.append(entry);
} else if (sections[0] == QLatin1String("typeinfo")) {
......@@ -193,7 +193,7 @@ bool QmlDirParser::parse()
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
const Component entry(sections[0].toUtf8(), sections[1], -1, -1);
const Component entry(sections[0], sections[1], -1, -1);
_components.append(entry);
} else if (sectionCount == 3) {
const QString &version = sections[1];
......@@ -211,7 +211,7 @@ bool QmlDirParser::parse()
const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
if (validVersionNumber) {
const Component entry(sections[0].toUtf8(), sections[2], majorVersion, minorVersion);
const Component entry(sections[0], sections[2], majorVersion, minorVersion);
_components.append(entry);
}
......
......@@ -91,11 +91,11 @@ public:
Component()
: majorVersion(0), minorVersion(0), internal(false) {}
Component(const QByteArray &typeName, const QString &fileName, int majorVersion, int minorVersion)
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
: typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
internal(false) {}
QByteArray typeName;
QString typeName;
QString fileName;
int majorVersion;
int minorVersion;
......
......@@ -246,9 +246,6 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
AST::UiSignature *UiSignature;
AST::UiFormalList *UiFormalList;
AST::UiFormal *UiFormal;
};
public:
......@@ -781,7 +778,10 @@ case $rule_number: {
UiScriptStatement: Block ;
UiScriptStatement: EmptyStatement ;
UiScriptStatement: ExpressionStatement ;
UiScriptStatement: IfStatement ; --- ### do we really want if statement in a binding?
UiScriptStatement: IfStatement ;
UiScriptStatement: WithStatement ;
UiScriptStatement: SwitchStatement ;
UiScriptStatement: TryStatement ;
UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
/.
......@@ -816,6 +816,7 @@ UiParameterList: UiPropertyType JsIdentifier ;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
node->propertyTypeToken = loc(1);
node->identifierToken = loc(2);
sym(1).Node = node;
} break;
......@@ -1100,6 +1101,7 @@ case $rule_number: {
}
loc(1).length = lexer->tokenLength();
yylloc = loc(1); // adjust the location of the current token
AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
......@@ -1121,6 +1123,7 @@ case $rule_number: {
}
loc(1).length = lexer->tokenLength();
yylloc = loc(1); // adjust the location of the current token
AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
......@@ -2810,6 +2813,8 @@ case $rule_number: {
} break;
./
Program: Empty ;
Program: SourceElements ;
/.
case $rule_number: {
......
......@@ -799,31 +799,6 @@ void UiProgram::accept0(Visitor *visitor)
visitor->endVisit(this);
}
void UiSignature::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
accept(formals, visitor);
}
visitor->endVisit(this);
}
void UiFormalList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
for (UiFormalList *it = this; it; it = it->next) {
accept(it->formal, visitor);
}
}
visitor->endVisit(this);
}
void UiFormal::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void UiPublicMember::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
......
This diff is collapsed.
......@@ -169,9 +169,6 @@ class UiObjectMember;
class UiObjectMemberList;
class UiArrayMemberList;
class UiQualifiedId;
class UiFormalList;
class UiFormal;
class UiSignature;
} } // namespace AST
......
......@@ -74,9 +74,6 @@ public:
virtual bool visit(UiObjectMemberList *) { return true; }
virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
virtual bool visit(UiSignature *) { return true; }
virtual bool visit(UiFormalList *) { return true; }
virtual bool visit(UiFormal *) { return true; }
virtual void endVisit(UiProgram *) {}
virtual void endVisit(UiImportList *) {}
......@@ -91,9 +88,6 @@ public:
virtual void endVisit(UiObjectMemberList *) {}
virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
virtual void endVisit(UiSignature *) {}
virtual void endVisit(UiFormalList *) {}
virtual void endVisit(UiFormal *) {}
// QmlJS
virtual bool visit(ThisExpression *) { return true; }
......
......@@ -49,7 +49,12 @@
#else // !QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT
# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB)
// QmlDevTools is a static library
# define QML_PARSER_EXPORT
# else
# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT
# endif
#endif // QT_CREATOR
#endif // QMLJSGLOBAL_P_H
This diff is collapsed.
......@@ -157,15 +157,15 @@ public:
T_XOR = 79,
T_XOR_EQ = 80,
ACCEPT_STATE = 640,
RULE_COUNT = 345,
STATE_COUNT = 641,
ACCEPT_STATE = 644,
RULE_COUNT = 349,
STATE_COUNT = 645,
TERMINAL_COUNT = 102,
NON_TERMINAL_COUNT = 107,
GOTO_INDEX_OFFSET = 641,
GOTO_INFO_OFFSET = 2818,
GOTO_CHECK_OFFSET = 2818
GOTO_INDEX_OFFSET = 645,
GOTO_INFO_OFFSET = 2807,
GOTO_CHECK_OFFSET = 2807
};
static const char *const spell [];
......
......@@ -97,13 +97,18 @@ Lexer::Lexer(Engine *engine)
, _restrictedKeyword(false)
, _terminator(false)
, _followsClosingBrace(false)
, _delimited(false)
, _delimited(true)
, _qmlMode(true)
{
if (engine)
engine->setLexer(this);
}
bool Lexer::qmlMode() const
{
return _qmlMode;
}
QString Lexer::code() const
{
return _code;
......@@ -147,7 +152,7 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
_restrictedKeyword = false;
_terminator = false;
_followsClosingBrace = false;
_delimited = false;
_delimited = true;
}
void Lexer::scanChar()
......@@ -176,6 +181,7 @@ int Lexer::lex()
switch (_tokenKind) {
case T_LBRACE:
case T_SEMICOLON:
case T_COLON:
_delimited = true;
break;
......
......@@ -136,6 +136,8 @@ public:
public:
Lexer(Engine *engine);
bool qmlMode() const;
QString code() const;
void setCode(const QString &code, int lineno, bool qmlMode = true);
......@@ -174,12 +176,13 @@ public:
BalancedParentheses
};
protected:
int classify(const QChar *s, int n, bool qmlMode);
private:
inline void scanChar();
int scanToken();
int classify(const QChar *s, int n, bool qmlMode);
bool isLineTerminator() const;
static bool isIdentLetter(QChar c);
static bool isDecimalDigit(ushort c);
......
This diff is collapsed.
......@@ -108,9 +108,6 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
AST::UiSignature *UiSignature;
AST::UiFormalList *UiFormalList;
AST::UiFormal *UiFormal;
};
public:
......@@ -231,9 +228,9 @@ protected:
#define J_SCRIPT_REGEXPLITERAL_RULE1 76
#define J_SCRIPT_REGEXPLITERAL_RULE1 79
#define J_SCRIPT_REGEXPLITERAL_RULE2 77
#define J_SCRIPT_REGEXPLITERAL_RULE2 80
QT_QML_END_NAMESPACE
......
......@@ -212,21 +212,6 @@ bool Evaluate::visit(AST::UiQualifiedId *ast)
return false;
}
bool Evaluate::visit(AST::UiSignature *)
{
return false;
}
bool Evaluate::visit(AST::UiFormalList *)
{
return false;
}
bool Evaluate::visit(AST::UiFormal *)
{
return false;
}
bool Evaluate::visit(AST::ThisExpression *)
{
return false;
......
......@@ -79,9 +79,6 @@ protected:
virtual bool visit(AST::UiObjectMemberList *ast);
virtual bool visit(AST::UiArrayMemberList *ast);
virtual bool visit(AST::UiQualifiedId *ast);
virtual bool visit(AST::UiSignature *ast);
virtual bool visit(AST::UiFormalList *ast);
virtual bool visit(AST::UiFormal *ast);
// QmlJS
virtual bool visit(AST::ThisExpression *ast);
......
......@@ -238,9 +238,6 @@ protected: // visiting methods:
return false;
}
virtual bool visit(UiFormal *ast) { terminal(ast->identifierToken); terminal(ast->asToken); terminal(ast->aliasToken); return false; }
virtual bool visit(UiSignature *ast) { terminal(ast->lparenToken); nonterminal(ast->formals); terminal(ast->rparenToken); return false; }
virtual bool visit(StringLiteral *ast) { terminal(ast->literalToken); return false; }
virtual bool visit(NumericLiteral *ast) { terminal(ast->literalToken); return false; }
virtual bool visit(TrueLiteral *ast) { terminal(ast->trueToken); return false; }
......
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