Front-ends: Remove now defunct afterEOF and related, use scanner's instead.
Code using atEndOfFile was dead, instead do something useful with the scanners atEndOfInput(). This allows a better error message for early termination of cascading errors.
This commit is contained in:
parent
830b0cc98b
commit
5e56423046
9 changed files with 14 additions and 19 deletions
|
|
@ -55,7 +55,6 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
|
|||
contextPragma(true, false), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0), statementNestingLevel(0),
|
||||
inMain(false), postMainReturn(false), currentFunctionType(nullptr), blockName(nullptr),
|
||||
limits(resources.limits), parsingBuiltins(parsingBuiltins),
|
||||
afterEOF(false),
|
||||
atomicUintOffsets(nullptr), anyIndexLimits(false)
|
||||
{
|
||||
// ensure we always have a linkage node, even if empty, to simplify tree topology algorithms
|
||||
|
|
@ -193,13 +192,15 @@ bool TParseContext::parseShaderStrings(TPpContext& ppContext, TInputScanner& inp
|
|||
}
|
||||
|
||||
// This is called from bison when it has a parse (syntax) error
|
||||
// Note though that to stop cascading errors, we set EOF, which
|
||||
// will usually cause a syntax error, so be more accurate that
|
||||
// compilation is terminating.
|
||||
void TParseContext::parserError(const char* s)
|
||||
{
|
||||
if (afterEOF) {
|
||||
if (tokensBeforeEOF == 1)
|
||||
error(getCurrentLoc(), "", "premature end of input", s, "");
|
||||
} else
|
||||
if (! getScanner()->atEndOfInput() || numErrors == 0)
|
||||
error(getCurrentLoc(), "", "", s, "");
|
||||
else
|
||||
error(getCurrentLoc(), "compilation terminated", "", "");
|
||||
}
|
||||
|
||||
void TParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>& tokens)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
|
||||
TInfoSink& infoSink, bool forwardCompatible, EShMessages messages)
|
||||
: TParseVersions(interm, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
|
||||
symbolTable(symbolTable), tokensBeforeEOF(false),
|
||||
symbolTable(symbolTable),
|
||||
linkage(nullptr), scanContext(nullptr), ppContext(nullptr) { }
|
||||
virtual ~TParseContextBase() { }
|
||||
|
||||
|
|
@ -125,7 +125,6 @@ public:
|
|||
}
|
||||
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
|
||||
bool tokensBeforeEOF;
|
||||
|
||||
protected:
|
||||
TParseContextBase(TParseContextBase&);
|
||||
|
|
@ -387,7 +386,6 @@ protected:
|
|||
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2 * 2 * 2)); // see computeSamplerTypeIndex()
|
||||
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
|
||||
TPrecisionManager precisionManager;
|
||||
bool afterEOF;
|
||||
TQualifier globalBufferDefaults;
|
||||
TQualifier globalUniformDefaults;
|
||||
TQualifier globalInputDefaults;
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ public:
|
|||
currentSource = numSources;
|
||||
}
|
||||
|
||||
bool atEndOfInput() const { return endOfFileReached; }
|
||||
|
||||
const TSourceLoc& getSourceLoc() const
|
||||
{
|
||||
if (singleLogical) {
|
||||
|
|
|
|||
|
|
@ -762,12 +762,8 @@ const char* TPpContext::tokenize(TPpToken* ppToken)
|
|||
break;
|
||||
}
|
||||
|
||||
if (tokenString) {
|
||||
if (tokenString[0] != 0)
|
||||
parseContext.tokensBeforeEOF = 1;
|
||||
|
||||
if (tokenString)
|
||||
return tokenString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue