c++ - std::map of string and regex -
i'm working on c++ project small language implemented. in fact, main consists on kind of "pseudo-instructions" use preprocessor translate them valid c++ code. project assignment course , code in main has in format.
this part of line in main.cpp:
program_start  regex(name): start text(a) text(b) end  //text(a) text(b) gives string "ab" . . //more regex definitions here . .  program_end   and on .h file have:
std::map<std::string, std::regex> regex_map; std::string regex_name;  #define program_begin int main(){ #define program_end   return 0;}  #define regex(name) \ std::regex name; \ regex_map[#name] = name; \       //exception here (1) ? (regex_name = #name) \  #define start (regex_name = ""); \  #define end \   regex_map.find(regex_name)->second.assign(currstr,std::regex::ecmascript); \  #define text(a)  getregex(#a); ...   i want create map containing regex , string representing regex's name string value of regex isn't known until reach end.  want insert pair in map empty regex on regex(name) macro , on end macro, using regex's name find pair on map, want assign string regex.
but though project built fine, on line show above exception:
unhandled exception @ 0x0097171f in (project name).exe: 0xc0000005: access violation reading location 0x00000000.
any idea why happens , how can achieve want do?
note: getregex(#a) isn't important in case. creates instance of class have made , gives value string currstr.
note2: use of ternary operator supporting ":" character in main.
 
 
  
Comments
Post a Comment