diff --git a/include/common.h b/include/common.h index 372cf07..8524162 100644 --- a/include/common.h +++ b/include/common.h @@ -1,5 +1,7 @@ #ifndef COMMON_H #define COMMON_H +//#include +#include #include #include #include @@ -314,4 +316,8 @@ inline bool str2uint(const char* str, uint64_t* res) inline bool str2double(const std::string& str, double* res) {return str2double(str.c_str(),res);} inline bool str2int(const std::string& str, int64_t* res) {return str2int(str.c_str(),res);} inline bool str2uint(const std::string& str, int64_t* res) {return str2uint(str.c_str(),res);} + +inline void tolower(std::string& str) {for(auto& p: str) p=tolower(p);} +inline void tolower(std::string* str) {for(auto& p:*str) p=tolower(p);} +inline void tolower(char* str) {for(*str=tolower(*str);'\0'!=*str++;*str=tolower(*str));} #endif diff --git a/src/parser/grammatical.y b/src/parser/grammatical.y index 2ade5c6..0f0aedc 100644 --- a/src/parser/grammatical.y +++ b/src/parser/grammatical.y @@ -14,7 +14,6 @@ %{ #include -#include #include "parser.h" #include "object.h" #include "globals.h" @@ -104,7 +103,7 @@ line: NAME ASSIGN object ENDL {COUT(DEBUG)<<" NAME ASSIGN object ENDL\n"; if(G_vars.count(*$1)!=0) delete G_vars[*$1]; G_vars[*$1]=$3; delete $1;} | NAME ASSIGN list ENDL {COUT(DEBUG)<<" NAME ASSIGN list ENDL\n"; if(G_vars.count(*$1)!=0) delete G_vars[*$1]; G_vars[*$1]=$3; delete $1;} | NAME OBRACE list CBRACE ENDL {COUT(DEBUG)<<" NAME OBRACE list CBRACE ENDL\n"; - transform($1->begin(),$1->end(),$1->begin(),::tolower); + tolower($1); ObjectList* ol=dynamic_cast($3); if(*$1=="save") G_tosave.push_back(ol); else if(*$1=="print") G_toprint.push_back(ol); @@ -117,7 +116,7 @@ line: } delete $1;} | NAME OBRACE object CBRACE ENDL {COUT(DEBUG)<<" NAME OBRACE object CBRACE ENDL\n"; - transform($1->begin(),$1->end(),$1->begin(),::tolower); + tolower($1); ObjectList* ol=new ObjectList($3); if(*$1=="save") G_tosave.push_back(ol); else if(*$1=="print") G_toprint.push_back(ol); diff --git a/src/parser/lexical.l b/src/parser/lexical.l index 9c8cb07..33a90b9 100644 --- a/src/parser/lexical.l +++ b/src/parser/lexical.l @@ -14,7 +14,6 @@ %x PREPROC %{ -#include #include "common.h" #include "parser.h" // flex use register keyword, but it deprecated in C++11. @@ -44,7 +43,7 @@ std::string str; @[Ii][Nn][Cc][Ll][Uu][Dd][Ee][ \t]*\" yy_push_state(INCLUDE,yyscanner); str.erase(); yynextsym; @ BEGIN(PREPROC); yynextsym; [a-zA-Z]* { - yynextsym; str=yytext; transform(str.begin(),str.end(),str.begin(),::tolower); + yynextsym; str=yytext; tolower(str); if("use"==str) return DIR_USE; if("includepath"==str) return DIR_INCLUDEPATH; if("modulepath"==str) return DIR_MODULEPATH;