-
Notifications
You must be signed in to change notification settings - Fork 1
/
sparql-star-grammar.ebnf
255 lines (254 loc) · 13 KB
/
sparql-star-grammar.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/* SPARQL-star, version 2021-12-17
* https://www.w3.org/2021/12/rdf-star.html#sparql-star-ebnf
*/
QueryUnit ::= Query
Query ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery) ValuesClause
UpdateUnit ::= Update
Prologue ::= ( BaseDecl | PrefixDecl) *
BaseDecl ::= 'BASE' IRIREF
PrefixDecl ::= 'PREFIX' PNAME_NS IRIREF
SelectQuery ::= SelectClause DatasetClause* WhereClause SolutionModifier
SubSelect ::= SelectClause WhereClause SolutionModifier ValuesClause
SelectClause ::= 'SELECT' ( 'DISTINCT' | 'REDUCED') ? ( ( Var | ( '(' Expression 'AS' Var ')') ) + | '*')
ConstructQuery ::= 'CONSTRUCT'
( ( ConstructTemplate DatasetClause* WhereClause SolutionModifier)( DatasetClause* 'WHERE' '{' TriplesTemplate? '}' SolutionModifier) )
DescribeQuery ::= 'DESCRIBE' ( VarOrIri+ | '*') DatasetClause* WhereClause? SolutionModifier
AskQuery ::= 'ASK' DatasetClause* WhereClause ValuesClause
DatasetClause ::= 'FROM' ( DefaultGraphClause | NamedGraphClause)
DefaultGraphClause ::= SourceSelector
NamedGraphClause ::= 'NAMED' SourceSelector
SourceSelector ::= iri
WhereClause ::= 'WHERE'? GroupGraphPattern
SolutionModifier ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses?
GroupClause ::= 'GROUP' 'BY' GroupCondition+
GroupCondition ::= BuiltInCall | FunctionCall | ( '(' Expression ( 'AS' Var) ? ')') | Var
HavingClause ::= 'HAVING' HavingCondition+
HavingCondition ::= Constraint
OrderClause ::= 'ORDER' 'BY' OrderCondition+
OrderCondition ::= ( ( 'ASC' | 'DESC') BrackettedExpression) | ( Constraint | Var)
LimitOffsetClauses ::= ( LimitClause OffsetClause? ) | ( OffsetClause LimitClause? )
LimitClause ::= 'LIMIT' INTEGER
OffsetClause ::= 'OFFSET' INTEGER
ValuesClause ::= ( 'VALUES' DataBlock) ?
Update ::= Prologue ( Update1 ( ';' Update) ? ) ?
Update1 ::= Load | Clear | Drop | Add | Move | Copy | Create | InsertData | DeleteData | DeleteWhere | Modify
Load ::= 'LOAD' 'SILENT'? iri ( 'INTO' GraphRef) ?
Clear ::= 'CLEAR' 'SILENT'? GraphRefAll
Drop ::= 'DROP' 'SILENT'? GraphRefAll
Create ::= 'CREATE' 'SILENT'? GraphRef
Add ::= 'ADD' 'SILENT'? GraphOrDefault 'TO' GraphOrDefault
Move ::= 'MOVE' 'SILENT'? GraphOrDefault 'TO' GraphOrDefault
Copy ::= 'COPY' 'SILENT'? GraphOrDefault 'TO' GraphOrDefault
InsertData ::= 'INSERT DATA' QuadData
DeleteData ::= 'DELETE DATA' QuadData
DeleteWhere ::= 'DELETE WHERE' QuadPattern
Modify ::= ( 'WITH' iri) ? ( ( DeleteClause InsertClause? ) | InsertClause) UsingClause* 'WHERE' GroupGraphPattern
DeleteClause ::= 'DELETE' QuadPattern
InsertClause ::= 'INSERT' QuadPattern
UsingClause ::= 'USING' ( iri | ( 'NAMED' iri) )
GraphOrDefault ::= 'DEFAULT' | ( 'GRAPH'? iri)
GraphRef ::= 'GRAPH' iri
GraphRefAll ::= GraphRef | 'DEFAULT' | 'NAMED' | 'ALL'
QuadPattern ::= '{' Quads '}'
QuadData ::= '{' Quads '}'
Quads ::= TriplesTemplate? ( QuadsNotTriples '.'? TriplesTemplate? ) *
QuadsNotTriples ::= 'GRAPH' VarOrIri '{' TriplesTemplate? '}'
TriplesTemplate ::= TriplesSameSubject ( '.' TriplesTemplate? ) ?
GroupGraphPattern ::= '{' ( SubSelect | GroupGraphPatternSub) '}'
GroupGraphPatternSub ::= TriplesBlock? ( GraphPatternNotTriples '.'? TriplesBlock? ) *
TriplesBlock ::= TriplesSameSubjectPath ( '.' TriplesBlock? ) ?
GraphPatternNotTriples ::= GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData
OptionalGraphPattern ::= 'OPTIONAL' GroupGraphPattern
GraphGraphPattern ::= 'GRAPH' VarOrIri GroupGraphPattern
ServiceGraphPattern ::= 'SERVICE' 'SILENT'? VarOrIri GroupGraphPattern
Bind ::= 'BIND' '(' Expression 'AS' Var ')'
InlineData ::= 'VALUES' DataBlock
DataBlock ::= InlineDataOneVar | InlineDataFull
InlineDataOneVar ::= Var '{' DataBlockValue* '}'
InlineDataFull ::= ( NIL | ( '(' Var* ')') ) '{' ( ( '(' DataBlockValue* ')') | NIL) * '}'
DataBlockValue ::= QuotedTriple | iri | RDFLiteral | NumericLiteral | BooleanLiteral | 'UNDEF'
MinusGraphPattern ::= 'MINUS' GroupGraphPattern
GroupOrUnionGraphPattern ::= GroupGraphPattern ( 'UNION' GroupGraphPattern) *
Filter ::= 'FILTER' Constraint
Constraint ::= BrackettedExpression | BuiltInCall | FunctionCall
FunctionCall ::= iri ArgList
ArgList ::= NIL | ( '(' 'DISTINCT'? Expression ( ',' Expression) * ')')
ExpressionList ::= NIL | ( '(' Expression ( ',' Expression) * ')')
ConstructTemplate ::= '{' ConstructTriples? '}'
ConstructTriples ::= TriplesSameSubject ( '.' ConstructTriples? ) ?
TriplesSameSubject ::= ( VarOrTermOrQuotedTP PropertyListNotEmpty) | ( TriplesNode PropertyList)
PropertyList ::= PropertyListNotEmpty?
PropertyListNotEmpty ::= Verb ObjectList ( ';' ( Verb ObjectList) ? ) *
Verb ::= VarOrIri | 'a'
ObjectList ::= Object ( ',' Object) *
Object ::= GraphNode AnnotationPattern?
TriplesSameSubjectPath ::= ( VarOrTermOrQuotedTP PropertyListPathNotEmpty) | ( TriplesNodePath PropertyListPath)
PropertyListPath ::= PropertyListPathNotEmpty?
PropertyListPathNotEmpty ::= ( VerbPath | VerbSimple) ObjectListPath ( ';' ( ( VerbPath | VerbSimple) ObjectList) ? ) *
VerbPath ::= Path
VerbSimple ::= Var
ObjectListPath ::= ObjectPath ( ',' ObjectPath) *
ObjectPath ::= GraphNodePath AnnotationPatternPath?
Path ::= PathAlternative
PathAlternative ::= PathSequence ( '|' PathSequence) *
PathSequence ::= PathEltOrInverse ( '/' PathEltOrInverse) *
PathElt ::= PathPrimary PathMod?
PathEltOrInverse ::= PathElt | ( '^' PathElt)
PathMod ::= '*' | '?' | '+'
PathPrimary ::= iri | 'a' | ( '!' PathNegatedPropertySet) | ( '(' Path ')')
PathNegatedPropertySet ::= PathOneInPropertySet | ( '(' ( PathOneInPropertySet ( '|' PathOneInPropertySet) * ) ? ')')
PathOneInPropertySet ::= iri | 'a' | ( '^' ( iri | 'a') )
Integer ::= INTEGER
TriplesNode ::= Collection | BlankNodePropertyList
BlankNodePropertyList ::= '[' PropertyListNotEmpty ']'
TriplesNodePath ::= CollectionPath | BlankNodePropertyListPath
BlankNodePropertyListPath ::= '[' PropertyListPathNotEmpty ']'
Collection ::= '(' GraphNode+ ')'
CollectionPath ::= '(' GraphNodePath+ ')'
GraphNode ::= VarOrTermOrQuotedTP | TriplesNode
GraphNodePath ::= VarOrTermOrQuotedTP | TriplesNodePath
VarOrTerm ::= Var | GraphTerm
VarOrIri ::= Var | iri
Var ::= VAR1 | VAR2
GraphTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
Expression ::= ConditionalOrExpression
ConditionalOrExpression ::= ConditionalAndExpression ( '||' ConditionalAndExpression) *
ConditionalAndExpression ::= ValueLogical ( '&&' ValueLogical) *
ValueLogical ::= RelationalExpression
RelationalExpression ::= NumericExpression
( ( '=' NumericExpression)( '!=' NumericExpression) | ( '<' NumericExpression) | ( '>' NumericExpression) | ( '<=' NumericExpression) | ( '>=' NumericExpression) | ( 'IN' ExpressionList) | ( 'NOT' 'IN' ExpressionList) ) ?
NumericExpression ::= AdditiveExpression
AdditiveExpression ::= MultiplicativeExpression
( ( '+' MultiplicativeExpression)( '-' MultiplicativeExpression) | ( ( NumericLiteralPositive | NumericLiteralNegative) ( ( '*' UnaryExpression) | ( '/' UnaryExpression) ) ? ) ) *
MultiplicativeExpression ::= UnaryExpression ( ( '*' UnaryExpression) | ( '/' UnaryExpression) ) *
UnaryExpression ::= ( '!' PrimaryExpression) | ( '+' PrimaryExpression) | ( '-' PrimaryExpression) | PrimaryExpression
PrimaryExpression ::= BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprQuotedTP
BrackettedExpression ::= '(' Expression ')'
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 ')')
| ( 'SHA224' '(' 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 ')')
| ( 'TRIPLE' '(' Expression ',' Expression ',' Expression ')')
| ( 'SUBJECT' '(' Expression ')')
| ( 'PREDICATE' '(' Expression ')')
| ( 'OBJECT' '(' Expression ')')
| ( 'isTRIPLE' '(' Expression ')')
| RegexExpression
| ExistsFunc
| NotExistsFunc
RegexExpression ::= 'REGEX' '(' Expression ',' Expression ( ',' Expression) ? ')'
SubstringExpression ::= 'SUBSTR' '(' Expression ',' Expression ( ',' Expression) ? ')'
StrReplaceExpression ::= 'REPLACE' '(' Expression ',' Expression ',' Expression ( ',' Expression) ? ')'
ExistsFunc ::= 'EXISTS' GroupGraphPattern
NotExistsFunc ::= 'NOT' 'EXISTS' GroupGraphPattern
Aggregate ::= ( 'COUNT' '(' 'DISTINCT'? ( '*'Expression) ')')
| ( 'SUM' '(' 'DISTINCT'? Expression ')')
| ( 'MIN' '(' 'DISTINCT'? Expression ')')
| ( 'MAX' '(' 'DISTINCT'? Expression ')')
| ( 'AVG' '(' 'DISTINCT'? Expression ')')
| ( 'SAMPLE' '(' 'DISTINCT'? Expression ')')
| ( 'GROUP_CONCAT' '(' 'DISTINCT'? Expression ( ';' 'SEPARATOR' '=' String) ? ')')
iriOrFunction ::= iri ArgList?
RDFLiteral ::= String ( LANGTAG | ( '^^' iri) ) ?
NumericLiteral ::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
NumericLiteralUnsigned ::= INTEGER | DECIMAL | DOUBLE
NumericLiteralPositive ::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
NumericLiteralNegative ::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
BooleanLiteral ::= 'true' | 'false'
String ::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
iri ::= IRIREF | PrefixedName
PrefixedName ::= PNAME_LN | PNAME_NS
BlankNode ::= BLANK_NODE_LABEL | ANON
QuotedTP ::= '<<' qtSubjectOrObject Verb qtSubjectOrObject '>>'
QuotedTriple ::= '<<' DataValueTerm ( iri | 'a') DataValueTerm '>>'
qtSubjectOrObject ::= Var | BlankNode | iri | RDFLiteral | NumericLiteral | BooleanLiteral | QuotedTP
DataValueTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | QuotedTriple
VarOrTermOrQuotedTP ::= Var | GraphTerm | QuotedTP
AnnotationPattern ::= '{|' PropertyListNotEmpty '|}'
AnnotationPatternPath ::= '{|' PropertyListPathNotEmpty '|}'
ExprQuotedTP ::= '<<' ExprVarOrTerm Verb ExprVarOrTerm '>>'
ExprVarOrTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprQuotedTP
IRIREF ::= '<' ([^<>"{}|^`\]-[#x00-#x20])* '>'
PNAME_NS ::= PN_PREFIX? ':'
PNAME_LN ::= PNAME_NS PN_LOCAL
BLANK_NODE_LABEL ::= '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
VAR1 ::= '?' VARNAME
VAR2 ::= '$' VARNAME
LANGTAG ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
INTEGER ::= [0-9]+
DECIMAL ::= [0-9]* '.' [0-9]+
DOUBLE ::= [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT
INTEGER_POSITIVE ::= '+' INTEGER
DECIMAL_POSITIVE ::= '+' DECIMAL
DOUBLE_POSITIVE ::= '+' DOUBLE
INTEGER_NEGATIVE ::= '-' INTEGER
DECIMAL_NEGATIVE ::= '-' DECIMAL
DOUBLE_NEGATIVE ::= '-' DOUBLE
EXPONENT ::= [eE] [+-]? [0-9]+
STRING_LITERAL1 ::= "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'"
STRING_LITERAL2 ::= '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"'
STRING_LITERAL_LONG1 ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''"
STRING_LITERAL_LONG2 ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""'
ECHAR ::= '\' [tbnrf\"']
NIL ::= '(' WS* ')'
WS ::= #x20 | #x9 | #xD | #xA
ANON ::= '[' WS* ']'
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]
PN_CHARS_U ::= PN_CHARS_BASE | '_'
VARNAME ::= ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX ) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX) )?
PLX ::= PERCENT | PN_LOCAL_ESC
PERCENT ::= '%' HEX HEX
HEX ::= [0-9] | [A-F] | [a-f]
PN_LOCAL_ESC ::= '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%' )