BNF for xpath-grammar.jj

NON-TERMINALS

START ::= XPath <EOF>
XPath ::= Expr
Expr ::= ExprSingle ( "," ExprSingle )*
ExprSingle ::= ( ForExpr | QuantifiedExpr | IfExpr | OrExpr )
ForExpr ::= SimpleForClause "return" ExprSingle
SimpleForClause ::= "for" "$" VarName "in" ExprSingle ( "," "$" VarName "in" 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 ::= RangeExpr ( ( ValueComp | GeneralComp | NodeComp ) 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 ::= PathExpr
GeneralComp ::= ( "=" | "!=" | <LeftAngleBracket> | "<=" | ">" | ">=" )
ValueComp ::= ( "eq" | "ne" | "lt" | "le" | "gt" | "ge" )
NodeComp ::= ( "is" | "<<" | ">>" )
PathExpr ::= ( ( <Slash> ( RelativePathExpr )? ) | ( <SlashSlash> RelativePathExpr ) | RelativePathExpr )
RelativePathExpr ::= StepExpr ( ( <Slash> | <SlashSlash> ) StepExpr )*
StepExpr ::= ( FilterExpr | 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 ::= ( QName | Wildcard )
Wildcard ::= ( "*" | <NCNameColonStar> | <StarColonNCName> )
FilterExpr ::= PrimaryExpr PredicateList
PredicateList ::= ( Predicate )*
Predicate ::= "[" Expr "]"
PrimaryExpr ::= ( Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall )
Literal ::= ( NumericLiteral | <StringLiteral> )
NumericLiteral ::= ( <IntegerLiteral> | <DecimalLiteral> | <DoubleLiteral> )
VarRef ::= "$" VarName
VarName ::= QName
ParenthesizedExpr ::= "(" ( Expr )? ")"
ContextItemExpr ::= "."
FunctionCall ::= FunctionQName ( "(" ( ExprSingle ( "," ExprSingle )* )? ")" )
SingleType ::= AtomicType ( "?" )?
SequenceType ::= ( ( "empty-sequence" "(" ")" ) | ( ItemType ( OccurrenceIndicator )? ) )
OccurrenceIndicator ::= ( "?" | "*" | <Plus> )
ItemType ::= ( KindTest | ( "item" "(" ")" ) | AtomicType )
AtomicType ::= QName
KindTest ::= ( DocumentTest | ElementTest | AttributeTest | SchemaElementTest | SchemaAttributeTest | PITest | CommentTest | TextTest | AnyKindTest )
AnyKindTest ::= "node" "(" ")"
DocumentTest ::= "document-node" "(" ( ( ElementTest | SchemaElementTest ) )? ")"
TextTest ::= "text" "(" ")"
CommentTest ::= "comment" "(" ")"
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 ::= QName
ElementName ::= QName
TypeName ::= QName
NCName ::= QName
QName ::= ( FunctionQName | "attribute" | "comment" | "document-node" | "element" | "empty-sequence" | "if" | "item" | "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" | "lt" | "mod" | "namespace" | "ne" | "of" | "or" | "parent" | "preceding" | "preceding-sibling" | "return" | "satisfies" | "self" | "some" | "then" | "to" | "treat" | "union" )