forked from qt-creator/qt-creator
make excess closing braces non-fatal
and as that happens to be the only syntax error we can get during the parsing stage, remove the fatal error handling alltogether.
This commit is contained in:
@@ -139,7 +139,7 @@ public:
|
|||||||
|
|
||||||
ProBlock *currentBlock();
|
ProBlock *currentBlock();
|
||||||
void updateItem();
|
void updateItem();
|
||||||
bool parseLine(const QString &line);
|
void parseLine(const QString &line);
|
||||||
void insertVariable(const ushort **pCur, const ushort *end);
|
void insertVariable(const ushort **pCur, const ushort *end);
|
||||||
void insertOperator(const char op);
|
void insertOperator(const char op);
|
||||||
void insertComment(const QString &comment);
|
void insertComment(const QString &comment);
|
||||||
@@ -154,7 +154,6 @@ public:
|
|||||||
QString m_proitem;
|
QString m_proitem;
|
||||||
QString m_pendingComment;
|
QString m_pendingComment;
|
||||||
ushort *m_proitemPtr;
|
ushort *m_proitemPtr;
|
||||||
bool m_syntaxError;
|
|
||||||
bool m_contNextLine;
|
bool m_contNextLine;
|
||||||
bool m_inQuote;
|
bool m_inQuote;
|
||||||
int m_parens;
|
int m_parens;
|
||||||
@@ -291,27 +290,20 @@ bool ProFileEvaluator::Private::read(ProFile *pro, QTextStream *ts)
|
|||||||
m_inQuote = false;
|
m_inQuote = false;
|
||||||
m_parens = 0;
|
m_parens = 0;
|
||||||
m_contNextLine = false;
|
m_contNextLine = false;
|
||||||
m_syntaxError = false;
|
|
||||||
m_lineNo = 1;
|
m_lineNo = 1;
|
||||||
m_blockstack.clear();
|
m_blockstack.clear();
|
||||||
m_blockstack.push(pro);
|
m_blockstack.push(pro);
|
||||||
|
|
||||||
while (!ts->atEnd()) {
|
while (!ts->atEnd()) {
|
||||||
QString line = ts->readLine();
|
QString line = ts->readLine();
|
||||||
if (!parseLine(line)) {
|
parseLine(line);
|
||||||
q->errorMessage(format(".pro parse failure."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++m_lineNo;
|
++m_lineNo;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::parseLine(const QString &line)
|
void ProFileEvaluator::Private::parseLine(const QString &line)
|
||||||
{
|
{
|
||||||
if (m_blockstack.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const ushort *cur = (const ushort *)line.unicode(),
|
const ushort *cur = (const ushort *)line.unicode(),
|
||||||
*end = cur + line.length();
|
*end = cur + line.length();
|
||||||
int parens = m_parens;
|
int parens = m_parens;
|
||||||
@@ -367,8 +359,6 @@ bool ProFileEvaluator::Private::parseLine(const QString &line)
|
|||||||
if (c == '}') {
|
if (c == '}') {
|
||||||
m_proitemPtr = ptr;
|
m_proitemPtr = ptr;
|
||||||
leaveScope();
|
leaveScope();
|
||||||
if (m_syntaxError)
|
|
||||||
goto done1;
|
|
||||||
goto nextItem;
|
goto nextItem;
|
||||||
}
|
}
|
||||||
if (c == '=') {
|
if (c == '=') {
|
||||||
@@ -397,13 +387,10 @@ bool ProFileEvaluator::Private::parseLine(const QString &line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_proitemPtr = ptr;
|
m_proitemPtr = ptr;
|
||||||
done1:
|
|
||||||
m_contNextLine = escaped;
|
m_contNextLine = escaped;
|
||||||
done:
|
done:
|
||||||
m_inQuote = inQuote;
|
m_inQuote = inQuote;
|
||||||
m_parens = parens;
|
m_parens = parens;
|
||||||
if (m_syntaxError)
|
|
||||||
return false;
|
|
||||||
if (m_contNextLine) {
|
if (m_contNextLine) {
|
||||||
--m_proitemPtr;
|
--m_proitemPtr;
|
||||||
updateItem();
|
updateItem();
|
||||||
@@ -411,19 +398,14 @@ bool ProFileEvaluator::Private::parseLine(const QString &line)
|
|||||||
updateItem();
|
updateItem();
|
||||||
finalizeBlock();
|
finalizeBlock();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEvaluator::Private::finalizeBlock()
|
void ProFileEvaluator::Private::finalizeBlock()
|
||||||
{
|
{
|
||||||
if (m_blockstack.isEmpty()) {
|
if (m_blockstack.top()->blockKind() & ProBlock::SingleLine)
|
||||||
m_syntaxError = true;
|
leaveScope();
|
||||||
} else {
|
m_block = 0;
|
||||||
if (m_blockstack.top()->blockKind() & ProBlock::SingleLine)
|
m_commentItem = 0;
|
||||||
leaveScope();
|
|
||||||
m_block = 0;
|
|
||||||
m_commentItem = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEvaluator::Private::insertVariable(const ushort **pCur, const ushort *end)
|
void ProFileEvaluator::Private::insertVariable(const ushort **pCur, const ushort *end)
|
||||||
@@ -574,7 +556,10 @@ void ProFileEvaluator::Private::enterScope(bool multiLine)
|
|||||||
void ProFileEvaluator::Private::leaveScope()
|
void ProFileEvaluator::Private::leaveScope()
|
||||||
{
|
{
|
||||||
updateItem();
|
updateItem();
|
||||||
m_blockstack.pop();
|
if (m_blockstack.count() == 1)
|
||||||
|
q->errorMessage(format("Excess closing brace."));
|
||||||
|
else
|
||||||
|
m_blockstack.pop();
|
||||||
finalizeBlock();
|
finalizeBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user