diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 35c79ff60..47346b814 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -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; } diff --git a/components/compiler/parser.cpp b/components/compiler/parser.cpp index d5a7506c5..2c7686589 100644 --- a/components/compiler/parser.cpp +++ b/components/compiler/parser.cpp @@ -1,6 +1,9 @@ #include "parser.hpp" +#include +#include + #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) {} diff --git a/components/compiler/parser.hpp b/components/compiler/parser.hpp index 5bb541f92..88268eb22 100644 --- a/components/compiler/parser.hpp +++ b/components/compiler/parser.hpp @@ -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);