com.saxonica.expr
Class Query30Parser

java.lang.Object
  extended by net.sf.saxon.expr.parser.ExpressionParser
      extended by net.sf.saxon.query.QueryParser
          extended by com.saxonica.expr.Query30Parser

public class Query30Parser
extends QueryParser

Parser extension for new syntax in XQuery 3.0 (was 1.1). Note this cannot currently be used at the same time as the XQuery Update extensions.


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.saxon.expr.parser.ExpressionParser
ExpressionParser.TemporaryContainer
 
Field Summary
 
Fields inherited from class net.sf.saxon.query.QueryParser
executable, FUNCTION_IS_NONDETERMINISTIC, FUNCTION_IS_PRIVATE, FUNCTION_IS_UPDATING, importedModules, queryVersion, XQUERY10, XQUERY30
 
Fields inherited from class net.sf.saxon.expr.parser.ExpressionParser
allowXPath30Syntax, defaultContainer, env, language, languageVersion, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
 
Constructor Summary
Query30Parser()
           
 
Method Summary
protected  void checkForClauseAllowingEmpty(ForClause clause)
          Check a ForClause for an "outer for"
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(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)
 QueryParser newParser()
          Create a new parser of the same kind
protected  int parseAnnotations()
          Parse the annotations that can appear in a variable or function declaration
protected  void parseContextItemDeclaration()
          Parse a context item declaration.
protected  void parseCountClause(List clauseList)
          Parse a LetClause.
protected  void parseDecimalFormatDeclaration()
          Parse a named decimal format declaration.
protected  void parseDefaultDecimalFormat()
          Parse a default decimal format declaration "declare" "default" "decimal-format" (property "=" string-literal)*
protected  Expression parseDynamicFunctionCall(Expression functionItem)
          Parse a dynamic function call
 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 The "function(" has already been read
protected  void parseGroupByClause(List<Clause> clauseList)
          Parse a Group By clause.
protected  Expression parseInlineFunction()
          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) Syntax: QName # integer The QName and # have already been read
protected  Expression parseMapExpression()
          Parse a map expression.
 ItemType parseMapItemType()
          Parse the item type used for function items (XPath 3.0) Syntax: map '(' '*' ') | map '(' ItemType ',' 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
protected  Expression parseNamedNamespaceConstructor(int offset)
          Parse a namespace node constructor of the form namespace name { expr }
protected  Expression parseNamespaceConstructor(int offset)
          Parse a computed namespace constructor of the form namespace {expr}{expr}
protected  ItemType parseParenthesizedItemType()
          Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)
protected  Expression parseSwitchExpression()
          Parse a Switch Expression.
protected  Expression parseTryCatchExpression()
          Parse a Try/Catch Expression.
protected  void parseWindowClause(List<Clause> clauseList)
          Parse a tumbling or sliding window clause.
 
Methods inherited from class net.sf.saxon.query.QueryParser
applyModuleImport, atStartOfRelativePath, customizeTokenizer, getExecutable, getLanguage, grumble, lookAhead, makeLetExpression, makeSimpleContent, makeStringJoin, makeStringLiteral, makeXQueryExpression, normalizeEQName, parseConstructor, parseExtensionExpression, parseFLWORExpression, parseFunctionDeclaration, parseLibraryModule, parseRevalidationDeclaration, parseTypeswitchExpression, parseUpdatingFunctionDeclaration, parseValidateExpression, readCollationName, setDefaultValue, setDisableCycleChecks, setExecutable, stringify, URILiteral
 
Methods inherited from class net.sf.saxon.expr.parser.ExpressionParser
currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, getCodeInjector, getDefaultContainer, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, isKeyword, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeNodeName, makeStructuredQName, makeTracer, nextToken, parse, parseBasicStep, parseBinaryExpression, parseExpression, parseExprSingle, parseFunctionCall, parseItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, parseStringLiteral, parseTypePattern, parseVariableReference, reportMissingFunction, resolveFunctionName, setCodeInjector, 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

Query30Parser

public Query30Parser()
Method Detail

newParser

public QueryParser newParser()
Create a new parser of the same kind

Overrides:
newParser in class QueryParser
Returns:
a new parser of the same kind as this one

getPermittedFunctions

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

Overrides:
getPermittedFunctions in class QueryParser
Returns:
a code indicating which system library functions are supported in this version of the language

parseAnnotations

protected int parseAnnotations()
                        throws XPathException
Parse the annotations that can appear in a variable or function declaration

Overrides:
parseAnnotations in class QueryParser
Throws:
XPathException

parseLiteralFunctionItem

protected Expression parseLiteralFunctionItem()
                                       throws XPathException
Parse a literal function item (introduced in XQuery 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 - if a static error is encountered

parseFunctionItemType

public ItemType parseFunctionItemType()
                               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 The "function(" has already been read

Overrides:
parseFunctionItemType in class ExpressionParser
Returns:
the item type representing a function item
Throws:
XPathException - if a static error occurs (including the case where XPath 3.0 syntax is not enabled)

parseFunctionArgument

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

Overrides:
parseFunctionArgument in class ExpressionParser
Returns:
the Expression used as the argument, or null if the argument is the place-holder "?"
Throws:
XPathException - if the argument expression does not parse correctly

parseMapItemType

public ItemType parseMapItemType()
                          throws XPathException
Parse the item type used for function items (XPath 3.0) Syntax: map '(' '*' ') | map '(' ItemType ',' 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

Overrides:
parseMapItemType in class ExpressionParser
Returns:
the item type of the map
Throws:
XPathException - if a parsing error occurs or if the map syntax is not available

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
Returns:
the item type
Throws:
XPathException - if a syntax error is found

parseDynamicFunctionCall

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

Overrides:
parseDynamicFunctionCall in class ExpressionParser
Parameters:
functionItem - the expression that determines the function to be called
Returns:
the expression that results from the parsing
Throws:
XPathException - if a static error is found

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
Returns:
the parsed inline function
Throws:
XPathException - if a syntax error is found

makeCurriedFunction

protected Expression makeCurriedFunction(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)

Overrides:
makeCurriedFunction in class ExpressionParser
Parameters:
offset -
name - the function name (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
Returns:
the curried function
Throws:
XPathException

parseMapExpression

protected Expression parseMapExpression()
                                 throws XPathException
Parse a map expression. Requires XPath/XQuery 3.0 Provisional syntax map { expr := expr (, expr := expr )*} }

Overrides:
parseMapExpression in class ExpressionParser
Returns:
the map expression
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

parseTryCatchExpression

protected Expression parseTryCatchExpression()
                                      throws XPathException
Parse a Try/Catch Expression. This construct is XQuery-3.0 only. The syntax allows: try { Expr } catch NameTest ('|' NameTest)* { Expr } We don't currently implement the CatchVars

Overrides:
parseTryCatchExpression in class ExpressionParser
Returns:
the parsed expression; except that this version of the method always throws an exception
Throws:
XPathException - if a static error is found

checkForClauseAllowingEmpty

protected void checkForClauseAllowingEmpty(ForClause clause)
                                    throws XPathException
Check a ForClause for an "outer for"

Overrides:
checkForClauseAllowingEmpty in class QueryParser
Parameters:
clause - the clause to be checked
Throws:
XPathException - if invalid

parseCountClause

protected void parseCountClause(List clauseList)
                         throws XPathException
Parse a LetClause.

[44] LetClause ::= <"let" "$"> VarName TypeDeclaration? ":=" ExprSingle ("," "$" VarName TypeDeclaration? ":=" ExprSingle)*

Overrides:
parseCountClause in class QueryParser
Parameters:
clauseList - - the components of the parsed LetClause are appended to the supplied list
Throws:
XPathException

parseGroupByClause

protected void parseGroupByClause(List<Clause> clauseList)
                           throws XPathException
Parse a Group By clause. Handles the full XQuery 3.0 syntax: "group by" ($varname ["collation" URILiteral]) [,...]

Overrides:
parseGroupByClause in class QueryParser
Parameters:
clauseList - the list of clauses for the expression, to which this clause will be added
Throws:
XPathException

parseWindowClause

protected void parseWindowClause(List<Clause> clauseList)
                          throws XPathException
Parse a tumbling or sliding window clause.

Overrides:
parseWindowClause in class QueryParser
Parameters:
clauseList - the list of clauses for the expression, to which this clause will be added
Throws:
XPathException

parseNamespaceConstructor

protected Expression parseNamespaceConstructor(int offset)
                                        throws XPathException
Parse a computed namespace constructor of the form namespace {expr}{expr}

Overrides:
parseNamespaceConstructor in class QueryParser
Parameters:
offset -
Returns:
the compiled Namespace instruction
Throws:
XPathException

parseNamedNamespaceConstructor

protected Expression parseNamedNamespaceConstructor(int offset)
                                             throws XPathException
Parse a namespace node constructor of the form namespace name { expr }

Overrides:
parseNamedNamespaceConstructor in class QueryParser
Parameters:
offset -
Returns:
the compiled instruction
Throws:
XPathException

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)

parseSwitchExpression

protected Expression parseSwitchExpression()
                                    throws XPathException
Parse a Switch Expression. This construct is XQuery-3.0-only. SwitchExpr ::= "switch" "(" Expr ")" SwitchCaseClause+ "default" "return" ExprSingle SwitchCaseClause ::= ("case" ExprSingle)+ "return" ExprSingle

Overrides:
parseSwitchExpression in class ExpressionParser
Returns:
the expression that results from the parsing
Throws:
XPathException - if a static error is found

parseContextItemDeclaration

protected void parseContextItemDeclaration()
                                    throws XPathException
Parse a context item declaration. "declare" "context" "item" TypeDeclaration? ((":=" ExprSingle ) | ("external" (":=" ExprSingle ))

Overrides:
parseContextItemDeclaration in class QueryParser
Throws:
XPathException

parseDecimalFormatDeclaration

protected void parseDecimalFormatDeclaration()
                                      throws XPathException
Parse a named decimal format declaration. "declare" "decimal-format" QName (property "=" string-literal)*

Overrides:
parseDecimalFormatDeclaration in class QueryParser
Throws:
XPathException

parseDefaultDecimalFormat

protected void parseDefaultDecimalFormat()
                                  throws XPathException
Parse a default decimal format declaration "declare" "default" "decimal-format" (property "=" string-literal)*

Overrides:
parseDefaultDecimalFormat in class QueryParser
Throws:
XPathException


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