leave();
continue;
} else if (m_tokenIndex == m_tokens.size() - 1
- && lexerState == Scanner::Normal) {
+ && (lexerState & Scanner::MultiLineMask) == Scanner::Normal) {
leave();
} else if (m_tokenIndex == 0) {
// to allow enter/leave to update the indentDepth
}
if (topState != multiline_comment_start
&& topState != multiline_comment_cont
- && lexerState == Scanner::MultiLineComment) {
+ && (lexerState & Scanner::MultiLineMask) == Scanner::MultiLineComment) {
enter(multiline_comment_start);
}
static inline int multiLineState(int state)
{
- return state & 0x3;
+ return state & Scanner::MultiLineMask;
}
static inline void setMultiLineState(int *state, int s)
{
- *state = s | (*state & ~0x3);
+ *state = s | (*state & ~Scanner::MultiLineMask);
}
static inline bool regexpMayFollow(int state)
{
- return state & 0x4;
+ return state & Scanner::RegexpMayFollow;
}
static inline void setRegexpMayFollow(int *state, bool on)
{
- *state = (on << 2) | (*state & 0x3);
+ *state = (on ? Scanner::RegexpMayFollow : 0) | (*state & ~Scanner::RegexpMayFollow);
}
QList<Token> Scanner::operator()(const QString &text, int startState)
_state = startState;
QList<Token> tokens;
- // ### handle multi line comment state.
-
int index = 0;
if (multiLineState(_state) == MultiLineComment) {
MultiLineComment = 1,
MultiLineStringDQuote = 2,
MultiLineStringSQuote = 3,
+ MultiLineMask = 3,
+
RegexpMayFollow = 4 // flag that may be combined with the above
};
// if a string literal doesn't start with a quote, it must be multiline
if (quote != QLatin1Char('"') && quote != QLatin1Char('\'')) {
const int startState = blockStartState(cursor.block());
- if (startState == Scanner::MultiLineStringDQuote)
+ if ((startState & Scanner::MultiLineMask) == Scanner::MultiLineStringDQuote)
quote = QLatin1Char('"');
- else if (startState == Scanner::MultiLineStringSQuote)
+ else if ((startState & Scanner::MultiLineMask) == Scanner::MultiLineStringSQuote)
quote = QLatin1Char('\'');
}
onClosingParenthesis('-', token.end() - 1, index == tokens.size()-1);
m_inMultilineComment = false;
} else if (!m_inMultilineComment
- && m_scanner.state() == Scanner::MultiLineComment
+ && (m_scanner.state() & Scanner::MultiLineMask) == Scanner::MultiLineComment
&& index == tokens.size() - 1) {
onOpeningParenthesis('+', token.offset, index == 0);
m_inMultilineComment = true;
if (previousState != -1) {
state = previousState & 0xff;
m_braceDepth = (previousState >> 8);
- m_inMultilineComment = (state == Scanner::MultiLineComment);
+ m_inMultilineComment = ((state & Scanner::MultiLineMask) == Scanner::MultiLineComment);
}
m_foldingIndent = m_braceDepth;