mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 12:23:53 +00:00
allow use of IDs as function arguments, even if the ID matches a keyword (Fixes #2830)
This commit is contained in:
parent
e9e057de2e
commit
c157fef2e0
4 changed files with 48 additions and 2 deletions
|
@ -353,7 +353,10 @@ namespace Compiler
|
|||
if (extensions->isInstruction (keyword, argumentType, hasExplicit))
|
||||
{
|
||||
// pretend this is not a keyword
|
||||
return parseName (loc.mLiteral, loc, scanner);
|
||||
std::string name = loc.mLiteral;
|
||||
if (name.size()>=2 && name[0]=='"' && name[name.size()-1]=='"')
|
||||
name = name.substr (1, name.size()-2);
|
||||
return parseName (name, loc, scanner);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,23 @@ namespace Compiler
|
|||
|
||||
bool LineParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
|
||||
{
|
||||
if (mState==MessageState || mState==MessageCommaState)
|
||||
{
|
||||
if (const Extensions *extensions = getContext().getExtensions())
|
||||
{
|
||||
std::string argumentType; // ignored
|
||||
bool hasExplicit = false; // ignored
|
||||
if (extensions->isInstruction (keyword, argumentType, hasExplicit))
|
||||
{
|
||||
// pretend this is not a keyword
|
||||
std::string name = loc.mLiteral;
|
||||
if (name.size()>=2 && name[0]=='"' && name[name.size()-1]=='"')
|
||||
name = name.substr (1, name.size()-2);
|
||||
return parseName (name, loc, scanner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mState==SetMemberVarState)
|
||||
{
|
||||
mMemberName = loc.mLiteral;
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include "scanner.hpp"
|
||||
#include "generator.hpp"
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include "context.hpp"
|
||||
#include "extensions.hpp"
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
|
@ -33,6 +36,25 @@ namespace Compiler
|
|||
return Parser::parseName (name, loc, scanner);
|
||||
}
|
||||
|
||||
bool StringParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
|
||||
{
|
||||
if (const Extensions *extensions = getContext().getExtensions())
|
||||
{
|
||||
std::string argumentType; // ignored
|
||||
bool hasExplicit = false; // ignored
|
||||
if (extensions->isInstruction (keyword, argumentType, hasExplicit))
|
||||
{
|
||||
// pretend this is not a keyword
|
||||
std::string name = loc.mLiteral;
|
||||
if (name.size()>=2 && name[0]=='"' && name[name.size()-1]=='"')
|
||||
name = name.substr (1, name.size()-2);
|
||||
return parseName (name, loc, scanner);
|
||||
}
|
||||
}
|
||||
|
||||
return Parser::parseKeyword (keyword, loc, scanner);
|
||||
}
|
||||
|
||||
bool StringParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
|
||||
{
|
||||
if (code==Scanner::S_comma && mState==StartState)
|
||||
|
|
|
@ -32,6 +32,10 @@ namespace Compiler
|
|||
///< Handle a name token.
|
||||
/// \return fetch another token?
|
||||
|
||||
virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner);
|
||||
///< Handle a keyword token.
|
||||
/// \return fetch another token?
|
||||
|
||||
virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner);
|
||||
///< Handle a special character token.
|
||||
/// \return fetch another token?
|
||||
|
|
Loading…
Reference in a new issue