[1]   RuleSet   ::=   ( Prologue ( Rule | Data ) )*
[2]   Rule   ::=   Rule1 | Rule2 | Rule3 | Declaration
[3]   Rule1   ::=   'RULE' HeadTemplate 'WHERE' BodyPattern
[4]   Rule2   ::=   'IF' BodyPattern 'THEN' HeadTemplate
[5]   Rule3   ::=   HeadTemplate ':-' BodyPattern
[6]   Declaration   ::=   ( 'TRANSITIVE' '(' iri ')' | 'SYMMETRIC' '(' iri ')' | 'INVERSE' '(' iri ',' iri ')' )
[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 | ImportsDecl )*
[13]   BaseDecl   ::=   'BASE' IRIREF
[14]   PrefixDecl   ::=   'PREFIX' PNAME_NS IRIREF
[15]   VersionDecl   ::=   'VERSION' VersionSpecifier
[16]   VersionSpecifier   ::=   STRING_LITERAL1 | STRING_LITERAL2
[17]   ImportsDecl   ::=   'IMPORTS' iri
[18]   TriplesTemplateBlock   ::=   '{' TriplesTemplate? '}'
[19]   TriplesTemplate   ::=   TriplesSameSubject ( '.' TriplesTemplate? )?
[20]   TriplesBlock   ::=   TriplesSameSubjectPath ( '.' TriplesBlock? )?
[21]   ReifiedTripleBlock   ::=   ReifiedTriple PropertyList
[22]   ReifiedTripleBlockPath   ::=   ReifiedTriple PropertyListPath
[23]   Assignment   ::=   Bind
[24]   Bind   ::=   'BIND' '(' Expression 'AS' Var ')'
[25]   Let   ::=   'LET' '(' Var ':=' Expression ')'
[26]   Reifier   ::=   '~' VarOrReifierId?
[27]   VarOrReifierId   ::=   Var | iri | BlankNode
[28]   Filter   ::=   'FILTER' Constraint
[29]   Constraint   ::=   BrackettedExpression | BuiltInCall | FunctionCall
[30]   FunctionCall   ::=   iri ArgList
[31]   ArgList   ::=   NIL | '(' Expression ( ',' Expression )* ')'
[32]   ExpressionList   ::=   NIL | '(' Expression ( ',' Expression )* ')'
[33]   TriplesSameSubject   ::=   VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList | ReifiedTripleBlock
[34]   PropertyList   ::=   PropertyListNotEmpty?
[35]   PropertyListNotEmpty   ::=   Verb ObjectList ( ';' ( Verb ObjectList )? )*
[36]   Verb   ::=   VarOrIri | 'a'
[37]   ObjectList   ::=   Object ( ',' Object )*
[38]   Object   ::=   GraphNode Annotation
[39]   TriplesSameSubjectPath   ::=   VarOrTerm PropertyListPathNotEmpty | TriplesNodePath PropertyListPath | ReifiedTripleBlockPath
[40]   PropertyListPath   ::=   PropertyListPathNotEmpty?
[41]   PropertyListPathNotEmpty   ::=   ( VerbPath | VerbSimple ) ObjectListPath ( ';' ( ( VerbPath | VerbSimple ) ObjectListPath )? )*
[42]   VerbPath   ::=   Path
[43]   VerbSimple   ::=   Var
[44]   ObjectListPath   ::=   ObjectPath ( ',' ObjectPath )*
[45]   ObjectPath   ::=   GraphNodePath AnnotationPath
[46]   Path   ::=   PathSequence
[47]   PathSequence   ::=   PathEltOrInverse ( '/' PathEltOrInverse )*
[48]   PathEltOrInverse   ::=   PathElt | '^' PathElt
[49]   PathElt   ::=   PathPrimary
[50]   PathPrimary   ::=   iri | 'a' | '(' Path ')'
[51]   TriplesNode   ::=   Collection | BlankNodePropertyList
[52]   BlankNodePropertyList   ::=   '[' PropertyListNotEmpty ']'
[53]   TriplesNodePath   ::=   CollectionPath | BlankNodePropertyListPath
[54]   BlankNodePropertyListPath   ::=   '[' PropertyListPathNotEmpty ']'
[55]   Collection   ::=   '(' GraphNode+ ')'
[56]   CollectionPath   ::=   '(' GraphNodePath+ ')'
[57]   AnnotationPath   ::=   ( Reifier | AnnotationBlockPath )*
[58]   AnnotationBlockPath   ::=   '{|' PropertyListPathNotEmpty '|}'
[59]   Annotation   ::=   ( Reifier | AnnotationBlock )*
[60]   AnnotationBlock   ::=   '{|' PropertyListNotEmpty '|}'
[61]   GraphNode   ::=   VarOrTerm | TriplesNode | ReifiedTriple
[62]   GraphNodePath   ::=   VarOrTerm | TriplesNodePath | ReifiedTriple
[63]   VarOrTerm   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | TripleTerm
[64]   ReifiedTriple   ::=   '<<' ReifiedTripleSubject Verb ReifiedTripleObject Reifier? '>>'
[65]   ReifiedTripleSubject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | ReifiedTriple
[66]   ReifiedTripleObject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | ReifiedTriple | TripleTerm
[67]   TripleTerm   ::=   '<<(' TripleTermSubject Verb TripleTermObject ')>>'
[68]   TripleTermSubject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode
[69]   TripleTermObject   ::=   Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | TripleTerm
[70]   TripleTermData   ::=   '<<(' TripleTermDataSubject ( iri | 'a' ) TripleTermDataObject ')>>'
[71]   TripleTermDataSubject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral
[72]   TripleTermDataObject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | TripleTermData
[73]   VarOrIri   ::=   Var | iri
[74]   Var   ::=   VAR1 | VAR2
[75]   Expression   ::=   ConditionalOrExpression
[76]   ConditionalOrExpression   ::=   ConditionalAndExpression ( '||' ConditionalAndExpression )*
[77]   ConditionalAndExpression   ::=   ValueLogical ( '&&' ValueLogical )*
[78]   ValueLogical   ::=   RelationalExpression
[79]   RelationalExpression   ::=   NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression | 'IN' ExpressionList | 'NOT' 'IN' ExpressionList )?
[80]   NumericExpression   ::=   AdditiveExpression
[81]   AdditiveExpression   ::=   MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | ( NumericLiteralPositive | NumericLiteralNegative ) ( ( '*' UnaryExpression ) | ( '/' UnaryExpression ) )* )*
[82]   MultiplicativeExpression   ::=   UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )*
[83]   UnaryExpression   ::=     '!' PrimaryExpression
| '+' PrimaryExpression
| '-' PrimaryExpression
| PrimaryExpression
[84]   PrimaryExpression   ::=   BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprTripleTerm
[85]   ExprTripleTerm   ::=   '<<(' ExprTripleTermSubject Verb ExprTripleTermObject ')>>'
[86]   ExprTripleTermSubject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var
[87]   ExprTripleTermObject   ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprTripleTerm
[88]   BrackettedExpression   ::=   '(' Expression ')'
[89]   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 ')'
[90]   iriOrFunction   ::=   iri ArgList?
[91]   RDFLiteral   ::=   String ( LANG_DIR | '^^' iri )?
[92]   NumericLiteral   ::=   NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
[93]   NumericLiteralUnsigned   ::=   INTEGER | DECIMAL | DOUBLE
[94]   NumericLiteralPositive   ::=   INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
[95]   NumericLiteralNegative   ::=   INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
[96]   BooleanLiteral   ::=   'true' | 'false'
[97]   String   ::=   STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[98]   iri   ::=   IRIREF | PrefixedName
[99]   PrefixedName   ::=   PNAME_LN | PNAME_NS
[100]   BlankNode   ::=   BLANK_NODE_LABEL | ANON

Productions for terminals:

[101]   IRIREF   ::=   '<' ([^<>"{}|^`\]-[#x00-#x20])* '>'
[102]   PNAME_NS   ::=   PN_PREFIX? ':'
[103]   PNAME_LN   ::=   PNAME_NS PN_LOCAL
[104]   BLANK_NODE_LABEL   ::=   '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
[105]   VAR1   ::=   '?' VARNAME
[106]   VAR2   ::=   '$' VARNAME
[107]   LANG_DIR   ::=   '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ('--' [a-zA-Z]+)?
[108]   INTEGER   ::=   [0-9]+
[109]   DECIMAL   ::=   [0-9]* '.' [0-9]+
[110]   DOUBLE   ::=   ( ([0-9]+ ('.'[0-9]*)? ) | ( '.' ([0-9])+ ) ) [eE][+-]?[0-9]+
[111]   INTEGER_POSITIVE   ::=   '+' INTEGER
[112]   DECIMAL_POSITIVE   ::=   '+' DECIMAL
[113]   DOUBLE_POSITIVE   ::=   '+' DOUBLE
[114]   INTEGER_NEGATIVE   ::=   '-' INTEGER
[115]   DECIMAL_NEGATIVE   ::=   '-' DECIMAL
[116]   DOUBLE_NEGATIVE   ::=   '-' DOUBLE
[117]   STRING_LITERAL1   ::=   "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'"
[118]   STRING_LITERAL2   ::=   '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"'
[119]   STRING_LITERAL_LONG1   ::=   "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''"
[120]   STRING_LITERAL_LONG2   ::=   '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""'
[121]   ECHAR   ::=   '\' [tbnrf\"']
[122]   NIL   ::=   '(' WS* ')'
[123]   WS   ::=   #x20 | #x9 | #xD | #xA
[124]   ANON   ::=   '[' WS* ']'
[125]   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]
[126]   PN_CHARS_U   ::=   PN_CHARS_BASE | '_'
[127]   VARNAME   ::=   ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
[128]   PN_CHARS   ::=   PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
[129]   PN_PREFIX   ::=   PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
[130]   PN_LOCAL   ::=   (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX) )?
[131]   PLX   ::=   PERCENT | PN_LOCAL_ESC
[132]   PERCENT   ::=   '%' HEX HEX
[133]   HEX   ::=   [0-9] | [A-F] | [a-f]
[134]   PN_LOCAL_ESC   ::=   '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%' )