summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-08 22:46:10 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-08 22:46:10 (GMT)
commitd29c604b0365dfbc20f8aea8d2cb63f621995219 (patch)
tree511904026a961cadf5e7e13ff90b7e9baad1efbf /src/declarative/qml
parentcce03d9a3c95dd81c31003e0a96c5bb3dca6f0c0 (diff)
parent7731e5f7d33d3ec251299c7651e777d7e0054573 (diff)
downloadQt-d29c604b0365dfbc20f8aea8d2cb63f621995219.zip
Qt-d29c604b0365dfbc20f8aea8d2cb63f621995219.tar.gz
Qt-d29c604b0365dfbc20f8aea8d2cb63f621995219.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/parser/qmljs.g1
-rw-r--r--src/declarative/qml/parser/qmljsastfwd_p.h4
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.cpp6
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.h4
-rw-r--r--src/declarative/qml/parser/qmljslexer.cpp16
-rw-r--r--src/declarative/qml/parser/qmljslexer_p.h3
-rw-r--r--src/declarative/qml/qmetaobjectbuilder_p.h8
7 files changed, 32 insertions, 10 deletions
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
index b0ef866..4ed75e8 100644
--- a/src/declarative/qml/parser/qmljs.g
+++ b/src/declarative/qml/parser/qmljs.g
@@ -80,6 +80,7 @@
%token T_DEBUGGER "debugger"
%token T_RESERVED_WORD "reserved word"
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
+%token T_COMMENT "comment"
--- context keywords.
%token T_PUBLIC "public"
diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h
index f79cfc2..a6fee1d 100644
--- a/src/declarative/qml/parser/qmljsastfwd_p.h
+++ b/src/declarative/qml/parser/qmljsastfwd_p.h
@@ -62,9 +62,9 @@ namespace QmlJS { namespace AST {
class SourceLocation
{
public:
- SourceLocation(quint32 offset = 0, quint32 length = 0)
+ SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
: offset(offset), length(length),
- startLine(0), startColumn(0)
+ startLine(line), startColumn(column)
{ }
bool isValid() const { return length != 0; }
diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp
index 02d9b9c..eab8944 100644
--- a/src/declarative/qml/parser/qmljsengine_p.cpp
+++ b/src/declarative/qml/parser/qmljsengine_p.cpp
@@ -178,6 +178,12 @@ Engine::~Engine()
QSet<NameId> Engine::literals() const
{ return _literals; }
+void Engine::addComment(int pos, int len, int line, int col)
+{ if (len > 0) _comments.append(QmlJS::AST::SourceLocation(pos, len, line, col)); }
+
+QList<QmlJS::AST::SourceLocation> Engine::comments() const
+{ return _comments; }
+
NameId *Engine::intern(const QChar *u, int s)
{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h
index 5aea983..877fff2 100644
--- a/src/declarative/qml/parser/qmljsengine_p.h
+++ b/src/declarative/qml/parser/qmljsengine_p.h
@@ -143,6 +143,7 @@ class Engine
Lexer *_lexer;
NodePool *_nodePool;
QSet<NameId> _literals;
+ QList<QmlJS::AST::SourceLocation> _comments;
public:
Engine();
@@ -150,6 +151,9 @@ public:
QSet<NameId> literals() const;
+ void addComment(int pos, int len, int line, int col);
+ QList<QmlJS::AST::SourceLocation> comments() const;
+
NameId *intern(const QChar *u, int s);
static QString toString(NameId *id);
diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp
index 9da6ec0..3be1710 100644
--- a/src/declarative/qml/parser/qmljslexer.cpp
+++ b/src/declarative/qml/parser/qmljslexer.cpp
@@ -43,6 +43,8 @@
#include "config.h"
#endif
+#include <QDebug>
+
#include "qmljsengine_p.h"
#include "qmljslexer_p.h"
#include "qmljsgrammar_p.h"
@@ -71,7 +73,7 @@ extern double integerFromString(const char *buf, int size, int radix);
using namespace QmlJS;
-Lexer::Lexer(Engine *eng)
+Lexer::Lexer(Engine *eng, bool tokenizeComments)
: driver(eng),
yylineno(0),
done(false),
@@ -94,8 +96,9 @@ Lexer::Lexer(Engine *eng)
check_reserved(true),
parenthesesState(IgnoreParentheses),
parenthesesCount(0),
- prohibitAutomaticSemicolon(false)
-{
+ prohibitAutomaticSemicolon(false),
+ tokenizeComments(tokenizeComments)
+{qDebug()<<"--- new lexer";
driver->setLexer(this);
// allocate space for read buffers
buffer8 = new char[size8];
@@ -647,22 +650,29 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
+ qDebug() << "--- state is InSingleLineComment @" << startlineno << ":"<<startcolumn;
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (current == 0) {
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
setDone(Eof);
}
+
break;
case InMultiLineComment:
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
errmsg = QLatin1String("Unclosed comment at end of file");
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
}
+
break;
case InIdentifier:
if (isIdentLetter(current) || isDecimalDigit(current)) {
diff --git a/src/declarative/qml/parser/qmljslexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h
index 5817868..6cca45d 100644
--- a/src/declarative/qml/parser/qmljslexer_p.h
+++ b/src/declarative/qml/parser/qmljslexer_p.h
@@ -67,7 +67,7 @@ class NameId;
class Lexer
{
public:
- Lexer(Engine *eng);
+ Lexer(Engine *eng, bool tokenizeComments = false);
~Lexer();
void setCode(const QString &c, int lineno);
@@ -239,6 +239,7 @@ private:
ParenthesesState parenthesesState;
int parenthesesCount;
bool prohibitAutomaticSemicolon;
+ bool tokenizeComments;
};
} // namespace QmlJS
diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h
index d503163..c0b7426 100644
--- a/src/declarative/qml/qmetaobjectbuilder_p.h
+++ b/src/declarative/qml/qmetaobjectbuilder_p.h
@@ -68,7 +68,7 @@ class QMetaPropertyBuilderPrivate;
class QMetaEnumBuilder;
class QMetaEnumBuilderPrivate;
-class Q_CORE_EXPORT QMetaObjectBuilder
+class Q_DECLARATIVE_EXPORT QMetaObjectBuilder
{
public:
enum AddMember
@@ -189,7 +189,7 @@ private:
friend class QMetaEnumBuilder;
};
-class Q_CORE_EXPORT QMetaMethodBuilder
+class Q_DECLARATIVE_EXPORT QMetaMethodBuilder
{
public:
QMetaMethodBuilder() : _mobj(0), _index(0) {}
@@ -227,7 +227,7 @@ private:
QMetaMethodBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaPropertyBuilder
+class Q_DECLARATIVE_EXPORT QMetaPropertyBuilder
{
public:
QMetaPropertyBuilder() : _mobj(0), _index(0) {}
@@ -278,7 +278,7 @@ private:
QMetaPropertyBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaEnumBuilder
+class Q_DECLARATIVE_EXPORT QMetaEnumBuilder
{
public:
QMetaEnumBuilder() : _mobj(0), _index(0) {}