src/declarative/qml/parser/qdeclarativejslexer.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   118     delete [] buffer16;
   118     delete [] buffer16;
   119 }
   119 }
   120 
   120 
   121 void Lexer::setCode(const QString &c, int lineno)
   121 void Lexer::setCode(const QString &c, int lineno)
   122 {
   122 {
   123     errmsg = QString();
   123     errmsg.clear();
   124     yylineno = lineno;
   124     yylineno = lineno;
   125     yycolumn = 1;
   125     yycolumn = 1;
   126     restrKeyword = false;
   126     restrKeyword = false;
   127     delimited = false;
   127     delimited = false;
   128     stackToken = -1;
   128     stackToken = -1;
   675                 if (restrKeyword) {
   675                 if (restrKeyword) {
   676                     token = QDeclarativeJSGrammar::T_SEMICOLON;
   676                     token = QDeclarativeJSGrammar::T_SEMICOLON;
   677                     setDone(Other);
   677                     setDone(Other);
   678                 } else
   678                 } else
   679                     state = Start;
   679                     state = Start;
   680                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   680                 if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
   681             } else if (current == 0) {
   681             } else if (current == 0) {
   682                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   682                 if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
   683                 setDone(Eof);
   683                 setDone(Eof);
   684             }
   684             }
   685 
   685 
   686             break;
   686             break;
   687         case InMultiLineComment:
   687         case InMultiLineComment:
   688             if (current == 0) {
   688             if (current == 0) {
   689                 setDone(Bad);
   689                 setDone(Bad);
   690                 err = UnclosedComment;
   690                 err = UnclosedComment;
   691                 errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
   691                 errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
   692                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   692                 if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
   693             } else if (isLineTerminator()) {
   693             } else if (isLineTerminator()) {
   694                 shiftWindowsLineBreak();
   694                 shiftWindowsLineBreak();
   695                 yylineno++;
   695                 yylineno++;
   696             } else if (current == '*' && next1 == '/') {
   696             } else if (current == '*' && next1 == '/') {
   697                 state = Start;
   697                 state = Start;
   698                 shift(1);
   698                 shift(1);
   699                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   699                 if (driver) driver->addComment(startpos+2, tokenLength()-3, startlineno, startcolumn+2);
   700             }
   700             }
   701 
   701 
   702             break;
   702             break;
   703         case InIdentifier:
   703         case InIdentifier:
   704             if (isIdentLetter(current) || isDecimalDigit(current)) {
   704             if (isIdentLetter(current) || isDecimalDigit(current)) {