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,20 +365,9 @@ bool RuleTextParser::parseValue(bool expectValueEnd)
{ {
const QChar *value = parsedCharPtr(); const QChar *value = parsedCharPtr();
for (;;) { if (!parseValueChars(expectValueEnd))
const char *extraChars = expectValueEnd ? extraValueEndChars : extraValueChars;
if (!parseChars(CharLetter | CharValue, extraChars))
return false; return false;
if (!checkValueEnd(expectValueEnd)) {
if (hasError())
return false;
break;
}
}
const QStringView valueView(value, currentCharPtr() - value); const QStringView valueView(value, currentCharPtr() - value);
m_ruleFilter.addValue(valueView); m_ruleFilter.addValue(valueView);
@ -386,6 +375,21 @@ bool RuleTextParser::parseValue(bool expectValueEnd)
return true; 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) bool RuleTextParser::checkValueEnd(bool &expectValueEnd)
{ {
const bool isValueBegin = (m_charType == CharValueBegin); const bool isValueBegin = (m_charType == CharValueBegin);

View File

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