[*] "Improve" (bug fix) and "clean up" (hardly) legacy simple parse list tokenizer
This commit is contained in:
parent
97069a1515
commit
c20b802da7
@ -89,7 +89,7 @@ namespace Aurora::Parse
|
||||
auto isvararg = type == ParsableTag::kParseStringVararg;
|
||||
bool stringLevel = false;
|
||||
bool escapedNewLine = false;
|
||||
bool escapedQuote = false;
|
||||
bool escapeNextLegal = false;
|
||||
|
||||
auto isTerminating = IsTerminating(state, terminatingChars);
|
||||
static auto isSpace = ContainedHerein(whiteChars);
|
||||
@ -107,8 +107,7 @@ namespace Aurora::Parse
|
||||
}
|
||||
|
||||
// some characters should be considered universally illegal such as nasty unicode spaces,
|
||||
// carriage returns, and any other nasty crash exploit depending characters
|
||||
// DO NOT USE THIS TO ESCAPE ENGINE TAGS/COLOR ESCAPES/WHATEVER THE FUCK
|
||||
// carriage returns, and any other nasty crash exploit dependee characters
|
||||
if (isIgnore(cur))
|
||||
{
|
||||
continue;
|
||||
@ -126,13 +125,6 @@ namespace Aurora::Parse
|
||||
}
|
||||
}
|
||||
|
||||
// if we hit a space in a string, assume we're at the end of the token, unless we're parsing
|
||||
// a string in quotation marks or are consuming the entire line (ParsableTag::kParseStringVararg)
|
||||
if ((isSpace(cur)) && (!stringLevel) && (!isvararg))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// if the string starts with a quotation mark, set stringLevel to true
|
||||
// TODO: I dont remember the parse rules. Check the old tests. Should this be AuStartsWith?
|
||||
if ((cur == '"') && (isString) && (out.empty()))
|
||||
@ -156,36 +148,41 @@ namespace Aurora::Parse
|
||||
}
|
||||
|
||||
// escape character for "'s in strings
|
||||
if ((isString) && (stringLevel)) // && (peek == '\"'))
|
||||
if (isString && (peek == '\"' || peek == ' ' || peek == '\n' || peek == '\r'))
|
||||
{
|
||||
escapedQuote = true;
|
||||
escapeNextLegal = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// see above
|
||||
if ((isString) && (AuExchange(escapedQuote, false)))
|
||||
if (AuExchange(escapeNextLegal, false))
|
||||
{
|
||||
out += cur;
|
||||
continue;
|
||||
}
|
||||
|
||||
// match the ending '"' character in the token to terminate strings containing spaces
|
||||
// do not make this more ambiguous by removing the **else if**.
|
||||
// this is mutally exclusive with the above block and must be kept in this order
|
||||
else if (
|
||||
if (
|
||||
(cur == '"') && (isString) && (stringLevel) //
|
||||
|
||||
&& (((peekStatus && (isPeekterminating || isSpace(peek))) || (!peekStatus)))) // expected to fail
|
||||
// can we expect to fail next iteration?
|
||||
&& (((peekStatus && (isPeekterminating || isSpace(peek)) /*Is ending character?*/) ||
|
||||
(!peekStatus)))) // Is EoS?
|
||||
{
|
||||
stringLevel = false;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
// if we hit a space in a string, assume we're at the end of the token, unless we're parsing
|
||||
// a string in quotation marks or are consuming the entire line (ParsableTag::kParseStringVararg)
|
||||
if ((isSpace(cur)) && (!stringLevel) && (!isvararg))
|
||||
{
|
||||
// otherwise emit
|
||||
out += cur;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise emit
|
||||
out += cur;
|
||||
}
|
||||
|
||||
//SysAssert(!stringLevel, "Parsed tag of string type must end with \", got {}", out);
|
||||
|
Loading…
Reference in New Issue
Block a user