forked from qt-creator/qt-creator
BareMetal: Minimize nested blocks of code in KEIL parser
Change-Id: I420eb67683413730f67fce9dd103487380296548 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -92,7 +92,8 @@ bool KeilParser::parseArmWarningOrErrorDetailsMessage(const QString &lne)
|
|||||||
{
|
{
|
||||||
const QRegularExpression re("^\"(.+)\", line (\\d+).*:\\s+(Warning|Error):(\\s+|.+)([#|L].+)$");
|
const QRegularExpression re("^\"(.+)\", line (\\d+).*:\\s+(Warning|Error):(\\s+|.+)([#|L].+)$");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
enum CaptureIndex { FilePathIndex = 1, LineNumberIndex,
|
enum CaptureIndex { FilePathIndex = 1, LineNumberIndex,
|
||||||
MessageTypeIndex, MessageNoteIndex, DescriptionIndex };
|
MessageTypeIndex, MessageNoteIndex, DescriptionIndex };
|
||||||
const Utils::FilePath fileName = Utils::FilePath::fromUserInput(
|
const Utils::FilePath fileName = Utils::FilePath::fromUserInput(
|
||||||
@@ -103,23 +104,20 @@ bool KeilParser::parseArmWarningOrErrorDetailsMessage(const QString &lne)
|
|||||||
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
|
bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
|
||||||
{
|
{
|
||||||
const QRegularExpression re("^(Error|Fatal error):\\s(.+)$");
|
const QRegularExpression re("^(Error|Fatal error):\\s(.+)$");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
enum CaptureIndex { MessageTypeIndex = 1, DescriptionIndex };
|
enum CaptureIndex { MessageTypeIndex = 1, DescriptionIndex };
|
||||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||||
const QString descr = match.captured(DescriptionIndex);
|
const QString descr = match.captured(DescriptionIndex);
|
||||||
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
|
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MCS51 compiler specific parsers.
|
// 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 QRegularExpression re("^\\*{3} (WARNING|ERROR) (\\w+) IN LINE (\\d+) OF (.+\\.\\S+): (.+)$");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
|
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
|
||||||
FilePathIndex, MessageTextIndex };
|
FilePathIndex, MessageTextIndex };
|
||||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||||
@@ -140,15 +139,14 @@ bool KeilParser::parseMcs51WarningOrErrorDetailsMessage1(const QString &lne)
|
|||||||
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
|
bool KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
|
||||||
{
|
{
|
||||||
const QRegularExpression re("^\\*{3} (WARNING|ERROR) (#\\w+) IN (\\d+) \\((.+), LINE \\d+\\): (.+)$");
|
const QRegularExpression re("^\\*{3} (WARNING|ERROR) (#\\w+) IN (\\d+) \\((.+), LINE \\d+\\): (.+)$");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
|
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex, LineNumberIndex,
|
||||||
FilePathIndex, MessageTextIndex };
|
FilePathIndex, MessageTextIndex };
|
||||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||||
@@ -160,30 +158,28 @@ bool KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
|
|||||||
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
const Task task(type, descr, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
|
bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
|
||||||
{
|
{
|
||||||
const QRegularExpression re("^\\*{3} (WARNING|FATAL ERROR) (.+)$");
|
const QRegularExpression re("^\\*{3} (WARNING|FATAL ERROR) (.+)$");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
enum CaptureIndex { MessageTypeIndex = 1, MessageDescriptionIndex };
|
enum CaptureIndex { MessageTypeIndex = 1, MessageDescriptionIndex };
|
||||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||||
const QString descr = match.captured(MessageDescriptionIndex);
|
const QString descr = match.captured(MessageDescriptionIndex);
|
||||||
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
|
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
|
bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
|
||||||
{
|
{
|
||||||
const QRegularExpression re("^(A|C)51 FATAL[ |-]ERROR");
|
const QRegularExpression re("^(A|C)51 FATAL[ |-]ERROR");
|
||||||
const QRegularExpressionMatch match = re.match(lne);
|
const QRegularExpressionMatch match = re.match(lne);
|
||||||
if (match.hasMatch()) {
|
if (!match.hasMatch())
|
||||||
|
return false;
|
||||||
const QString key = match.captured(1);
|
const QString key = match.captured(1);
|
||||||
QString descr;
|
QString descr;
|
||||||
if (key == QLatin1Char('A'))
|
if (key == QLatin1Char('A'))
|
||||||
@@ -194,8 +190,6 @@ bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
|
|||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
newTask(task);
|
newTask(task);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeilParser::stdError(const QString &line)
|
void KeilParser::stdError(const QString &line)
|
||||||
|
Reference in New Issue
Block a user