allow . and - in the name part of a begin script statement, but not at the beginning of a name. Fixes #4061

0.6.3
Marc Zinnschlag 7 years ago
parent dd5ebe225b
commit 2dff3aab22

@ -63,6 +63,7 @@ namespace Compiler
if (mState==BeginState && keyword==Scanner::K_begin) if (mState==BeginState && keyword==Scanner::K_begin)
{ {
mState = NameState; mState = NameState;
scanner.enableTolerantNames(); /// \todo disable
return true; return true;
} }

@ -27,6 +27,7 @@ namespace Compiler
if (c=='\n') if (c=='\n')
{ {
mStrictKeywords = false; mStrictKeywords = false;
mTolerantNames = false;
mLoc.mColumn = 0; mLoc.mColumn = 0;
++mLoc.mLine; ++mLoc.mLine;
mLoc.mLiteral.clear(); mLoc.mLiteral.clear();
@ -363,7 +364,7 @@ namespace Compiler
} }
else if (!(c=='"' && name.empty())) else if (!(c=='"' && name.empty()))
{ {
if (!isStringCharacter (c)) if (!isStringCharacter (c) && !(mTolerantNames && (c=='.' || c=='-')))
{ {
putback (c); putback (c);
break; break;
@ -577,7 +578,7 @@ namespace Compiler
const Extensions *extensions) const Extensions *extensions)
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (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),
mStrictKeywords (false) mStrictKeywords (false), mTolerantNames (false)
{ {
} }
@ -634,4 +635,9 @@ namespace Compiler
{ {
mStrictKeywords = true; mStrictKeywords = true;
} }
void Scanner::enableTolerantNames()
{
mTolerantNames = true;
}
} }

@ -38,6 +38,7 @@ namespace Compiler
std::string mPutbackName; std::string mPutbackName;
TokenLoc mPutbackLoc; TokenLoc mPutbackLoc;
bool mStrictKeywords; bool mStrictKeywords;
bool mTolerantNames;
public: public:
@ -129,6 +130,11 @@ namespace Compiler
/// ///
/// \attention This mode lasts only until the next newline is reached. /// \attention This mode lasts only until the next newline is reached.
void enableStrictKeywords(); 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…
Cancel
Save