mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
allow keywords as strings in messagebox instruction (Fixes #2991)
This commit is contained in:
parent
647bed7f40
commit
06efd72a89
3 changed files with 27 additions and 6 deletions
|
@ -411,7 +411,12 @@ namespace Compiler
|
|||
}
|
||||
|
||||
case Scanner::K_set: mState = SetState; return true;
|
||||
case Scanner::K_messagebox: mState = MessageState; return true;
|
||||
|
||||
case Scanner::K_messagebox:
|
||||
|
||||
mState = MessageState;
|
||||
scanner.enableStrictKeywords();
|
||||
return true;
|
||||
|
||||
case Scanner::K_return:
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace Compiler
|
|||
|
||||
if (c=='\n')
|
||||
{
|
||||
mStrictKeywords = false;
|
||||
mLoc.mColumn = 0;
|
||||
++mLoc.mLine;
|
||||
mLoc.mLiteral.clear();
|
||||
|
@ -294,8 +295,11 @@ namespace Compiler
|
|||
name = name.substr (1, name.size()-2);
|
||||
// allow keywords enclosed in ""
|
||||
/// \todo optionally disable
|
||||
// cont = parser.parseName (name, loc, *this);
|
||||
// return true;
|
||||
if (mStrictKeywords)
|
||||
{
|
||||
cont = parser.parseName (name, loc, *this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
@ -567,7 +571,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),
|
||||
mStrictKeywords (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -619,4 +624,9 @@ namespace Compiler
|
|||
if (mExtensions)
|
||||
mExtensions->listKeywords (keywords);
|
||||
}
|
||||
|
||||
void Scanner::enableStrictKeywords()
|
||||
{
|
||||
mStrictKeywords = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Compiler
|
|||
float mPutbackFloat;
|
||||
std::string mPutbackName;
|
||||
TokenLoc mPutbackLoc;
|
||||
bool mStrictKeywords;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -116,13 +117,18 @@ namespace Compiler
|
|||
///< put back a float token
|
||||
|
||||
void putbackName (const std::string& name, const TokenLoc& loc);
|
||||
///< put back a name toekn
|
||||
///< put back a name token
|
||||
|
||||
void putbackKeyword (int keyword, const TokenLoc& loc);
|
||||
///< put back a keyword token
|
||||
|
||||
void listKeywords (std::vector<std::string>& keywords);
|
||||
///< Append all known keywords to \a kaywords.
|
||||
///< Append all known keywords to \a keywords.
|
||||
|
||||
/// Do not accept keywords in quotation marks anymore.
|
||||
///
|
||||
/// \attention This mode lasts only until the next newline is reached.
|
||||
void enableStrictKeywords();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue