Skip to content

Commit

Permalink
Increase maintainability (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Dec 11, 2019
1 parent d34dde4 commit f363822
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/xml/xpath/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ function _gpfXmlXPathParse (xpathExpression) {
}

function level () {
var relative = Boolean(consumeIfTokenMatch(_GPF_XML_XPATH_TOKEN.CURRENT)),
var relative,
chain = new _GpfXmlXPathChain(),
subOrDeep,
operator;
subOrDeep = consumeIfTokenMatch(_GPF_XML_XPATH_TOKEN.SUB, _GPF_XML_XPATH_TOKEN.DEEP);
if (!subOrDeep) {

function firstLevelNoSubOrDeep () {
if (relative) {
gpf.Error.invalidXPathSyntax();
}
Expand All @@ -131,6 +131,16 @@ function _gpfXmlXPathParse (xpathExpression) {
token: _GPF_XML_XPATH_TOKEN.SUB
};
}

function firstLevel () {
relative = Boolean(consumeIfTokenMatch(_GPF_XML_XPATH_TOKEN.CURRENT));
subOrDeep = consumeIfTokenMatch(_GPF_XML_XPATH_TOKEN.SUB, _GPF_XML_XPATH_TOKEN.DEEP);
if (!subOrDeep) {
firstLevelNoSubOrDeep();
}
}

firstLevel();
while (subOrDeep) {
operator = new levelClasses[subOrDeep.token](relative);
operator.addChild(match());
Expand Down

0 comments on commit f363822

Please sign in to comment.