## net.sf.saxon.expr
Class ExpressionParser

    java.lang.Object
      net.sf.saxon.expr.ExpressionParser

Direct Known Subclasses:
  SelectionParser

    public class ExpressionParser

extends Object

Parser for XPath expressions and XSLT patterns. This code was originally inspired by James Clark's xt but has been totally rewritten (several times)

Author:
  Michael Kay

Nested Class Summary
`static class` `ExpressionParser.ForClause`

Constructor Summary
`ExpressionParser()`

Method Summary
`Stack` `getRangeVariableStack()` Get the range variable stack.
`Tokenizer` `getTokenizer()` Get the tokenizer (the lexical analyzer)
`boolean` `isCompileWithTracing()` Determine whether trace hooks are included in the compiled code.
`LocalNameTest` `makeLocalNameTest(short nodeType, String localName)` Make a LocalNameTest (*:name)
`int` `makeNameCode(String qname, boolean useDefault)` Make a NameCode, using this Element as the context for namespace resolution
`NamespaceTest` `makeNamespaceTest(short nodeType, String prefix)` Make a NamespaceTest (name:*)
`NameTest` `makeNameTest(short nodeType, String qname, boolean useDefault)` Make a NameTest, using the static context for namespace resolution
`Expression` `parse(String expression, int start, int terminator, int lineNumber, StaticContext env)` Parse a string representing an expression
`Pattern` `parsePattern(String pattern, StaticContext env)` Parse a string representing an XSLT pattern
`SequenceType` `parseSequenceType(String input, StaticContext env)` Parse a string representing a sequence type
`void` `setCompileWithTracing(boolean trueOrFalse)` Set whether trace hooks are to be included in the compiled code.
`void` `setRangeVariableStack(Stack stack)` Set the range variable stack.
`void` `setScanOnly(boolean scanOnly)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ExpressionParser

    public ExpressionParser()

Method Detail

### setCompileWithTracing

    public void setCompileWithTracing(boolean trueOrFalse)

  Set whether trace hooks are to be included in the compiled code. To use tracing, it is necessary both to compile the code with trace hooks included, and to supply a TraceListener at run-time

  Parameters:
    `trueOrFalse` - true if trace code is to be compiled in, false otherwise

### isCompileWithTracing

    public boolean isCompileWithTracing()

  Determine whether trace hooks are included in the compiled code.

  Returns:
    true if trace hooks are included, false if not.

### getTokenizer

    public Tokenizer getTokenizer()

  Get the tokenizer (the lexical analyzer)

  Returns:
    the tokenizer (the lexical analyzer)

### parse

    public Expression parse(String expression,
                            int start,
                            int terminator,
                            int lineNumber,
                            StaticContext env)
                     throws StaticError

  Parse a string representing an expression

  Parameters:
    `expression` - the expression expressed as a String
    `start` - offset within the string where parsing is to start
    `terminator` - character to treat as terminating the expression
    `lineNumber` - location of the start of the expression, for diagnostics
    `env` - the static context for the expression
  Returns:
    an Expression object representing the result of parsing
  Throws:
    `StaticError` - if the expression contains a syntax error

### parsePattern

    public Pattern parsePattern(String pattern,
                                StaticContext env)
                         throws StaticError

  Parse a string representing an XSLT pattern

  Parameters:
    `pattern` - the pattern expressed as a String
    `env` - the static context for the pattern
  Returns:
    a Pattern object representing the result of parsing
  Throws:
    `StaticError` - if the pattern contains a syntax error

### parseSequenceType

    public SequenceType parseSequenceType(String input,
                                          StaticContext env)
                                   throws StaticError

  Parse a string representing a sequence type

  Parameters:
    `input` - the string, which should conform to the XPath SequenceType production
    `env` - the static context
  Returns:
    a SequenceType object representing the type
  Throws:
    `StaticError` - if any error is encountered

### getRangeVariableStack

    public Stack getRangeVariableStack()

  Get the range variable stack. Used when parsing a nested subexpression inside an attribute constructor

### setRangeVariableStack

    public void setRangeVariableStack(Stack stack)

  Set the range variable stack. Used when parsing a nested subexpression inside an attribute constructor.

### makeNameCode

    public final int makeNameCode(String qname,
                                  boolean useDefault)
                           throws StaticError

  Make a NameCode, using this Element as the context for namespace resolution

  Parameters:
    `qname` - The name as written, in the form "[prefix:]localname"
    `useDefault` - Defines the action when there is no prefix. If true, use the default namespace URI for element names. If false, use no namespace URI (as for attribute names).
  Returns:
    the namecode, which can be used to identify this name in the name pool
  Throws:
    `StaticError` - if the name is invalid, or the prefix undeclared

### makeNameTest

    public NameTest makeNameTest(short nodeType,
                                 String qname,
                                 boolean useDefault)
                          throws StaticError

  Make a NameTest, using the static context for namespace resolution

  Parameters:
    `nodeType` - the type of node required (identified by a constant in class Type)
    `qname` - the lexical QName of the required node
    `useDefault` - true if the default namespace should be used when the QName is unprefixed
  Returns:
    a NameTest, representing a pattern that tests for a node of a given node kind and a given name
  Throws:
    `StaticError` - if the QName is invalid

### makeNamespaceTest

    public NamespaceTest makeNamespaceTest(short nodeType,
                                           String prefix)
                                    throws StaticError

  Make a NamespaceTest (name:*)

  Parameters:
    `nodeType` - integer code identifying the type of node required
    `prefix` - the namespace prefix
  Returns:
    the NamespaceTest, a pattern that matches all nodes in this namespace
  Throws:
    `StaticError` - if the namespace prefix is not declared

### makeLocalNameTest

    public LocalNameTest makeLocalNameTest(short nodeType,
                                           String localName)
                                    throws StaticError

  Make a LocalNameTest (*:name)

  Parameters:
    `nodeType` - the kind of node to be matched
    `localName` - the requred local name
  Returns:
    a LocalNameTest, a pattern which matches all nodes of a given local name, regardless of namespace
  Throws:
    `StaticError` - if the local name is invalid

### setScanOnly

    public void setScanOnly(boolean scanOnly)

Copyright (C) Michael H. Kay. All rights reserved.