Grammar in EBNF notion

The definition of the syntax for the SPARQL-Generate language, as given by a grammar expressed in EBNF notation.

1 QueryUnit ::= Query
2 GenerateUnit ::= Query
3 Query ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery | GenerateQuery) ValuesClause
4 GenerateQuery ::= 'GENERATE' (SourceSelector | GenerateTemplate) DatasetClause IteratorOrSourceClause WhereClause? SolutionModifier
5 GenerateTemplate ::= '{' GenerateTemplateSub '}'
6 GenerateTemplateSub ::= ( ConstructTriples )? ( SubGenerateQuery (ConstructTriples)?)
7 SubGenerateQuery ::= 'GENERATE' (SourceSelector | GenerateTemplate) IteratorOrSourceClause WhereClause? SolutionModifier '.'
8 IteratorOrSourceClause ::= (IteratorClause | SourceClause | Bind )
9 IteratorClause ::= 'ITERATOR' FunctionCall 'AS' Var+
10 SourceClause ::= 'SOURCE' VarOrXIri ('ACCEPT' VarOrXIri)? 'AS' Var
11 VarOrXIri ::= ( VarOrXExpr | Xiri )
12 VarOrXExpr ::= ( Var | XExpr )
13 Xiri ::= ( iri | XIRIref_START XIRIREF_Sub )
14 XExpr ::= ( '$' | '?' ) '{' Expression '}'
15 Prologue ::= ( BaseDecl | PrefixDecl )
16 BaseDecl ::= 'BASE' IRIREF
17 PrefixDecl ::= 'PREFIX' PNAME_NS IRIREF
18 SelectQuery ::= SelectClause DatasetClause WhereClause SolutionModifier
19 SubSelect ::= SelectClause WhereClause SolutionModifier ValuesClause
20 SelectClause ::= 'SELECT' ( 'DISTINCT' | 'REDUCED' )? ( ( Var | ( '(' Expression 'AS' Var ')' ) )+ | '' )
21 ConstructQuery ::= 'CONSTRUCT' ( ConstructTemplate DatasetClause WhereClause SolutionModifier | DatasetClause 'WHERE' '{' TriplesTemplate? '}' SolutionModifier )
22 DescribeQuery ::= 'DESCRIBE' ( VarOrXIri+ | '' ) DatasetClause WhereClause? SolutionModifier
23 AskQuery ::= 'ASK' DatasetClause WhereClause SolutionModifier
24 DatasetClause ::= 'FROM' ( DefaultGraphClause | NamedGraphClause )
25 DefaultGraphClause ::= SourceSelector
26 NamedGraphClause ::= 'NAMED' SourceSelector
27 SourceSelector ::= iri
28 WhereClause ::= 'WHERE'? GroupGraphPattern
29 SolutionModifier ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses?
30 GroupClause ::= 'GROUP' 'BY' GroupCondition+
31 GroupCondition ::= BuiltInCall | FunctionCall | '(' Expression ( 'AS' Var )? ')' | Var
32 HavingClause ::= 'HAVING' HavingCondition+
33 HavingCondition ::= Constraint
34 OrderClause ::= 'ORDER' 'BY' OrderCondition+
35 OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | ( Constraint | Var )
36 LimitOffsetClauses ::= LimitClause OffsetClause? | OffsetClause LimitClause?
37 LimitClause ::= 'LIMIT' INTEGER
38 OffsetClause ::= 'OFFSET' INTEGER
39 ValuesClause ::= ( 'VALUES' DataBlock )?
40 TriplesTemplate ::= TriplesSameSubject ( '.' TriplesTemplate? )?
41 GroupGraphPattern ::= '{' ( SubSelect | GroupGraphPatternSub ) '}'
42 GroupGraphPatternSub ::= TriplesBlock? ( GraphPatternNotTriples '.'? TriplesBlock? )
43 TriplesBlock ::= TriplesSameSubjectPath ( '.' TriplesBlock? )?
44 GraphPatternNotTriples ::= GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData
45 OptionalGraphPattern ::= 'OPTIONAL' GroupGraphPattern
46 GraphGraphPattern ::= 'GRAPH' VarOrXIri GroupGraphPattern
47 ServiceGraphPattern ::= 'SERVICE' 'SILENT'? VarOrXIri GroupGraphPattern
48 Bind ::= 'BIND' '(' Expression 'AS' Var ')'
49 InlineData ::= 'VALUES' DataBlock
50 DataBlock ::= InlineDataOneVar | InlineDataFull
51 InlineDataOneVar ::= Var '{' DataBlockValue '}'
52 InlineDataFull ::= ( NIL | '(' Var ')' ) '{' ( '(' DataBlockValue ')' | NIL ) '}'
53 DataBlockValue ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | 'UNDEF'
54 MinusGraphPattern ::= 'MINUS' GroupGraphPattern
55 GroupOrUnionGraphPattern ::= GroupGraphPattern ( 'UNION' GroupGraphPattern )
56 Filter ::= 'FILTER' Constraint
57 Constraint ::= BrackettedExpression | BuiltInCall | FunctionCall
58 FunctionCall ::= iri ArgList
59 ArgList ::= NIL | '(' 'DISTINCT'? Expression ( ',' Expression ) ')'
60 ExpressionList ::= NIL | '(' Expression ( ',' Expression ) ')'
61 ConstructTemplate ::= '{' ConstructTriples? '}'
62 ConstructTriples ::= TriplesSameSubject ( '.' ConstructTriples? )?
63 TriplesSameSubject ::= VarOrXTerm PropertyListNotEmpty | TriplesNode PropertyList
64 PropertyList ::= PropertyListNotEmpty?
65 PropertyListNotEmpty ::= Verb ObjectList ( ';' ( Verb ObjectList )? )
66 VarOrXTerm ::= Var | XTerm
67 XTerm ::= ( XNode | NumericLiteral | BooleanLiteral | BlankNode | NIL )
68 XNode ::= ( XExpr | XRDFLiteral | Xiri )
69 XRDFLiteral ::= XString ( LANGTAG | DATATYPE Xiri )?
70 Verb ::= VarOrXTerm | 'a'
71 XString ::= XString_Literal1 | XString_Literal2 | XString_Literal_Long1 | XString_Literal_Long2
72 ObjectList ::= Object ( ',' Object )
73 Object ::= GraphNode
74 TriplesSameSubjectPath ::= VarOrXTerm PropertyListPathNotEmpty | TriplesNodePath PropertyListPath
75 PropertyListPath ::= PropertyListPathNotEmpty?
76 PropertyListPathNotEmpty ::= ( VerbPath | VerbSimple ) ObjectListPath ( ';' ( ( VerbPath | VerbSimple ) ObjectList )? )
77 VerbPath ::= Path
78 VerbSimple ::= VarOrXExpr
79 ObjectListPath ::= ObjectPath ( ',' ObjectPath )
80 ObjectPath ::= GraphNodePath
81 Path ::= PathAlternative
82 PathAlternative ::= PathSequence ( '|' PathSequence )
83 PathSequence ::= PathEltOrInverse ( '/' PathEltOrInverse )
84 PathElt ::= PathPrimary PathMod?
85 PathEltOrInverse ::= PathElt | '^' PathElt
86 PathMod ::= '?' | '' | '+'
87 PathPrimary ::= Xiri | 'a' | '!' PathNegatedPropertySet | '(' Path ')'
88 PathNegatedPropertySet ::= PathOneInPropertySet | '(' ( PathOneInPropertySet ( '|' PathOneInPropertySet ) )? ')'
89 PathOneInPropertySet ::= Xiri | 'a' | '^' ( Xiri | 'a' )
90 Integer ::= INTEGER
91 TriplesNode ::= Collection | BlankNodePropertyList
92 BlankNodePropertyList ::= '[' PropertyListNotEmpty ']'
93 TriplesNodePath ::= CollectionPath | BlankNodePropertyListPath
94 BlankNodePropertyListPath ::= '[' PropertyListPathNotEmpty ']'
95 Collection ::= '(' GraphNode+ ')'
96 CollectionPath ::= '(' GraphNodePath+ ')'
97 GraphNode ::= VarOrXTerm | TriplesNode
98 GraphNodePath ::= VarOrXTerm | TriplesNodePath
99 Var ::= VAR1 | VAR2
100 GraphTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
101 Expression ::= ConditionalOrExpression
102 ConditionalOrExpression ::= ConditionalAndExpression ( '||' ConditionalAndExpression )
103 ConditionalAndExpression ::= ValueLogical ( '&&' ValueLogical )
104 ValueLogical ::= RelationalExpression
105 RelationalExpression ::= NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression | 'IN' ExpressionList | 'NOT' 'IN' ExpressionList )?
106 NumericExpression ::= AdditiveExpression
107 AdditiveExpression ::= MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | ( NumericLiteralPositive | NumericLiteralNegative ) ( ( '' UnaryExpression ) | ( '/' UnaryExpression ) ) )
108 MultiplicativeExpression ::= UnaryExpression ( '' UnaryExpression | '/' UnaryExpression )
109 UnaryExpression ::= '!' PrimaryExpression | '+' PrimaryExpression | '-' PrimaryExpression | PrimaryExpression
110 PrimaryExpression ::= BrackettedExpression | BuiltInCall | XiriOrFunction | XRDFLiteral | NumericLiteral | BooleanLiteral | Var
111 XiriOrFunction ::= Xiri ( ArgList )?
112 BrackettedExpression ::= '(' Expression ')'
113 BuiltInCall ::= Aggregate | 'STR' '(' Expression ')' | 'LANG' '(' Expression ')' | 'LANGMATCHES' '(' Expression ',' Expression ')' | 'DATATYPE' '(' Expression ')' | 'BOUND' '(' Var ')' | 'IRI' '(' Expression ')' | 'URI' '(' Expression ')' | 'BNODE' ( '(' Expression ')' | NIL ) | 'RAND' NIL | 'ABS' '(' Expression ')' | 'CEIL' '(' Expression ')' | 'FLOOR' '(' Expression ')' | 'ROUND' '(' Expression ')' | 'CONCAT' ExpressionList | SubstringExpression | 'STRLEN' '(' Expression ')' | StrReplaceExpression | '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 ')' | 'STRDT' '(' Expression ',' Expression ')' | 'sameTerm' '(' Expression ',' Expression ')' | 'isIRI' '(' Expression ')' | 'isURI' '(' Expression ')' | 'isBLANK' '(' Expression ')' | 'isLITERAL' '(' Expression ')' | 'isNUMERIC' '(' Expression ')' | RegexExpression | ExistsFunc | NotExistsFunc
114 RegexExpression ::= 'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')'
115 SubstringExpression ::= 'SUBSTR' '(' Expression ',' Expression ( ',' Expression )? ')'
116 StrReplaceExpression ::= 'REPLACE' '(' Expression ',' Expression ',' Expression ( ',' Expression )? ')'
117 ExistsFunc ::= 'EXISTS' GroupGraphPattern
118 NotExistsFunc ::= 'NOT' 'EXISTS' GroupGraphPattern
119 Aggregate ::= 'COUNT' '(' 'DISTINCT'? ( '' | Expression ) ')' | 'SUM' '(' 'DISTINCT'? Expression ')' | 'MIN' '(' 'DISTINCT'? Expression ')' | 'MAX' '(' 'DISTINCT'? Expression ')' | 'AVG' '(' 'DISTINCT'? Expression ')' | 'SAMPLE' '(' 'DISTINCT'? Expression ')' | 'GROUPCONCAT' '(' 'DISTINCT'? Expression ( ';' 'SEPARATOR' '=' String )? ')'
120 iriOrFunction ::= iri ArgList?
121 RDFLiteral ::= String ( LANGTAG | ( '^^' iri ) )?
122 NumericLiteral ::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
123 NumericLiteralUnsigned ::= INTEGER | DECIMAL | DOUBLE
124 NumericLiteralPositive ::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
125 NumericLiteralNegative ::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
126 BooleanLiteral ::= 'true' | 'false'
127 String ::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
128 iri ::= IRIREF | PrefixedName
129 PrefixedName ::= PNAME_LN | PNAME_NS
130 BlankNode ::= BLANK_NODE_LABEL | ANON
131 IRIREF ::= '<' ([^><"{}^\|`]-[#x00-#x20])* '>'
132 PNAME_NS ::= PN_PREFIX? ':'
133 PNAME_LN ::= PNAME_NS PN_LOCAL
134 BLANK_NODE_LABEL ::= ':' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.') PN_CHARS)?
135 VAR1 ::= '?' VARNAME
136 VAR2 ::= '$' VARNAME
137 LANGTAG ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)
138 INTEGER ::= [0-9]+
139 DECIMAL ::= [0-9] '.' [0-9]+
140 DOUBLE ::= [0-9]+ '.' [0-9] EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT
141 INTEGER_POSITIVE ::= '+' INTEGER
142 DECIMAL_POSITIVE ::= '+' DECIMAL
143 DOUBLE_POSITIVE ::= '+' DOUBLE
144 INTEGER_NEGATIVE ::= '-' INTEGER
145 DECIMAL_NEGATIVE ::= '-' DECIMAL
146 DOUBLE_NEGATIVE ::= '-' DOUBLE
147 EXPONENT ::= [eE] [+-]? [0-9]+
148 STRING_LITERAL1 ::= "'" ( ([^#x27#x5C#xA#xD#x7B]) | ECHAR )* "'"
149 STRING_LITERAL2 ::= '"' ( ([^#x22#x5C#xA#xD#x7B]) | ECHAR ) '"'
150 STRING_LITERAL_LONG1 ::= QUOTE_3S ( ("'" | "''")? ( ([^#x27#x5C#x7B]) | ECHAR ))* QUOTE_3S
151 STRING_LITERAL_LONG2 ::= QUOTE_3D ( ('"' | '""')? ( ([^#x22#x5C#x7B]) | ECHAR ))* QUOTE_3D
152 ECHAR ::= '\' [tbnrf\"']
153 NIL ::= '(' WS ')'
154 WS ::= #x20 | #x9 | #xD | #xA
155 ANON ::= '[' WS ']'
156 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]
157 PN_CHARS_U ::= PN_CHARS_BASE | ''
158 VARNAME ::= ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )
159 PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
160 PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS|'.') PN_CHARS)?
161 PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX) (PN_CHARS | ':' | PLX) )?
162 PLX ::= PERCENT | PN_LOCAL_ESC
163 PERCENT ::= '%' HEX HEX
164 HEX ::= [0-9] | [A-F] | [a-f]
165 PN_LOCAL_ESC ::= '\' ( '' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%' )
166 XIRIref_START ::= "<" ([^><"{}^\|`]-[#x00-#x20])* "{"
167 XIRIREF_Sub ::= Expression ( RI XIRIREF_Sub | XIRIref_END )
168 XIRIref_END ::= "}" ([^><"{}^\|`]-[#x00-#x20])* ">"
169 RI ::= "}" ([^><"{}^\|`]-[#x00-#x20])* "{"
170 DATATYPE ::= '^^'
171 XString_Literal1 ::= ( STRING_LITERAL1 | STRING_LITERAL1_START XString_Literal1_Sub )
172 STRING_LITERAL1_START ::= "'" ( ([^#x27#x5C#xA#xD#x7B]) | ECHAR )* "{"
173 XString_Literal1_Sub ::= Expression ( S1 XString_Literal1_Sub | STRING_LITERAL1_END )
174 S1 ::= "}" ( ([^#x27#x5C#xA#xD#x7B]) | ECHAR )* "{"
175 STRING_LITERAL1_END ::= "}" ( ([^#x27#x5C#xA#xD#x7B]) | ECHAR )* "'"
176 XString_Literal2 ::= ( STRING_LITERAL2 | STRING_LITERAL2_START XString_Literal2_Sub )
177 XString_Literal2_Sub ::= Expression | ( (S2) XString_Literal2_Sub | STRING_LITERAL2_END )
178 S2 ::= "}" ( ([^#x22#x5C#xA#xD#x7B]) | ECHAR )* "{"
179 STRING_LITERAL2_END ::= "}" ( ([^#x22#x5C#xA#xD#x7B]) | ECHAR )* '"'
180 STRING_LITERAL2_START ::= '"' ( ([^#x22#x5C#xA#xD#x7B]) | ECHAR )* "{"
181 XString_Literal_Long1 ::= ( STRING_LITERAL_LONG1 | STRING_LITERAL_LONG1_START XString_Literal_Long1_Sub )
182 QUOTE_3S ::= "'''"
183 STRING_LITERAL_LONG1_START ::= QUOTE_3S (("'" | "''")? ([^#x27#x5C#x7B] | ECHAR ))* ("'" | "''")? "{"
184 XString_Literal_Long1_Sub ::= Expression ( L1 XString_Literal_Long1_Sub | STRING_LITERAL_LONG1_END )
185 L1 ::= "}" ( ("'" | "''")? ([^#x27#x5C#x7B]) | ECHAR )* "{"
186 STRING_LITERAL_LONG1_END ::= "}" ( ("'" | "''")? ([^#x27#x5C#x7B] | ECHAR ))* QUOTE_3S
187 XString_Literal_Long2 ::= ( STRING_LITERAL_LONG2 | STRING_LITERAL_LONG2_START XString_Literal_Long2_Sub )
188 QUOTE_3D ::= '"""'
189 STRING_LITERAL_LONG2_START ::= QUOTE_3D ( ('"' | '""')? ([^#x22#x5C#x7B] | ECHAR ))* ('"' | '""')? "{"
190 XString_Literal_Long2_Sub ::= Expression ( L2 XString_Literal_Long2_Sub | STRING_LITERAL_LONG2_END)
191 L2 ::= "}" ( ('"' | '""')? ([^#x22#x5C#x7B] | ECHAR ))* "{"
192 STRING_LITERAL_LONG2_END ::= "}" ( ('"' | '""')? ([^#x22#x5C#x7B] | ECHAR ))* QUOTE_3D

Back to top

Version: 1.2.3-SNAPSHOT. Last Published: 2018-09-06.