com.saxonica.expr
Class Query30Parser

java.lang.Object
  extended by net.sf.saxon.expr.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.query.QueryParser
QueryParser.LetClause
 
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.query.QueryParser
executable, FUNCTION_IS_NONDETERMINISTIC, FUNCTION_IS_PRIVATE, FUNCTION_IS_UPDATING, importedModules, queryVersion, XQUERY10, XQUERY30
 
Fields inherited from class net.sf.saxon.expr.ExpressionParser
allowXPath30Syntax, compileWithTracing, defaultContainer, env, language, languageVersion, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
 
Constructor Summary
Query30Parser()
           
 
Method Summary
protected  void checkForClauseAllowingEmpty(ExpressionParser.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(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)
 QueryParser newParser()
          Create a new parser of the same kind
protected  void parseContextItemDeclaration()
          Parse a context item declaration.
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
 ForExpression parseForClauseAllowingVersion(ExpressionParser.ForClause clause, StructuredQName varQName)
          Parse an "outer for" clause - XQuery 1.1 only
protected  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 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 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  void parseOuterForClause(List clauseList)
          Parse an Outer ForClause.
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  Expression processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList, Expression action)
          Process a grouping expression
 
Methods inherited from class net.sf.saxon.query.QueryParser
applyModuleImport, atStartOfRelativePath, getExecutable, getLanguage, grumble, lookAhead, makeLetExpression, makeSimpleContent, makeStringJoin, makeStringLiteral, makeXQueryExpression, normalizeEQName, parseConstructor, parseExtensionExpression, parseForExpression, parseFunctionDeclaration, parseLibraryModule, parseRevalidationDeclaration, parseTypeswitchExpression, parseUpdatingFunctionDeclaration, parseValidateExpression, readCollationName, setDefaultValue, setDisableCycleChecks, setExecutable, stringify, URILiteral
 
Methods inherited from class net.sf.saxon.expr.ExpressionParser
currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, getDefaultContainer, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, isCompileWithTracing, isKeyword, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeStructuredQName, makeTracer, nextToken, parse, parseBasicStep, parseExpression, parseExprSingle, parseFunctionCall, parseItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, parseStringLiteral, parseUnionExpression, 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

Query30Parser

public Query30Parser()
Method Detail

newParser

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

Overrides:
newParser in class QueryParser

getPermittedFunctions

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

Overrides:
getPermittedFunctions in class QueryParser

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

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
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

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

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

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

parseForClauseAllowingVersion

public ForExpression parseForClauseAllowingVersion(ExpressionParser.ForClause clause,
                                                   StructuredQName varQName)
                                            throws XPathException
Description copied from class: QueryParser
Parse an "outer for" clause - XQuery 1.1 only

Overrides:
parseForClauseAllowingVersion in class QueryParser
Parameters:
clause - the "for clause"
Throws:
XPathException

checkForClauseAllowingEmpty

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

Overrides:
checkForClauseAllowingEmpty in class QueryParser
Throws:
XPathException - if invalid

parseGroupByClause

protected void parseGroupByClause(List clauseList)
                           throws XPathException
Parse a Group By clause. Currently only a subset of the XQuery 3.0 syntax is supported: "group by" $varname ("collation" URILiteral).

There are also constraints on the structure of a FLWOR expression that contains a group-by clause, but these are imposed at a different level. For the moment, we just parse the clause as it comes.

Overrides:
parseGroupByClause in class QueryParser
Throws:
XPathException

processGroupingExpression

protected Expression processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList,
                                               Expression action)
                                        throws XPathException
Process a grouping expression

Overrides:
processGroupingExpression in class QueryParser
Parameters:
clauseList - the list of clauses (for, let, group by)
action - the return clause, optionally wrapped with if-then-else to reflect the where clause
Throws:
XPathException

parseOuterForClause

protected void parseOuterForClause(List clauseList)
                            throws XPathException
Parse an Outer ForClause.

[42] OuterForClause ::= <"outer" "for" "$"> VarName TypeDeclaration? PositionalVar? "in" ExprSingle ("," "$" VarName TypeDeclaration? PositionalVar? "in" ExprSingle)*

Parameters:
clauseList - - the components of the parsed ForClause are appended to the supplied list
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

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-2010 Saxonica Limited. All rights reserved.