com.saxonica.expr
Class XPath30Parser

java.lang.Object
  extended by net.sf.saxon.expr.ExpressionParser
      extended by com.saxonica.expr.XPath30Parser

public class XPath30Parser
extends ExpressionParser

Parser extension for new syntax in XPath 3.0.

This contains code duplicated with the XQuery1.1 parser. This is handled by putting the common code into static methods of this class, which are invoked from both the XPath30Parser and the XQuery11Parser.


Nested Class Summary
static class XPath30Parser.InlineFunctionDetails
           
 
Nested classes/interfaces inherited from class net.sf.saxon.expr.ExpressionParser
ExpressionParser.FLWORClause, ExpressionParser.ForClause, ExpressionParser.TemporaryContainer
 
Field Summary
 
Fields inherited from class net.sf.saxon.expr.ExpressionParser
allowXPath30Syntax, compileWithTracing, defaultContainer, env, language, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
 
Constructor Summary
XPath30Parser()
           
 
Method Summary
static Binding findOuterRangeVariable(StructuredQName qName, Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack)
           
protected  Binding findRangeVariable(StructuredQName qName)
          Locate a range variable with a given name.
 int getPermittedFunctions()
          Get the permitted set of standard functions in this environment
protected  boolean isNamespaceTestAllowed()
          Ask whether the syntax namespace-node() is allowed in a node kind test.
protected  Expression makeCurriedFunction(FunctionCall fcall, Expression[] args, IntSet placeMarkers)
          Process a function call in which one or more of the argument positions are represented as "?" placemarkers (indicating partial application or currying)
static Expression makeCurriedFunction(StaticContext env, Container container, FunctionCall fcall, Expression[] args, IntSet placeMarkers)
           
protected  Expression parseDynamicFunctionCall(Expression functionItem)
          Parse a dynamic function call
static Expression parseDynamicFunctionCall(Expression functionItem, ExpressionParser p)
           
protected  Expression parseFunctionArgument()
          Parse a function argument.
 ItemType parseFunctionItemType()
          Parse the item type used for function items (XQuery 1.1 higher order functions) Syntax (changed by WG decision on 2009-09-22): function '(' '*' ') | function '(' (SeqType (',' SeqType)*)? ')' 'as' SeqType For backwards compatibility with Saxon 9.2 we allow the "*" to be omitted for the time being TODO: remove support for the old syntax The "function(" has already been read
static ItemType parseFunctionItemType(ExpressionParser p)
           
protected  Expression parseInlineFunction()
          Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read
static Expression parseInlineFunction(ExpressionParser p, Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack)
           
protected  Expression parseLiteralFunctionItem()
          Parse a literal function item (introduced in XQuery 3.0 and XPath 3.0) Syntax: QName # integer The QName and # have already been read
static Expression parseLiteralFunctionItem(ExpressionParser p)
           
protected  ItemType parseParenthesizedItemType()
          Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)
 
Methods inherited from class net.sf.saxon.expr.ExpressionParser
atStartOfRelativePath, currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, getDefaultContainer, getLanguage, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, isCompileWithTracing, isKeyword, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeStringLiteral, makeStructuredQName, makeTracer, nextToken, normalizeEQName, parse, parseBasicStep, parseConstructor, parseExpression, parseExprSingle, parseExtensionExpression, parseForExpression, parseFunctionCall, parseItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, parseStringLiteral, parseSwitchExpression, parseTryCatchExpression, parseTypeswitchExpression, parseUnionExpression, parseValidateExpression, parseVariableReference, resolveFunctionName, setCompileWithTracing, setDefaultContainer, setLanguage, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPath30Parser

public XPath30Parser()
Method Detail

getPermittedFunctions

public int getPermittedFunctions()
Get the permitted set of standard functions in this environment


parseLiteralFunctionItem

protected Expression parseLiteralFunctionItem()
                                       throws XPathException
Parse a literal function item (introduced in XQuery 3.0 and XPath 3.0) Syntax: QName # integer The QName and # have already been read

Overrides:
parseLiteralFunctionItem in class ExpressionParser
Returns:
an ExternalObject representing the function item
Throws:
XPathException

parseLiteralFunctionItem

public static Expression parseLiteralFunctionItem(ExpressionParser p)
                                           throws XPathException
Throws:
XPathException

parseFunctionItemType

public ItemType parseFunctionItemType()
                               throws XPathException
Parse the item type used for function items (XQuery 1.1 higher order functions) Syntax (changed by WG decision on 2009-09-22): function '(' '*' ') | function '(' (SeqType (',' SeqType)*)? ')' 'as' SeqType For backwards compatibility with Saxon 9.2 we allow the "*" to be omitted for the time being TODO: remove support for the old syntax The "function(" has already been read

Overrides:
parseFunctionItemType in class ExpressionParser
Throws:
XPathException

parseFunctionItemType

public static ItemType parseFunctionItemType(ExpressionParser p)
                                      throws XPathException
Throws:
XPathException

parseFunctionArgument

protected Expression parseFunctionArgument()
                                    throws XPathException
Parse a function argument. The special marker "?" is allowed and causes "null" to be returned

Overrides:
parseFunctionArgument in class ExpressionParser
Throws:
XPathException

parseParenthesizedItemType

protected ItemType parseParenthesizedItemType()
                                       throws XPathException
Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)

Overrides:
parseParenthesizedItemType in class ExpressionParser
Throws:
XPathException

parseDynamicFunctionCall

protected Expression parseDynamicFunctionCall(Expression functionItem)
                                       throws XPathException
Parse a dynamic function call

Overrides:
parseDynamicFunctionCall in class ExpressionParser
Returns:
the expression that results from the parsing
Throws:
XPathException

parseDynamicFunctionCall

public static Expression parseDynamicFunctionCall(Expression functionItem,
                                                  ExpressionParser p)
                                           throws XPathException
Throws:
XPathException

parseInlineFunction

protected Expression parseInlineFunction()
                                  throws XPathException
Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read

Overrides:
parseInlineFunction in class ExpressionParser
Throws:
XPathException - if a syntax error is found

parseInlineFunction

public static Expression parseInlineFunction(ExpressionParser p,
                                             Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack)
                                      throws XPathException
Throws:
XPathException

makeCurriedFunction

protected Expression makeCurriedFunction(FunctionCall fcall,
                                         Expression[] args,
                                         IntSet placeMarkers)
                                  throws XPathException
Process a function call in which one or more of the argument positions are represented as "?" placemarkers (indicating partial application or currying)

Overrides:
makeCurriedFunction in class ExpressionParser
Parameters:
fcall - the function call (as if there were no currying)
args - the arguments (with EmptySequence in the placemarker positions)
placeMarkers - the positions of the placemarkers
Returns:
the curried function
Throws:
XPathException

makeCurriedFunction

public static Expression makeCurriedFunction(StaticContext env,
                                             Container container,
                                             FunctionCall fcall,
                                             Expression[] args,
                                             IntSet placeMarkers)
                                      throws XPathException
Throws:
XPathException

findRangeVariable

protected Binding findRangeVariable(StructuredQName qName)
Locate a range variable with a given name. (By "range variable", we mean a variable declared within the expression where it is used.)

Overrides:
findRangeVariable in class ExpressionParser
Parameters:
qName - identifies the name of the range variable
Returns:
null if not found (this means the variable is probably a context variable); otherwise the relevant RangeVariable

findOuterRangeVariable

public static Binding findOuterRangeVariable(StructuredQName qName,
                                             Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack)

isNamespaceTestAllowed

protected boolean isNamespaceTestAllowed()
Ask whether the syntax namespace-node() is allowed in a node kind test.

Overrides:
isNamespaceTestAllowed in class ExpressionParser
Returns:
true (currently allowed only in XQuery 3.0 and XPath 3.0)


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.