BNF for xpath-grammar.jj

NON-TERMINALS

START ::= XPath <EOF>
XPath ::= Expr
ParamList ::= Param ( "," Param )*
Param ::= "$" EQName ( TypeDeclaration )?
FunctionBody ::= EnclosedExpr
EnclosedExpr ::= <Lbrace> Expr <Rbrace>
Expr ::= ExprSingle ( "," ExprSingle )*
ExprSingle ::= ( ForExpr | LetExpr | QuantifiedExpr | IfExpr | OrExpr )
ForExpr ::= SimpleForClause "return" ExprSingle
SimpleForClause ::= "for" SimpleForBinding ( "," SimpleForBinding )*
SimpleForBinding ::= "$" VarName "in" ExprSingle
LetExpr ::= SimpleLetClause "return" ExprSingle
SimpleLetClause ::= "let" SimpleLetBinding ( "," SimpleLetBinding )*
SimpleLetBinding ::= "$" VarName ":=" ExprSingle
QuantifiedExpr ::= ( "some" | "every" ) "$" VarName "in" ExprSingle ( "," "$" VarName "in" ExprSingle )* "satisfies" ExprSingle
IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle
OperatorExpr ::= OrExpr
OrExpr ::= AndExpr ( "or" AndExpr )*
AndExpr ::= ComparisonExpr ( "and" ComparisonExpr )*
ComparisonExpr ::= StringConcatExpr ( ( ValueComp | GeneralComp | NodeComp ) StringConcatExpr )?
StringConcatExpr ::= RangeExpr ( "||" RangeExpr )*
RangeExpr ::= AdditiveExpr ( "to" AdditiveExpr )?
AdditiveExpr ::= MultiplicativeExpr ( ( <Plus> | <Minus> ) 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" SingleType ) )?
CastExpr ::= UnaryExpr ( ( "cast" "as" SingleType ) )?
UnaryExpr ::= ( ( <Minus> | <Plus> ) )* ValueExpr
ValueExpr ::= SimpleMapExpr
GeneralComp ::= ( "=" | "!=" | <LeftAngleBracket> | "<=" | ">" | ">=" )
ValueComp ::= ( "eq" | "ne" | "lt" | "le" | "gt" | "ge" )
NodeComp ::= ( "is" | "<<" | ">>" )
SimpleMapExpr ::= PathExpr ( "!" PathExpr )*
PathExpr ::= ( ( <Slash> ( RelativePathExpr )? ) | ( <SlashSlash> RelativePathExpr ) | RelativePathExpr )
RelativePathExpr ::= StepExpr ( ( <Slash> | <SlashSlash> ) StepExpr )*
StepExpr ::= ( PostfixExpr | AxisStep )
AxisStep ::= ( ReverseStep | ForwardStep ) PredicateList
ForwardStep ::= ( ( ForwardAxis NodeTest ) | AbbrevForwardStep )
ForwardAxis ::= ( ( "child" "::" ) | ( "descendant" "::" ) | ( "attribute" "::" ) | ( "self" "::" ) | ( "descendant-or-self" "::" ) | ( "following-sibling" "::" ) | ( "following" "::" ) | ( "namespace" "::" ) )
AbbrevForwardStep ::= ( "@" )? NodeTest
ReverseStep ::= ( ( ReverseAxis NodeTest ) | AbbrevReverseStep )
ReverseAxis ::= ( ( "parent" "::" ) | ( "ancestor" "::" ) | ( "preceding-sibling" "::" ) | ( "preceding" "::" ) | ( "ancestor-or-self" "::" ) )
AbbrevReverseStep ::= ".."
NodeTest ::= ( KindTest | NameTest )
NameTest ::= ( EQName | Wildcard )
Wildcard ::= ( "*" | <NCNameColonStar> | <StarColonNCName> | <URIQualifiedStar> )
PostfixExpr ::= PrimaryExpr ( ( Predicate | ArgumentList ) )*
ArgumentList ::= "(" ( Argument ( "," Argument )* )? ")"
PredicateList ::= ( Predicate )*
Predicate ::= "[" Expr "]"
PrimaryExpr ::= ( Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall | FunctionItemExpr )
Literal ::= ( NumericLiteral | <StringLiteral> )
NumericLiteral ::= ( <IntegerLiteral> | <DecimalLiteral> | <DoubleLiteral> )
VarRef ::= "$" VarName
VarName ::= EQName
ParenthesizedExpr ::= "(" ( Expr )? ")"
ContextItemExpr ::= "."
FunctionCall ::= FunctionEQName ArgumentList
Argument ::= ( ExprSingle | ArgumentPlaceholder )
ArgumentPlaceholder ::= "?"
FunctionItemExpr ::= ( NamedFunctionRef | InlineFunctionExpr )
NamedFunctionRef ::= FunctionEQName "#" <IntegerLiteral>
InlineFunctionExpr ::= "function" "(" ( ParamList )? ")" ( "as" SequenceType )? FunctionBody
SingleType ::= SimpleTypeName ( "?" )?
TypeDeclaration ::= "as" SequenceType
SequenceType ::= ( ( "empty-sequence" "(" ")" ) | ( ItemType ( OccurrenceIndicator )? ) )
OccurrenceIndicator ::= ( "?" | "*" | <Plus> )
ItemType ::= ( KindTest | ( "item" "(" ")" ) | FunctionTest | AtomicOrUnionType | ParenthesizedItemType )
AtomicOrUnionType ::= EQName
KindTest ::= ( DocumentTest | ElementTest | AttributeTest | SchemaElementTest | SchemaAttributeTest | PITest | CommentTest | TextTest | NamespaceNodeTest | AnyKindTest )
AnyKindTest ::= "node" "(" ")"
DocumentTest ::= "document-node" "(" ( ( ElementTest | SchemaElementTest ) )? ")"
TextTest ::= "text" "(" ")"
CommentTest ::= "comment" "(" ")"
NamespaceNodeTest ::= "namespace-node" "(" ")"
PITest ::= "processing-instruction" "(" ( ( NCName | <StringLiteral> ) )? ")"
AttributeTest ::= "attribute" "(" ( AttribNameOrWildcard ( "," TypeName )? )? ")"
AttribNameOrWildcard ::= ( AttributeName | "*" )
SchemaAttributeTest ::= "schema-attribute" "(" AttributeDeclaration ")"
AttributeDeclaration ::= AttributeName
ElementTest ::= "element" "(" ( ElementNameOrWildcard ( "," TypeName ( "?" )? )? )? ")"
ElementNameOrWildcard ::= ( ElementName | "*" )
SchemaElementTest ::= "schema-element" "(" ElementDeclaration ")"
ElementDeclaration ::= ElementName
AttributeName ::= EQName
ElementName ::= EQName
SimpleTypeName ::= TypeName
TypeName ::= EQName
FunctionTest ::= ( AnyFunctionTest | TypedFunctionTest )
AnyFunctionTest ::= "function" "(" "*" ")"
TypedFunctionTest ::= "function" "(" ( SequenceType ( "," SequenceType )* )? ")" "as" SequenceType
ParenthesizedItemType ::= "(" ItemType ")"
EQName ::= ( QName | <URIQualifiedName> )
FunctionEQName ::= ( FunctionQName | <URIQualifiedName> )
NCName ::= QName
QName ::= ( FunctionQName | "attribute" | "comment" | "document-node" | "element" | "empty-sequence" | "function" | "if" | "item" | "namespace-node" | "node" | "processing-instruction" | "schema-attribute" | "schema-element" | "text" )
FunctionQName ::= ( <QNameToken> | "ancestor" | "ancestor-or-self" | "and" | "as" | "cast" | "castable" | "child" | "descendant" | "descendant-or-self" | "div" | "else" | "eq" | "every" | "except" | "following" | "following-sibling" | "for" | "ge" | "gt" | "idiv" | "in" | "instance" | "intersect" | "is" | "le" | "let" | "lt" | "mod" | "namespace" | "ne" | "of" | "or" | "parent" | "preceding" | "preceding-sibling" | "return" | "satisfies" | "self" | "some" | "then" | "to" | "treat" | "union" )