Commit 9be3ab0f authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Copied in a new version of the QML parser from Qt Kinetic.

parent df9e5027
......@@ -89,6 +89,7 @@
--- feed tokens
%token T_FEED_UI_PROGRAM
%token T_FEED_UI_OBJECT_MEMBER
%token T_FEED_JS_STATEMENT
%token T_FEED_JS_EXPRESSION
......@@ -285,6 +286,7 @@ public:
bool parse() { return parse(T_FEED_UI_PROGRAM); }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
AST::UiProgram *ast() const
{ return AST::cast<AST::UiProgram *>(program); }
......@@ -305,6 +307,14 @@ public:
return program->expressionCast();
}
AST::UiObjectMember *uiObjectMember() const
{
if (! program)
return 0;
return program->uiObjectMemberCast();
}
QList<DiagnosticMessage> diagnosticMessages() const
{ return diagnostic_messages; }
......@@ -550,6 +560,14 @@ case $rule_number: {
} break;
./
TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
program = sym(1).Node;
} break;
./
UiProgram: UiImportListOpt UiRootMember ;
/.
case $rule_number: {
......@@ -850,6 +868,21 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
node->typeModifier = sym(2).sval;
node->propertyToken = loc(1);
node->typeModifierToken = loc(2);
node->typeToken = loc(4);
node->identifierToken = loc(6);
node->semicolonToken = loc(7);
sym(1).Node = node;
} break;
./
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
/.
......
......@@ -75,6 +75,11 @@ Statement *Node::statementCast()
return 0;
}
UiObjectMember *Node::uiObjectMemberCast()
{
return 0;
}
ExpressionNode *ExpressionNode::expressionCast()
{
return this;
......@@ -90,6 +95,11 @@ Statement *Statement::statementCast()
return this;
}
UiObjectMember *UiObjectMember::uiObjectMemberCast()
{
return this;
}
void NestedExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
......
......@@ -228,6 +228,7 @@ public:
virtual ExpressionNode *expressionCast();
virtual BinaryExpression *binaryExpressionCast();
virtual Statement *statementCast();
virtual UiObjectMember *uiObjectMemberCast();
void accept(Visitor *visitor);
static void accept(Node *node, Visitor *visitor);
......@@ -2356,6 +2357,8 @@ class UiObjectMember: public Node
public:
virtual SourceLocation firstSourceLocation() const = 0;
virtual SourceLocation lastSourceLocation() const = 0;
virtual UiObjectMember *uiObjectMemberCast();
};
class UiObjectMemberList: public Node
......@@ -2481,13 +2484,13 @@ public:
UiPublicMember(NameId *memberType,
NameId *name)
: type(Property), memberType(memberType), name(name), expression(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
: type(Property), typeModifier(0), memberType(memberType), name(name), expression(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
UiPublicMember(NameId *memberType,
NameId *name,
ExpressionNode *expression)
: type(Property), memberType(memberType), name(name), expression(expression), isDefaultMember(false), isReadonlyMember(false), parameters(0)
: type(Property), typeModifier(0), memberType(memberType), name(name), expression(expression), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
......@@ -2509,6 +2512,7 @@ public:
// attributes
enum { Signal, Property } type;
NameId *typeModifier;
NameId *memberType;
NameId *name;
ExpressionNode *expression;
......@@ -2518,6 +2522,7 @@ public:
SourceLocation defaultToken;
SourceLocation readonlyToken;
SourceLocation propertyToken;
SourceLocation typeModifierToken;
SourceLocation typeToken;
SourceLocation identifierToken;
SourceLocation colonToken;
......
......@@ -41,7 +41,7 @@
#include "qmljsastvisitor_p.h"
QT_QML_BEGIN_NAMESPACE
QT_BEGIN_NAMESPACE
namespace QmlJS { namespace AST {
......@@ -55,4 +55,4 @@ Visitor::~Visitor()
} } // namespace QmlJS::AST
QT_QML_END_NAMESPACE
QT_END_NAMESPACE
......@@ -2,6 +2,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
......@@ -21,10 +22,9 @@
** 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.1, included in the file LGPL_EXCEPTION.txt in this
** package.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
......@@ -59,8 +59,8 @@ class QmlJSGrammar
public:
enum {
EOF_SYMBOL = 0,
REDUCE_HERE = 96,
SHIFT_THERE = 95,
REDUCE_HERE = 97,
SHIFT_THERE = 96,
T_AND = 1,
T_AND_AND = 2,
T_AND_EQ = 3,
......@@ -86,8 +86,9 @@ public:
T_EQ_EQ = 18,
T_EQ_EQ_EQ = 19,
T_FALSE = 83,
T_FEED_JS_EXPRESSION = 94,
T_FEED_JS_STATEMENT = 93,
T_FEED_JS_EXPRESSION = 95,
T_FEED_JS_STATEMENT = 94,
T_FEED_UI_OBJECT_MEMBER = 93,
T_FEED_UI_PROGRAM = 92,
T_FINALLY = 20,
T_FOR = 21,
......@@ -156,15 +157,15 @@ public:
T_XOR = 79,
T_XOR_EQ = 80,
ACCEPT_STATE = 621,
RULE_COUNT = 337,
STATE_COUNT = 622,
TERMINAL_COUNT = 97,
ACCEPT_STATE = 630,
RULE_COUNT = 340,
STATE_COUNT = 631,
TERMINAL_COUNT = 98,
NON_TERMINAL_COUNT = 105,
GOTO_INDEX_OFFSET = 622,
GOTO_INFO_OFFSET = 2402,
GOTO_CHECK_OFFSET = 2402
GOTO_INDEX_OFFSET = 631,
GOTO_INFO_OFFSET = 2618,
GOTO_CHECK_OFFSET = 2618
};
static const char *const spell [];
......
......@@ -133,6 +133,7 @@ public:
bool parse() { return parse(T_FEED_UI_PROGRAM); }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
AST::UiProgram *ast() const
{ return AST::cast<AST::UiProgram *>(program); }
......@@ -153,6 +154,14 @@ public:
return program->expressionCast();
}
AST::UiObjectMember *uiObjectMember() const
{
if (! program)
return 0;
return program->uiObjectMemberCast();
}
QList<DiagnosticMessage> diagnosticMessages() const
{ return diagnostic_messages; }
......@@ -222,9 +231,9 @@ protected:
#define J_SCRIPT_REGEXPLITERAL_RULE1 69
#define J_SCRIPT_REGEXPLITERAL_RULE1 72
#define J_SCRIPT_REGEXPLITERAL_RULE2 70
#define J_SCRIPT_REGEXPLITERAL_RULE2 73
QT_QML_END_NAMESPACE
......
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