public class XPath30Parser extends ExpressionParser
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.
Modifier and Type | Class and Description |
---|---|
static class |
XPath30Parser.InlineFunctionDetails |
static class |
XPath30Parser.TemporaryXSLTVariableBinding |
ExpressionParser.TemporaryContainer
allowXPath30Syntax, catchDepth, codeInjector, defaultContainer, env, language, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
Constructor and Description |
---|
XPath30Parser() |
Modifier and Type | Method and Description |
---|---|
static Expression |
curryFunction(Expression functionExp,
Expression[] args,
IntSet placeMarkers)
Process a function expression in which one or more of the argument positions are
represented as "?" placemarkers (indicating partial application or currying)
|
static Binding |
findOuterRangeVariable(StructuredQName qName,
Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack,
StaticContext env) |
protected Binding |
findRangeVariable(StructuredQName qName)
Locate a range variable with a given name.
|
protected boolean |
isNamespaceTestAllowed()
Ask whether the syntax namespace-node() is allowed in a node kind test.
|
static Expression |
makeCurriedFunction(ExpressionParser parser,
StaticContext env,
int offset,
StructuredQName name,
Expression[] args,
IntSet placeMarkers) |
protected Expression |
makeCurriedFunction(int offset,
StructuredQName name,
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)
|
protected Expression |
parseDynamicFunctionCall(Expression functionItem)
Parse a dynamic function call
|
static Expression |
parseDynamicFunctionCall(Expression functionItem,
ExpressionParser p) |
Expression |
parseFunctionArgument()
Parse a function argument.
|
ItemType |
parseFunctionItemType()
Parse the item type used for function items (XQuery 3.0 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
The "function(" has already been read
|
static ItemType |
parseFunctionItemType(ExpressionParser p) |
static Expression |
parseInlineFunction(ExpressionParser p,
Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack,
Map<StructuredQName,Annotation> annotations) |
protected Expression |
parseInlineFunction(Map<StructuredQName,Annotation> annotations)
Parse an inline function
"function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr
On entry, "function (" has already been read
|
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)
Parse a literal function item (function#arity).
|
protected Expression |
parseMapExpression()
Parse a map expression.
|
protected static Expression |
parseMapExpression(ExpressionParser parser) |
ItemType |
parseMapItemType()
Parse the item type used for function items (XPath 3.0)
Syntax:
map '(' '*' ') |
map '(' ItemType ',' SeqType ')' 'as' SeqType
The "function(" has already been read
|
static ItemType |
parseMapItemType(ExpressionParser p) |
protected ItemType |
parseParenthesizedItemType()
Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)
|
atStartOfRelativePath, currentTokenDisplay, customizeTokenizer, declareRangeVariable, disallowedAtStartOfRelativePath, expect, getCodeInjector, getDefaultContainer, getLanguage, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, isKeyword, isReservedInQuery, makeLocalNameTest, makeNameCode, makeNamespaceTest, makeNameTest, makeNodeName, makeStringLiteral, makeStructuredQName, makeStructuredQNameSilently, makeTracer, nextToken, normalizeEQName, parse, parseAnnotations, parseBasicStep, parseBinaryExpression, parseConstructor, parseExpression, parseExprSingle, parseExtensionExpression, parseFLWORExpression, parseFunctionCall, parseItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseSimpleMappingExpression, parseStepExpression, parseStringLiteral, parseSwitchExpression, parseTryCatchExpression, parseTypePattern, parseTypeswitchExpression, parseValidateExpression, parseVariableReference, reportMissingFunction, resolveFunctionName, setCodeInjector, setDefaultContainer, setLanguage, setLocation, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, testPermittedAxis, undeclareRangeVariable, warning
protected Expression parseLiteralFunctionItem() throws XPathException
parseLiteralFunctionItem
in class ExpressionParser
XPathException
- if a static error is encounteredpublic static Expression parseLiteralFunctionItem(ExpressionParser p) throws XPathException
p
- the parserXPathException
- in the event of a syntax errorpublic ItemType parseFunctionItemType() throws XPathException
parseFunctionItemType
in class ExpressionParser
XPathException
- if a static error occurs (including the case
where XPath 3.0 syntax is not enabled)public static ItemType parseFunctionItemType(ExpressionParser p) throws XPathException
XPathException
public Expression parseFunctionArgument() throws XPathException
parseFunctionArgument
in class ExpressionParser
XPathException
- if the argument expression does not parse correctlypublic ItemType parseMapItemType() throws XPathException
parseMapItemType
in class ExpressionParser
XPathException
- if a parsing error occurs or if the map syntax
is not availablepublic static ItemType parseMapItemType(ExpressionParser p) throws XPathException
XPathException
protected ItemType parseParenthesizedItemType() throws XPathException
parseParenthesizedItemType
in class ExpressionParser
XPathException
- if a syntax error is foundprotected Expression parseDynamicFunctionCall(Expression functionItem) throws XPathException
parseDynamicFunctionCall
in class ExpressionParser
functionItem
- the expression that determines the function to be calledXPathException
- if a static error is foundpublic static Expression parseDynamicFunctionCall(Expression functionItem, ExpressionParser p) throws XPathException
XPathException
protected Expression parseInlineFunction(Map<StructuredQName,Annotation> annotations) throws XPathException
parseInlineFunction
in class ExpressionParser
annotations
- the function annotations, which have already been read, or null if there are noneXPathException
- if a syntax error is foundpublic static Expression parseInlineFunction(ExpressionParser p, Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack, Map<StructuredQName,Annotation> annotations) throws XPathException
XPathException
protected Expression makeCurriedFunction(int offset, StructuredQName name, Expression[] args, IntSet placeMarkers) throws XPathException
makeCurriedFunction
in class ExpressionParser
offset
- offset in the query source of the start of the expressionname
- the function call (as if there were no currying)args
- the arguments (with EmptySequence in the placemarker positions)placeMarkers
- the positions of the placemarkers @return the curried functionXPathException
public static Expression makeCurriedFunction(ExpressionParser parser, StaticContext env, int offset, StructuredQName name, Expression[] args, IntSet placeMarkers) throws XPathException
XPathException
public static Expression curryFunction(Expression functionExp, Expression[] args, IntSet placeMarkers)
functionExp
- an expression that returns the function to be curriedargs
- the arguments (with EmptySequence in the placemarker positions)placeMarkers
- the positions of the placemarkersprotected Expression parseMapExpression() throws XPathException
parseMapExpression
in class ExpressionParser
XPathException
protected static Expression parseMapExpression(ExpressionParser parser) throws XPathException
XPathException
protected Binding findRangeVariable(StructuredQName qName)
findRangeVariable
in class ExpressionParser
qName
- identifies the name of the range variablepublic static Binding findOuterRangeVariable(StructuredQName qName, Stack<XPath30Parser.InlineFunctionDetails> inlineFunctionStack, StaticContext env)
protected boolean isNamespaceTestAllowed()
isNamespaceTestAllowed
in class ExpressionParser
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.