basex-lsp/bundles/grammar/XQuery-40.ebnf.old
2025-08-16 18:01:03 +01:00

1299 lines
No EOL
38 KiB
EBNF
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* XQuery 4.0: An XML Query Language
* version https://qt4cg.org/specifications/xquery-40/
* extracted from https://qt4cg.org/specifications/xquery-40/xquery-40.html on Tue Jul 29, 2025, 19:30 (UTC+02)
* and transformed by rexify-xquery-40.xq
*/
Module ::= VersionDecl? ( LibraryModule | MainModule ) EOF
VersionDecl
::= 'xquery' ( 'encoding' StringLiteral | 'version' StringLiteral ( 'encoding' StringLiteral )? ) Separator
Separator
::= ';'
LibraryModule
::= ModuleDecl Prolog
ModuleDecl
::= 'module' 'namespace' NCName '=' URILiteral Separator
NCName ::= UnreservedNCName
| 'NaN'
| 'allowing'
| 'ancestor'
| 'ancestor-or-self'
| 'and'
| 'array'
| 'as'
| 'ascending'
| 'at'
| 'attribute'
| 'base-uri'
| 'boundary-space'
| 'by'
| 'case'
| 'cast'
| 'castable'
| 'catch'
| 'child'
| 'collation'
| 'comment'
| 'construction'
| 'context'
| 'copy-namespaces'
| 'count'
| 'decimal-format'
| 'decimal-separator'
| 'declare'
| 'default'
| 'descendant'
| 'descendant-or-self'
| 'descending'
| 'digit'
| 'div'
| 'document'
| 'document-node'
| 'element'
| 'else'
| 'empty'
| 'empty-sequence'
| 'encoding'
| 'end'
| 'enum'
| 'eq'
| 'every'
| 'except'
| 'exponent-separator'
| 'external'
| 'false'
| 'finally'
| 'fixed'
| 'fn'
| 'following'
| 'following-or-self'
| 'following-sibling'
| 'following-sibling-or-self'
| 'follows'
| 'for'
| 'function'
| 'ge'
| 'get'
| 'gnode'
| 'greatest'
| 'group'
| 'grouping-separator'
| 'gt'
| 'idiv'
| 'if'
| 'import'
| 'in'
| 'infinity'
| 'inherit'
| 'instance'
| 'intersect'
| 'is'
| 'is-not'
| 'item'
| 'jnode'
| 'key'
| 'lax'
| 'le'
| 'least'
| 'let'
| 'lt'
| 'map'
| 'member'
| 'minus-sign'
| 'mod'
| 'module'
| 'namespace'
| 'namespace-node'
| 'ne'
| 'next'
| 'no-inherit'
| 'no-preserve'
| 'node'
| 'of'
| 'only'
| 'option'
| 'or'
| 'order'
| 'ordered'
| 'ordering'
| 'otherwise'
| 'parent'
| 'pattern-separator'
| 'per-mille'
| 'percent'
| 'precedes'
| 'preceding'
| 'preceding-or-self'
| 'preceding-sibling'
| 'preceding-sibling-or-self'
| 'preserve'
| 'previous'
| 'processing-instruction'
| 'record'
| 'return'
| 'satisfies'
| 'schema'
| 'schema-attribute'
| 'schema-element'
| 'self'
| 'sliding'
| 'some'
| 'stable'
| 'start'
| 'strict'
| 'strip'
| 'switch'
| 'text'
| 'then'
| 'to'
| 'treat'
| 'true'
| 'try'
| 'tumbling'
| 'type'
| 'typeswitch'
| 'union'
| 'unordered'
| 'validate'
| 'value'
| 'variable'
| 'version'
| 'when'
| 'where'
| 'while'
| 'window'
| 'xquery'
| 'zero-digit'
| ''
| ''
| ''
| ''
URILiteral
::= StringLiteral
Prolog ::= ( ( DefaultNamespaceDecl | Setter | NamespaceDecl | Import ) Separator )* ( ( ContextValueDecl | VarDecl | FunctionDecl | ItemTypeDecl | NamedRecordTypeDecl | OptionDecl ) Separator )*
DefaultNamespaceDecl
::= 'declare' 'fixed'? 'default' ( 'element' | 'function' ) 'namespace' URILiteral
Setter ::= BoundarySpaceDecl
| DefaultCollationDecl
| BaseURIDecl
| ConstructionDecl
| OrderingModeDecl
| EmptyOrderDecl
| CopyNamespacesDecl
| DecimalFormatDecl
BoundarySpaceDecl
::= 'declare' 'boundary-space' ( 'preserve' | 'strip' )
DefaultCollationDecl
::= 'declare' 'default' 'collation' URILiteral
BaseURIDecl
::= 'declare' 'base-uri' URILiteral
ConstructionDecl
::= 'declare' 'construction' ( 'strip' | 'preserve' )
OrderingModeDecl
::= 'declare' 'ordering' ( 'ordered' | 'unordered' )
EmptyOrderDecl
::= 'declare' 'default' 'order' 'empty' ( 'greatest' | 'least' )
CopyNamespacesDecl
::= 'declare' 'copy-namespaces' PreserveMode ',' InheritMode
PreserveMode
::= 'preserve'
| 'no-preserve'
InheritMode
::= 'inherit'
| 'no-inherit'
DecimalFormatDecl
::= 'declare' ( 'decimal-format' EQName | 'default' 'decimal-format' ) ( DFPropertyName '=' StringLiteral )*
EQName ::= QName
| URIQualifiedName
QName ::= UnreservedFunctionQName
| 'attribute'
| 'comment'
| 'document-node'
| 'element'
| 'namespace-node'
| 'node'
| 'schema-attribute'
| 'schema-element'
| 'processing-instruction'
| 'text'
| 'array'
| 'enum'
| 'fn'
| 'function'
| 'gnode'
| 'get'
| 'if'
| 'item'
| 'jnode'
| 'map'
| 'record'
| 'switch'
| 'type'
| 'typeswitch'
UnreservedFunctionQName
::= UnreservedQName
| 'NaN'
| 'allowing'
| 'ancestor'
| 'ancestor-or-self'
| 'and'
| 'as'
| 'ascending'
| 'at'
| 'base-uri'
| 'boundary-space'
| 'by'
| 'case'
| 'cast'
| 'castable'
| 'catch'
| 'child'
| 'collation'
| 'construction'
| 'context'
| 'copy-namespaces'
| 'count'
| 'decimal-format'
| 'decimal-separator'
| 'declare'
| 'default'
| 'descendant'
| 'descendant-or-self'
| 'descending'
| 'digit'
| 'div'
| 'document'
| 'else'
| 'empty'
| 'empty-sequence'
| 'encoding'
| 'end'
| 'eq'
| 'every'
| 'except'
| 'exponent-separator'
| 'external'
| 'false'
| 'finally'
| 'fixed'
| 'following'
| 'following-or-self'
| 'following-sibling'
| 'following-sibling-or-self'
| 'follows'
| 'for'
| 'ge'
| 'greatest'
| 'group'
| 'grouping-separator'
| 'gt'
| 'idiv'
| 'import'
| 'in'
| 'infinity'
| 'inherit'
| 'instance'
| 'intersect'
| 'is'
| 'is-not'
| 'key'
| 'lax'
| 'le'
| 'least'
| 'let'
| 'lt'
| 'member'
| 'minus-sign'
| 'mod'
| 'module'
| 'namespace'
| 'ne'
| 'next'
| 'no-inherit'
| 'no-preserve'
| 'of'
| 'only'
| 'option'
| 'or'
| 'order'
| 'ordered'
| 'ordering'
| 'otherwise'
| 'parent'
| 'pattern-separator'
| 'per-mille'
| 'percent'
| 'precedes'
| 'preceding'
| 'preceding-or-self'
| 'preceding-sibling'
| 'preceding-sibling-or-self'
| 'preserve'
| 'previous'
| 'return'
| 'satisfies'
| 'schema'
| 'self'
| 'sliding'
| 'some'
| 'stable'
| 'start'
| 'strict'
| 'strip'
| 'then'
| 'to'
| 'treat'
| 'true'
| 'try'
| 'tumbling'
| 'union'
| 'unordered'
| 'validate'
| 'value'
| 'variable'
| 'version'
| 'when'
| 'where'
| 'while'
| 'window'
| 'xquery'
| 'zero-digit'
| ''
| ''
| ''
| ''
DFPropertyName
::= 'decimal-separator'
| 'grouping-separator'
| 'infinity'
| 'minus-sign'
| 'NaN'
| 'percent'
| 'per-mille'
| 'zero-digit'
| 'digit'
| 'pattern-separator'
| 'exponent-separator'
NamespaceDecl
::= 'declare' 'namespace' NCName '=' URILiteral
Import ::= SchemaImport
| ModuleImport
SchemaImport
::= 'import' 'schema' SchemaPrefix? URILiteral ( 'at' URILiteral ( ',' URILiteral )* )?
SchemaPrefix
::= 'namespace' NCName '='
| 'fixed'? 'default' 'element' 'namespace'
ModuleImport
::= 'import' 'module' ( 'namespace' NCName '=' )? URILiteral ( 'at' URILiteral ( ',' URILiteral )* )?
ContextValueDecl
::= 'declare' 'context' ( 'value' ( 'as' SequenceType )? | 'item' ( 'as' ItemType )? ) ( ':=' VarValue | 'external' ( ':=' VarDefaultValue )? )
SequenceType
::= 'empty-sequence' '(' ')'
| ItemType ( OccurrenceIndicator / )
ItemType ::= RegularItemType
| FunctionType
| TypeName
| ChoiceItemType
RegularItemType
::= AnyItemTest
| NodeKindTest
| GNodeType
| JNodeType
| MapType
| ArrayType
| RecordType
| EnumerationType
AnyItemTest
::= 'item' '(' ')'
NodeKindTest
::= DocumentTest
| ElementTest
| AttributeTest
| SchemaElementTest
| SchemaAttributeTest
| PITest
| CommentTest
| TextTest
| NamespaceNodeTest
| AnyNodeKindTest
DocumentTest
::= 'document-node' '(' ( ElementTest | SchemaElementTest | NameTestUnion )? ')'
ElementTest
::= 'element' '(' ( NameTestUnion ( ',' TypeName '?'? )? )? ')'
NameTestUnion
::= NameTest ( '|' NameTest )*
NameTest ::= EQName
| Wildcard
TypeName ::= EQName
SchemaElementTest
::= 'schema-element' '(' ElementName ')'
ElementName
::= EQName
AttributeTest
::= 'attribute' '(' ( NameTestUnion ( ',' TypeName )? )? ')'
SchemaAttributeTest
::= 'schema-attribute' '(' AttributeName ')'
AttributeName
::= EQName
PITest ::= 'processing-instruction' '(' ( NCName | StringLiteral )? ')'
CommentTest
::= 'comment' '(' ')'
TextTest ::= 'text' '(' ')'
NamespaceNodeTest
::= 'namespace-node' '(' ')'
AnyNodeKindTest
::= 'node' '(' ')'
GNodeType
::= 'gnode' '(' ')'
JNodeType
::= 'jnode' '(' SequenceType? ')'
MapType ::= AnyMapType
| TypedMapType
AnyMapType
::= 'map' '(' '*' ')'
TypedMapType
::= 'map' '(' ItemType ',' SequenceType ')'
ArrayType
::= AnyArrayType
| TypedArrayType
AnyArrayType
::= 'array' '(' '*' ')'
TypedArrayType
::= 'array' '(' SequenceType ')'
RecordType
::= AnyRecordType
| TypedRecordType
AnyRecordType
::= 'record' '(' '*' ')'
TypedRecordType
::= 'record' '(' ( FieldDeclaration ( ',' FieldDeclaration )* )? ExtensibleFlag? ')'
FieldDeclaration
::= FieldName '?'? ( 'as' SequenceType )?
FieldName
::= NCName
| StringLiteral
ExtensibleFlag
::= ',' '*'
EnumerationType
::= 'enum' '(' StringLiteral ( ',' StringLiteral )* ')'
FunctionType
::= Annotation* ( AnyFunctionType | TypedFunctionType )
Annotation
::= '%' EQName ( '(' AnnotationValue ( ',' AnnotationValue )* ')' )?
AnnotationValue
::= StringLiteral
| '-'? NumericLiteral
| QNameLiteral
| 'true' '(' ')'
| 'false' '(' ')'
NumericLiteral
::= IntegerLiteral
| HexIntegerLiteral
| BinaryIntegerLiteral
| DecimalLiteral
| DoubleLiteral
QNameLiteral
::= '#' EQName
AnyFunctionType
::= ( 'function' | 'fn' ) '(' '*' ')'
TypedFunctionType
::= ( 'function' | 'fn' ) '(' ( TypedFunctionParam ( ',' TypedFunctionParam )* )? ')' 'as' SequenceType
TypedFunctionParam
::= ( '$' EQName 'as' )? SequenceType
ChoiceItemType
::= '(' ItemType ( '|' ItemType )* ')'
OccurrenceIndicator
::= '?'
| '*'
| '+'
VarValue ::= ExprSingle
ExprSingle
::= FLWORExpr
| QuantifiedExpr
| SwitchExpr
| TypeswitchExpr
| IfExpr
| TryCatchExpr
| OrExpr
FLWORExpr
::= InitialClause IntermediateClause* ReturnClause
InitialClause
::= ForClause
| LetClause
| WindowClause
ForClause
::= 'for' ForBinding ( ',' ForBinding )*
ForBinding
::= ForItemBinding
| ForMemberBinding
| ForEntryBinding
ForItemBinding
::= VarNameAndType AllowingEmpty? PositionalVar? 'in' ExprSingle
VarNameAndType
::= '$' EQName TypeDeclaration?
TypeDeclaration
::= 'as' SequenceType
AllowingEmpty
::= 'allowing' 'empty'
PositionalVar
::= 'at' VarName
VarName ::= '$' EQName
ForMemberBinding
::= 'member' VarNameAndType PositionalVar? 'in' ExprSingle
ForEntryBinding
::= ( ForEntryKeyBinding ForEntryValueBinding? | ForEntryValueBinding ) PositionalVar? 'in' ExprSingle
ForEntryKeyBinding
::= 'key' VarNameAndType
ForEntryValueBinding
::= 'value' VarNameAndType
LetClause
::= 'let' LetBinding ( ',' LetBinding )*
LetBinding
::= LetValueBinding
| LetSequenceBinding
| LetArrayBinding
| LetMapBinding
LetValueBinding
::= VarNameAndType ':=' ExprSingle
LetSequenceBinding
::= '$' '(' VarNameAndType ( ',' VarNameAndType )* ')' TypeDeclaration? ':=' ExprSingle
LetArrayBinding
::= '$' '[' VarNameAndType ( ',' VarNameAndType )* ']' TypeDeclaration? ':=' ExprSingle
LetMapBinding
::= '$' '{' VarNameAndType ( ',' VarNameAndType )* '}' TypeDeclaration? ':=' ExprSingle
WindowClause
::= 'for' ( TumblingWindowClause | SlidingWindowClause )
TumblingWindowClause
::= 'tumbling' 'window' VarNameAndType 'in' ExprSingle WindowStartCondition? WindowEndCondition?
WindowStartCondition
::= 'start' WindowVars ( 'when' ExprSingle )?
WindowVars
::= CurrentVar? PositionalVar? PreviousVar? NextVar?
CurrentVar
::= VarName
PreviousVar
::= 'previous' VarName
NextVar ::= 'next' VarName
WindowEndCondition
::= 'only'? 'end' WindowVars ( 'when' ExprSingle )?
SlidingWindowClause
::= 'sliding' 'window' VarNameAndType 'in' ExprSingle WindowStartCondition? WindowEndCondition
IntermediateClause
::= InitialClause
| WhereClause
| WhileClause
| GroupByClause
| OrderByClause
| CountClause
WhereClause
::= 'where' ExprSingle
WhileClause
::= 'while' ExprSingle
GroupByClause
::= 'group' 'by' GroupingSpec ( ',' GroupingSpec )*
GroupingSpec
::= VarName ( TypeDeclaration? ':=' ExprSingle )? ( 'collation' URILiteral )?
OrderByClause
::= 'stable'? 'order' 'by' OrderSpec ( ',' OrderSpec )*
OrderSpec
::= ExprSingle OrderModifier
OrderModifier
::= ( 'ascending' | 'descending' )? ( 'empty' ( 'greatest' | 'least' ) )? ( 'collation' URILiteral )?
CountClause
::= 'count' VarName
ReturnClause
::= 'return' ExprSingle
QuantifiedExpr
::= ( 'some' | 'every' ) QuantifierBinding ( ',' QuantifierBinding )* 'satisfies' ExprSingle
QuantifierBinding
::= VarNameAndType 'in' ExprSingle
SwitchExpr
::= 'switch' SwitchComparand ( SwitchCases | BracedSwitchCases )
SwitchComparand
::= '(' Expr? ')'
Expr ::= ExprSingle ( ',' ExprSingle )*
SwitchCases
::= SwitchCaseClause+ 'default' 'return' ExprSingle
SwitchCaseClause
::= ( 'case' SwitchCaseOperand )+ 'return' ExprSingle
SwitchCaseOperand
::= Expr
BracedSwitchCases
::= '{' SwitchCases '}'
TypeswitchExpr
::= 'typeswitch' '(' Expr ')' ( TypeswitchCases | BracedTypeswitchCases )
TypeswitchCases
::= CaseClause+ 'default' VarName? 'return' ExprSingle
CaseClause
::= 'case' ( VarName 'as' )? SequenceTypeUnion 'return' ExprSingle
SequenceTypeUnion
::= SequenceType ( '|' SequenceType )*
BracedTypeswitchCases
::= '{' TypeswitchCases '}'
IfExpr ::= 'if' '(' Expr ')' ( UnbracedActions | BracedAction )
UnbracedActions
::= 'then' ExprSingle 'else' ExprSingle
BracedAction
::= EnclosedExpr
EnclosedExpr
::= '{' Expr? '}'
TryCatchExpr
::= TryClause ( CatchClause+ FinallyClause? | FinallyClause )
TryClause
::= 'try' EnclosedExpr
CatchClause
::= 'catch' NameTestUnion EnclosedExpr
FinallyClause
::= 'finally' EnclosedExpr
OrExpr ::= AndExpr ( 'or' AndExpr )*
AndExpr ::= ComparisonExpr ( 'and' ComparisonExpr )*
ComparisonExpr
::= OtherwiseExpr ( ( ValueComp | GeneralComp | NodeComp ) OtherwiseExpr )?
OtherwiseExpr
::= StringConcatExpr ( 'otherwise' StringConcatExpr )*
StringConcatExpr
::= RangeExpr ( '||' RangeExpr )*
RangeExpr
::= AdditiveExpr ( 'to' AdditiveExpr )?
AdditiveExpr
::= MultiplicativeExpr ( ( '+' | '-' ) MultiplicativeExpr )*
MultiplicativeExpr
::= UnionExpr ( ( '*' | '×' | 'div' | '÷' | 'idiv' | 'mod' ) UnionExpr )*
UnionExpr
::= IntersectExceptExpr ( ( 'union' | '|' ) IntersectExceptExpr )*
IntersectExceptExpr
::= InstanceofExpr ( ( 'intersect' | 'except' ) InstanceofExpr )*
InstanceofExpr
::= TreatExpr ( 'instance' 'of' SequenceType )?
TreatExpr
::= CastableExpr ( 'treat' 'as' SequenceType )?
CastableExpr
::= CastExpr ( 'castable' 'as' CastTarget '?'? )?
CastExpr ::= PipelineExpr ( 'cast' 'as' CastTarget '?'? )?
PipelineExpr
::= ArrowExpr ( ( '->' | '-' ) ArrowExpr )*
ArrowExpr
::= UnaryExpr ( SequenceArrowTarget | MappingArrowTarget )*
UnaryExpr
::= ( '-' | '+' )* ValueExpr
ValueExpr
::= ValidateExpr
| ExtensionExpr
| SimpleMapExpr
ValidateExpr
::= 'validate' ( ValidationMode | 'type' TypeName )? '{' Expr '}'
ValidationMode
::= 'lax'
| 'strict'
ExtensionExpr
::= Pragma+ '{' Expr? '}'
Pragma ::= '(#' S EQName ( S PragmaContents )? '#)'
/* ws: explicit */
SimpleMapExpr
::= PathExpr ( '!' PathExpr )*
PathExpr ::= AbsolutePathExpr
| RelativePathExpr
AbsolutePathExpr
::= '/' ( RelativePathExpr / )
| '//' RelativePathExpr
RelativePathExpr
::= StepExpr ( ( '/' | '//' ) StepExpr )*
StepExpr ::= PostfixExpr
| AxisStep
PostfixExpr
::= PrimaryExpr
| FilterExpr
| DynamicFunctionCall
| LookupExpr
| FilterExprAM
PrimaryExpr
::= Literal
| VarRef
| ParenthesizedExpr
| ContextValueRef
| FunctionCall
| OrderedExpr
| UnorderedExpr
| NodeConstructor
| FunctionItemExpr
| MapConstructor
| ArrayConstructor
| StringTemplate
| StringConstructor
| UnaryLookup
Literal ::= NumericLiteral
| StringLiteral
| QNameLiteral
VarRef ::= '$' EQName
ParenthesizedExpr
::= '(' Expr? ')'
ContextValueRef
::= '.'
FunctionCall
::= UnreservedFunctionEQName ArgumentList
UnreservedFunctionEQName
::= UnreservedFunctionQName
| URIQualifiedName
ArgumentList
::= '(' ( PositionalArguments ( ',' KeywordArguments )? | KeywordArguments )? ')'
PositionalArguments
::= Argument
| PositionalArguments ',' Argument
Argument ::= ExprSingle
| ArgumentPlaceholder
ArgumentPlaceholder
::= '?'
KeywordArguments
::= KeywordArgument ( ',' KeywordArgument )*
KeywordArgument
::= EQName ':=' Argument
OrderedExpr
::= 'ordered' EnclosedExpr
UnorderedExpr
::= 'unordered' EnclosedExpr
NodeConstructor
::= DirectConstructor
| ComputedConstructor
DirectConstructor
::= DirElemConstructor
| DirCommentConstructor
| DirPIConstructor
DirElemConstructor
::= '<'^DirElemConstructor QName DirAttributeList ( '/>' | '>' DirElemContent* '</' QName S? '>' )
/* ws: explicit */
DirAttributeList
::= ( S ( QName S? '=' S? DirAttributeValue )? )*
/* ws: explicit */
DirAttributeValue
::= '"' ( EscapeQuot | QuotAttrValueContent )* '"'
| "'" ( EscapeApos | AposAttrValueContent )* "'"
/* ws: explicit */
QuotAttrValueContent
::= QuotAttrContentChar
| CommonContent
CommonContent
::= PredefinedEntityRef
| CharRef
| '{{'
| '}}'
| EnclosedExpr
AposAttrValueContent
::= AposAttrContentChar
| CommonContent
DirElemContent
::= DirectConstructor
| CDataSection
| CommonContent
| ElementContentChar
CDataSection
::= '<![CDATA[' CDataSectionContents ']]>'
/* ws: explicit */
DirCommentConstructor
::= '<!--' DirCommentContents '-->'
/* ws: explicit */
DirPIConstructor
::= '<?' PITarget ( S DirPIContents )? '?>'
/* ws: explicit */
ComputedConstructor
::= CompDocConstructor
| CompElemConstructor
| CompAttrConstructor
| CompNamespaceConstructor
| CompTextConstructor
| CompCommentConstructor
| CompPIConstructor
CompDocConstructor
::= 'document' EnclosedExpr
CompElemConstructor
::= 'element' CompNodeName EnclosedContentExpr
CompNodeName
::= QNameLiteral
| UnreservedName
| '{' Expr '}'
UnreservedName
::= UnreservedQName
| URIQualifiedName
EnclosedContentExpr
::= EnclosedExpr
CompAttrConstructor
::= 'attribute' CompNodeName EnclosedExpr
CompNamespaceConstructor
::= 'namespace' CompNodeNCName EnclosedExpr
CompNodeNCName
::= MarkedNCName
| UnreservedNCName
| '{' Expr '}'
MarkedNCName
::= '#' NCName
CompTextConstructor
::= 'text' EnclosedExpr
CompCommentConstructor
::= 'comment' EnclosedExpr
CompPIConstructor
::= 'processing-instruction' CompNodeNCName EnclosedExpr
FunctionItemExpr
::= NamedFunctionRef
| InlineFunctionExpr
NamedFunctionRef
::= UnreservedFunctionEQName '#' IntegerLiteral
InlineFunctionExpr
::= Annotation* ( 'function' | 'fn' ) FunctionSignature? FunctionBody
FunctionSignature
::= '(' ParamList ')' TypeDeclaration?
ParamList
::= ( VarNameAndType ( ',' VarNameAndType )* )?
FunctionBody
::= EnclosedExpr
MapConstructor
::= 'map'? '{' ( MapConstructorEntry ( ',' MapConstructorEntry )* )? '}'
MapConstructorEntry
::= ExprSingle ( ':' ExprSingle )?
ArrayConstructor
::= SquareArrayConstructor
| CurlyArrayConstructor
SquareArrayConstructor
::= '[' ( ExprSingle ( ',' ExprSingle )* )? ']'
CurlyArrayConstructor
::= 'array' EnclosedExpr
StringTemplate
::= '`' ( StringTemplateFixedPart | StringTemplateVariablePart )* '`'
/* ws: explicit */
StringTemplateVariablePart
::= EnclosedExpr
/* ws: explicit */
StringConstructor
::= '``[' StringConstructorContent ']``'
/* ws: explicit */
StringConstructorContent
::= StringConstructorChars ( StringInterpolation StringConstructorChars )*
/* ws: explicit */
StringInterpolation
::= '`' EnclosedExpr '`'
UnaryLookup
::= Lookup
Lookup ::= '?' KeySpecifier
KeySpecifier
::= NCName
| IntegerLiteral
| StringLiteral
| VarRef
| ParenthesizedExpr
| LookupWildcard
LookupWildcard
::= '*'
FilterExpr
::= PostfixExpr Predicate
Predicate
::= '[' Expr ']'
DynamicFunctionCall
::= PostfixExpr PositionalArgumentList
PositionalArgumentList
::= '(' PositionalArguments? ')'
LookupExpr
::= PostfixExpr Lookup
FilterExprAM
::= PostfixExpr '?[' Expr ']'
AxisStep ::= ( AbbreviatedStep | FullStep ) Predicate*
AbbreviatedStep
::= '..'
| '@' NodeTest
| SimpleNodeTest
NodeTest ::= UnionNodeTest
| SimpleNodeTest
UnionNodeTest
::= '(' SimpleNodeTest ( '|' SimpleNodeTest )* ')'
SimpleNodeTest
::= TypeTest
| Selector
TypeTest ::= RegularItemType
| 'type' '(' SequenceType ')'
Selector ::= EQName
| Wildcard
| 'get' '(' Expr ')'
FullStep ::= Axis NodeTest
Axis ::= ( 'ancestor' | 'ancestor-or-self' | 'attribute' | 'child' | 'descendant' | 'descendant-or-self' | 'following' | 'following-or-self' | 'following-sibling' | 'following-sibling-or-self' | 'parent' | 'preceding' | 'preceding-or-self' | 'preceding-sibling' | 'preceding-sibling-or-self' | 'self' ) '::'
SequenceArrowTarget
::= ( '=>' | '=' ) ArrowTarget
ArrowTarget
::= FunctionCall
| RestrictedDynamicCall
RestrictedDynamicCall
::= ( VarRef | ParenthesizedExpr | FunctionItemExpr | MapConstructor | ArrayConstructor ) PositionalArgumentList
MappingArrowTarget
::= ( '=!>' | '=!' ) ArrowTarget
CastTarget
::= TypeName
| ChoiceItemType
| EnumerationType
ValueComp
::= 'eq'
| 'ne'
| 'lt'
| 'le'
| 'gt'
| 'ge'
GeneralComp
::= '='
| '!='
| ( '<'^GeneralComp | '' )
| ( '<=' | '=' )
| ( '>' | '' )
| ( '>=' | '=' )
NodeComp ::= 'is'
| 'is-not'
| NodePrecedes
| NodeFollows
NodePrecedes
::= ( '<<' | '' )
| 'precedes'
NodeFollows
::= ( '>>' | '' )
| 'follows'
VarDefaultValue
::= ExprSingle
VarDecl ::= 'declare' Annotation* 'variable' VarNameAndType ( ':=' VarValue | 'external' ( ':=' VarDefaultValue )? )
FunctionDecl
::= 'declare' Annotation* 'function' UnreservedFunctionEQName '(' ParamListWithDefaults? ')' TypeDeclaration? ( FunctionBody | 'external' )
ParamListWithDefaults
::= ParamWithDefault ( ',' ParamWithDefault )*
ParamWithDefault
::= VarNameAndType ( ':=' ExprSingle )?
ItemTypeDecl
::= 'declare' Annotation* 'type' EQName 'as' ItemType
NamedRecordTypeDecl
::= 'declare' Annotation* 'record' EQName '(' ( ExtendedFieldDeclaration ( ',' ExtendedFieldDeclaration )* )? ExtensibleFlag? ')'
ExtendedFieldDeclaration
::= FieldDeclaration ( ':=' ExprSingle )?
OptionDecl
::= 'declare' 'option' EQName StringLiteral
MainModule
::= Prolog QueryBody
QueryBody
::= Expr
Whitespace
::= S^WS
| Comment
/* ws: definition */
Comment ::= '(:' ( CommentContents | Comment )* ':)'
/* ws: explicit */
<?TOKENS?>
StringLiteral
::= AposStringLiteral
| QuotStringLiteral
/* ws: explicit */
AposStringLiteral
::= "'" ( PredefinedEntityRef | CharRef | EscapeApos | [^'&] )* "'"
/* ws: explicit */
PredefinedEntityRef
::= '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';'
/* ws: explicit */
CharRef ::= '&#' [0-9]+ ';'
| '&#x' [0-9a-fA-F]+ ';'
EscapeApos
::= "''"
/* ws: explicit */
QuotStringLiteral
::= '"' ( PredefinedEntityRef | CharRef | EscapeQuot | [^"&] )* '"'
/* ws: explicit */
EscapeQuot
::= '""'
/* ws: explicit */
AposAttrContentChar
::= Char - ['{}<&]
Char ::= #x9
| #xA
| #xD
| [#x20-#xD7FF]
| [#xE000-#xFFFD]
| [#x10000-#x10FFFF]
CDataSectionContents
::= Char* - ( Char* ']]>' Char* ) & ']]'
UnreservedNCName
::= NCName - ReservedName
NCName ::= Name - ( Char* ':' Char* )
Name ::= NameStartChar NameChar*
NameStartChar
::= ':'
| [A-Z]
| '_'
| [a-z]
| [#xC0-#xD6]
| [#xD8-#xF6]
| [#xF8-#x2FF]
| [#x370-#x37D]
| [#x37F-#x1FFF]
| [#x200C-#x200D]
| [#x2070-#x218F]
| [#x2C00-#x2FEF]
| [#x3001-#xD7FF]
| [#xF900-#xFDCF]
| [#xFDF0-#xFFFD]
| [#x10000-#xEFFFF]
NameChar ::= NameStartChar
| '-'
| '.'
| [0-9]
| #xB7
| [#x0300-#x036F]
| [#x203F-#x2040]
ReservedName
::= 'NaN'
| 'allowing'
| 'ancestor'
| 'ancestor-or-self'
| 'and'
| 'array'
| 'as'
| 'ascending'
| 'at'
| 'attribute'
| 'base-uri'
| 'boundary-space'
| 'by'
| 'case'
| 'cast'
| 'castable'
| 'catch'
| 'child'
| 'collation'
| 'comment'
| 'construction'
| 'context'
| 'copy-namespaces'
| 'count'
| 'decimal-format'
| 'decimal-separator'
| 'declare'
| 'default'
| 'descendant'
| 'descendant-or-self'
| 'descending'
| 'digit'
| 'div'
| 'document'
| 'document-node'
| 'element'
| 'else'
| 'empty'
| 'empty-sequence'
| 'encoding'
| 'end'
| 'enum'
| 'eq'
| 'every'
| 'except'
| 'exponent-separator'
| 'external'
| 'false'
| 'finally'
| 'fixed'
| 'fn'
| 'following'
| 'following-or-self'
| 'following-sibling'
| 'following-sibling-or-self'
| 'follows'
| 'for'
| 'function'
| 'ge'
| 'get'
| 'gnode'
| 'greatest'
| 'group'
| 'grouping-separator'
| 'gt'
| 'idiv'
| 'if'
| 'import'
| 'in'
| 'infinity'
| 'inherit'
| 'instance'
| 'intersect'
| 'is'
| 'is-not'
| 'item'
| 'jnode'
| 'key'
| 'lax'
| 'le'
| 'least'
| 'let'
| 'lt'
| 'map'
| 'member'
| 'minus-sign'
| 'mod'
| 'module'
| 'namespace'
| 'namespace-node'
| 'ne'
| 'next'
| 'no-inherit'
| 'no-preserve'
| 'node'
| 'of'
| 'only'
| 'option'
| 'or'
| 'order'
| 'ordered'
| 'ordering'
| 'otherwise'
| 'parent'
| 'pattern-separator'
| 'per-mille'
| 'percent'
| 'precedes'
| 'preceding'
| 'preceding-or-self'
| 'preceding-sibling'
| 'preceding-sibling-or-self'
| 'preserve'
| 'previous'
| 'processing-instruction'
| 'record'
| 'return'
| 'satisfies'
| 'schema'
| 'schema-attribute'
| 'schema-element'
| 'self'
| 'sliding'
| 'some'
| 'stable'
| 'start'
| 'strict'
| 'strip'
| 'switch'
| 'text'
| 'then'
| 'to'
| 'treat'
| 'true'
| 'try'
| 'tumbling'
| 'type'
| 'typeswitch'
| 'union'
| 'unordered'
| 'validate'
| 'value'
| 'variable'
| 'version'
| 'when'
| 'where'
| 'while'
| 'window'
| 'xquery'
| 'zero-digit'
| ''
| ''
| ''
| ''
S ::= ( #x20 | #x9 | #xD | #xA )+
DirCommentContents
::= ( Char - '-' | '-' ( Char - '-' ) )*
/* ws: explicit */
ElementContentChar
::= Char - [{}<&]
PITarget ::= NCName - ( ( 'X' | 'x' ) ( 'M' | 'm' ) ( 'L' | 'l' ) )
DirPIContents
::= Char* - ( Char* '?>' Char* ) & '?'
URIQualifiedName
::= BracedURILiteral NCName
/* ws: explicit */
BracedURILiteral
::= 'Q' '{' ( PredefinedEntityRef | CharRef | [^&{}] )* '}'
/* ws: explicit */
IntegerLiteral
::= Digits
/* ws: explicit */
Digits ::= DecDigit ( ( DecDigit | '_' )* DecDigit )?
/* ws: explicit */
DecDigit ::= [0-9]
/* ws: explicit */
EOF ::= $
Wildcard ::= '*'
| NCName ':*'
| '*:' NCName
| BracedURILiteral '*'
/* ws: explicit */
HexIntegerLiteral
::= '0x' HexDigits
/* ws: explicit */
HexDigits
::= HexDigit ( ( HexDigit | '_' )* HexDigit )?
/* ws: explicit */
HexDigit ::= [0-9a-fA-F]
/* ws: explicit */
BinaryIntegerLiteral
::= '0b' BinaryDigits
/* ws: explicit */
BinaryDigits
::= BinaryDigit ( ( BinaryDigit | '_' )* BinaryDigit )?
/* ws: explicit */
BinaryDigit
::= [0-1]
/* ws: explicit */
DecimalLiteral
::= '.' Digits
| Digits '.' Digits?
/* ws: explicit */
DoubleLiteral
::= ( '.' Digits | Digits ( '.' Digits? )? ) [eE] [+#x2D]? Digits
/* ws: explicit */
PragmaContents
::= Char* - ( Char* '#)' Char* ) & '#'
QuotAttrContentChar
::= Char - ["{}<&]
StringConstructorChars
::= Char* - ( Char* ( '`{' | ']``' ) Char* ) & ( '`{' | ']`' )
StringTemplateFixedPart
::= ( Char - ( '{' | '}' | '`' ) | '{{' | '}}' | '``' )+
/* ws: explicit */
UnreservedQName
::= QName - ReservedName
QName ::= PrefixedName
| UnprefixedName
PrefixedName
::= Prefix ':' LocalPart
Prefix ::= NCName
LocalPart
::= NCName
UnprefixedName
::= LocalPart
CommentContents
::= ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) & ':'
| Char+ - ( Char* ( '(:' | ':)' ) Char* ) & '('
/* ws: explicit */
QNameOrKeywordDelimiter
::= $
| ':'
| Char - NameChar
NCNameDelimiter
::= $ $
| ( Char - NameChar ) ( $ | Char )
| ':' ( Char - NameStartChar )
NumericLiteralDelimiter
::= QNameOrKeywordDelimiter
| '-'
GeneralCompDelimiter
::= [^?]
DirElemConstructorDelimiter
::= QName ( S QName S? '=' | S? [/>] )
'*' << Wildcard
QNameOrKeywordDelimiter
\\ UnreservedQName 'NaN' 'allowing' 'ancestor' 'ancestor-or-self' 'and' 'array' 'as' 'ascending' 'at' 'attribute' 'base-uri' 'boundary-space' 'by' 'case' 'cast' 'castable' 'catch' 'child' 'collation' 'comment' 'construction' 'context' 'copy-namespaces' 'count' 'decimal-format' 'decimal-separator' 'declare' 'default' 'descendant' 'descendant-or-self' 'descending' 'digit' 'div' 'document' 'document-node' 'element' 'else' 'empty' 'empty-sequence' 'encoding' 'end' 'enum' 'eq' 'every' 'except' 'exponent-separator' 'external' 'false' 'finally' 'fixed' 'fn' 'following' 'following-or-self' 'following-sibling' 'following-sibling-or-self' 'follows' 'for' 'function' 'ge' 'get' 'gnode' 'greatest' 'group' 'grouping-separator' 'gt' 'idiv' 'if' 'import' 'in' 'infinity' 'inherit' 'instance' 'intersect' 'is' 'is-not' 'item' 'jnode' 'key' 'lax' 'le' 'least' 'let' 'lt' 'map' 'member' 'minus-sign' 'mod' 'module' 'namespace' 'namespace-node' 'ne' 'next' 'no-inherit' 'no-preserve' 'node' 'of' 'only' 'option' 'or' 'order' 'ordered' 'ordering' 'otherwise' 'parent' 'pattern-separator' 'per-mille' 'percent' 'precedes' 'preceding' 'preceding-or-self' 'preceding-sibling' 'preceding-sibling-or-self' 'preserve' 'previous' 'processing-instruction' 'record' 'return' 'satisfies' 'schema' 'schema-attribute' 'schema-element' 'self' 'sliding' 'some' 'stable' 'start' 'strict' 'strip' 'switch' 'text' 'then' 'to' 'treat' 'true' 'try' 'tumbling' 'type' 'typeswitch' 'union' 'unordered' 'validate' 'value' 'variable' 'version' 'when' 'where' 'while' 'window' 'xquery' 'zero-digit'
Char \\ '' '=' '' '=' '' '' '</' '<<' '<='
NCNameDelimiter
\\ UnreservedNCName
NumericLiteralDelimiter
\\ DecimalLiteral DoubleLiteral IntegerLiteral
GeneralCompDelimiter
\\ '<'^GeneralComp
DirElemConstructorDelimiter
\\ '<'^DirElemConstructor
S \\ '(#'