src/declarative/qml/parser/qdeclarativejslexer.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    55 #include <stdlib.h>
    55 #include <stdlib.h>
    56 #include <stdio.h>
    56 #include <stdio.h>
    57 #include <string.h>
    57 #include <string.h>
    58 
    58 
    59 QT_BEGIN_NAMESPACE
    59 QT_BEGIN_NAMESPACE
    60 Q_DECL_IMPORT extern double qstrtod(const char *s00, char const **se, bool *ok);
    60 Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
    61 QT_END_NAMESPACE
    61 QT_END_NAMESPACE
    62 
    62 
    63 QT_QML_BEGIN_NAMESPACE
    63 QT_QML_BEGIN_NAMESPACE
    64 
    64 
    65 #define shiftWindowsLineBreak() \
    65 #define shiftWindowsLineBreak() \
   101       parenthesesState(IgnoreParentheses),
   101       parenthesesState(IgnoreParentheses),
   102       parenthesesCount(0),
   102       parenthesesCount(0),
   103       prohibitAutomaticSemicolon(false),
   103       prohibitAutomaticSemicolon(false),
   104       tokenizeComments(tokenizeComments)
   104       tokenizeComments(tokenizeComments)
   105 {
   105 {
   106     driver->setLexer(this);
   106     if (driver) driver->setLexer(this);
   107     // allocate space for read buffers
   107     // allocate space for read buffers
   108     buffer8 = new char[size8];
   108     buffer8 = new char[size8];
   109     buffer16 = new QChar[size16];
   109     buffer16 = new QChar[size16];
   110     pattern = 0;
   110     pattern = 0;
   111     flags = 0;
   111     flags = 0;
   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                 driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   680                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   681             } else if (current == 0) {
   681             } else if (current == 0) {
   682                 driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   682                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   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                 driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   692                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   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                 driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   699                 if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
   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)) {