[1]   RulesUnit   ::=   ByteOrderMark ( Prologue ( Rule | Data ) )*
[2]   ByteOrderMark   ::=   '\uFEFF'?
[3]   Rule   ::=   Rule1 | Rule2 | Rule3
[4]   Rule1   ::=   'RULE' HeadTemplate 'WHERE' BodyPattern
[5]   Rule2   ::=   'IF' BodyPattern 'THEN' HeadTemplate
[6]   Rule3   ::=   HeadTemplate ':-' BodyPattern
[7]   Data   ::=   'DATA' TriplesTemplateBlock
[8]   HeadTemplate   ::=   TriplesTemplateBlock
[9]   BodyPattern   ::=   '{' BodyPattern1? Assignment* '}'
[10]   BodyPattern1   ::=   ( Filter | BodyPatternSub ( Filter BodyPatternSub? )* )
[11]   BodyPatternSub   ::=   TriplesBlock
[12]   Prologue   ::=   ( BaseDecl | PrefixDecl | VersionDecl )*
[13]   BaseDecl   ::=   'BASE' IRIREF
[14]   PrefixDecl   ::=   'PREFIX' PNAME_NS IRIREF
[15]   VersionDecl   ::=   'VERSION' VersionSpecifier
[16]   VersionSpecifier   ::=   STRING_LITERAL1 | STRING_LITERAL2
[17]   TriplesTemplateBlock   ::=   '{' TriplesTemplate? '}'
[18]   TriplesTemplate   ::=   TriplesSameSubject ( '.' TriplesTemplate? )?
[19]   TriplesBlock   ::=   TriplesSameSubjectPath ( '.' TriplesBlock? )?
[20]   ReifiedTripleBlock   ::=   ReifiedTriple PropertyList
[21]   ReifiedTripleBlockPath   ::=   ReifiedTriple PropertyListPath
[22]   Assignment   ::=   Bind
[23]   Bind   ::=   'BIND' '(' Expression 'AS' Var ')'
[24]   Let   ::=   'LET' '(' Var ':=' Expression ')'
[25]   Reifier   ::=   '~' VarOrReifierId?
[26]   VarOrReifierId   ::=   Var | iri | BlankNode
[27]   Filter   ::=   'FILTER' Constraint
[28]   Constraint   ::=   BrackettedExpression | BuiltInCall | FunctionCall
[29]   FunctionCall   ::=   iri ArgList
[30]   ArgList   ::=   NIL | '(' Expression ( ',' Expression )* ')'
[31]   ExpressionList   ::=   NIL | '(' Expression ( ',' Expression )* ')'
[32]   TriplesSameSubject   ::=   VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList | ReifiedTripleBlock
[33]   PropertyList   ::=   PropertyListNotEmpty?
[34]   PropertyListNotEmpty   ::=   Verb ObjectList ( ';' ( Verb ObjectList )? )*
[35]   Verb   ::=   VarOrIri | 'a'
[36]   ObjectList   ::=   Object ( ',' Object )*
[37]   Object   ::=   GraphNode Annotation
[38]   TriplesSameSubjectPath   ::=   VarOrTerm PropertyListPathNotEmpty | TriplesNodePath PropertyListPath | ReifiedTripleBlockPath
[39]   PropertyListPath   ::=   PropertyListPathNotEmpty?
[40]   PropertyListPathNotEmpty   ::=   ( VerbPath | VerbSimple ) ObjectListPath ( ';' ( ( VerbPath | VerbSimple ) ObjectListPath )? )*
[41]   VerbPath   ::=   Path
[42]   VerbSimple   ::=   Var
[43]   ObjectListPath   ::=   ObjectPath ( ',' ObjectPath )*
[44]   ObjectPath   ::=   GraphNodePath AnnotationPath
[45]   Path   ::=   PathSequence
[46]   PathSequence   ::=   PathEltOrInverse ( '/' PathEltOrInverse )*
[47]   PathEltOrInverse   ::=   PathElt | '^' PathElt
[48]   PathElt   ::=   PathPrimary
[49]   PathPrimary   ::=   iri | 'a' | '(' Path ')'
[50]   TriplesNode   ::=   Collection | BlankNodePropertyList
[51]   BlankNodePropertyList   ::=   '[' PropertyListNotEmpty ']'
[52]   TriplesNodePath   ::=   CollectionPath | BlankNodePropertyListPath
[53]   BlankNodePropertyListPath   ::=   '[' PropertyListPathNotEmpty ']'
[54]   Collection   ::=   '(' GraphNode+ ')'
[55]   CollectionPath   ::=   '(' GraphNodePath+ ')'
[56]   AnnotationPath   ::=   ( Reifier | AnnotationBlockPath )*
[57]   AnnotationBlockPath   ::=   '{|' PropertyListPathNotEmpty '|}'
[58]   Annotation   ::=   ( Reifier | AnnotationBlock )*
[59]   AnnotationBlock   ::=   '{|' PropertyListNotEmpty '|}'
[60]   GraphNode   ::=   VarOrTerm | TriplesNode | ReifiedTriple
[61]   GraphNodePath   ::=   VarOrTerm | TriplesNodePath | ReifiedTriple
[62]   VarOrTerm   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | TripleTerm
[63]   ReifiedTriple   ::=   '<<' ReifiedTripleSubject Verb ReifiedTripleObject Reifier? '>>'
[64]   ReifiedTripleSubject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | ReifiedTriple
[65]   ReifiedTripleObject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | ReifiedTriple | TripleTerm
[66]   TripleTerm   ::=   '<<(' TripleTermSubject Verb TripleTermObject ')>>'
[67]   TripleTermSubject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode
[68]   TripleTermObject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | TripleTerm
[69]   TripleTermData   ::=   '<<(' TripleTermDataSubject ( iri | 'a' ) TripleTermDataObject ')>>'
[70]   TripleTermDataSubject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral
[71]   TripleTermDataObject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | TripleTermData
[72]   VarOrIri   ::=   Var | iri
[73]   Var   ::=   VAR1 | VAR2
[74]   Expression   ::=   ConditionalOrExpression
[75]   ConditionalOrExpression   ::=   ConditionalAndExpression ( '||' ConditionalAndExpression )*
[76]   ConditionalAndExpression   ::=   ValueLogical ( '&&' ValueLogical )*
[77]   ValueLogical   ::=   RelationalExpression
[78]   RelationalExpression   ::=   NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression | 'IN' ExpressionList | 'NOT' 'IN' ExpressionList )?
[79]   NumericExpression   ::=   AdditiveExpression
[80]   AdditiveExpression   ::=   MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | ( NumericLiteralPositive | NumericLiteralNegative ) ( ( '*' UnaryExpression ) | ( '/' UnaryExpression ) )* )*
[81]   MultiplicativeExpression   ::=   UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )*
[82]   UnaryExpression   ::=     '!' PrimaryExpression
| '+' PrimaryExpression
| '-' PrimaryExpression
| PrimaryExpression
[83]   PrimaryExpression   ::=   BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprTripleTerm
[84]   ExprTripleTerm   ::=   '<<(' ExprTripleTermSubject Verb ExprTripleTermObject ')>>'
[85]   ExprTripleTermSubject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var
[86]   ExprTripleTermObject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprTripleTerm
[87]   BrackettedExpression   ::=   '(' Expression ')'
[88]   BuiltInCall   ::=     'STR' '(' Expression ')'
| 'LANG' '(' Expression ')'
| 'LANGMATCHES' '(' Expression ',' Expression ')'
| 'LANGDIR' '(' Expression ')'
| 'DATATYPE' '(' Expression ')'
| 'BOUND' '(' Var ')'
| 'IRI' '(' Expression ')'
| 'URI' '(' Expression ')'
| 'BNODE' ( '(' Expression ')' | NIL )
| 'RAND' NIL
| 'ABS' '(' Expression ')'
| 'CEIL' '(' Expression ')'
| 'FLOOR' '(' Expression ')'
| 'ROUND' '(' Expression ')'
| 'CONCAT' ExpressionList
| 'SUBSTR' '(' Expression ',' Expression ( ',' Expression )? ')'
| 'STRLEN' '(' Expression ')'
| 'REPLACE' '(' Expression ',' Expression ',' Expression ( ',' Expression )? ')'
| 'UCASE' '(' Expression ')'
| 'LCASE' '(' Expression ')'
| 'ENCODE_FOR_URI' '(' Expression ')'
| 'CONTAINS' '(' Expression ',' Expression ')'
| 'STRSTARTS' '(' Expression ',' Expression ')'
| 'STRENDS' '(' Expression ',' Expression ')'
| 'STRBEFORE' '(' Expression ',' Expression ')'
| 'STRAFTER' '(' Expression ',' Expression ')'
| 'YEAR' '(' Expression ')'
| 'MONTH' '(' Expression ')'
| 'DAY' '(' Expression ')'
| 'HOURS' '(' Expression ')'
| 'MINUTES' '(' Expression ')'
| 'SECONDS' '(' Expression ')'
| 'TIMEZONE' '(' Expression ')'
| 'TZ' '(' Expression ')'
| 'NOW' NIL
| 'UUID' NIL
| 'STRUUID' NIL
| 'MD5' '(' Expression ')'
| 'SHA1' '(' Expression ')'
| 'SHA256' '(' Expression ')'
| 'SHA384' '(' Expression ')'
| 'SHA512' '(' Expression ')'
| 'COALESCE' ExpressionList
| 'IF' '(' Expression ',' Expression ',' Expression ')'
| 'STRLANG' '(' Expression ',' Expression ')'
| 'STRLANGDIR' '(' Expression ',' Expression ',' Expression ')'
| 'STRDT' '(' Expression ',' Expression ')'
| 'sameTerm' '(' Expression ',' Expression ')'
| 'isIRI' '(' Expression ')'
| 'isURI' '(' Expression ')'
| 'isBLANK' '(' Expression ')'
| 'isLITERAL' '(' Expression ')'
| 'isNUMERIC' '(' Expression ')'
| 'hasLANG' '(' Expression ')'
| 'hasLANGDIR' '(' Expression ')'
| 'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')'
| 'isTRIPLE' '(' Expression ')'
| 'TRIPLE' '(' Expression ',' Expression ',' Expression ')'
| 'SUBJECT' '(' Expression ')'
| 'PREDICATE' '(' Expression ')'
| 'OBJECT' '(' Expression ')'
[89]   iriOrFunction   ::=   iri ArgList?
[90]   RDFLiteral   ::=   String ( LANG_DIR | '^^' iri )?
[91]   NumericLiteral   ::=   NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
[92]   NumericLiteralUnsigned   ::=   INTEGER | DECIMAL | DOUBLE
[93]   NumericLiteralPositive   ::=   INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
[94]   NumericLiteralNegative   ::=   INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
[95]   BooleanLiteral   ::=   'true' | 'false'
[96]   String   ::=   STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[97]   iri   ::=   IRIREF | PrefixedName
[98]   PrefixedName   ::=   PNAME_LN | PNAME_NS
[99]   BlankNode   ::=   BLANK_NODE_LABEL | ANON

Productions for terminals:

[100]   IRIREF   ::=   '<' ([^<>"{}|^`\]-[#x00-#x20])* '>'
[101]   PNAME_NS   ::=   PN_PREFIX? ':'
[102]   PNAME_LN   ::=   PNAME_NS PN_LOCAL
[103]   BLANK_NODE_LABEL   ::=   '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
[104]   VAR1   ::=   '?' VARNAME
[105]   VAR2   ::=   '$' VARNAME
[106]   LANG_DIR   ::=   '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ('--' [a-zA-Z]+)?
[107]   INTEGER   ::=   [0-9]+
[108]   DECIMAL   ::=   [0-9]* '.' [0-9]+
[109]   DOUBLE   ::=   ( [0-9]+ '.' [0-9]* | '.' ([0-9])+ | ([0-9])+ ) [eE][+-]?[0-9]+
[110]   INTEGER_POSITIVE   ::=   '+' INTEGER
[111]   DECIMAL_POSITIVE   ::=   '+' DECIMAL
[112]   DOUBLE_POSITIVE   ::=   '+' DOUBLE
[113]   INTEGER_NEGATIVE   ::=   '-' INTEGER
[114]   DECIMAL_NEGATIVE   ::=   '-' DECIMAL
[115]   DOUBLE_NEGATIVE   ::=   '-' DOUBLE
[116]   STRING_LITERAL1   ::=   "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'"
[117]   STRING_LITERAL2   ::=   '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"'
[118]   STRING_LITERAL_LONG1   ::=   "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''"
[119]   STRING_LITERAL_LONG2   ::=   '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""'
[120]   ECHAR   ::=   '\' [tbnrf\"']
[121]   NIL   ::=   '(' WS* ')'
[122]   WS   ::=   #x20 | #x9 | #xD | #xA
[123]   ANON   ::=   '[' WS* ']'
[124]   PN_CHARS_BASE   ::=   [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[125]   PN_CHARS_U   ::=   PN_CHARS_BASE | '_'
[126]   VARNAME   ::=   ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
[127]   PN_CHARS   ::=   PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
[128]   PN_PREFIX   ::=   PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
[129]   PN_LOCAL   ::=   (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX) )?
[130]   PLX   ::=   PERCENT | PN_LOCAL_ESC
[131]   PERCENT   ::=   '%' HEX HEX
[132]   HEX   ::=   [0-9] | [A-F] | [a-f]
[133]   PN_LOCAL_ESC   ::=   '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%' )