mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 22:45:36 +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_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:
|
case Scanner::K_return:
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Compiler
|
||||||
|
|
||||||
if (c=='\n')
|
if (c=='\n')
|
||||||
{
|
{
|
||||||
|
mStrictKeywords = false;
|
||||||
mLoc.mColumn = 0;
|
mLoc.mColumn = 0;
|
||||||
++mLoc.mLine;
|
++mLoc.mLine;
|
||||||
mLoc.mLiteral.clear();
|
mLoc.mLiteral.clear();
|
||||||
|
@ -294,8 +295,11 @@ namespace Compiler
|
||||||
name = name.substr (1, name.size()-2);
|
name = name.substr (1, name.size()-2);
|
||||||
// allow keywords enclosed in ""
|
// allow keywords enclosed in ""
|
||||||
/// \todo optionally disable
|
/// \todo optionally disable
|
||||||
// cont = parser.parseName (name, loc, *this);
|
if (mStrictKeywords)
|
||||||
// return true;
|
{
|
||||||
|
cont = parser.parseName (name, loc, *this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -567,7 +571,8 @@ namespace Compiler
|
||||||
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
|
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
|
||||||
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,4 +624,9 @@ namespace Compiler
|
||||||
if (mExtensions)
|
if (mExtensions)
|
||||||
mExtensions->listKeywords (keywords);
|
mExtensions->listKeywords (keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scanner::enableStrictKeywords()
|
||||||
|
{
|
||||||
|
mStrictKeywords = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Compiler
|
||||||
float mPutbackFloat;
|
float mPutbackFloat;
|
||||||
std::string mPutbackName;
|
std::string mPutbackName;
|
||||||
TokenLoc mPutbackLoc;
|
TokenLoc mPutbackLoc;
|
||||||
|
bool mStrictKeywords;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -116,13 +117,18 @@ namespace Compiler
|
||||||
///< put back a float token
|
///< put back a float token
|
||||||
|
|
||||||
void putbackName (const std::string& name, const TokenLoc& loc);
|
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);
|
void putbackKeyword (int keyword, const TokenLoc& loc);
|
||||||
///< put back a keyword token
|
///< put back a keyword token
|
||||||
|
|
||||||
void listKeywords (std::vector<std::string>& keywords);
|
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