Class QuickXPathParser

java.lang.Object
com.saxonica.ee.optim.QuickXPathParser
All Implemented Interfaces:
XPathParser.Accelerator

public class QuickXPathParser extends Object implements XPathParser.Accelerator
This class performs a quick parse of commonly encountered XPath expressions that conform to common syntactic patterns. Instead of using the full recursive-descent parser, the expression is tokenized, and the sequence of tokens is tested against a table of known common sequences. If the XPath expression supplied cannot be parsed (either because it is too complicated or because it is invalid), the quick parser simply returns null and leaves the work to the regular parser.
  • Constructor Details

    • QuickXPathParser

      public QuickXPathParser()
  • Method Details

    • parse

      public Expression parse(Tokenizer t, StaticContext env, String expression, int start, int terminator)
      Attempt to parse an expression, provided it is very simple.
      Specified by:
      parse in interface XPathParser.Accelerator
      Parameters:
      t - the tokenizer
      env - the static context
      expression - the string containing expression to be parsed
      start - start position within the input string
      terminator - either EOF or RCURLY, indicating how parsing should end
      Returns:
      either the parsed expression, or null if it is erroneous or too complex to parse.