mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Allow script names starting with digits (Fixes #1730)
This commit is contained in:
parent
82b4148a62
commit
a0dbb40c8e
3 changed files with 20 additions and 5 deletions
|
@ -65,6 +65,7 @@ namespace Compiler
|
|||
if (mState==BeginState && keyword==Scanner::K_begin)
|
||||
{
|
||||
mState = NameState;
|
||||
scanner.allowNameStartingwithDigit();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ namespace Compiler
|
|||
|
||||
bool Scanner::scanToken (Parser& parser)
|
||||
{
|
||||
bool allowDigit = mNameStartingWithDigit;
|
||||
mNameStartingWithDigit = false;
|
||||
|
||||
switch (mPutback)
|
||||
{
|
||||
case Putback_Special:
|
||||
|
@ -112,6 +115,7 @@ namespace Compiler
|
|||
else if (isWhitespace (c))
|
||||
{
|
||||
mLoc.mLiteral.clear();
|
||||
mNameStartingWithDigit = allowDigit;
|
||||
return true;
|
||||
}
|
||||
else if (c==':')
|
||||
|
@ -120,21 +124,21 @@ namespace Compiler
|
|||
mLoc.mLiteral.clear();
|
||||
return true;
|
||||
}
|
||||
else if (std::isdigit (c))
|
||||
else if (std::isalpha (c) || c=='_' || c=='"' || (allowDigit && std::isdigit (c)))
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
if (scanInt (c, parser, cont))
|
||||
if (scanName (c, parser, cont))
|
||||
{
|
||||
mLoc.mLiteral.clear();
|
||||
return cont;
|
||||
}
|
||||
}
|
||||
else if (std::isalpha (c) || c=='_' || c=='"')
|
||||
else if (std::isdigit (c))
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
if (scanName (c, parser, cont))
|
||||
if (scanInt (c, parser, cont))
|
||||
{
|
||||
mLoc.mLiteral.clear();
|
||||
return cont;
|
||||
|
@ -516,7 +520,8 @@ namespace Compiler
|
|||
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
|
||||
const Extensions *extensions)
|
||||
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions),
|
||||
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0)
|
||||
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0),
|
||||
mNameStartingWithDigit (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -568,4 +573,9 @@ namespace Compiler
|
|||
if (mExtensions)
|
||||
mExtensions->listKeywords (keywords);
|
||||
}
|
||||
|
||||
void Scanner::allowNameStartingwithDigit()
|
||||
{
|
||||
mNameStartingWithDigit = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Compiler
|
|||
float mPutbackFloat;
|
||||
std::string mPutbackName;
|
||||
TokenLoc mPutbackLoc;
|
||||
bool mNameStartingWithDigit;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -122,6 +123,9 @@ namespace Compiler
|
|||
|
||||
void listKeywords (std::vector<std::string>& keywords);
|
||||
///< Append all known keywords to \a kaywords.
|
||||
|
||||
/// For the next token allow names to start with a digit.
|
||||
void allowNameStartingwithDigit();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue