diff options
Diffstat (limited to 'src/declarative/qml/parser/qmljslexer.cpp')
-rw-r--r-- | src/declarative/qml/parser/qmljslexer.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
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)) { |