UI: RuleTextParser: Minor refactor

This commit is contained in:
Nodir Temirkhodjaev 2024-11-07 10:58:23 +05:00
parent ce9e323f18
commit bf99e98c9d
2 changed files with 27 additions and 19 deletions

View File

@ -97,14 +97,8 @@ bool RuleTextParser::parseLines()
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_OR);
for (;;) {
if (!skipComments(CharLineBegin)) {
if (!isEmpty()) {
setError(ErrorUnexpectedStartOfLine, tr("Unexpected start of line"));
return false;
}
if (!parseLineComments())
break;
}
if (!parseLine())
break;
@ -115,6 +109,19 @@ bool RuleTextParser::parseLines()
return !hasError();
}
bool RuleTextParser::parseLineComments()
{
if (!skipComments(CharLineBegin)) {
if (!isEmpty()) {
setError(ErrorUnexpectedStartOfLine, tr("Unexpected start of line"));
}
return false;
}
return true;
}
bool RuleTextParser::parseLine()
{
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_AND);
@ -157,27 +164,27 @@ bool RuleTextParser::parseLineSection(RuleCharTypes expectedSeparator)
if (!nextCharType(CharLineBegin | expectedSeparator, CharSpace))
return false;
if (!processSection())
if (!parseSection())
break;
}
return !hasError();
}
bool RuleTextParser::processSection()
bool RuleTextParser::parseSection()
{
if ((m_charType & (CharListBegin | CharBracketBegin | CharDigit | CharValueBegin)) != 0) {
return processSectionBlock();
return parseSectionBlock();
}
return processSectionChar();
return parseSectionChar();
}
bool RuleTextParser::processSectionBlock()
bool RuleTextParser::parseSectionBlock()
{
switch (m_charType) {
case CharListBegin: {
processSectionList();
parseSectionList();
} break;
case CharBracketBegin: {
parseBracketValues();
@ -193,7 +200,7 @@ bool RuleTextParser::processSectionBlock()
return false;
}
bool RuleTextParser::processSectionChar()
bool RuleTextParser::parseSectionChar()
{
switch (m_charType) {
case CharLetter: {
@ -218,7 +225,7 @@ bool RuleTextParser::processSectionChar()
return false;
}
void RuleTextParser::processSectionList()
void RuleTextParser::parseSectionList()
{
if (!checkListBegin())
return;

View File

@ -94,12 +94,13 @@ private:
void setupCharPtr();
bool parseLines();
bool parseLineComments();
bool parseLine();
bool parseLineSection(RuleCharTypes expectedSeparator);
bool processSection();
bool processSectionBlock();
bool processSectionChar();
void processSectionList();
bool parseSection();
bool parseSectionBlock();
bool parseSectionChar();
void parseSectionList();
bool checkListBegin();
bool checkListEnd();