Package net.sf.saxon.expr.parser
Class ParserExtension
- java.lang.Object
-
- net.sf.saxon.expr.parser.ParserExtension
-
public class ParserExtension extends Object
Dummy Parser extension for syntax in XPath that is accepted only in Saxon-PE and -EE. Primarily, this means XPath 3.0 syntax associated with higher-order functions.
-
-
Constructor Summary
Constructors Constructor Description ParserExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressioncreateDynamicCurriedFunction(XPathParser p, Expression functionItem, ArrayList<Expression> args, IntSet placeMarkers)LocalBindingfindOuterRangeVariable(XPathParser p, StructuredQName qName)When a variable reference occurs within an inline function, it might be a reference to a variable declared outside the inline function (which needs to become part of the closure.voidhandleExternalFunctionDeclaration(XQueryParser p, XQueryFunction func)ExpressionmakeArgumentPlaceMarker(XPathParser p)Parse a function argument.ExpressionmakeCurriedFunction(XPathParser parser, 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 ExpressionparseExtendedExprSingle(XPathParser p)ItemTypeparseExtendedItemType(XPathParser p)Parse an ItemType within a SequenceTypeItemTypeparseFunctionItemType(XPathParser p, AnnotationList annotations)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 readprotected ExpressionparseInlineFunction(XPathParser p, AnnotationList annotations)Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been readExpressionparseNamedFunctionReference(XPathParser p)Parse a literal function item (function#arity).voidparseRevalidationDeclaration(XQueryParser p)Parse the "declare revalidation" declaration.ExpressionparseSimpleInlineFunction(XPathParser p)ExpressionparseTildePattern(XPathParser p)Parse an extended XSLT pattern in the form ~type-alias (predicate)*voidparseTypeAliasDeclaration(XQueryParser p)Parse a type alias declaration.voidparseUpdatingFunctionDeclaration(XQueryParser p)Parse an updating function declaration (allowed in XQuery Update only)
-
-
-
Method Detail
-
parseNamedFunctionReference
public Expression parseNamedFunctionReference(XPathParser p) throws XPathException
Parse a literal function item (function#arity). On entry, the function name and the '#' token have already been read- Parameters:
p- the parser- Returns:
- an expression representing the function value
- Throws:
XPathException- in the event of a syntax error
-
parseFunctionItemType
public ItemType parseFunctionItemType(XPathParser p, AnnotationList annotations) throws XPathException
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- Parameters:
annotations- the list of annotation assertions for this function item type- Throws:
XPathException
-
parseExtendedItemType
public ItemType parseExtendedItemType(XPathParser p) throws XPathException
Parse an ItemType within a SequenceType- Returns:
- the ItemType after parsing
- Throws:
XPathException- if a static error is found
-
parseTildePattern
public Expression parseTildePattern(XPathParser p) throws XPathException
Parse an extended XSLT pattern in the form ~type-alias (predicate)*- Returns:
- the equivalent expression in the form .[. instance of type] (predicate)*
- Throws:
XPathException
-
makeArgumentPlaceMarker
public Expression makeArgumentPlaceMarker(XPathParser p) throws XPathException
Parse a function argument. The special marker "?" is allowed and causes "null" to be returned- Throws:
XPathException
-
parseInlineFunction
protected Expression parseInlineFunction(XPathParser p, AnnotationList annotations) throws XPathException
Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read- Throws:
XPathException- if a syntax error is found
-
parseSimpleInlineFunction
public Expression parseSimpleInlineFunction(XPathParser p) throws XPathException
- Throws:
XPathException
-
makeCurriedFunction
public Expression makeCurriedFunction(XPathParser parser, int offset, StructuredQName name, 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)- Parameters:
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 function- Throws:
XPathException
-
findOuterRangeVariable
public LocalBinding findOuterRangeVariable(XPathParser p, StructuredQName qName)
When a variable reference occurs within an inline function, it might be a reference to a variable declared outside the inline function (which needs to become part of the closure. This code looks for such an outer variable- Parameters:
qName- the name of the variable- Returns:
- a binding for the variable; this will typically be a binding to a newly added parameter for the innermost function in which the variable reference appears. As a side effect, all the inline functions between the declaration of the variable and its use will have this variable as an additional parameter, each one bound to the corresponding parameter in the containing function.
-
createDynamicCurriedFunction
public Expression createDynamicCurriedFunction(XPathParser p, Expression functionItem, ArrayList<Expression> args, IntSet placeMarkers) throws XPathException
- Throws:
XPathException
-
handleExternalFunctionDeclaration
public void handleExternalFunctionDeclaration(XQueryParser p, XQueryFunction func) throws XPathException
- Throws:
XPathException
-
parseTypeAliasDeclaration
public void parseTypeAliasDeclaration(XQueryParser p) throws XPathException
Parse a type alias declaration. Allowed only in Saxon-PE and higher- Throws:
XPathException- if parsing fails
-
parseRevalidationDeclaration
public void parseRevalidationDeclaration(XQueryParser p) throws XPathException
Parse the "declare revalidation" declaration. Syntax: not allowed unless XQuery update is in use- Throws:
XPathException- if the syntax is incorrect, or is not allowed in this XQuery processor
-
parseUpdatingFunctionDeclaration
public void parseUpdatingFunctionDeclaration(XQueryParser p) throws XPathException
Parse an updating function declaration (allowed in XQuery Update only)- Throws:
XPathException- if parsing fails or if updating functions are not allowed
-
parseExtendedExprSingle
protected Expression parseExtendedExprSingle(XPathParser p) throws XPathException
- Throws:
XPathException
-
-