diff --git a/components/compiler/fileparser.cpp b/components/compiler/fileparser.cpp index 8711d92fe..52a9a63f1 100644 --- a/components/compiler/fileparser.cpp +++ b/components/compiler/fileparser.cpp @@ -63,6 +63,7 @@ namespace Compiler if (mState==BeginState && keyword==Scanner::K_begin) { mState = NameState; + scanner.enableTolerantNames(); /// \todo disable return true; } diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index c2ec13b01..bb0fb9374 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -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; + } } diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 270782c74..49fbaa96a 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -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(); }; }