mirror of
https://github.com/tnodir/fort
synced 2024-11-14 22:19:05 +00:00
UI: RuleTextParser: Minor refactor
This commit is contained in:
parent
ce9e323f18
commit
bf99e98c9d
@ -97,14 +97,8 @@ bool RuleTextParser::parseLines()
|
|||||||
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_OR);
|
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_OR);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!skipComments(CharLineBegin)) {
|
if (!parseLineComments())
|
||||||
if (!isEmpty()) {
|
|
||||||
setError(ErrorUnexpectedStartOfLine, tr("Unexpected start of line"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (!parseLine())
|
if (!parseLine())
|
||||||
break;
|
break;
|
||||||
@ -115,6 +109,19 @@ bool RuleTextParser::parseLines()
|
|||||||
return !hasError();
|
return !hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RuleTextParser::parseLineComments()
|
||||||
|
{
|
||||||
|
if (!skipComments(CharLineBegin)) {
|
||||||
|
if (!isEmpty()) {
|
||||||
|
setError(ErrorUnexpectedStartOfLine, tr("Unexpected start of line"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RuleTextParser::parseLine()
|
bool RuleTextParser::parseLine()
|
||||||
{
|
{
|
||||||
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_AND);
|
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_AND);
|
||||||
@ -157,27 +164,27 @@ bool RuleTextParser::parseLineSection(RuleCharTypes expectedSeparator)
|
|||||||
if (!nextCharType(CharLineBegin | expectedSeparator, CharSpace))
|
if (!nextCharType(CharLineBegin | expectedSeparator, CharSpace))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!processSection())
|
if (!parseSection())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !hasError();
|
return !hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RuleTextParser::processSection()
|
bool RuleTextParser::parseSection()
|
||||||
{
|
{
|
||||||
if ((m_charType & (CharListBegin | CharBracketBegin | CharDigit | CharValueBegin)) != 0) {
|
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) {
|
switch (m_charType) {
|
||||||
case CharListBegin: {
|
case CharListBegin: {
|
||||||
processSectionList();
|
parseSectionList();
|
||||||
} break;
|
} break;
|
||||||
case CharBracketBegin: {
|
case CharBracketBegin: {
|
||||||
parseBracketValues();
|
parseBracketValues();
|
||||||
@ -193,7 +200,7 @@ bool RuleTextParser::processSectionBlock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RuleTextParser::processSectionChar()
|
bool RuleTextParser::parseSectionChar()
|
||||||
{
|
{
|
||||||
switch (m_charType) {
|
switch (m_charType) {
|
||||||
case CharLetter: {
|
case CharLetter: {
|
||||||
@ -218,7 +225,7 @@ bool RuleTextParser::processSectionChar()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleTextParser::processSectionList()
|
void RuleTextParser::parseSectionList()
|
||||||
{
|
{
|
||||||
if (!checkListBegin())
|
if (!checkListBegin())
|
||||||
return;
|
return;
|
||||||
|
@ -94,12 +94,13 @@ private:
|
|||||||
void setupCharPtr();
|
void setupCharPtr();
|
||||||
|
|
||||||
bool parseLines();
|
bool parseLines();
|
||||||
|
bool parseLineComments();
|
||||||
bool parseLine();
|
bool parseLine();
|
||||||
bool parseLineSection(RuleCharTypes expectedSeparator);
|
bool parseLineSection(RuleCharTypes expectedSeparator);
|
||||||
bool processSection();
|
bool parseSection();
|
||||||
bool processSectionBlock();
|
bool parseSectionBlock();
|
||||||
bool processSectionChar();
|
bool parseSectionChar();
|
||||||
void processSectionList();
|
void parseSectionList();
|
||||||
bool checkListBegin();
|
bool checkListBegin();
|
||||||
bool checkListEnd();
|
bool checkListEnd();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user