forked from qt-creator/qt-creator
Nim: Removed useless QLatin1String and QLatin1Char
Change-Id: Id4f5cbd8c9ba515ec1e4acf4c7cbd19f7c3bb519 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,16 +29,6 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
namespace {
|
|
||||||
QSet<QString> asStringSet(const std::initializer_list<const char *> strings)
|
|
||||||
{
|
|
||||||
QSet<QString> result;
|
|
||||||
for (auto s : strings)
|
|
||||||
result.insert(QLatin1String(s));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Nim {
|
namespace Nim {
|
||||||
|
|
||||||
NimLexer::NimLexer(const QChar *text, int length, State state)
|
NimLexer::NimLexer(const QChar *text, int length, State state)
|
||||||
@@ -134,8 +124,7 @@ NimLexer::Token NimLexer::readOperator()
|
|||||||
|
|
||||||
bool NimLexer::matchCommentStart()
|
bool NimLexer::matchCommentStart()
|
||||||
{
|
{
|
||||||
return m_stream.peek() == QLatin1Char('#')
|
return m_stream.peek() == '#' && m_stream.peek(1) != '#';
|
||||||
&& m_stream.peek(1) != QLatin1Char('#');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NimLexer::Token NimLexer::readComment()
|
NimLexer::Token NimLexer::readComment()
|
||||||
@@ -179,8 +168,7 @@ NimLexer::Token NimLexer::readMultiLineComment(bool moveForward)
|
|||||||
|
|
||||||
bool NimLexer::matchDocumentationStart()
|
bool NimLexer::matchDocumentationStart()
|
||||||
{
|
{
|
||||||
return m_stream.peek() == QLatin1Char('#')
|
return m_stream.peek() == '#' && m_stream.peek(1) == '#';
|
||||||
&& m_stream.peek(1) == QLatin1Char('#');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NimLexer::Token NimLexer::readDocumentation()
|
NimLexer::Token NimLexer::readDocumentation()
|
||||||
@@ -211,15 +199,15 @@ NimLexer::Token NimLexer::readNumber()
|
|||||||
|
|
||||||
bool NimLexer::matchIdentifierOrKeywordStart()
|
bool NimLexer::matchIdentifierOrKeywordStart()
|
||||||
{
|
{
|
||||||
static QRegularExpression isLetter(QLatin1String("[a-zA-Z\x80-\xFF]"));
|
static QRegularExpression isLetter("[a-zA-Z\x80-\xFF]");
|
||||||
return isLetter.match(m_stream.peek()).hasMatch();
|
return isLetter.match(m_stream.peek()).hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
NimLexer::Token NimLexer::readIdentifierOrKeyword()
|
NimLexer::Token NimLexer::readIdentifierOrKeyword()
|
||||||
{
|
{
|
||||||
static QRegularExpression isLetter {QLatin1String("[a-zA-Z\x80-\xFF]")};
|
static QRegularExpression isLetter("[a-zA-Z\x80-\xFF]");
|
||||||
static QSet<QString> keywords =
|
static QSet<QString> keywords = {
|
||||||
::asStringSet({"addr", "and", "as", "asm", "atomic",
|
"addr", "and", "as", "asm", "atomic",
|
||||||
"bind", "block", "break",
|
"bind", "block", "break",
|
||||||
"case", "cast", "concept", "const", "continue", "converter",
|
"case", "cast", "concept", "const", "continue", "converter",
|
||||||
"defer", "discard", "distinct", "div", "do",
|
"defer", "discard", "distinct", "div", "do",
|
||||||
@@ -240,13 +228,13 @@ NimLexer::Token NimLexer::readIdentifierOrKeyword()
|
|||||||
"when", "while", "with", "without",
|
"when", "while", "with", "without",
|
||||||
"xor",
|
"xor",
|
||||||
"yield"
|
"yield"
|
||||||
});
|
};
|
||||||
m_stream.setAnchor();
|
m_stream.setAnchor();
|
||||||
m_stream.move();
|
m_stream.move();
|
||||||
|
|
||||||
while (!m_stream.isEnd()) {
|
while (!m_stream.isEnd()) {
|
||||||
const QChar &c = m_stream.peek();
|
const QChar &c = m_stream.peek();
|
||||||
if (!(c == QLatin1Char('_')
|
if (!(c == '_'
|
||||||
|| c.isDigit()
|
|| c.isDigit()
|
||||||
|| isLetter.match(c).hasMatch()))
|
|| isLetter.match(c).hasMatch()))
|
||||||
break;
|
break;
|
||||||
@@ -263,7 +251,7 @@ NimLexer::Token NimLexer::readIdentifierOrKeyword()
|
|||||||
|
|
||||||
bool NimLexer::matchStringLiteralStart()
|
bool NimLexer::matchStringLiteralStart()
|
||||||
{
|
{
|
||||||
return m_stream.peek() == QLatin1Char('"');
|
return m_stream.peek() == '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
NimLexer::Token NimLexer::readStringLiteral()
|
NimLexer::Token NimLexer::readStringLiteral()
|
||||||
@@ -272,8 +260,7 @@ NimLexer::Token NimLexer::readStringLiteral()
|
|||||||
m_stream.move();
|
m_stream.move();
|
||||||
|
|
||||||
while (!m_stream.isEnd()) {
|
while (!m_stream.isEnd()) {
|
||||||
if (m_stream.peek() != QLatin1Char('\\')
|
if (m_stream.peek() != '\\' && m_stream.peek(1) == '"') {
|
||||||
&& m_stream.peek(1) == QLatin1Char('"')) {
|
|
||||||
m_stream.move(2);
|
m_stream.move(2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -287,9 +274,9 @@ NimLexer::Token NimLexer::readStringLiteral()
|
|||||||
|
|
||||||
bool NimLexer::matchMultiLineStringLiteralStart()
|
bool NimLexer::matchMultiLineStringLiteralStart()
|
||||||
{
|
{
|
||||||
return m_stream.peek() == QLatin1Char('"')
|
return m_stream.peek() == '"'
|
||||||
&& m_stream.peek(1) == QLatin1Char('"')
|
&& m_stream.peek(1) == '"'
|
||||||
&& m_stream.peek(2) == QLatin1Char('"');
|
&& m_stream.peek(2) == '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
NimLexer::Token NimLexer::readMultiLineStringLiteral(bool moveForward)
|
NimLexer::Token NimLexer::readMultiLineStringLiteral(bool moveForward)
|
||||||
|
Reference in New Issue
Block a user