UI: RuleTextParser: Simplify parseValue()

This commit is contained in:
Nodir Temirkhodjaev 2024-11-07 11:44:14 +05:00
parent daa710ff4a
commit cfcf4539ab
2 changed files with 18 additions and 13 deletions

View File

@ -365,19 +365,8 @@ bool RuleTextParser::parseValue(bool expectValueEnd)
{
const QChar *value = parsedCharPtr();
for (;;) {
const char *extraChars = expectValueEnd ? extraValueEndChars : extraValueChars;
if (!parseChars(CharLetter | CharValue, extraChars))
return false;
if (!checkValueEnd(expectValueEnd)) {
if (hasError())
return false;
break;
}
}
if (!parseValueChars(expectValueEnd))
return false;
const QStringView valueView(value, currentCharPtr() - value);
@ -386,6 +375,21 @@ bool RuleTextParser::parseValue(bool expectValueEnd)
return true;
}
bool RuleTextParser::parseValueChars(bool &expectValueEnd)
{
for (;;) {
const char *extraChars = expectValueEnd ? extraValueEndChars : extraValueChars;
if (!parseChars(CharLetter | CharValue, extraChars))
return false;
if (!checkValueEnd(expectValueEnd))
break;
}
return !hasError();
}
bool RuleTextParser::checkValueEnd(bool &expectValueEnd)
{
const bool isValueBegin = (m_charType == CharValueBegin);

View File

@ -112,6 +112,7 @@ private:
bool checkBracketValuesSeparator(RuleCharTypes expectedSeparator);
bool checkBracketValueEnd();
bool parseValue(bool expectValueEnd);
bool parseValueChars(bool &expectValueEnd);
bool checkValueEnd(bool &expectValueEnd);
bool checkAddFilter();