forked from mirror/openmw-tes3mp
allow . and - in the name part of a begin script statement, but not at the beginning of a name. Fixes #4061
This commit is contained in:
parent
dd5ebe225b
commit
2dff3aab22
3 changed files with 15 additions and 2 deletions
components/compiler
|
@ -63,6 +63,7 @@ namespace Compiler
|
|||
if (mState==BeginState && keyword==Scanner::K_begin)
|
||||
{
|
||||
mState = NameState;
|
||||
scanner.enableTolerantNames(); /// \todo disable
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Compiler
|
|||
if (c=='\n')
|
||||
{
|
||||
mStrictKeywords = false;
|
||||
mTolerantNames = false;
|
||||
mLoc.mColumn = 0;
|
||||
++mLoc.mLine;
|
||||
mLoc.mLiteral.clear();
|
||||
|
@ -363,7 +364,7 @@ namespace Compiler
|
|||
}
|
||||
else if (!(c=='"' && name.empty()))
|
||||
{
|
||||
if (!isStringCharacter (c))
|
||||
if (!isStringCharacter (c) && !(mTolerantNames && (c=='.' || c=='-')))
|
||||
{
|
||||
putback (c);
|
||||
break;
|
||||
|
@ -577,7 +578,7 @@ namespace Compiler
|
|||
const Extensions *extensions)
|
||||
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions),
|
||||
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0),
|
||||
mStrictKeywords (false)
|
||||
mStrictKeywords (false), mTolerantNames (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -634,4 +635,9 @@ namespace Compiler
|
|||
{
|
||||
mStrictKeywords = true;
|
||||
}
|
||||
|
||||
void Scanner::enableTolerantNames()
|
||||
{
|
||||
mTolerantNames = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Compiler
|
|||
std::string mPutbackName;
|
||||
TokenLoc mPutbackLoc;
|
||||
bool mStrictKeywords;
|
||||
bool mTolerantNames;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -129,6 +130,11 @@ namespace Compiler
|
|||
///
|
||||
/// \attention This mode lasts only until the next newline is reached.
|
||||
void enableStrictKeywords();
|
||||
|
||||
/// Continue parsing a name when hitting a '.' or a '-'
|
||||
///
|
||||
/// \attention This mode lasts only until the next newline is reached.
|
||||
void enableTolerantNames();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue