summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/parser
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2009-06-10 10:02:29 (GMT)
committerErik Verbruggen <erik.verbruggen@nokia.com>2009-06-10 10:02:29 (GMT)
commitc0bbe44ab6290dee088138c01724779026d2c033 (patch)
treef6344fcf5fc9cd5fe58754afbac3c68c3438d33a /src/declarative/qml/parser
parentbf750d1df7e1474ffddc547205f7f20520559ea7 (diff)
downloadQt-c0bbe44ab6290dee088138c01724779026d2c033.zip
Qt-c0bbe44ab6290dee088138c01724779026d2c033.tar.gz
Qt-c0bbe44ab6290dee088138c01724779026d2c033.tar.bz2
Changed the QML parser and the AST to store the position of comma tokens
of QML arrays. Also exposed these positions through the QML DOM.
Diffstat (limited to 'src/declarative/qml/parser')
-rw-r--r--src/declarative/qml/parser/javascript.g9
-rw-r--r--src/declarative/qml/parser/javascriptast.cpp12
-rw-r--r--src/declarative/qml/parser/javascriptast_p.h37
-rw-r--r--src/declarative/qml/parser/javascriptastfwd_p.h1
-rw-r--r--src/declarative/qml/parser/javascriptastvisitor_p.h2
-rw-r--r--src/declarative/qml/parser/javascriptparser.cpp9
-rw-r--r--src/declarative/qml/parser/javascriptparser_p.h1
7 files changed, 60 insertions, 11 deletions
diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/javascript.g
index 8cabeea..884d814 100644
--- a/src/declarative/qml/parser/javascript.g
+++ b/src/declarative/qml/parser/javascript.g
@@ -568,15 +568,16 @@ case $rule_number: {
UiArrayMemberList: UiObjectDefinition ;
/.
case $rule_number: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+ sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
} break;
./
UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
/.
case $rule_number: {
- AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
- sym(1).UiObjectMemberList, sym(3).UiObjectMember);
+ AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
sym(1).Node = node;
} break;
./
@@ -616,7 +617,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).UiObjectMemberList->finish());
+ sym(4).UiArrayMemberList->finish());
node->colonToken = loc(2);
node->lbracketToken = loc(3);
node->rbracketToken = loc(5);
diff --git a/src/declarative/qml/parser/javascriptast.cpp b/src/declarative/qml/parser/javascriptast.cpp
index 130229b..ada19d5 100644
--- a/src/declarative/qml/parser/javascriptast.cpp
+++ b/src/declarative/qml/parser/javascriptast.cpp
@@ -893,7 +893,7 @@ void UiArrayBinding::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(qualifiedId, visitor);
- for (UiObjectMemberList *it = members; it; it = it->next)
+ for (UiArrayMemberList *it = members; it; it = it->next)
acceptChild(it->member, visitor);
}
@@ -910,6 +910,16 @@ void UiObjectMemberList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+void UiArrayMemberList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiArrayMemberList *it = this; it; it = it->next)
+ acceptChild(it->member, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
void UiQualifiedId::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
diff --git a/src/declarative/qml/parser/javascriptast_p.h b/src/declarative/qml/parser/javascriptast_p.h
index 23d59e5..8c1e2bc 100644
--- a/src/declarative/qml/parser/javascriptast_p.h
+++ b/src/declarative/qml/parser/javascriptast_p.h
@@ -207,6 +207,7 @@ public:
Kind_UiObjectDefinition,
Kind_UiObjectInitializer,
Kind_UiObjectMemberList,
+ Kind_UiArrayMemberList,
Kind_UiProgram,
Kind_UiPublicMember,
Kind_UiQualifiedId,
@@ -2301,6 +2302,38 @@ public:
UiObjectMember *member;
};
+class UiArrayMemberList: public Node
+{
+public:
+ JAVASCRIPT_DECLARE_AST_NODE(UiArrayMemberList)
+
+ UiArrayMemberList(UiObjectMember *member)
+ : next(this), member(member)
+ { kind = K; }
+
+ UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
+ : member(member)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ UiArrayMemberList *finish()
+ {
+ UiArrayMemberList *head = next;
+ next = 0;
+ return head;
+ }
+
+// attributes
+ UiArrayMemberList *next;
+ UiObjectMember *member;
+ SourceLocation commaToken;
+};
+
class UiObjectInitializer: public Node
{
public:
@@ -2481,7 +2514,7 @@ public:
JAVASCRIPT_DECLARE_AST_NODE(UiArrayBinding)
UiArrayBinding(UiQualifiedId *qualifiedId,
- UiObjectMemberList *members)
+ UiArrayMemberList *members)
: qualifiedId(qualifiedId),
members(members)
{ kind = K; }
@@ -2496,7 +2529,7 @@ public:
// attributes
UiQualifiedId *qualifiedId;
- UiObjectMemberList *members;
+ UiArrayMemberList *members;
SourceLocation colonToken;
SourceLocation lbracketToken;
SourceLocation rbracketToken;
diff --git a/src/declarative/qml/parser/javascriptastfwd_p.h b/src/declarative/qml/parser/javascriptastfwd_p.h
index 822a2d7..23270e5 100644
--- a/src/declarative/qml/parser/javascriptastfwd_p.h
+++ b/src/declarative/qml/parser/javascriptastfwd_p.h
@@ -174,6 +174,7 @@ class UiSourceElement;
class UiArrayBinding;
class UiObjectMember;
class UiObjectMemberList;
+class UiArrayMemberList;
class UiQualifiedId;
} } // namespace AST
diff --git a/src/declarative/qml/parser/javascriptastvisitor_p.h b/src/declarative/qml/parser/javascriptastvisitor_p.h
index 81df364..7c73e43 100644
--- a/src/declarative/qml/parser/javascriptastvisitor_p.h
+++ b/src/declarative/qml/parser/javascriptastvisitor_p.h
@@ -80,6 +80,7 @@ public:
virtual bool visit(UiScriptBinding *) { return true; }
virtual bool visit(UiArrayBinding *) { return true; }
virtual bool visit(UiObjectMemberList *) { return true; }
+ virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
virtual void endVisit(UiProgram *) {}
@@ -93,6 +94,7 @@ public:
virtual void endVisit(UiScriptBinding *) {}
virtual void endVisit(UiArrayBinding *) {}
virtual void endVisit(UiObjectMemberList *) {}
+ virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
// JavaScript
diff --git a/src/declarative/qml/parser/javascriptparser.cpp b/src/declarative/qml/parser/javascriptparser.cpp
index 34ecd0e..bbffc4f 100644
--- a/src/declarative/qml/parser/javascriptparser.cpp
+++ b/src/declarative/qml/parser/javascriptparser.cpp
@@ -239,12 +239,13 @@ case 10: {
} break;
case 11: {
- sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
+ sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
} break;
case 12: {
- AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
- sym(1).UiObjectMemberList, sym(3).UiObjectMember);
+ AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
sym(1).Node = node;
} break;
@@ -270,7 +271,7 @@ case 15: {
case 17: {
AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
- sym(4).UiObjectMemberList->finish());
+ sym(4).UiArrayMemberList->finish());
node->colonToken = loc(2);
node->lbracketToken = loc(3);
node->rbracketToken = loc(5);
diff --git a/src/declarative/qml/parser/javascriptparser_p.h b/src/declarative/qml/parser/javascriptparser_p.h
index 2ae4c34..b6a2432 100644
--- a/src/declarative/qml/parser/javascriptparser_p.h
+++ b/src/declarative/qml/parser/javascriptparser_p.h
@@ -117,6 +117,7 @@ public:
AST::UiArrayBinding *UiArrayBinding;
AST::UiObjectMember *UiObjectMember;
AST::UiObjectMemberList *UiObjectMemberList;
+ AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
};