BareMetal: Minimize nested blocks of code in KEIL parser

Change-Id: I420eb67683413730f67fce9dd103487380296548
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Denis Shienkov
2019-10-15 12:00:38 +03:00
parent e90a48e639
commit 1e54d45139

View File

@@ -92,7 +92,8 @@ bool KeilParser::parseArmWarningOrErrorDetailsMessage(const QString &lne)
{
const QRegularExpression re("^\"(.+)\", line (\\d+).*:\\s+(Warning|Error):(\\s+|.+)([#|L].+)$");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
enum CaptureIndex { FilePathIndex = 1, LineNumberIndex,
MessageTypeIndex, MessageNoteIndex, DescriptionIndex };
const Utils::FilePath fileName = Utils::FilePath::fromUserInput(
@@ -104,14 +105,13 @@ bool KeilParser::parseArmWarningOrErrorDetailsMessage(const QString &lne)
newTask(task);
return true;
}
return false;
}
bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
{
const QRegularExpression re("^(Error|Fatal error):\\s(.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
enum CaptureIndex { MessageTypeIndex = 1, DescriptionIndex };
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
const QString descr = match.captured(DescriptionIndex);
@@ -119,8 +119,6 @@ bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
newTask(task);
return true;
}
return false;
}
// MCS51 compiler specific parsers.
@@ -128,7 +126,8 @@ bool KeilParser::parseMcs51WarningOrErrorDetailsMessage1(const QString &lne)
{
const QRegularExpression re("^\\*{3} (WARNING|ERROR) (\\w+) IN LINE (\\d+) OF (.+\\.\\S+): (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
FilePathIndex, MessageTextIndex };
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
@@ -141,14 +140,13 @@ bool KeilParser::parseMcs51WarningOrErrorDetailsMessage1(const QString &lne)
newTask(task);
return true;
}
return false;
}
bool KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
{
const QRegularExpression re("^\\*{3} (WARNING|ERROR) (#\\w+) IN (\\d+) \\((.+), LINE \\d+\\): (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
FilePathIndex, MessageTextIndex };
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
@@ -161,14 +159,13 @@ bool KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
newTask(task);
return true;
}
return false;
}
bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
{
const QRegularExpression re("^\\*{3} (WARNING|FATAL ERROR) (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
enum CaptureIndex { MessageTypeIndex = 1, MessageDescriptionIndex };
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
const QString descr = match.captured(MessageDescriptionIndex);
@@ -176,14 +173,13 @@ bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
newTask(task);
return true;
}
return false;
}
bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
{
const QRegularExpression re("^(A|C)51 FATAL[ |-]ERROR");
const QRegularExpressionMatch match = re.match(lne);
if (match.hasMatch()) {
if (!match.hasMatch())
return false;
const QString key = match.captured(1);
QString descr;
if (key == QLatin1Char('A'))
@@ -195,8 +191,6 @@ bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
newTask(task);
return true;
}
return false;
}
void KeilParser::stdError(const QString &line)
{