Made the hurt hazard work better.

This commit is contained in:
2023-04-01 23:52:34 -07:00
parent 55dc3dc943
commit 765f506db1
15 changed files with 128 additions and 64 deletions

View File

@ -64,7 +64,15 @@ struct PrefabComponentParserRuleset PrefabRegistry::getRuleset(std::string type)
// Find each instance of "@optional" when it's used within a comment
// e.g. // @optional or /* @optional */ in the string data.
std::regex regex("^\\s*(?:\\/\\/|\\/\\*){1}\\s*\\@optional\\s*(?:\\*\\/)?\\s*$", std::regex_constants::ECMAScript | std::regex_constants::multiline);
std::regex_constants::syntax_option_type regexFlags;
#if defined(__GNUC__)
regexFlags = std::regex_constants::ECMAScript | std::regex_constants::multiline;
#else
regexFlags = std::regex_constants::ECMAScript;
#endif
std::regex regex("^\\s*(?:\\/\\/|\\/\\*){1}\\s*\\@optional\\s*(?:\\*\\/)?\\s*$", regexFlags);
std::sregex_iterator it(data.begin(), data.end(), regex);
std::sregex_iterator end;
while(it != end) {
@ -92,7 +100,7 @@ struct PrefabComponentParserRuleset PrefabRegistry::getRuleset(std::string type)
auto variableString = data.substr(varStart, varLength);
// Now (should) be able to extract the type;
std::regex regex2("^\\s*(?:[\\S]+<)?([\\w*:_\\s]+)(?:[\\S]+)? (\\**[\\w]+)\\s*$", std::regex_constants::ECMAScript | std::regex_constants::multiline);
std::regex regex2("^\\s*(?:[\\S]+<)?([\\w*:_\\s]+)(?:[\\S]+)? (\\**[\\w]+)\\s*$", regexFlags);
std::smatch match;
if(!std::regex_search(variableString, match, regex2)) {
std::cout << "Failed to extract type and name from variable string! " << variableString << std::endl;