forked from qt-creator/qt-creator
don't give up on parsing errors
instead of erroring out the parse, only error out the evaluation in exact mode. that way we can do cumulative evaluation even on broken files. Task-number: QTCREATORBUG-3093
This commit is contained in:
@@ -1137,6 +1137,9 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
ProFile *pro, ProFileEvaluatorHandler::EvalFileType type,
|
ProFile *pro, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
ProFileEvaluator::LoadFlags flags)
|
ProFileEvaluator::LoadFlags flags)
|
||||||
{
|
{
|
||||||
|
if (!m_cumulative && !pro->isOk())
|
||||||
|
return ReturnFalse;
|
||||||
|
|
||||||
m_handler->aboutToEval(currentProFile(), pro, type);
|
m_handler->aboutToEval(currentProFile(), pro, type);
|
||||||
m_profileStack.push(pro);
|
m_profileStack.push(pro);
|
||||||
if (flags & LoadPreFiles) {
|
if (flags & LoadPreFiles) {
|
||||||
|
|||||||
@@ -310,6 +310,8 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
ptr += 4;
|
ptr += 4;
|
||||||
ushort *xprPtr = ptr;
|
ushort *xprPtr = ptr;
|
||||||
|
|
||||||
|
ushort *oldTokPtr = tokPtr;
|
||||||
|
|
||||||
#define FLUSH_LHS_LITERAL(setSep) \
|
#define FLUSH_LHS_LITERAL(setSep) \
|
||||||
do { \
|
do { \
|
||||||
if ((tlen = ptr - xprPtr)) { \
|
if ((tlen = ptr - xprPtr)) { \
|
||||||
@@ -356,9 +358,14 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
c = *cur;
|
c = *cur;
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
++cur;
|
++cur;
|
||||||
goto flushLine;
|
if (!inError)
|
||||||
|
goto flushLine;
|
||||||
|
++m_lineNo;
|
||||||
|
goto freshLine;
|
||||||
} else if (!c) {
|
} else if (!c) {
|
||||||
goto flushLine;
|
if (!inError)
|
||||||
|
goto flushLine;
|
||||||
|
goto flushFile;
|
||||||
} else if (c != ' ' && c != '\t' && c != '\r') {
|
} else if (c != ' ' && c != '\t' && c != '\r') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -430,8 +437,11 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
}
|
}
|
||||||
tlen = ptr - xprPtr;
|
tlen = ptr - xprPtr;
|
||||||
if (context == CtxTest) {
|
if (context == CtxTest) {
|
||||||
if (needSep)
|
if (needSep) {
|
||||||
goto extraChars;
|
extraChars:
|
||||||
|
parseError(fL1S("Extra characters after test expression."));
|
||||||
|
goto parseErr;
|
||||||
|
}
|
||||||
if (tlen)
|
if (tlen)
|
||||||
finalizeHashStr(xprPtr, tlen);
|
finalizeHashStr(xprPtr, tlen);
|
||||||
else
|
else
|
||||||
@@ -533,7 +543,12 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
parseError(fL1S("Missing %1 terminator [found %2]")
|
parseError(fL1S("Missing %1 terminator [found %2]")
|
||||||
.arg(QChar(term))
|
.arg(QChar(term))
|
||||||
.arg(c ? QString(c) : QString::fromLatin1("end-of-line")));
|
.arg(c ? QString(c) : QString::fromLatin1("end-of-line")));
|
||||||
return false;
|
parseErr:
|
||||||
|
pro->setOk(false);
|
||||||
|
xprStack.resize(0);
|
||||||
|
tokPtr = oldTokPtr;
|
||||||
|
inError = true;
|
||||||
|
goto skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
joinToken:
|
joinToken:
|
||||||
@@ -616,8 +631,7 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
FLUSH_LHS_LITERAL(false);
|
FLUSH_LHS_LITERAL(false);
|
||||||
if (ptr == buf) {
|
if (ptr == buf) {
|
||||||
parseError(fL1S("Opening parenthesis without prior test name."));
|
parseError(fL1S("Opening parenthesis without prior test name."));
|
||||||
inError = true;
|
goto parseErr;
|
||||||
goto skip;
|
|
||||||
}
|
}
|
||||||
*ptr++ = TokTestCall;
|
*ptr++ = TokTestCall;
|
||||||
term = ':';
|
term = ':';
|
||||||
@@ -690,8 +704,7 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
putLineMarker(tokPtr);
|
putLineMarker(tokPtr);
|
||||||
if (!(tlen = ptr - buf)) {
|
if (!(tlen = ptr - buf)) {
|
||||||
parseError(fL1S("Assignment operator without prior variable name."));
|
parseError(fL1S("Assignment operator without prior variable name."));
|
||||||
inError = true;
|
goto parseErr;
|
||||||
goto skip;
|
|
||||||
}
|
}
|
||||||
putBlock(tokPtr, buf, tlen);
|
putBlock(tokPtr, buf, tlen);
|
||||||
putTok(tokPtr, tok);
|
putTok(tokPtr, tok);
|
||||||
@@ -743,11 +756,11 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
FLUSH_LITERAL(false);
|
FLUSH_LITERAL(false);
|
||||||
if (quote) {
|
if (quote) {
|
||||||
parseError(fL1S("Missing closing %1 quote").arg(QChar(quote)));
|
parseError(fL1S("Missing closing %1 quote").arg(QChar(quote)));
|
||||||
return false;
|
goto parseErr;
|
||||||
}
|
}
|
||||||
if (!xprStack.isEmpty()) {
|
if (!xprStack.isEmpty()) {
|
||||||
parseError(fL1S("Missing closing parenthesis in function call"));
|
parseError(fL1S("Missing closing parenthesis in function call"));
|
||||||
return false;
|
goto parseErr;
|
||||||
}
|
}
|
||||||
if (context == CtxValue) {
|
if (context == CtxValue) {
|
||||||
tokPtr[-1] = litCount ? litCount + expCount : 0;
|
tokPtr[-1] = litCount ? litCount + expCount : 0;
|
||||||
@@ -756,17 +769,8 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
} else {
|
} else {
|
||||||
finalizeCond(tokPtr, buf, ptr);
|
finalizeCond(tokPtr, buf, ptr);
|
||||||
}
|
}
|
||||||
if (!c) {
|
if (!c)
|
||||||
flushScopes(tokPtr);
|
break;
|
||||||
if (m_blockstack.size() > 1)
|
|
||||||
parseError(fL1S("Missing closing brace(s)."));
|
|
||||||
while (m_blockstack.size())
|
|
||||||
leaveScope(tokPtr);
|
|
||||||
xprBuff.clear();
|
|
||||||
*pro->itemsRef() =
|
|
||||||
QString(tokBuff.constData(), tokPtr - (ushort *)tokBuff.constData());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
++m_lineNo;
|
++m_lineNo;
|
||||||
goto freshLine;
|
goto freshLine;
|
||||||
}
|
}
|
||||||
@@ -783,13 +787,21 @@ bool ProFileParser::read(ProFile *pro, const QString &in)
|
|||||||
++m_lineNo;
|
++m_lineNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flushFile:
|
||||||
|
flushScopes(tokPtr);
|
||||||
|
if (m_blockstack.size() > 1) {
|
||||||
|
parseError(fL1S("Missing closing brace(s)."));
|
||||||
|
pro->setOk(false);
|
||||||
|
}
|
||||||
|
while (m_blockstack.size())
|
||||||
|
leaveScope(tokPtr);
|
||||||
|
xprBuff.clear();
|
||||||
|
*pro->itemsRef() = QString(tokBuff.constData(), tokPtr - (ushort *)tokBuff.constData());
|
||||||
|
return true;
|
||||||
|
|
||||||
#undef FLUSH_LITERAL
|
#undef FLUSH_LITERAL
|
||||||
#undef FLUSH_LHS_LITERAL
|
#undef FLUSH_LHS_LITERAL
|
||||||
#undef FLUSH_RHS_LITERAL
|
#undef FLUSH_RHS_LITERAL
|
||||||
|
|
||||||
extraChars:
|
|
||||||
parseError(fL1S("Extra characters after test expression."));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileParser::putLineMarker(ushort *&tokPtr)
|
void ProFileParser::putLineMarker(ushort *&tokPtr)
|
||||||
|
|||||||
@@ -336,7 +336,8 @@ void ProStringList::removeDuplicates()
|
|||||||
|
|
||||||
ProFile::ProFile(const QString &fileName)
|
ProFile::ProFile(const QString &fileName)
|
||||||
: m_refCount(1),
|
: m_refCount(1),
|
||||||
m_fileName(fileName)
|
m_fileName(fileName),
|
||||||
|
m_ok(true)
|
||||||
{
|
{
|
||||||
if (!fileName.startsWith(QLatin1Char('(')))
|
if (!fileName.startsWith(QLatin1Char('(')))
|
||||||
m_directoryName = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
|
m_directoryName = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
|
||||||
|
|||||||
@@ -199,11 +199,15 @@ public:
|
|||||||
void ref() { m_refCount.ref(); }
|
void ref() { m_refCount.ref(); }
|
||||||
void deref() { if (!m_refCount.deref()) delete this; }
|
void deref() { if (!m_refCount.deref()) delete this; }
|
||||||
|
|
||||||
|
bool isOk() const { return m_ok; }
|
||||||
|
void setOk(bool ok) { m_ok = ok; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProItemRefCount m_refCount;
|
ProItemRefCount m_refCount;
|
||||||
QString m_proitems;
|
QString m_proitems;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
QString m_directoryName;
|
QString m_directoryName;
|
||||||
|
bool m_ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user