forked from mirror/openmw-tes3mp
made local variable names case-insensitive
This commit is contained in:
parent
c6a37b2e18
commit
10cb9d3dab
3 changed files with 22 additions and 6 deletions
|
@ -49,8 +49,10 @@ namespace Compiler
|
|||
scanner.scan (skip);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string name2 = toLower (name);
|
||||
|
||||
char type = mLocals.getType (name);
|
||||
char type = mLocals.getType (name2);
|
||||
|
||||
if (type!=' ')
|
||||
{
|
||||
|
@ -61,7 +63,7 @@ namespace Compiler
|
|||
}
|
||||
|
||||
mLocals.declare (mState==ShortState ? 's' : (mState==LongState ? 'l' : 'f'),
|
||||
name);
|
||||
name2);
|
||||
|
||||
mState = EndState;
|
||||
return true;
|
||||
|
@ -70,10 +72,11 @@ namespace Compiler
|
|||
if (mState==SetState)
|
||||
{
|
||||
// local variable?
|
||||
char type = mLocals.getType (name);
|
||||
std::string name2 = toLower (name);
|
||||
char type = mLocals.getType (name2);
|
||||
if (type!=' ')
|
||||
{
|
||||
mName = name;
|
||||
mName = name2;
|
||||
mState = SetLocalVarState;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
#include "parser.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
|
||||
#include "errorhandler.hpp"
|
||||
#include "exception.hpp"
|
||||
|
||||
|
@ -50,6 +53,16 @@ namespace Compiler
|
|||
return mContext;
|
||||
}
|
||||
|
||||
std::string Parser::toLower (const std::string& name)
|
||||
{
|
||||
std::string lowerCase;
|
||||
|
||||
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||
(int(*)(int)) std::tolower);
|
||||
|
||||
return lowerCase;
|
||||
}
|
||||
|
||||
Parser::Parser (ErrorHandler& errorHandler, Context& context)
|
||||
: mErrorHandler (errorHandler), mContext (context)
|
||||
{}
|
||||
|
|
|
@ -21,8 +21,6 @@ namespace Compiler
|
|||
|
||||
protected:
|
||||
|
||||
// mutators
|
||||
|
||||
void reportSeriousError (const std::string& message, const TokenLoc& loc);
|
||||
///< Report the error and throw a exception.
|
||||
|
||||
|
@ -41,6 +39,8 @@ namespace Compiler
|
|||
Context& getContext();
|
||||
///< Return context
|
||||
|
||||
static std::string toLower (const std::string& name);
|
||||
|
||||
public:
|
||||
|
||||
Parser (ErrorHandler& errorHandler, Context& context);
|
||||
|
|
Loading…
Reference in a new issue