summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/SimpleLexer.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2010-06-29 17:57:15 +0200
committerErik Verbruggen <erik.verbruggen@nokia.com>2010-07-02 11:18:51 +0200
commit8e4fb678fd68cbb01d5548ba07dfcb2927868df4 (patch)
tree8d2a8d2dd7c31a3bfa0d98b28f2cb7589e18ecc5 /src/libs/cplusplus/SimpleLexer.cpp
parente3e8b1a5c01ddc230772ee0553ca325704295312 (diff)
downloadqt-creator-8e4fb678fd68cbb01d5548ba07dfcb2927868df4.tar.gz
Removing SimpleToken
Diffstat (limited to 'src/libs/cplusplus/SimpleLexer.cpp')
-rw-r--r--src/libs/cplusplus/SimpleLexer.cpp80
1 files changed, 18 insertions, 62 deletions
diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp
index 83f3a5189c..1efa043e7b 100644
--- a/src/libs/cplusplus/SimpleLexer.cpp
+++ b/src/libs/cplusplus/SimpleLexer.cpp
@@ -37,47 +37,6 @@
using namespace CPlusPlus;
-SimpleToken::SimpleToken(const Token &token)
- : _kind(token.f.kind)
- , _flags(0)
- , _position(token.begin())
- , _length(token.f.length)
-{
- f._whitespace = token.f.whitespace;
- f._newline = token.f.newline;
-}
-
-bool SimpleToken::isLiteral() const
-{
- return _kind >= T_FIRST_LITERAL && _kind <= T_LAST_LITERAL;
-}
-
-bool SimpleToken::isOperator() const
-{
- return _kind >= T_FIRST_OPERATOR && _kind <= T_LAST_OPERATOR;
-}
-
-bool SimpleToken::isKeyword() const
-{
- return _kind >= T_FIRST_KEYWORD && _kind < T_FIRST_QT_KEYWORD;
-}
-
-bool SimpleToken::isComment() const
-{
- return _kind == T_COMMENT || _kind == T_DOXY_COMMENT ||
- _kind == T_CPP_COMMENT || _kind == T_CPP_DOXY_COMMENT;
-}
-
-bool SimpleToken::isObjCAtKeyword() const
-{
- return _kind >= T_FIRST_OBJC_AT_KEYWORD && _kind <= T_LAST_OBJC_AT_KEYWORD;
-}
-
-const char *SimpleToken::name() const
-{
- return Token::name(_kind);
-}
-
SimpleLexer::SimpleLexer()
: _lastState(0),
_skipComments(false),
@@ -119,9 +78,9 @@ void SimpleLexer::setSkipComments(bool skipComments)
_skipComments = skipComments;
}
-QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
+QList<Token> SimpleLexer::operator()(const QString &text, int state)
{
- QList<SimpleToken> tokens;
+ QList<Token> tokens;
const QByteArray bytes = text.toLatin1();
const char *firstChar = bytes.constData();
@@ -131,6 +90,7 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
lex.setQtMocRunEnabled(_qtMocRunEnabled);
lex.setObjCEnabled(_objCEnabled);
lex.setStartWithNewline(true);
+ lex.setObjCEnabled(_objCEnabled);
if (! _skipComments)
lex.setScanCommentTokens(true);
@@ -147,57 +107,53 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
break;
QStringRef spell = text.midRef(lex.tokenOffset(), lex.tokenLength());
- SimpleToken simpleTk(tk);
lex.setScanAngleStringLiteralTokens(false);
if (tk.f.newline && tk.is(T_POUND))
inPreproc = true;
- else if (inPreproc && tokens.size() == 1 && simpleTk.is(T_IDENTIFIER) &&
+ else if (inPreproc && tokens.size() == 1 && tk.is(T_IDENTIFIER) &&
spell == QLatin1String("include"))
lex.setScanAngleStringLiteralTokens(true);
else if (_objCEnabled
- && inPreproc && tokens.size() == 1 && simpleTk.is(T_IDENTIFIER) &&
+ && inPreproc && tokens.size() == 1 && tk.is(T_IDENTIFIER) &&
spell == QLatin1String("import"))
lex.setScanAngleStringLiteralTokens(true);
- if (_objCEnabled && tk.is(T_IDENTIFIER))
- simpleTk.f._objcTypeQualifier = (classifyObjectiveCContextKeyword(firstChar + tk.offset, tk.f.length) != Token_identifier);
-
- tokens.append(simpleTk);
+ tokens.append(tk);
}
_lastState = lex.state();
return tokens;
}
-int SimpleLexer::tokenAt(const QList<SimpleToken> &tokens, int offset)
+int SimpleLexer::tokenAt(const QList<Token> &tokens, unsigned offset)
{
for (int index = tokens.size() - 1; index >= 0; --index) {
- const SimpleToken &tk = tokens.at(index);
- if (tk.position() <= offset && tk.end() >= offset)
+ const Token &tk = tokens.at(index);
+ if (tk.begin() <= offset && tk.end() >= offset)
return index;
}
return -1;
}
-SimpleToken SimpleLexer::tokenAt(const QString &text,
- int offset,
- int state,
- bool qtMocRunEnabled)
+Token SimpleLexer::tokenAt(const QString &text,
+ unsigned offset,
+ int state,
+ bool qtMocRunEnabled)
{
SimpleLexer tokenize;
tokenize.setQtMocRunEnabled(qtMocRunEnabled);
- const QList<SimpleToken> tokens = tokenize(text, state);
+ const QList<Token> tokens = tokenize(text, state);
const int tokenIdx = tokenAt(tokens, offset);
- return (tokenIdx == -1) ? SimpleToken() : tokens.at(tokenIdx);
+ return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
}
-int SimpleLexer::tokenBefore(const QList<SimpleToken> &tokens, int offset)
+int SimpleLexer::tokenBefore(const QList<Token> &tokens, unsigned offset)
{
for (int index = tokens.size() - 1; index >= 0; --index) {
- const SimpleToken &tk = tokens.at(index);
- if (tk.position() <= offset)
+ const Token &tk = tokens.at(index);
+ if (tk.begin() <= offset)
return index;
}