@matdata/yasqe 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/build/ts/grammar/tokenizer.d.ts +37 -0
  3. package/build/ts/src/CodeMirror.d.ts +21 -0
  4. package/build/ts/src/autocompleters/classes.d.ts +3 -0
  5. package/build/ts/src/autocompleters/index.d.ts +39 -0
  6. package/build/ts/src/autocompleters/prefixes.d.ts +3 -0
  7. package/build/ts/src/autocompleters/properties.d.ts +3 -0
  8. package/build/ts/src/autocompleters/variables.d.ts +3 -0
  9. package/build/ts/src/defaults.d.ts +75 -0
  10. package/build/ts/src/imgs.d.ts +7 -0
  11. package/build/ts/src/index.d.ts +303 -0
  12. package/build/ts/src/prefixFold.d.ts +8 -0
  13. package/build/ts/src/prefixUtils.d.ts +9 -0
  14. package/build/ts/src/sparql.d.ts +20 -0
  15. package/build/ts/src/tokenUtils.d.ts +4 -0
  16. package/build/ts/src/tooltip.d.ts +2 -0
  17. package/build/ts/src/trie.d.ts +13 -0
  18. package/build/yasqe.html +108 -0
  19. package/build/yasqe.min.css +2 -0
  20. package/build/yasqe.min.css.map +1 -0
  21. package/build/yasqe.min.js +3 -0
  22. package/build/yasqe.min.js.LICENSE.txt +3 -0
  23. package/build/yasqe.min.js.map +1 -0
  24. package/grammar/README.md +12 -0
  25. package/grammar/_tokenizer-table.js +4776 -0
  26. package/grammar/build.sh +2 -0
  27. package/grammar/sparql11-grammar.pl +834 -0
  28. package/grammar/sparqljs-browser-min.js +4535 -0
  29. package/grammar/tokenizer.ts +729 -0
  30. package/grammar/util/gen_ll1.pl +37 -0
  31. package/grammar/util/gen_sparql11.pl +11 -0
  32. package/grammar/util/ll1.pl +175 -0
  33. package/grammar/util/output_to_javascript.pl +75 -0
  34. package/grammar/util/prune.pl +49 -0
  35. package/grammar/util/rewrite.pl +104 -0
  36. package/package.json +40 -0
  37. package/src/CodeMirror.ts +54 -0
  38. package/src/autocompleters/classes.ts +32 -0
  39. package/src/autocompleters/index.ts +346 -0
  40. package/src/autocompleters/prefixes.ts +130 -0
  41. package/src/autocompleters/properties.ts +28 -0
  42. package/src/autocompleters/show-hint.scss +38 -0
  43. package/src/autocompleters/variables.ts +52 -0
  44. package/src/defaults.ts +149 -0
  45. package/src/imgs.ts +14 -0
  46. package/src/index.ts +1089 -0
  47. package/src/prefixFold.ts +93 -0
  48. package/src/prefixUtils.ts +65 -0
  49. package/src/scss/buttons.scss +275 -0
  50. package/src/scss/codemirrorMods.scss +36 -0
  51. package/src/scss/yasqe.scss +89 -0
  52. package/src/sparql.ts +215 -0
  53. package/src/tokenUtils.ts +121 -0
  54. package/src/tooltip.ts +31 -0
  55. package/src/trie.ts +238 -0
@@ -0,0 +1,834 @@
1
+ /*
2
+
3
+ SPARQL 1.1 grammar rules based on the Last Call Working Draft of 24/07/2012:
4
+ http://www.w3.org/TR/2012/WD-sparql11-query-20120724/#sparqlGrammar
5
+
6
+ Be careful with grammar notation - it is EBNF in prolog syntax!
7
+
8
+ [...] lists always represent sequence.
9
+ or can be used as binary operator or n-ary prefix term - do not put [...]
10
+ inside unless you want sequence as a single disjunct.
11
+
12
+ *, +, ? - generally used as 1-ary terms
13
+
14
+ stephen.cresswell@tso.co.uk
15
+ */
16
+
17
+ % We need to be careful with end-of-input marker $
18
+ % Since we never actually receive this from Codemirror,
19
+ % we can't have it appear on RHS of deployed rules.
20
+ % However, we do need it to check whether rules *could* precede
21
+ % end-of-input, so use it with top-level
22
+
23
+ :-dynamic '==>'/2.
24
+
25
+ sparql11 ==> [prologue,(queryAll or updateAll), $].
26
+ queryUnit ==> [query,$].
27
+ updateUnit ==> [update,$].
28
+
29
+ query ==>
30
+ [prologue,or(selectQuery,constructQuery,describeQuery,askQuery),valuesClause].
31
+ queryAll ==>
32
+ [or(selectQuery,constructQuery,describeQuery,askQuery),valuesClause].
33
+
34
+ prologue ==>
35
+ %[?(baseDecl),*(prefixDecl)].
36
+ [*(baseDecl or prefixDecl)].
37
+
38
+ baseDecl ==>
39
+ ['BASE','IRI_REF'].
40
+
41
+ prefixDecl ==>
42
+ ['PREFIX','PNAME_NS','IRI_REF'].
43
+
44
+ % [7]
45
+ selectQuery ==>
46
+ [selectClause,*(datasetClause),whereClause,solutionModifier].
47
+
48
+ subSelect ==>
49
+ [selectClause,whereClause,solutionModifier,valuesClause].
50
+
51
+ % [9]
52
+ selectClause ==>
53
+ ['SELECT',
54
+ ?('DISTINCT' or 'REDUCED'),
55
+ (+(var or ['(',expression,'AS',var,')']) or '*')].
56
+
57
+ %selectQuery ==>
58
+ % ['SELECT',
59
+ % ?('DISTINCT' or 'REDUCED'),
60
+ % (+(var) or '*'),
61
+ % *(datasetClause),whereClause,solutionModifier].
62
+
63
+ %[10]
64
+ constructQuery ==>
65
+ ['CONSTRUCT',
66
+ [constructTemplate,*(datasetClause),whereClause,solutionModifier]
67
+ or
68
+ [*(datasetClause),'WHERE','{',?(triplesTemplate),'}',solutionModifier]].
69
+
70
+ describeQuery ==>
71
+ ['DESCRIBE',+(varOrIRIref) or '*',
72
+ *(describeDatasetClause),?(whereClause),solutionModifier].
73
+
74
+ askQuery ==>
75
+ ['ASK',*(datasetClause),whereClause,solutionModifier].
76
+
77
+ describeDatasetClause ==> % Not in spec - artificial distinction
78
+ ['FROM',defaultGraphClause or namedGraphClause].
79
+ datasetClause ==>
80
+ ['FROM',defaultGraphClause or namedGraphClause].
81
+
82
+ defaultGraphClause ==>
83
+ [sourceSelector].
84
+
85
+ namedGraphClause ==>
86
+ ['NAMED',sourceSelector].
87
+
88
+ sourceSelector ==>
89
+ [iriRef].
90
+
91
+ whereClause ==>
92
+ [?('WHERE'),groupGraphPattern].
93
+
94
+ %[18]
95
+ solutionModifier ==>
96
+ [?(groupClause),?(havingClause),?(orderClause),?(limitOffsetClauses)].
97
+
98
+ %[19]
99
+ groupClause ==>
100
+ ['GROUP','BY',+(groupCondition)].
101
+
102
+ %[20]
103
+ groupCondition ==>
104
+ [builtInCall].
105
+ groupCondition ==>
106
+ [functionCall].
107
+ groupCondition ==>
108
+ ['(',expression,?(['AS',var]),')'].
109
+ groupCondition ==>
110
+ [var].
111
+
112
+ %[21]
113
+ havingClause ==>
114
+ ['HAVING',+(havingCondition)].
115
+ %[22]
116
+ havingCondition ==>
117
+ [constraint].
118
+
119
+ orderClause ==>
120
+ ['ORDER','BY',+(orderCondition)].
121
+
122
+ orderCondition ==>
123
+ ['ASC' or 'DESC',brackettedExpression].
124
+ orderCondition ==>
125
+ [constraint].
126
+ orderCondition ==>
127
+ [var].
128
+
129
+ %[25]
130
+ limitOffsetClauses ==>
131
+ [limitClause, ?(offsetClause)].
132
+ limitOffsetClauses ==>
133
+ [offsetClause, ?(limitClause)].
134
+
135
+ %[26]
136
+ limitClause ==>
137
+ ['LIMIT','INTEGER'].
138
+
139
+ %[27]
140
+ offsetClause ==>
141
+ ['OFFSET','INTEGER'].
142
+
143
+ %[28]
144
+ %bindingsClause ==>
145
+ % ['BINDINGS',*(var),'{',
146
+ % *(['(',*(bindingValue),')'] or 'NIL'),
147
+ % '}'].
148
+ %bindingsClause ==> [].
149
+
150
+ %[28]
151
+ valuesClause ==> ['VALUES',dataBlock].
152
+ valuesClause ==> [].
153
+
154
+ %[29]
155
+ update ==> [prologue,?([update1,?([';',update])])].
156
+ updateAll ==> [?([update1,?([';',update])])].
157
+ %[30]
158
+ update1 ==> [load].
159
+ update1 ==> [clear].
160
+ update1 ==> [drop].
161
+ update1 ==> [add].
162
+ update1 ==> [move].
163
+ update1 ==> [copy].
164
+ update1 ==> [create].
165
+ update1 ==> ['INSERT',insert1].
166
+ update1 ==> ['DELETE',delete1].
167
+ update1 ==> [modify].
168
+
169
+ %[31]
170
+ load ==> ['LOAD','?SILENT_1',iriRef,?(['INTO',graphRef])].
171
+ clear ==> ['CLEAR','?SILENT_2',graphRefAll].
172
+ drop ==> ['DROP','?SILENT_2',graphRefAll].
173
+ create ==> ['CREATE','?SILENT_3',graphRef].
174
+ add ==> ['ADD','?SILENT_4',graphOrDefault,'TO',graphOrDefault].
175
+ move ==> ['MOVE','?SILENT_4',graphOrDefault,'TO',graphOrDefault].
176
+ copy ==> ['COPY','?SILENT_4',graphOrDefault,'TO',graphOrDefault].
177
+
178
+ % Distinguish uses of ?('SILENT') to keep table clean.
179
+ % This is only needed because Flint uses the LL1 table to provide suggestions.
180
+ '?SILENT_1'==>[].
181
+ '?SILENT_1'==>['SILENT'].
182
+ '?SILENT_2'==>[].
183
+ '?SILENT_2'==>['SILENT'].
184
+ '?SILENT_3'==>[].
185
+ '?SILENT_3'==>['SILENT'].
186
+ '?SILENT_4'==>[].
187
+ '?SILENT_4'==>['SILENT'].
188
+
189
+ %[38]-[41] Deviate from spec because we separated symbols e.g. was 'INSERT DATA'.
190
+ % By separating symbols, we lose LL1 property, so have to re-jiggle grammar
191
+ % to avoid multiple rules that begin with DELETE.
192
+ insert1 ==> ['DATA',quadData].
193
+ insert1 ==> [quadPattern,
194
+ *(usingClause),
195
+ 'WHERE',
196
+ groupGraphPattern].
197
+
198
+ delete1 ==> ['DATA',quadDataNoBnodes]. % Originally nt deleteData
199
+ delete1 ==> ['WHERE',quadPatternNoBnodes]. % Originally nt deleteWhere
200
+ delete1 ==> [quadPatternNoBnodes,?(insertClause), % Originally part of nt modify
201
+ *(usingClause),
202
+ 'WHERE',
203
+ groupGraphPattern].
204
+
205
+ %[41]
206
+ % In the spec, WITH is optional, but we have refactored
207
+ % and handled cases beginning 'DELETE' or 'INSERT'.
208
+ modify ==>
209
+ ['WITH',iriRef,
210
+ [deleteClause,?(insertClause)] or insertClause,
211
+ *(usingClause),
212
+ 'WHERE',
213
+ groupGraphPattern].
214
+
215
+ %[42]
216
+ deleteClause ==>
217
+ ['DELETE',quadPattern].
218
+ %[43]
219
+ insertClause ==>
220
+ ['INSERT',quadPattern].
221
+ %[44]
222
+ usingClause ==>
223
+ ['USING',iriRef or ['NAMED',iriRef]].
224
+ %[45]
225
+ graphOrDefault ==> ['DEFAULT'].
226
+ graphOrDefault ==> [?('GRAPH'),iriRef].
227
+ %[46]
228
+ graphRef ==> ['GRAPH',iriRef].
229
+ %[47]
230
+ graphRefAll ==> [graphRef].
231
+ graphRefAll ==> ['DEFAULT'].
232
+ graphRefAll ==> ['NAMED'].
233
+ graphRefAll ==> ['ALL'].
234
+ %[48]
235
+ quadPattern ==> ['{',quads,'}'].
236
+ quadPatternNoBnodes ==> ['{',disallowBnodes,quads,allowBnodes,'}'].
237
+ %[49]
238
+ quadData ==> ['{',disallowVars,quads,allowVars,'}'].
239
+ quadDataNoBnodes ==> ['{',disallowBnodes,disallowVars,quads,allowVars,allowBnodes,'}'].
240
+ % Special NTs that have a hard-wired side-effect in parser code
241
+ % - conditions appear in notes 8 and 9 in grammar section of SPARQL1.1 spec.
242
+ disallowVars==>[].
243
+ allowVars==>[].
244
+ disallowBnodes==>[].
245
+ allowBnodes==>[].
246
+ %[50]
247
+ quads ==>
248
+ [?(triplesTemplate),*([quadsNotTriples,?('.'),?(triplesTemplate)])].
249
+ %[51]
250
+ quadsNotTriples ==>
251
+ ['GRAPH',varOrIRIref,'{',?(triplesTemplate),'}'].
252
+ %[52]
253
+ triplesTemplate ==>
254
+ [triplesSameSubject,?(['.',?(triplesTemplate)])].
255
+ %[53]
256
+ groupGraphPattern ==>
257
+ ['{',subSelect or groupGraphPatternSub,'}'].
258
+ %groupGraphPattern ==> [
259
+ % '{',
260
+ % ?(triplesBlock),
261
+ % *([graphPatternNotTriples or filter, ?('.'), ?(triplesBlock)]),
262
+ % '}'].
263
+ %[54]
264
+ groupGraphPatternSub ==>
265
+ [?(triplesBlock),*([graphPatternNotTriples,?('.'),?(triplesBlock)])].
266
+ %[55]
267
+ triplesBlock ==>
268
+ [triplesSameSubjectPath,?(['.',?(triplesBlock)])].
269
+ %[56]
270
+ graphPatternNotTriples ==> [groupOrUnionGraphPattern].
271
+ graphPatternNotTriples ==> [optionalGraphPattern].
272
+ graphPatternNotTriples ==> [minusGraphPattern].
273
+ graphPatternNotTriples ==> [graphGraphPattern].
274
+ graphPatternNotTriples ==> [serviceGraphPattern].
275
+ graphPatternNotTriples ==> [filter].
276
+ graphPatternNotTriples ==> [bind].
277
+ graphPatternNotTriples ==> [inlineData].
278
+ %[57]
279
+ optionalGraphPattern ==> ['OPTIONAL',groupGraphPattern].
280
+ %[58]
281
+ graphGraphPattern ==>
282
+ ['GRAPH',varOrIRIref,groupGraphPattern].
283
+ %[59]
284
+ serviceGraphPattern ==>
285
+ ['SERVICE',?('SILENT'),varOrIRIref,groupGraphPattern].
286
+ %[60]
287
+ bind ==>
288
+ ['BIND','(',expression,'AS',var,')'].
289
+ %[61]
290
+ inlineData ==> ['VALUES',dataBlock].
291
+ %[62]
292
+ dataBlock ==> [inlineDataOneVar or inlineDataFull].
293
+ %[63]
294
+ inlineDataOneVar ==> [var,'{',*(dataBlockValue),'}'].
295
+ %[64]
296
+ inlineDataFull ==> [ 'NIL' or ['(',*(var),')'],
297
+ '{',*(['(',*(dataBlockValue),')'] or 'NIL'),'}'].
298
+ %[65]
299
+ dataBlockValue ==> [iriRef].
300
+ dataBlockValue ==> [rdfLiteral].
301
+ dataBlockValue ==> [numericLiteral].
302
+ dataBlockValue ==> [booleanLiteral].
303
+ dataBlockValue ==> ['UNDEF'].
304
+
305
+ %[66]
306
+ minusGraphPattern ==>
307
+ ['MINUS',groupGraphPattern].
308
+ %[67]
309
+ groupOrUnionGraphPattern ==>
310
+ [groupGraphPattern,*(['UNION',groupGraphPattern])].
311
+ %[68]
312
+ filter ==>
313
+ ['FILTER',constraint].
314
+ %[69]
315
+ constraint ==>
316
+ [brackettedExpression].
317
+ constraint ==>
318
+ [builtInCall].
319
+ constraint ==>
320
+ [functionCall].
321
+ %[70]
322
+ functionCall ==>
323
+ [iriRef,argList].
324
+ %[70]
325
+ argList ==>
326
+ ['NIL'].
327
+ argList ==>
328
+ ['(',?('DISTINCT'),expression,*([',',expression]),')'].
329
+ %[71]
330
+ expressionList ==> ['NIL'].
331
+ expressionList ==> ['(',expression,*([',',expression]),')'].
332
+ %[73]
333
+ constructTemplate ==>
334
+ ['{',?(constructTriples),'}'].
335
+ %[74]
336
+ constructTriples ==>
337
+ [triplesSameSubject,?(['.',?(constructTriples)])].
338
+ %[75]
339
+ triplesSameSubject ==>
340
+ [varOrTerm,propertyListNotEmpty].
341
+ triplesSameSubject ==>
342
+ [triplesNode,propertyList].
343
+ %[76]
344
+ propertyList ==> [propertyListNotEmpty].
345
+ propertyList ==> [].
346
+ %[77]
347
+ propertyListNotEmpty ==>
348
+ [verb,objectList,*([';',?([verb,objectList])])].
349
+ % storeProperty is a dummy for side-effect of remembering property
350
+ storeProperty==>[].
351
+ %[78]
352
+ verb ==> [storeProperty,varOrIRIref].
353
+ verb ==> [storeProperty,'a'].
354
+ %[79]
355
+ objectList ==>
356
+ [object,*([',',object])].
357
+ %[80]
358
+ object ==>
359
+ [graphNode].
360
+ %[81]
361
+ triplesSameSubjectPath ==> [varOrTerm,propertyListPathNotEmpty].
362
+ triplesSameSubjectPath ==> [triplesNodePath,propertyListPath].
363
+ %[82]
364
+ propertyListPath ==> [propertyListNotEmpty].
365
+ propertyListPath ==> [].
366
+ %[83]
367
+ propertyListPathNotEmpty ==>
368
+ [verbPath or verbSimple,
369
+ objectListPath,
370
+ *([';',?([verbPath or verbSimple,objectListPath])])].
371
+ %[84]
372
+ verbPath ==> [path].
373
+ %[85]
374
+ verbSimple ==> [var].
375
+ %[86]
376
+ objectListPath ==>
377
+ [objectPath,*([',',objectPath])].
378
+ %[87]
379
+ objectPath ==> [graphNodePath].
380
+ %[88]
381
+ path ==> [pathAlternative].
382
+ %[89].
383
+ pathAlternative ==>
384
+ [pathSequence,*(['|',pathSequence])].
385
+ %[90]
386
+ pathSequence ==>
387
+ [pathEltOrInverse,*(['/',pathEltOrInverse])].
388
+ %[91]
389
+ pathElt ==>
390
+ [pathPrimary,?(pathMod)].
391
+ %[92]
392
+ pathEltOrInverse ==> [pathElt].
393
+ pathEltOrInverse ==> ['^',pathElt].
394
+ %[93] - last case below looks weird because
395
+ % {0} and {0,1} and {0,} and {,1} are allowed
396
+ pathMod ==> ['*'].
397
+ pathMod ==> ['?'].
398
+ pathMod ==> ['+'].
399
+ pathMod ==>
400
+ ['{',
401
+ [integer,
402
+ ([',', '}' or [integer,'}']])
403
+ or
404
+ '}'
405
+ ]
406
+ or
407
+ [',',integer,'}']
408
+ ].
409
+
410
+ % Original expression from SPARQL1.1 spec:
411
+ %'{' ( Integer
412
+ % ( ','
413
+ % ( '}' | Integer '}' )
414
+ % | '}' )
415
+ % | ',' Integer '}' )
416
+
417
+ %[94]
418
+ pathPrimary ==> [storeProperty,iriRef].
419
+ pathPrimary ==> [storeProperty,'a'].
420
+ pathPrimary ==> ['!',pathNegatedPropertySet].
421
+ pathPrimary ==> ['(',path,')'].
422
+
423
+ %[95]
424
+ pathNegatedPropertySet ==>
425
+ [pathOneInPropertySet].
426
+ pathNegatedPropertySet ==>
427
+ ['(',
428
+ ?([pathOneInPropertySet,
429
+ *(['|',pathOneInPropertySet]) ]),
430
+ ')'].
431
+ %[96]
432
+ pathOneInPropertySet ==> [iriRef].
433
+ pathOneInPropertySet ==> ['a'].
434
+ pathOneInPropertySet ==> ['^',iriRef or 'a'].
435
+ %[97]
436
+ integer ==> ['INTEGER'].
437
+ %[98]
438
+ triplesNode ==> [collection].
439
+ triplesNode ==> [blankNodePropertyList].
440
+ %[99]
441
+ blankNodePropertyList ==> ['[',propertyListNotEmpty,']'].
442
+ %[100]
443
+ triplesNodePath ==> [collectionPath].
444
+ triplesNodePath ==> [blankNodePropertyListPath].
445
+ %[101]
446
+ blankNodePropertyListPath ==> ['[',propertyListPathNotEmpty,']'].
447
+ %[102]
448
+ collection ==> ['(',+(graphNode),')'].
449
+ %[103]
450
+ collectionPath ==> ['(',+(graphNodePath),')'].
451
+ %[104]
452
+ graphNode ==> [varOrTerm].
453
+ graphNode ==> [triplesNode].
454
+ %[105]
455
+ graphNodePath ==> [varOrTerm].
456
+ graphNodePath ==> [triplesNodePath].
457
+ %[106]
458
+ varOrTerm ==> [var].
459
+ varOrTerm ==> [graphTerm].
460
+ %[107]
461
+ varOrIRIref ==> [var].
462
+ varOrIRIref ==> [iriRef].
463
+ %[108]
464
+ var ==> ['VAR1'].
465
+ var ==> ['VAR2'].
466
+ %[109]
467
+ graphTerm ==> [iriRef].
468
+ graphTerm ==> [rdfLiteral].
469
+ graphTerm ==> [numericLiteral].
470
+ graphTerm ==> [booleanLiteral].
471
+ graphTerm ==> [blankNode].
472
+ graphTerm ==> ['NIL'].
473
+ %[110]
474
+ expression ==> [conditionalOrExpression].
475
+ %[111]
476
+ conditionalOrExpression ==>
477
+ [conditionalAndExpression,*(['||',conditionalAndExpression])].
478
+ %[112]
479
+ conditionalAndExpression ==>
480
+ [valueLogical,*(['&&',valueLogical])].
481
+ %[113]
482
+ valueLogical ==> [relationalExpression].
483
+ %[114]
484
+ relationalExpression ==>
485
+ [numericExpression,
486
+ ?(or(['=',numericExpression],
487
+ ['!=',numericExpression],
488
+ ['<',numericExpression],
489
+ ['>',numericExpression],
490
+ ['<=',numericExpression],
491
+ ['>=',numericExpression],
492
+ ['IN',expressionList],
493
+ ['NOT','IN',expressionList]))].
494
+ %[115]
495
+ numericExpression ==> [additiveExpression].
496
+ %[116]
497
+ additiveExpression ==>
498
+ [multiplicativeExpression,
499
+ *(or(['+',multiplicativeExpression],
500
+ ['-',multiplicativeExpression],
501
+ [numericLiteralPositive or numericLiteralNegative,
502
+ ?(['*',unaryExpression] or ['/',unaryExpression]) ]))].
503
+ %[117]
504
+ multiplicativeExpression ==>
505
+ [unaryExpression,*(['*',unaryExpression] or ['/',unaryExpression])].
506
+ %[118]
507
+ unaryExpression ==> ['!',primaryExpression].
508
+ unaryExpression ==> ['+',primaryExpression].
509
+ unaryExpression ==> ['-',primaryExpression].
510
+ unaryExpression ==> [primaryExpression].
511
+ %[119]
512
+ primaryExpression ==> [brackettedExpression].
513
+ primaryExpression ==> [builtInCall].
514
+ primaryExpression ==> [iriRefOrFunction].
515
+ primaryExpression ==> [rdfLiteral].
516
+ primaryExpression ==> [numericLiteral].
517
+ primaryExpression ==> [booleanLiteral].
518
+ primaryExpression ==> [var].
519
+ primaryExpression ==> [aggregate].
520
+ %[120]
521
+ brackettedExpression ==> ['(',expression,')'].
522
+ %[121]
523
+ builtInCall ==> ['STR','(',expression,')'].
524
+ builtInCall ==> ['LANG','(',expression,')'].
525
+ builtInCall ==> ['LANGMATCHES','(',expression,',',expression,')'].
526
+ builtInCall ==> ['DATATYPE','(',expression,')'].
527
+ builtInCall ==> ['BOUND','(',var,')'].
528
+ builtInCall ==> ['IRI','(',expression,')'].
529
+ builtInCall ==> ['URI','(',expression,')'].
530
+ %builtInCall ==> ['BNODE','(',?(expression),')']. % Avoided use of NIL
531
+ %builtInCall ==> ['RAND','(',')']. % Avoided use of NIL
532
+ builtInCall ==> ['BNODE',['(',expression,')'] or 'NIL'].
533
+ builtInCall ==> ['RAND',['(',expression,')'] or 'NIL'].
534
+ builtInCall ==> ['ABS','(',expression,')'].
535
+ builtInCall ==> ['CEIL','(',expression,')'].
536
+ builtInCall ==> ['FLOOR','(',expression,')'].
537
+ builtInCall ==> ['ROUND','(',expression,')'].
538
+ builtInCall ==> ['CONCAT',expressionList].
539
+ builtInCall ==> [substringExpression].
540
+ builtInCall ==> ['STRLEN','(',expression,')'].
541
+ builtInCall ==> [strReplaceExpression].
542
+ builtInCall ==> ['UCASE','(',expression,')'].
543
+ builtInCall ==> ['LCASE','(',expression,')'].
544
+ builtInCall ==> ['ENCODE_FOR_URI','(',expression,')'].
545
+ builtInCall ==> ['CONTAINS','(',expression,',',expression,')'].
546
+ builtInCall ==> ['STRSTARTS','(',expression,',',expression,')'].
547
+ builtInCall ==> ['STRENDS','(',expression,',',expression,')'].
548
+ builtInCall ==> ['STRBEFORE','(',expression,',',expression,')'].
549
+ builtInCall ==> ['STRAFTER','(',expression,',',expression,')'].
550
+ builtInCall ==> ['YEAR','(',expression,')'].
551
+ builtInCall ==> ['MONTH','(',expression,')'].
552
+ builtInCall ==> ['DAY','(',expression,')'].
553
+ builtInCall ==> ['HOURS','(',expression,')'].
554
+ builtInCall ==> ['MINUTES','(',expression,')'].
555
+ builtInCall ==> ['SECONDS','(',expression,')'].
556
+ builtInCall ==> ['TIMEZONE','(',expression,')'].
557
+ builtInCall ==> ['TZ','(',expression,')'].
558
+ %builtInCall ==> ['NOW','(',')']. % Avoided NIL
559
+ builtInCall ==> ['NOW','NIL'].
560
+ builtInCall ==> ['UUID','NIL'].
561
+ builtInCall ==> ['STRUUID','NIL'].
562
+ builtInCall ==> ['MD5','(',expression,')'].
563
+ builtInCall ==> ['SHA1','(',expression,')'].
564
+ builtInCall ==> ['SHA256','(',expression,')'].
565
+ builtInCall ==> ['SHA384','(',expression,')'].
566
+ builtInCall ==> ['SHA512','(',expression,')'].
567
+ builtInCall ==> ['COALESCE',expressionList].
568
+ builtInCall ==> ['IF','(',expression,',',expression,',',expression,')'].
569
+ builtInCall ==> ['STRLANG','(',expression,',',expression,')'].
570
+ builtInCall ==> ['STRDT','(',expression,',',expression,')'].
571
+ builtInCall ==> ['SAMETERM','(',expression,',',expression,')'].
572
+ builtInCall ==> ['ISIRI','(',expression,')'].
573
+ builtInCall ==> ['ISURI','(',expression,')'].
574
+ builtInCall ==> ['ISBLANK','(',expression,')'].
575
+ builtInCall ==> ['ISLITERAL','(',expression,')'].
576
+ builtInCall ==> ['ISNUMERIC','(',expression,')'].
577
+ builtInCall ==> [regexExpression].
578
+ builtInCall ==> [existsFunc].
579
+ builtInCall ==> [notExistsFunc].
580
+ %[122]
581
+ regexExpression ==>
582
+ ['REGEX','(',expression,',',expression,?([',',expression]),')'].
583
+ %[123]
584
+ substringExpression ==>
585
+ ['SUBSTR','(',expression,',',expression,?([',',expression]),')'].
586
+ %[124]
587
+ strReplaceExpression ==>
588
+ ['REPLACE','(',expression,',',expression,',',expression,?([',',expression]),')'].
589
+ %[125]
590
+ existsFunc ==>
591
+ ['EXISTS',groupGraphPattern].
592
+ %[126]
593
+ notExistsFunc ==>
594
+ ['NOT','EXISTS',groupGraphPattern].
595
+ %[127]
596
+ aggregate ==> ['COUNT','(',?('DISTINCT'),'*' or expression,')'].
597
+ aggregate ==> ['SUM','(',?('DISTINCT'),expression,')'].
598
+ aggregate ==> ['MIN','(',?('DISTINCT'),expression,')'].
599
+ aggregate ==> ['MAX','(',?('DISTINCT'),expression,')'].
600
+ aggregate ==> ['AVG','(',?('DISTINCT'),expression,')'].
601
+ aggregate ==> ['SAMPLE','(',?('DISTINCT'),expression,')'].
602
+ aggregate ==>
603
+ ['GROUP_CONCAT','(',
604
+ ?('DISTINCT'),
605
+ expression,
606
+ ?([';','SEPARATOR','=',string]),
607
+ ')'].
608
+ %[128]
609
+ iriRefOrFunction ==> [iriRef,?(argList)].
610
+ %[129]
611
+ rdfLiteral ==> [string,?('LANGTAG' or ['^^',iriRef])].
612
+ %[130]
613
+ numericLiteral ==> [numericLiteralUnsigned].
614
+ numericLiteral ==> [numericLiteralPositive].
615
+ numericLiteral ==> [numericLiteralNegative].
616
+ %[131]
617
+ numericLiteralUnsigned ==> ['INTEGER'].
618
+ numericLiteralUnsigned ==> ['DECIMAL'].
619
+ numericLiteralUnsigned ==> ['DOUBLE'].
620
+ %[132]
621
+ numericLiteralPositive ==> ['INTEGER_POSITIVE'].
622
+ numericLiteralPositive ==> ['DECIMAL_POSITIVE'].
623
+ numericLiteralPositive ==> ['DOUBLE_POSITIVE'].
624
+ %[133]
625
+ numericLiteralNegative ==> ['INTEGER_NEGATIVE'].
626
+ numericLiteralNegative ==> ['DECIMAL_NEGATIVE'].
627
+ numericLiteralNegative ==> ['DOUBLE_NEGATIVE'].
628
+ %[134]
629
+ booleanLiteral ==> ['TRUE'].
630
+ booleanLiteral ==> ['FALSE'].
631
+ %[135]
632
+ string ==> ['STRING_LITERAL1'].
633
+ string ==> ['STRING_LITERAL2'].
634
+ string ==> ['STRING_LITERAL_LONG1'].
635
+ string ==> ['STRING_LITERAL_LONG2'].
636
+ %[136]
637
+ iriRef ==> ['IRI_REF'].
638
+ iriRef ==> [prefixedName].
639
+ %[137]
640
+ prefixedName ==> ['PNAME_LN'].
641
+ prefixedName ==> ['PNAME_NS'].
642
+ %[138]
643
+ blankNode ==> ['BLANK_NODE_LABEL'].
644
+ blankNode ==> ['ANON'].
645
+
646
+
647
+ % tokens defined by regular expressions elsewhere
648
+ tm_regex([
649
+
650
+ 'IRI_REF',
651
+
652
+ 'VAR1',
653
+ 'VAR2',
654
+ 'LANGTAG',
655
+
656
+ 'DOUBLE',
657
+ 'DECIMAL',
658
+ 'INTEGER',
659
+ 'DOUBLE_POSITIVE',
660
+ 'DECIMAL_POSITIVE',
661
+ 'INTEGER_POSITIVE',
662
+ 'INTEGER_NEGATIVE',
663
+ 'DECIMAL_NEGATIVE',
664
+ 'DOUBLE_NEGATIVE',
665
+
666
+ 'STRING_LITERAL_LONG1',
667
+ 'STRING_LITERAL_LONG2',
668
+ 'STRING_LITERAL1',
669
+ 'STRING_LITERAL2',
670
+
671
+ 'NIL',
672
+ 'ANON',
673
+ 'PNAME_LN',
674
+ 'PNAME_NS',
675
+ 'BLANK_NODE_LABEL'
676
+ ]).
677
+
678
+ % Terminals where name of terminal is uppercased token content
679
+ tm_keywords([
680
+
681
+ 'GROUP_CONCAT', % Must appear before GROUP
682
+ 'DATATYPE', % Must appear before DATA
683
+
684
+ 'BASE',
685
+ 'PREFIX',
686
+ 'SELECT',
687
+ 'CONSTRUCT',
688
+ 'DESCRIBE',
689
+ 'ASK',
690
+ 'FROM',
691
+ 'NAMED',
692
+ 'ORDER',
693
+ 'BY',
694
+ 'LIMIT',
695
+ 'ASC',
696
+ 'DESC',
697
+ 'OFFSET',
698
+ 'DISTINCT',
699
+ 'REDUCED',
700
+ 'WHERE',
701
+ 'GRAPH',
702
+ 'OPTIONAL',
703
+ 'UNION',
704
+ 'FILTER',
705
+ 'GROUP',
706
+ 'HAVING',
707
+ 'AS',
708
+ 'VALUES',
709
+ 'LOAD',
710
+ 'CLEAR',
711
+ 'DROP',
712
+ 'CREATE',
713
+ 'MOVE',
714
+ 'COPY',
715
+ 'SILENT',
716
+ 'INSERT',
717
+ 'DELETE',
718
+ 'DATA',
719
+ 'WITH',
720
+ 'TO',
721
+ 'USING',
722
+ 'NAMED',
723
+ 'MINUS',
724
+ 'BIND',
725
+
726
+ 'LANGMATCHES',
727
+ 'LANG',
728
+ 'BOUND',
729
+ 'SAMETERM',
730
+ 'ISIRI',
731
+ 'ISURI',
732
+ 'ISBLANK',
733
+ 'ISLITERAL',
734
+ 'REGEX',
735
+ 'TRUE',
736
+ 'FALSE',
737
+
738
+ 'UNDEF',
739
+ 'ADD',
740
+ 'DEFAULT',
741
+ 'ALL',
742
+ 'SERVICE',
743
+ 'INTO',
744
+ 'IN',
745
+ 'NOT',
746
+ 'IRI',
747
+ 'URI',
748
+ 'BNODE',
749
+ 'RAND',
750
+ 'ABS',
751
+ 'CEIL',
752
+ 'FLOOR',
753
+ 'ROUND',
754
+ 'CONCAT',
755
+ 'STRLEN',
756
+ 'UCASE',
757
+ 'LCASE',
758
+ 'ENCODE_FOR_URI',
759
+ 'CONTAINS',
760
+ 'STRSTARTS',
761
+ 'STRENDS',
762
+ 'STRBEFORE',
763
+ 'STRAFTER',
764
+ 'YEAR',
765
+ 'MONTH',
766
+ 'DAY',
767
+ 'HOURS',
768
+ 'MINUTES',
769
+ 'SECONDS',
770
+ 'TIMEZONE',
771
+ 'TZ',
772
+ 'NOW',
773
+ 'UUID',
774
+ 'STRUUID',
775
+ 'MD5',
776
+ 'SHA1',
777
+ 'SHA256',
778
+ 'SHA384',
779
+ 'SHA512',
780
+ 'COALESCE',
781
+ 'IF',
782
+ 'STRLANG',
783
+ 'STRDT',
784
+ 'ISNUMERIC',
785
+ 'SUBSTR',
786
+ 'REPLACE',
787
+ 'EXISTS',
788
+ 'COUNT',
789
+ 'SUM',
790
+ 'MIN',
791
+ 'MAX',
792
+ 'AVG',
793
+ 'SAMPLE',
794
+ 'SEPARATOR',
795
+
796
+ 'STR'
797
+ ]).
798
+
799
+ % Other tokens representing fixed, case sensitive, strings
800
+ % Care! order longer tokens first - e.g. IRI_REF, <=, <
801
+ % e.g. >=, >
802
+ % e.g. NIL, '('
803
+ % e.g. ANON, [
804
+ % e.g. DOUBLE, DECIMAL, INTEGER
805
+ % e.g. INTEGER_POSITIVE, PLUS
806
+ tm_punct([
807
+ '*'= '\\*',
808
+ 'a'= 'a',
809
+ '.'= '\\.',
810
+ '{'= '\\{',
811
+ '}'= '\\}',
812
+ ','= ',',
813
+ '('= '\\(',
814
+ ')'= '\\)',
815
+ ';'= ';',
816
+ '['= '\\[',
817
+ ']'= '\\]',
818
+ '||'= '\\|\\|',
819
+ '&&'= '&&',
820
+ '='= '=',
821
+ '!='= '!=',
822
+ '!'= '!',
823
+ '<='= '<=',
824
+ '>='= '>=',
825
+ '<'= '<',
826
+ '>'= '>',
827
+ '+'= '\\+',
828
+ '-'= '-',
829
+ '/'= '\\/',
830
+ '^^'= '\\^\\^',
831
+ '?' = '\\?',
832
+ '|' = '\\|',
833
+ '^'= '\\^'
834
+ ]).