/**
* @throws ExpressionErrorException
*/
public function translateNthChild(XPathExpr
$xpath, FunctionNode
$function, bool
$last = false, bool
$addNameTest = true
): XPathExpr
{ try { [$a,
$b] = Parser::
parseSeries($function->
getArguments());
} catch (SyntaxErrorException
$e) { throw new ExpressionErrorException(sprintf('Invalid series: "%s".',
implode('", "',
$function->
getArguments())), 0,
$e);
} $xpath->
addStarPrefix();
if ($addNameTest) { $xpath->
addNameTest();
} if (0 ===
$a) { return $xpath->
addCondition('position() = '.
($last ? 'last() - '.
($b - 1
) :
$b));
} if ($a < 0
) { if ($b < 1
) { return $xpath->
addCondition('false()'
);
}