@surrealdb/lezer 1.0.0-beta.8 → 1.0.0

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.
@@ -1,18 +1,22 @@
1
1
  @top SurrealQL {
2
- expressions | WhereClause
2
+ expressions
3
3
  }
4
4
 
5
5
  @top PermissionInput {
6
6
  WhereClause | none | full
7
7
  }
8
8
 
9
+ @top IndexInput {
10
+ IndexClause
11
+ }
12
+
9
13
  @top CombinedResults {
10
- combinedExpressions
14
+ CombinedResult { CommentResult expression CommentResultClose { "" } }+
11
15
  }
12
16
 
13
17
  @top Syntax {
14
18
  (
15
- (for anyPermission) |
19
+ (for !for (create | update | delete | select)) |
16
20
  anyKeyword |
17
21
  anyLiteral |
18
22
  SyntaxDescribe { "@" rawident }
@@ -26,21 +30,200 @@
26
30
  binary @left
27
31
  union @left
28
32
  filter
33
+ for
34
+ clause
29
35
  }
30
36
 
31
37
  expressions {
32
38
  (expression ";")* expression ";"?
33
39
  }
34
40
 
35
- combinedExpressions {
36
- CombinedResult { CommentResult expression CommentResultClose { "" } }+
37
- }
38
-
39
41
  expression {
40
42
  statement |
41
43
  value
42
44
  }
43
45
 
46
+ paramDefinition[@name=ParamDefinition] {
47
+ VariableName
48
+ (":" Type { type })?
49
+ }
50
+
51
+ escapedParamDefinition[@name=ParamDefinition] {
52
+ VariableName
53
+ (":" Type { safeType })?
54
+ }
55
+
56
+ anyKeyword {
57
+ access |
58
+ algorithm |
59
+ alter |
60
+ analyzer |
61
+ any |
62
+ as |
63
+ asc |
64
+ assert |
65
+ at |
66
+ authenticate |
67
+ auto |
68
+ begin |
69
+ bm25 |
70
+ break |
71
+ by |
72
+ cancel |
73
+ capacity |
74
+ changefeed |
75
+ changes |
76
+ columns |
77
+ comment |
78
+ commit |
79
+ concurrently |
80
+ config |
81
+ content |
82
+ continue |
83
+ create |
84
+ database |
85
+ db |
86
+ default |
87
+ defer |
88
+ define |
89
+ delete |
90
+ desc |
91
+ dimension |
92
+ dist |
93
+ doc_ids_cache |
94
+ doc_ids_order |
95
+ doc_lengths_cache |
96
+ doc_lengths_order |
97
+ drop |
98
+ duplicate |
99
+ duration |
100
+ efc |
101
+ else |
102
+ end |
103
+ event |
104
+ exclude |
105
+ exists |
106
+ explain |
107
+ extend_candidates |
108
+ fetch |
109
+ field |
110
+ fields |
111
+ filters |
112
+ flexible |
113
+ for |
114
+ from |
115
+ functions |
116
+ graphql |
117
+ group |
118
+ highlights |
119
+ hnsw |
120
+ if |
121
+ ignore |
122
+ in |
123
+ include |
124
+ index |
125
+ info |
126
+ insert |
127
+ into |
128
+ issuer |
129
+ jwt |
130
+ keep_pruned_connections |
131
+ key |
132
+ kill |
133
+ let |
134
+ limit |
135
+ live |
136
+ lm |
137
+ m |
138
+ m0 |
139
+ merge |
140
+ mtree |
141
+ mtree_cache |
142
+ namespace |
143
+ noindex |
144
+ normal |
145
+ not |
146
+ ns |
147
+ on |
148
+ only |
149
+ option |
150
+ order |
151
+ out |
152
+ overwrite |
153
+ parallel |
154
+ param |
155
+ passhash |
156
+ password |
157
+ patch |
158
+ permissions |
159
+ postings_cache |
160
+ postings_order |
161
+ readonly |
162
+ rebuild |
163
+ record |
164
+ relate |
165
+ relation |
166
+ remove |
167
+ return |
168
+ roles |
169
+ root |
170
+ sc |
171
+ schemafull |
172
+ schemaless |
173
+ scope |
174
+ search |
175
+ select |
176
+ session |
177
+ set |
178
+ show |
179
+ signin |
180
+ signup |
181
+ since |
182
+ sleep |
183
+ split |
184
+ start |
185
+ structure |
186
+ table |
187
+ tables |
188
+ tb |
189
+ tempfiles |
190
+ terms_cache |
191
+ terms_order |
192
+ then |
193
+ throw |
194
+ timeout |
195
+ to |
196
+ token |
197
+ tokenizers |
198
+ transaction |
199
+ typeKeyword |
200
+ unique |
201
+ unset |
202
+ update |
203
+ upsert |
204
+ url |
205
+ use |
206
+ user |
207
+ valueKeyword |
208
+ values |
209
+ when |
210
+ where |
211
+ with
212
+ }
213
+
214
+ anyLiteral {
215
+ after |
216
+ before |
217
+ diff |
218
+ false |
219
+ full |
220
+ none |
221
+ null |
222
+ true |
223
+
224
+ IndexTypeClause
225
+ }
226
+
44
227
  SubQuery {
45
228
  "("
46
229
  expression
@@ -51,17 +234,31 @@ Block {
51
234
  "{" expressions? "}"
52
235
  }
53
236
 
54
- Closure {
55
- ParamList { "|" commaSep<VariableName ":" safeType>? "|" } ("->" type)? Block
237
+ Closure[since=2_0_0] {
238
+ "|" commaSep<escapedParamDefinition>? "|" ("->" type)? Block
239
+ }
240
+
241
+ subqueryStatement {
242
+ IfElseStatement |
243
+ LetStatement |
244
+ DeleteStatement |
245
+ CreateStatement |
246
+ SelectStatement |
247
+ RelateStatement |
248
+ UpdateStatement |
249
+ RemoveStatement |
250
+ UpsertStatement |
251
+ ReturnStatement |
252
+ AlterStatement |
253
+ DefineStatement |
254
+ RebuildStatement |
255
+ InsertStatement
56
256
  }
57
257
 
58
258
  statement[@isGroup=Statement] {
59
259
  BeginStatement |
60
260
  CancelStatement |
61
261
  CommitStatement |
62
- DefineStatement |
63
- AlterStatement |
64
- RemoveStatement |
65
262
  InfoForStatement |
66
263
  KillStatement |
67
264
  LiveSelectStatement |
@@ -69,21 +266,11 @@ statement[@isGroup=Statement] {
69
266
  SleepStatement |
70
267
  UseStatement |
71
268
  OptionStatement |
72
- RebuildStatement |
73
- CreateStatement |
74
- SelectStatement |
75
- DeleteStatement |
76
- InsertStatement |
77
269
  BreakStatement |
78
270
  ContinueStatement |
79
271
  ForStatement |
80
- ReturnStatement |
81
272
  ThrowStatement |
82
- IfElseStatement |
83
- LetStatement |
84
- RelateStatement |
85
- UpdateStatement |
86
- UpsertStatement
273
+ subqueryStatement
87
274
  }
88
275
 
89
276
  // Transaction statements
@@ -97,39 +284,40 @@ CommitStatement { commit transaction? }
97
284
  DefineStatement {
98
285
  define
99
286
  (
100
- ( access defineAccessOptions ) |
101
- ( namespace defineNamespaceOptions ) |
102
- ( database defineDatabaseOptions ) |
103
- ( user defineUserOptions ) |
104
- ( token defineTokenOptions ) |
105
- ( event defineEventOptions ) |
106
- ( field defineFieldOptions ) |
107
- ( index defineIndexOptions ) |
108
- ( analyzer defineAnalyzerOptions ) |
109
- ( functionKw defineFunctionOptions ) |
110
- ( param defineParamOptions ) |
111
- ( scope defineScopeOptions ) |
112
- ( table defineTableOptions )
287
+ AccessDefinition[since=2_0_0] { access defineAccessOptions } |
288
+ ( namespace defineNamespaceOptions ) |
289
+ ( database defineDatabaseOptions ) |
290
+ ( user defineUserOptions ) |
291
+ ( token defineTokenOptions ) |
292
+ ( event defineEventOptions ) |
293
+ ( field defineFieldOptions ) |
294
+ ( index defineIndexOptions ) |
295
+ ( analyzer defineAnalyzerOptions ) |
296
+ ( functionKw defineFunctionOptions ) |
297
+ ( param defineParamOptions ) |
298
+ ScopeDefinition[until=2_0_0] { scope defineScopeOptions } |
299
+ ( table defineTableOptions ) |
300
+ ( config defineConfigOptions ) |
301
+ ( api defineApiOptions ) |
302
+ ( bucket defineBucketOptions )
113
303
  )
114
304
  }
115
305
 
116
306
  defineAccessOptions {
117
- (IfNotExistsClause | overwrite)?
118
- Ident
119
- accessClauses1 {
120
- OnRootNsDbClause
121
- AccessTypeClause
122
- }
123
- accessClauses2 {
124
- AuthenticateClause?
125
- DurationClause?
126
- CommentClause?
127
- }
307
+ (IfNotExistsClause | OverwriteClause)?
308
+ value
309
+ OnRootNsDbClause
310
+ (
311
+ AccessTypeClause |
312
+ AuthenticateClause |
313
+ DurationClause |
314
+ CommentClause
315
+ )*
128
316
  }
129
317
 
130
318
  defineAnalyzerOptions {
131
- (IfNotExistsClause | overwrite)?
132
- Ident
319
+ (IfNotExistsClause | OverwriteClause)?
320
+ value
133
321
  (
134
322
  TokenizersClause |
135
323
  FiltersClause |
@@ -139,22 +327,31 @@ defineAnalyzerOptions {
139
327
  }
140
328
 
141
329
  defineEventOptions {
142
- (IfNotExistsClause | overwrite)?
143
- Ident
330
+ (IfNotExistsClause | OverwriteClause)?
331
+ value
144
332
  OnTableClause
145
- WhenThenClause
146
- CommentClause?
333
+ (
334
+ WhenClause {
335
+ when
336
+ value
337
+ } |
338
+ ThenClause {
339
+ then
340
+ commaSep<(SubQuery | Block)>
341
+ } |
342
+ CommentClause
343
+ )*
147
344
  }
148
345
 
149
346
  defineDatabaseOptions {
150
- (IfNotExistsClause | overwrite)?
151
- Ident on Ident
347
+ (IfNotExistsClause | OverwriteClause)?
348
+ value on value
152
349
  CommentClause?
153
350
  }
154
351
 
155
352
  defineFieldOptions {
156
- (IfNotExistsClause | overwrite)?
157
- Ident
353
+ (IfNotExistsClause | OverwriteClause)?
354
+ Idiom
158
355
  OnTableClause
159
356
  (
160
357
  TypeClause |
@@ -163,14 +360,16 @@ defineFieldOptions {
163
360
  ValueClause |
164
361
  AssertClause |
165
362
  PermissionsForClause |
166
- CommentClause
363
+ CommentClause |
364
+ ReferenceClause |
365
+ ComputedClause
167
366
  )*
168
367
  }
169
368
 
170
369
  defineFunctionOptions {
171
- (IfNotExistsClause | overwrite)?
370
+ (IfNotExistsClause | OverwriteClause)?
172
371
  customFunctionName
173
- ParamList { "(" commaSep<VariableName ":" type>? ")" }
372
+ params { "(" commaSep<paramDefinition>? ")" }
174
373
  ("->" type)?
175
374
  Block
176
375
  (
@@ -182,34 +381,38 @@ defineFunctionOptions {
182
381
  functionKw[@name=Keyword] { function }
183
382
 
184
383
  defineIndexOptions {
185
- (IfNotExistsClause | overwrite)?
186
- Ident
384
+ (IfNotExistsClause | OverwriteClause)?
385
+ value
187
386
  OnTableClause
188
- FieldsColumnsClause
189
387
  (
190
- UniqueClause |
191
- SearchAnalyzerClause |
192
- MtreeClause |
193
- HnswClause
194
- )
388
+ FieldsColumnsClause |
389
+ IndexClause |
390
+ CommentClause |
391
+ ConcurrentlyClause[since=2_0_0] { concurrently }
392
+ DeferClause[since=3_0_0] { defer }
393
+ )*
195
394
  }
196
395
 
197
396
  defineNamespaceOptions {
198
- (IfNotExistsClause | overwrite)?
199
- Ident
397
+ (IfNotExistsClause | OverwriteClause)?
398
+ value
200
399
  CommentClause?
201
400
  }
202
401
 
203
402
  defineParamOptions {
204
- (IfNotExistsClause | overwrite)?
403
+ (IfNotExistsClause | OverwriteClause)?
205
404
  VariableName
206
405
  valueKeyword
207
406
  value
407
+ (
408
+ PermissionsBasicClause |
409
+ CommentClause
410
+ )*
208
411
  }
209
412
 
210
413
  defineScopeOptions {
211
- (IfNotExistsClause | overwrite)?
212
- Ident
414
+ (IfNotExistsClause | OverwriteClause)?
415
+ value
213
416
  (
214
417
  SessionClause |
215
418
  SigninClause |
@@ -219,8 +422,8 @@ defineScopeOptions {
219
422
  }
220
423
 
221
424
  defineTableOptions {
222
- (IfNotExistsClause | overwrite)?
223
- Ident
425
+ (IfNotExistsClause | OverwriteClause)?
426
+ value
224
427
  (
225
428
  drop |
226
429
  (schemafull | schemaless) |
@@ -232,35 +435,89 @@ defineTableOptions {
232
435
  )*
233
436
  }
234
437
 
438
+ defineConfigOptions {
439
+ (IfNotExistsClause | OverwriteClause)?
440
+ (
441
+ graphql defineConfigGraphqlOptions |
442
+ api defineConfigApiOptions
443
+ )
444
+ }
445
+
446
+ defineConfigGraphqlOptions {
447
+ (
448
+ none |
449
+ auto |
450
+ tables ( none | auto | include commaSep<Ident> | exclude commaSep<Ident> ) |
451
+ functions ( none | auto )
452
+ )*
453
+ }
454
+
455
+ defineConfigApiOptions {
456
+ ApiOptions
457
+ }
458
+
235
459
  defineTokenOptions {
236
- (IfNotExistsClause | overwrite)?
237
- Ident
238
- ( on ( namespace | database | scope Ident ) )
460
+ (IfNotExistsClause | OverwriteClause)?
461
+ value
462
+ ( on ( namespace | database | scope value ) )
239
463
  TokenTypeClause
240
464
  ( valueKeyword String )
241
465
  }
242
466
 
243
467
  defineUserOptions {
244
- (IfNotExistsClause | overwrite)?
245
- Ident
468
+ (IfNotExistsClause | OverwriteClause)?
469
+ value
246
470
  OnRootNsDbClause
247
471
  ( ( password | passhash ) String )
248
472
  ( roles commaSep<Ident> )
249
473
  DurationClause?
250
474
  }
251
475
 
476
+ defineApiOptions {
477
+ (IfNotExistsClause | OverwriteClause)?
478
+ String
479
+ ApiOptions
480
+ (
481
+ for
482
+ (any | commaSep<HttpMethod>)
483
+ ApiOptions
484
+ then Block
485
+ )+
486
+ }
487
+
488
+ ApiOptions {
489
+ (
490
+ PermissionsBasicClause |
491
+ MiddlewareClause
492
+ )*
493
+ }
494
+
495
+ HttpMethod {
496
+ get | put | post | delete | patch | trace
497
+ }
498
+
499
+ defineBucketOptions {
500
+ (IfNotExistsClause | OverwriteClause)?
501
+ value
502
+ (
503
+ BackendClause |
504
+ PermissionsBasicClause |
505
+ CommentClause
506
+ )*
507
+ }
508
+
252
509
  // Alter statement
253
510
 
254
- AlterStatement {
511
+ AlterStatement[since=2_0_0] {
255
512
  alter
256
513
  (
257
- ( table alterTableOptions )
514
+ table alterTableOptions
258
515
  )
259
516
  }
260
517
 
261
518
  alterTableOptions {
262
519
  IfNotExistsClause?
263
- Ident
520
+ value
264
521
  (
265
522
  drop |
266
523
  (schemafull | schemaless) |
@@ -274,18 +531,20 @@ alterTableOptions {
274
531
  RemoveStatement {
275
532
  remove
276
533
  (
277
- ( namespace IfExistsClause? Ident ) |
278
- ( database IfExistsClause? Ident ) |
279
- ( user IfExistsClause? Ident on ( root | namespace | database ) ) |
280
- ( token IfExistsClause? Ident on ( namespace | database | scope ) ) |
281
- ( event IfExistsClause? Ident on table? Ident ) |
282
- ( field IfExistsClause? Ident on table? Ident ) |
283
- ( index IfExistsClause? Ident on table? Ident ) |
284
- ( analyzer IfExistsClause? Ident ) |
285
- ( functionKw IfExistsClause? customFunctionName ) |
286
- ( param IfExistsClause? VariableName ) |
287
- ( scope IfExistsClause? Ident ) |
288
- ( table IfExistsClause? Ident )
534
+ ( namespace IfExistsClause? value (and expunge)? ) |
535
+ ( database IfExistsClause? value (and expunge)? ) |
536
+ ( user IfExistsClause? value on ( root | namespace | database ) ) |
537
+ ( token IfExistsClause? value on ( namespace | database | scope ) ) |
538
+ ( event IfExistsClause? value OnTableClause ) |
539
+ ( field IfExistsClause? value OnTableClause ) |
540
+ ( index IfExistsClause? value OnTableClause ) |
541
+ ( analyzer IfExistsClause? value ) |
542
+ ( functionKw IfExistsClause? customFunctionName ) |
543
+ ( param IfExistsClause? VariableName ) |
544
+ ( scope IfExistsClause? value ) |
545
+ ( table IfExistsClause? value (and expunge)? )
546
+ ( api IfExistsClause? value ) |
547
+ ( bucket IfExistsClause? value )
289
548
  )
290
549
  }
291
550
 
@@ -293,42 +552,39 @@ RemoveStatement {
293
552
 
294
553
  CreateStatement {
295
554
  create only?
296
- createTarget { Ident | VariableName | FunctionCall | RecordId }
555
+ createTargets { commaSep<Ident | VariableName | FunctionCall | RecordId> }
297
556
  createContent { ContentClause | SetClause | UnsetClause | () }
298
- ReturnClause?
299
- TimeoutClause?
300
- ParallelClause?
557
+ createOptionals {
558
+ ReturnClause?
559
+ TimeoutClause?
560
+ ParallelClause?
561
+ }
301
562
  }
302
563
 
303
564
  SelectStatement {
304
- (select)
305
- (
306
- valueKeyword Predicate |
307
- commaSep<inclusivePredicate>
308
- )
309
- (from)
310
- (only)?
565
+ select
566
+ Fields
567
+ OmitClause?
568
+ from
569
+ only?
311
570
  (
312
571
  statement |
313
572
  (
314
573
  commaSep<value>
315
- selectClauses1 {
316
- WithClause?
317
- WhereClause?
318
- SplitClause?
319
- }
320
- selectClauses2 {
321
- GroupClause?
322
- OrderClause?
323
- LimitStartComboClause?
324
- }
325
- selectClauses3 {
326
- FetchClause?
327
- TimeoutClause?
328
- ParallelClause?
329
- TempfilesClause?
330
- ExplainClause?
331
- }
574
+ (
575
+ WithClause |
576
+ WhereClause |
577
+ SplitClause |
578
+ GroupClause |
579
+ OrderClause |
580
+ LimitStartComboClause |
581
+ FetchClause |
582
+ TimeoutClause |
583
+ ParallelClause |
584
+ TempfilesClause |
585
+ ExplainClause |
586
+ VersionClause
587
+ )*
332
588
  )
333
589
  )
334
590
  }
@@ -339,22 +595,28 @@ DeleteStatement {
339
595
  statement |
340
596
  (
341
597
  commaSep<value>
342
- WhereClause?
343
- ReturnClause?
344
- TimeoutClause?
345
- ParallelClause?
598
+ (
599
+ WhereClause |
600
+ ReturnClause |
601
+ TimeoutClause |
602
+ ParallelClause
603
+ )*
346
604
  )
347
605
  )
348
606
  }
349
607
 
350
608
  InsertStatement {
351
609
  insert
352
- ignore?
353
- relation?
354
- (into Ident)?
610
+ insertOptionals {
611
+ ignore?
612
+ relation?
613
+ (into Ident)?
614
+ }
355
615
  (
616
+ // TODO this should be value, but cannot easily union with VALUES syntax
356
617
  Object |
357
- ( "[" commaSep<Object> "]" ) |
618
+ VariableName |
619
+ BulkInsert[since=2_0_0] { ( "[" commaSep<Object> "]" ) } |
358
620
  (
359
621
  "(" commaSep<Ident> ")"
360
622
  values
@@ -367,60 +629,7 @@ InsertStatement {
367
629
  on duplicate key update
368
630
  commaSep<FieldAssignment>
369
631
  )?
370
- }
371
-
372
- IfElseStatement {
373
- if
374
- (
375
- Legacy {
376
- value
377
- then
378
- ( Block | SubQuery)
379
- (
380
- else if
381
- value
382
- then
383
- ( Block | SubQuery)
384
- )*
385
- (
386
- else
387
- ( Block | SubQuery)
388
- )?
389
- end
390
- } |
391
- Modern {
392
- value Block
393
- (
394
- else if
395
- value Block
396
- )*
397
- (
398
- else Block
399
- )?
400
- }
401
- )
402
- }
403
-
404
- relateSubject { Array | Ident | FunctionCall | VariableName | RecordId }
405
- RelateStatement {
406
- relate only?
407
- relateSubject "->" relateSubject "->" relateSubject
408
- ( ContentClause | SetClause )?
409
- ReturnClause?
410
- TimeoutClause?
411
- ParallelClause?
412
- }
413
-
414
- InfoForStatement {
415
- info for
416
- (
417
- root |
418
- ns | namespace |
419
- db | database |
420
- ( sc Ident | scope Ident) |
421
- ( tb Ident | table Ident)
422
- )
423
- structure?
632
+ InsertReturnClause[since=2_0_0] { ReturnClause? }
424
633
  }
425
634
 
426
635
  UpdateStatement {
@@ -429,14 +638,15 @@ UpdateStatement {
429
638
  statement |
430
639
  (
431
640
  commaSep<value>
432
- updateClause1 {
641
+ (
433
642
  ContentClause |
643
+ ReplaceClause |
434
644
  MergeClause |
435
645
  PatchClause |
436
646
  SetClause |
437
647
  UnsetClause
438
- }?
439
- updateClause2 {
648
+ )?
649
+ updateOptionals {
440
650
  WhereClause?
441
651
  ReturnClause?
442
652
  TimeoutClause?
@@ -446,20 +656,21 @@ UpdateStatement {
446
656
  )
447
657
  }
448
658
 
449
- UpsertStatement {
659
+ UpsertStatement[since=2_0_0] {
450
660
  upsert only?
451
661
  (
452
662
  statement |
453
663
  (
454
664
  commaSep<value>
455
- updateClause1 {
665
+ (
456
666
  ContentClause |
667
+ ReplaceClause |
457
668
  MergeClause |
458
669
  PatchClause |
459
670
  SetClause |
460
671
  UnsetClause
461
- }?
462
- updateClause2 {
672
+ )?
673
+ upsertOptionals {
463
674
  WhereClause?
464
675
  ReturnClause?
465
676
  TimeoutClause?
@@ -469,14 +680,75 @@ UpsertStatement {
469
680
  )
470
681
  }
471
682
 
683
+ relateSubject { Array | Ident | FunctionCall | VariableName | RecordId }
684
+
685
+ RelateStatement {
686
+ relate only?
687
+ relateSubject ("->" | "<-") relateSubject ("->" | "<-") relateSubject
688
+ ( ContentClause | SetClause )?
689
+ relateOptionals {
690
+ ReturnClause?
691
+ TimeoutClause?
692
+ ParallelClause?
693
+ }
694
+ }
695
+
696
+ // Info statement
697
+
698
+ InfoForStatement {
699
+ info for
700
+ (
701
+ root |
702
+ ns | namespace |
703
+ db | database |
704
+ ( sc Ident | scope Ident) |
705
+ ( tb Ident | table Ident)
706
+ )
707
+ structure?
708
+ }
709
+
472
710
  // Control statements
711
+
473
712
  BreakStatement { break }
474
713
  ContinueStatement { continue }
475
714
  ForStatement { for VariableName in ( Array | VariableName | SubQuery | Block ) Block }
476
715
  ReturnStatement { return expression }
477
716
  ThrowStatement { throw value }
478
717
 
718
+ IfElseStatement {
719
+ if
720
+ (
721
+ Legacy {
722
+ value
723
+ then
724
+ ( Block | SubQuery)
725
+ (
726
+ else if
727
+ value
728
+ then
729
+ ( Block | SubQuery)
730
+ )*
731
+ (
732
+ else
733
+ ( Block | SubQuery)
734
+ )?
735
+ end
736
+ } |
737
+ Modern {
738
+ value Block
739
+ (
740
+ else if
741
+ value Block
742
+ )*
743
+ (
744
+ else Block
745
+ )?
746
+ }
747
+ )
748
+ }
749
+
479
750
  // Live statements
751
+
480
752
  KillStatement { kill String }
481
753
  LiveSelectStatement {
482
754
  live select
@@ -490,40 +762,55 @@ LiveSelectStatement {
490
762
  FetchClause?
491
763
  }
492
764
 
493
- // Other statements
765
+ // Let statement
766
+
494
767
  LetStatement {
495
- let VariableName (":" type)? "=" value
768
+ let
769
+ paramDefinition
770
+ "="
771
+ (value | subqueryStatement)
496
772
  }
497
773
 
774
+ // Show statement
775
+
498
776
  ShowStatement {
499
777
  show changes for table
500
778
  Ident
501
779
  ( since String )?
502
- ( limit Int )?
780
+ ( limit number )?
503
781
  }
504
782
 
783
+ // Sleep statement
784
+
505
785
  SleepStatement {
506
786
  sleep Duration
507
787
  }
508
788
 
789
+ // Use statement
790
+
509
791
  useNs { ( ns | namespace ) Ident }
510
792
  useDb { ( db | database ) Ident }
793
+
511
794
  UseStatement {
512
795
  use
513
796
  ( useNs | useDb | ( useNs useDb ) )
514
797
  }
515
798
 
799
+ // Option statement
800
+
516
801
  OptionStatement {
517
- option
518
- Ident
519
- ( "=" ( true | false ) )?
802
+ option
803
+ Ident
804
+ ( "=" ( true | false ) )?
520
805
  }
521
806
 
522
- RebuildStatement {
523
- rebuild index
524
- IfExistsClause?
525
- Ident
526
- OnTableClause
807
+ // Rebuild statement
808
+
809
+ RebuildStatement[since=1_5_0] {
810
+ rebuild index
811
+ IfExistsClause?
812
+ Ident
813
+ OnTableClause
527
814
  }
528
815
 
529
816
  // Values
@@ -531,6 +818,7 @@ OnTableClause
531
818
  baseValue {
532
819
  String |
533
820
  prefixedString |
821
+ FormatString |
534
822
  number |
535
823
  true |
536
824
  false |
@@ -540,6 +828,7 @@ baseValue {
540
828
  VariableName |
541
829
  Ident[@dynamicPrecedence=-1] { rawident } |
542
830
  Array |
831
+ Set |
543
832
  RecordId |
544
833
  FunctionJs |
545
834
  FunctionCall |
@@ -549,55 +838,127 @@ baseValue {
549
838
  Object |
550
839
  TypeCast |
551
840
  Duration |
552
- Point { "(" Decimal "," Decimal ")" }
841
+ Point { "(" number "," number ")" }
553
842
  }
554
843
 
555
- Any { "?" }
556
- AnyStar[@name=Any] { "*" }
557
-
558
844
  value[@isGroup=Value] {
559
845
  baseValue |
560
846
  BinaryExpression |
847
+ Range |
561
848
  Path
562
849
  }
563
850
 
851
+ Any { "?" }
852
+ AnyStar[@name=Any] { "*" }
853
+ At[since=2_1_0] { "@" }
854
+ Optional[since=2_0_0] { "?" }
855
+
564
856
  // Binary expressions
565
857
 
566
- BinaryExpression {
567
- value !binary Operator value
858
+ BinaryExpression {
859
+ value !binary Operator value
860
+ }
861
+
862
+ Range[since=2_0_0] {
863
+ rangeOpOpenBoth |
864
+ value !range rangeOpOpenRight |
865
+ rangeOpOpenLeft !range value |
866
+ value !range rangeOp !range value
867
+ }
868
+
869
+ Idiom {
870
+ Ident ( "." Ident )*
568
871
  }
569
872
 
570
873
  Path {
571
874
  baseValue pathElement+ |
572
- GraphPath pathElement*
875
+ At ( dotPart pathElement* | pathElement+ ) |
876
+ Lookup pathElement*
573
877
  }
574
878
 
575
879
  pathElement {
576
- GraphPath |
880
+ Lookup |
577
881
  Subscript {
578
- "?"?
882
+ Optional?
579
883
  "."
580
- (
581
- Ident |
582
- FunctionName { rawident !method } ArgumentList |
583
- AnyStar |
584
- Destructure
585
- )
884
+ dotPart
586
885
  } |
587
- Filter { !filter "[" (WhereClause | value | WhereClause { "?" value } ) "]" }
886
+ Filter { !filter "[" (WhereClause | WhereClause { "?" value } | expression) "]" }
887
+ }
888
+
889
+ dotPart {
890
+ At |
891
+ Ident |
892
+ IdiomFunction |
893
+ AnyStar |
894
+ Destructure |
895
+ Recurse
896
+ }
897
+
898
+ Lookup {
899
+ ("<-" | "->" | "<->" | "<~")
900
+ (Ident | Any | LookupSelection)
588
901
  }
589
902
 
590
- GraphPath {
591
- ("<-" | "->" | "<->")
592
- (Ident | Any | "(" commaSep<GraphPredicate> ")")
903
+ LookupSelection {
904
+ "("
905
+ GraphFieldSelection[since=2_2_0] {
906
+ select
907
+ Fields
908
+ from
909
+ }?
910
+ commaSep<GraphPredicate>
911
+ (
912
+ WhereClause |
913
+ GraphSplitClause[since=2_2_0] { SplitClause } |
914
+ GraphGroupClause[since=2_2_0] { GroupClause } |
915
+ GraphOrderClause[since=2_2_0] { OrderClause } |
916
+ GraphLimitStartComboClause[since=2_2_0] { LimitStartComboClause } |
917
+ as Ident
918
+ )*
919
+ ")"
593
920
  }
594
921
 
595
922
  GraphPredicate {
596
- (value | Any) WhereClause? (as Ident)?
923
+ (value | Any)
924
+ }
925
+
926
+ Destructure[since=2_0_0] {
927
+ "{" commaSep<((Ident ":")? ( Ident | Lookup ) pathElement* )> "}"
928
+ }
929
+
930
+ IdiomFunction[since=2_0_0] {
931
+ FunctionName { rawident !method } ArgumentList
932
+ }
933
+
934
+ // Recursion
935
+
936
+ Recurse[since=2_1_0] {
937
+ "{" RecurseRange RecurseOptions "}"
938
+ ( "(" pathElement+ ")" )?
939
+ }
940
+
941
+ RecurseRange {
942
+ number |
943
+ rangeOpOpenBoth |
944
+ number rangeOpOpenRight |
945
+ rangeOpOpenLeft number |
946
+ number rangeOp number
947
+ }
948
+
949
+ RecurseOptions[since=2_2_0] {
950
+ ("+" recurseOptionName ("=" baseValue)?)*
951
+ }
952
+
953
+ recurseOptionName[@name=FunctionName] {
954
+ rawident
597
955
  }
598
956
 
599
- Destructure {
600
- "{" commaSep<((Ident ":")? Ident pathElement?)> "}"
957
+ // Fields
958
+
959
+ Fields {
960
+ valueKeyword Predicate |
961
+ commaSep<inclusivePredicate>
601
962
  }
602
963
 
603
964
  // Objects
@@ -621,7 +982,19 @@ Object {
621
982
 
622
983
  // Arrays
623
984
 
624
- Array { "[" commaSep<value>? "]"}
985
+ Array {
986
+ "[" commaSepTrailing<value>? "]"
987
+ }
988
+
989
+ // Sets
990
+
991
+ Set {
992
+ "{" (
993
+ "," |
994
+ value "," |
995
+ value "," value ("," value)*
996
+ ) "}"
997
+ }
625
998
 
626
999
  // Record Ids
627
1000
 
@@ -631,6 +1004,8 @@ RecordTbIdent {
631
1004
  bracketIdent
632
1005
  }
633
1006
 
1007
+ // Ideally we match "number" here, but I cannot for the life of me get it to
1008
+ // fall back to numberident after. This will suffice for now.
634
1009
  RecordIdIdent {
635
1010
  numberident |
636
1011
  tickIdent |
@@ -639,15 +1014,16 @@ RecordIdIdent {
639
1014
 
640
1015
  recordIdValue {
641
1016
  RecordIdIdent |
642
- Int |
643
1017
  Array |
644
- Object
1018
+ Object |
1019
+ RecordIdString { prefixedString }
645
1020
  }
646
1021
 
647
1022
  RecordIdRange {
648
- ( recordIdValue !range ">"? )?
649
- ".."
650
- ( !range "="? recordIdValue )?
1023
+ rangeOpOpenBoth |
1024
+ recordIdValue !range rangeOpOpenRight |
1025
+ rangeOpOpenLeft !range recordIdValue |
1026
+ recordIdValue !range rangeOp !range recordIdValue
651
1027
  }
652
1028
 
653
1029
  RecordId {
@@ -677,21 +1053,32 @@ FunctionJs {
677
1053
  javaScriptElement {
678
1054
  javaScriptContent | javaScriptBraceOpen javaScriptElement* javaScriptBraceClose
679
1055
  }
1056
+ BlockComment {
1057
+ "/*" (blockCommentContent | blockCommentNewline)* blockCommentEnd
1058
+ }
1059
+ FormatString {
1060
+ '$"' (formatStringContentDouble | Interpolation)* '"' |
1061
+ "$'" (formatStringContentSingle | Interpolation)* "'"
1062
+ }
1063
+ }
1064
+
1065
+ Interpolation {
1066
+ "{" expression "}"
680
1067
  }
681
1068
 
682
1069
  // Function invocation
683
1070
 
684
1071
  FunctionCall {
685
- ( count ArgumentListCount ) |
686
1072
  (
687
- (FunctionName | customFunctionName | rand)
688
- Version { "<" VersionNumber ">" }?
689
- ArgumentList
690
- )
1073
+ (FunctionName | customFunctionName | rand | count)
1074
+ Version { "<" VersionNumber ">" }?
1075
+ ArgumentList
1076
+ ) |
1077
+ RecordId ArgumentList |
1078
+ VariableName ArgumentList
691
1079
  }
692
1080
 
693
- ArgumentList { "(" commaSep<value>? ")" }
694
- ArgumentListCount[@name=ArgumentList] { "(" ( commaSep<value>? | statement ) ")" }
1081
+ ArgumentList { "(" (commaSep<value>? | subqueryStatement) ")" }
695
1082
 
696
1083
  // Assignment
697
1084
 
@@ -711,7 +1098,7 @@ PatchClause {
711
1098
  patch Array
712
1099
  }
713
1100
 
714
- TableTypeClause {
1101
+ TableTypeClause[since=1_4_0] {
715
1102
  typeKeyword
716
1103
  (
717
1104
  any |
@@ -720,6 +1107,7 @@ TableTypeClause {
720
1107
  relation
721
1108
  ( ( in | from ) piped<Ident> )?
722
1109
  ( ( out | to ) piped<Ident> )?
1110
+ EnforcedClause[since=2_0_0] { enforced? }
723
1111
  )
724
1112
  )
725
1113
  }
@@ -764,7 +1152,7 @@ JwtClause {
764
1152
  }
765
1153
 
766
1154
  OnTableClause {
767
- on table? Ident
1155
+ on table? value
768
1156
  }
769
1157
 
770
1158
  OnRootNsDbClause {
@@ -774,12 +1162,19 @@ OnRootNsDbClause {
774
1162
  AccessTypeClause {
775
1163
  typeKeyword (
776
1164
  ( jwt JwtClause ) |
777
- ( record SignupClause? SigninClause? ( with jwt JwtClause? ( with issuer key Ident )? )? )
1165
+ ( record (SignupClause | SigninClause)* ( with jwt JwtClause ( with issuer key Ident )? )? )
778
1166
  )
779
1167
  }
780
1168
 
781
1169
  FieldsColumnsClause {
782
- ( fields | columns ) commaSep<Ident>
1170
+ ( fields | columns ) commaSep<Idiom>
1171
+ }
1172
+
1173
+ IndexClause {
1174
+ UniqueClause |
1175
+ SearchAnalyzerClause |
1176
+ MtreeClause |
1177
+ HnswClause
783
1178
  }
784
1179
 
785
1180
  UniqueClause {
@@ -789,22 +1184,31 @@ UniqueClause {
789
1184
  SearchAnalyzerClause {
790
1185
  search analyzer
791
1186
  Ident
792
- (Bm25Clause | DocIdsOrderClause | DocLenghtsOrderClause | PostingsOrderClause |
793
- TermsOrderClause | DocIdsCacheClause | DocLenghtsCacheClause | PostingsCacheClause |
794
- TermsCacheClause | highlights)*
795
- }
796
-
797
- Bm25Clause { bm25 ( "(" Float "," Float ")")? }
798
- DocIdsCacheClause { doc_ids_cache Int }
799
- DocIdsOrderClause { doc_ids_order Int }
800
- DocLenghtsCacheClause { doc_lengths_cache Int }
801
- DocLenghtsOrderClause { doc_lengths_order Int }
802
- PostingsCacheClause { postings_cache Int }
803
- PostingsOrderClause { postings_order Int }
804
- TermsCacheClause { terms_cache Int }
805
- TermsOrderClause { terms_order Int }
806
-
807
- MtreeClause {
1187
+ (
1188
+ Bm25Clause |
1189
+ DocIdsOrderClause |
1190
+ DocLenghtsOrderClause |
1191
+ PostingsOrderClause |
1192
+ TermsOrderClause |
1193
+ DocIdsCacheClause |
1194
+ DocLenghtsCacheClause |
1195
+ PostingsCacheClause |
1196
+ TermsCacheClause |
1197
+ highlights
1198
+ )*
1199
+ }
1200
+
1201
+ Bm25Clause { bm25 ( "(" number "," number ")")? }
1202
+ DocIdsCacheClause { doc_ids_cache number }
1203
+ DocIdsOrderClause { doc_ids_order number }
1204
+ DocLenghtsCacheClause { doc_lengths_cache number }
1205
+ DocLenghtsOrderClause { doc_lengths_order number }
1206
+ PostingsCacheClause { postings_cache number }
1207
+ PostingsOrderClause { postings_order number }
1208
+ TermsCacheClause { terms_cache number }
1209
+ TermsOrderClause { terms_order number }
1210
+
1211
+ MtreeClause[since=1_3_0] {
808
1212
  mtree
809
1213
  IndexDimensionClause
810
1214
  (
@@ -817,10 +1221,10 @@ MtreeClause {
817
1221
  )*
818
1222
  }
819
1223
 
820
- MtreeCacheClause { mtree_cache Int }
821
- MtreeDistClause { dist ( cosine | euclidean | manhattan ) }
1224
+ MtreeCacheClause { mtree_cache number }
1225
+ MtreeDistClause { dist ( Distance ) }
822
1226
 
823
- HnswClause {
1227
+ HnswClause[since=1_5_0] {
824
1228
  hnsw
825
1229
  IndexDimensionClause
826
1230
  (
@@ -836,15 +1240,14 @@ IndexDimensionClause
836
1240
  )*
837
1241
  }
838
1242
 
839
- HnswDistClause { dist ( chebyshev | cosine | euclidean | hamming | jaccard | manhattan | ( minkowski number ) | pearson ) }
1243
+ HnswDistClause { dist ( Distance | ( minkowski number )) }
840
1244
 
841
- IndexDimensionClause { dimension Int }
842
- IndexTypeClause { typeKeyword ( f32 | f64 | i16 | i32 | i64 ) }
843
- IndexCapacityClause { capacity Int }
844
- IndexLmClause { lm Float }
845
- IndexM0Clause { m0 Int }
846
- IndexMClause { m Int }
847
- IndexEfcClause { efc Int }
1245
+ IndexDimensionClause { dimension number }
1246
+ IndexCapacityClause { capacity number }
1247
+ IndexLmClause { lm number }
1248
+ IndexM0Clause { m0 number }
1249
+ IndexMClause { m number }
1250
+ IndexEfcClause { efc number }
848
1251
  IndexExtendCandidatesClause { extend_candidates }
849
1252
  IndexKeepPrunedConnectionsClause { keep_pruned_connections }
850
1253
 
@@ -852,25 +1255,37 @@ ContentClause {
852
1255
  content Object
853
1256
  }
854
1257
 
1258
+ ReplaceClause {
1259
+ replace Object
1260
+ }
1261
+
855
1262
  SetClause {
856
1263
  set commaSep<FieldAssignment>
857
1264
  }
858
1265
 
1266
+ OmitClause {
1267
+ omit commaSep<inclusivePredicate>
1268
+ }
1269
+
859
1270
  UnsetClause {
860
1271
  unset commaSep<FieldAssignment>
861
1272
  }
862
1273
 
863
- IfNotExistsClause {
1274
+ IfNotExistsClause[since=1_3_0] {
864
1275
  if not exists
865
1276
  }
866
1277
 
867
- IfExistsClause {
1278
+ IfExistsClause[since=1_3_0] {
868
1279
  if exists
869
1280
  }
870
1281
 
1282
+ OverwriteClause[since=2_0_0] {
1283
+ overwrite
1284
+ }
1285
+
871
1286
  ReturnClause {
872
1287
  return
873
- ( before | after | diff | commaSep<inclusivePredicate> )
1288
+ ( before | after | diff | Fields )
874
1289
  }
875
1290
 
876
1291
  TimeoutClause {
@@ -882,49 +1297,50 @@ ParallelClause {
882
1297
  parallel
883
1298
  }
884
1299
 
885
- TempfilesClause {
1300
+ TempfilesClause[since=2_0_0] {
886
1301
  tempfiles
887
1302
  }
888
1303
 
889
1304
  FetchClause {
890
1305
  fetch
891
- commaSep<Ident>
1306
+ commaSep<Path>
892
1307
  }
893
1308
 
894
1309
  StartClause {
895
1310
  start
896
1311
  at?
897
- (Int | VariableName)
1312
+ (number | VariableName)
898
1313
  }
899
1314
 
900
1315
  LimitClause {
901
1316
  limit
902
1317
  by?
903
- (Int | VariableName)
1318
+ (number | VariableName)
904
1319
  }
905
1320
 
906
1321
  LimitStartComboClause {
907
- StartClause LimitClause? |
908
- LimitClause StartClause?
1322
+ StartClause (!clause LimitClause)? |
1323
+ LimitClause (!clause StartClause)?
909
1324
  }
910
1325
 
911
1326
  GroupClause {
912
1327
  group
913
- by?
914
- commaSep<Ident>
1328
+ (
1329
+ by? commaSep<Idiom> |
1330
+ all
1331
+ )
915
1332
  }
916
1333
 
917
1334
  OrderClause {
918
1335
  order
919
1336
  by?
920
- commaSep<Ident>
921
- ( asc | desc )?
1337
+ (commaSep<Order> | FunctionCall)
922
1338
  }
923
1339
 
924
1340
  SplitClause {
925
1341
  split
926
1342
  on?
927
- Ident
1343
+ Idiom
928
1344
  }
929
1345
 
930
1346
  WhereClause {
@@ -945,7 +1361,12 @@ ExplainClause {
945
1361
  full?
946
1362
  }
947
1363
 
948
- TokenizersClause { tokenizers commaSep<AnalyzerTokenizers> }
1364
+ VersionClause[since=2_0_0] {
1365
+ version
1366
+ prefixedString
1367
+ }
1368
+
1369
+ TokenizersClause { tokenizers commaSep<AnalyzerTokenizer> }
949
1370
 
950
1371
  FiltersClause {
951
1372
  filters
@@ -957,27 +1378,19 @@ FunctionClause {
957
1378
  customFunctionName
958
1379
  }
959
1380
 
960
- WhenThenClause {
961
- (
962
- when
963
- value
964
- )?
965
- then?
966
- commaSep<(SubQuery | Block)>
967
- }
968
-
969
1381
  TypeClause {
970
1382
  flexible?
971
1383
  typeKeyword
972
1384
  type
973
1385
  }
974
1386
 
975
- ReadonlyClause {
1387
+ ReadonlyClause[since=1_2_0] {
976
1388
  readonly
977
1389
  }
978
1390
 
979
1391
  DefaultClause {
980
1392
  default
1393
+ DefaultAlways[since=2_2_0] { always? }
981
1394
  value
982
1395
  }
983
1396
 
@@ -991,13 +1404,23 @@ AssertClause {
991
1404
  value
992
1405
  }
993
1406
 
1407
+ ReferenceClause {
1408
+ reference
1409
+ (on delete (reject | cascade | ignore | unset | then Block))?
1410
+ }
1411
+
1412
+ ComputedClause {
1413
+ computed
1414
+ value
1415
+ }
1416
+
994
1417
  PermissionsForClause {
995
1418
  permissions
996
1419
  (
997
1420
  none | full |
998
1421
  (
999
1422
  for
1000
- commaSep<( selectPermissions | createPermissions | updatePermissions | deletePermissions )>
1423
+ commaSep<select | create | update | delete>
1001
1424
  ( WhereClause | none | full )
1002
1425
  )+
1003
1426
  )
@@ -1005,7 +1428,12 @@ PermissionsForClause {
1005
1428
 
1006
1429
  PermissionsBasicClause {
1007
1430
  permissions
1008
- none | full | WhereClause
1431
+ (none | full | WhereClause)
1432
+ }
1433
+
1434
+ MiddlewareClause {
1435
+ middleware
1436
+ commaSep<FunctionCall>
1009
1437
  }
1010
1438
 
1011
1439
  CommentClause {
@@ -1016,44 +1444,32 @@ CommentClause {
1016
1444
  DurationValue {
1017
1445
  (for token Duration) | (for session Duration)
1018
1446
  }
1019
-
1020
- DurationClause {
1021
- duration commaSep<DurationValue>
1447
+
1448
+ DurationClause[since=2_0_0] {
1449
+ duration (for session)? commaSep<DurationValue>
1022
1450
  }
1023
1451
 
1024
1452
  TokenTypeClause {
1025
1453
  typeKeyword
1026
- (
1027
- jwks |
1028
- eddsa |
1029
- es256 |
1030
- es384 |
1031
- es512 |
1032
- ps256 |
1033
- ps384 |
1034
- ps512 |
1035
- rs256 |
1036
- rs384 |
1037
- rs512
1038
- )
1454
+ TokenType
1455
+ }
1456
+
1457
+ BackendClause {
1458
+ backend
1459
+ value
1039
1460
  }
1040
1461
 
1041
1462
  // Support
1042
1463
 
1043
- AnalyzerTokenizers {
1044
- blank |
1045
- camel |
1046
- class |
1047
- punct
1464
+ AnalyzerFilters {
1465
+ Filter ("(" (number "," number | Ident) ")")?
1048
1466
  }
1049
1467
 
1050
- AnalyzerFilters {
1051
- ascii |
1052
- lowercase |
1053
- uppercase |
1054
- ( edgengram "(" Int "," Int ")" ) |
1055
- ( ngram "(" Int "," Int ")" ) |
1056
- ( snowball "(" Ident ")" )
1468
+ Order {
1469
+ Idiom
1470
+ collate?
1471
+ numeric?
1472
+ ( asc | desc )?
1057
1473
  }
1058
1474
 
1059
1475
  Predicate {
@@ -1062,31 +1478,33 @@ Predicate {
1062
1478
  }
1063
1479
 
1064
1480
  inclusivePredicate {
1065
- AnyStar | Predicate
1481
+ AnyStar | Predicate
1066
1482
  }
1067
1483
 
1068
1484
  // Types
1069
1485
 
1070
- literalType {
1486
+ LiteralType[since=2_0_0] {
1071
1487
  String |
1072
- ArrayType { "[" type "]" } |
1488
+ number |
1489
+ Duration |
1490
+ ArrayType { "[" commaSep<type> "]" } |
1073
1491
  ObjectType { objectOpen ObjectTypeContent? "}" }
1074
1492
  // TODO support number and duration types
1075
1493
  }
1076
1494
 
1077
1495
  singleType {
1078
- TypeName { rawident } |
1079
- ParameterizedType { singleType "<" (type | Int) ">" } |
1080
- LiteralType { literalType }
1496
+ TypeName { rawident } |
1497
+ ParameterizedType { singleType "<" type ">" } |
1498
+ LiteralType
1081
1499
  }
1082
1500
 
1083
1501
  type {
1084
- singleType |
1085
- UnionType { type (!union "|" type)+ }
1502
+ singleType |
1503
+ UnionType { type (!union "|" type)+ }
1086
1504
  }
1087
1505
 
1088
1506
  safeType {
1089
- singleType | "<" type ">"
1507
+ singleType | "<" type ">"
1090
1508
  }
1091
1509
 
1092
1510
  ObjectTypeContent {
@@ -1106,42 +1524,41 @@ Ident {
1106
1524
  tickIdent
1107
1525
  }
1108
1526
 
1109
- number { Int | Float | Decimal }
1527
+ number { ("-" | "+")? (Int | Float | Decimal) }
1110
1528
 
1111
1529
  Operator {
1112
- binaryOperator |
1530
+ binaryOperator |
1113
1531
  "-" | "=" | ">" | "<" |
1114
- and |
1115
- or |
1116
- is |
1117
- ( is opNot ) |
1118
- contains |
1119
- containsnot |
1120
- containsall |
1121
- containsany |
1122
- containsnone |
1123
- inside | in |
1124
- notinside | ( opNot opIn ) |
1125
- allinside |
1126
- anyinside |
1127
- noneinside |
1128
-
1129
- outside |
1130
- intersects |
1131
-
1132
- ( "@" Int "@" ) |
1532
+ binaryOperatorKeyword |
1533
+ is | ( is opNot ) |
1534
+ in | ( opNot opIn ) |
1535
+
1536
+ ( "@" number "@" ) |
1133
1537
  (
1134
1538
  "<|"
1135
- Int
1136
- ( "," ( Int | chebyshev | cosine | euclidean | hamming | jaccard | manhattan | ( minkowski number ) | pearson ) )
1539
+ number
1540
+ ( "," ( number | Distance | ( minkowski number ) ) )
1137
1541
  "|>"
1138
1542
  )
1139
1543
  }
1140
1544
 
1545
+ @local tokens {
1546
+ blockCommentEnd { "*/" }
1547
+ blockCommentNewline { "\n" }
1548
+ @else blockCommentContent
1549
+ }
1550
+
1141
1551
  @external tokens objectToken from "./tokens" {
1142
1552
  objectOpen[@name=BraceOpen]
1143
1553
  }
1144
1554
 
1555
+ @external tokens rangeOperator from "./tokens" {
1556
+ rangeOp[@name=RangeOp],
1557
+ rangeOpOpenBoth[@name=RangeOp],
1558
+ rangeOpOpenLeft[@name=RangeOp],
1559
+ rangeOpOpenRight[@name=RangeOp]
1560
+ }
1561
+
1145
1562
  @tokens {
1146
1563
  // Characters
1147
1564
  "{"[@name=BraceOpen]
@@ -1149,10 +1566,14 @@ Operator {
1149
1566
  "[" "]"
1150
1567
  "<" ">"
1151
1568
  ":"[@name=Colon]
1152
- "->"[@name=ArrowRight]
1153
- "<-"[@name=ArrowLeft]
1154
- "<->"[@name=ArrowBoth]
1569
+ "->"[@name=LookupRight]
1570
+ "<-"[@name=LookupLeft]
1571
+ "<~"[@name=LookupLeft]
1572
+ "<->"[@name=LookupBoth]
1155
1573
  "|"[@name=Pipe]
1574
+ "~"[until=2_4_0]
1575
+ "!~"[until=2_4_0]
1576
+ "*~"[until=2_4_0]
1156
1577
 
1157
1578
  // Helpers
1158
1579
  whitespace { $[ \n\r\t] }
@@ -1165,15 +1586,18 @@ Operator {
1165
1586
  CommentResult[@name=Comment,closedBy=CommentResultClose] { "-------- Query" ![\n]* }
1166
1587
 
1167
1588
  // Numbers
1168
- Int { "-"? @digit+ }
1589
+ Int { @digit+ }
1169
1590
  frac { '.' @digit+ }
1170
1591
  exp { $[eE] $[+\-]? @digit+ }
1171
- Float { "-"? @digit+ (frac exp? | exp) "f"? }
1172
- Decimal { "-"? @digit+ frac? exp? "dec" }
1592
+ Float { (@digit+ (frac exp? | exp) "f"?) | "Infinity" | "NaN" }
1593
+ Decimal { @digit+ frac? exp? "dec" }
1173
1594
  VersionNumber { @digit+ ("." @digit+ ("." @digit+)?)? }
1174
1595
 
1175
1596
  String { "'" (!['\\] | "\\" _)* "'" | '"' (!["\\] | "\\" _)* '"' }
1176
- prefixedString[@name=String] { $[ruds] String }
1597
+ prefixedString[@name=String] { $[rudbf] String }
1598
+
1599
+ formatStringContentDouble { ("\\" _ | !["{\\])+ }
1600
+ formatStringContentSingle { ("\\" _ | !['{\\])+ }
1177
1601
 
1178
1602
  // Language
1179
1603
  VariableName { "$" (rawident | tickIdent | bracketIdent) }
@@ -1186,7 +1610,7 @@ Operator {
1186
1610
  rawident { (@asciiLetter | "_") (@asciiLetter | @digit | "_")* }
1187
1611
  numberident {
1188
1612
  rawident |
1189
- ( @digit+ (@asciiLetter | "_") (@asciiLetter | @digit | "_")* )
1613
+ @digit (@asciiLetter | @digit | "_")*
1190
1614
  }
1191
1615
 
1192
1616
  functionNameSegment { (@asciiLetter | "_") (@asciiLetter | "_" | @digit)* }
@@ -1204,12 +1628,13 @@ Operator {
1204
1628
 
1205
1629
  @precedence { CommentResult Comment Int "-" }
1206
1630
  @precedence { Comment binaryOperator }
1207
- @precedence { prefixedString rawident }
1208
- @precedence { customFunctionName FunctionName rawident }
1209
1631
  @precedence { Float Decimal Int rawident }
1210
- @precedence { DurationPart rawident }
1211
- @precedence { DurationPart Int }
1212
- @precedence { numberident Int rawident }
1632
+ @precedence { DurationPart Int rawident }
1633
+ @precedence { prefixedString numberident rawident }
1634
+ @precedence { customFunctionName FunctionName rawident }
1635
+ @precedence { "f'" 'f"' rawident }
1636
+ @precedence { "/*" Regex }
1637
+ @precedence { Float FunctionName }
1213
1638
 
1214
1639
  javaScriptContent { "\n" | ![{}\n'"]+ "\n"? | String }
1215
1640
  javaScriptBraceOpen { "{" }
@@ -1219,7 +1644,7 @@ Operator {
1219
1644
  "&&" | "||" | "??" | "?:" | "!=" | "==" | "?=" | "*=" | "~" | "!~" | "*~" |
1220
1645
  "<=" | ">=" | "+" | "+=" | "-=" | "*" | "×" | "/" | "÷" | "**" |
1221
1646
  $[∋∌⊇⊃⊅∈∉⊆⊂⊄] | "@@"
1222
- }
1647
+ }
1223
1648
 
1224
1649
  assignmentOperator[@name=Operator] {
1225
1650
  "=" |
@@ -1240,39 +1665,54 @@ piped<content> {
1240
1665
  content ("|" content)*
1241
1666
  }
1242
1667
 
1243
- @skip { whitespace | Comment }
1668
+ @skip { whitespace | Comment | BlockComment }
1244
1669
  @detectDelim
1245
1670
 
1246
1671
  @external propSource surqlHighlighting from "./highlight"
1672
+ @external prop since from "./version"
1673
+ @external prop until from "./version"
1247
1674
 
1248
1675
  @external extend { rawident } tokens from "./tokens" {
1249
1676
  access [@name=Keyword],
1250
1677
  algorithm [@name=Keyword],
1678
+ all [@name=Keyword],
1251
1679
  alter [@name=Keyword],
1680
+ always [@name=Keyword],
1252
1681
  analyzer [@name=Keyword],
1682
+ and [@name=Keyword],
1253
1683
  any [@name=Keyword],
1684
+ api [@name=Keyword],
1254
1685
  as [@name=Keyword],
1255
1686
  asc [@name=Keyword],
1256
1687
  assert [@name=Keyword],
1257
1688
  at [@name=Keyword],
1258
1689
  authenticate [@name=Keyword],
1690
+ auto [@name=Keyword],
1691
+ backend [@name=Keyword],
1259
1692
  begin [@name=Keyword],
1260
1693
  bm25 [@name=Keyword],
1261
1694
  break [@name=Keyword],
1695
+ bucket [@name=Keyword],
1262
1696
  by [@name=Keyword],
1263
1697
  cancel [@name=Keyword],
1264
1698
  capacity [@name=Keyword],
1699
+ cascade [@name=Keyword],
1265
1700
  changefeed [@name=Keyword],
1266
1701
  changes [@name=Keyword],
1702
+ collate [@name=Keyword],
1267
1703
  columns [@name=Keyword],
1268
1704
  comment [@name=Keyword],
1269
1705
  commit [@name=Keyword],
1706
+ computed [@name=Keyword],
1707
+ concurrently [@name=Keyword],
1708
+ config [@name=Keyword],
1270
1709
  content [@name=Keyword],
1271
1710
  continue [@name=Keyword],
1272
1711
  create [@name=Keyword],
1273
1712
  database [@name=Keyword],
1274
1713
  db [@name=Keyword],
1275
1714
  default [@name=Keyword],
1715
+ defer [@name=Keyword],
1276
1716
  define [@name=Keyword],
1277
1717
  delete [@name=Keyword],
1278
1718
  desc [@name=Keyword],
@@ -1288,9 +1728,12 @@ piped<content> {
1288
1728
  efc [@name=Keyword],
1289
1729
  else [@name=Keyword],
1290
1730
  end [@name=Keyword],
1731
+ enforced [@name=Keyword],
1291
1732
  event [@name=Keyword],
1733
+ exclude [@name=Keyword],
1292
1734
  exists [@name=Keyword],
1293
1735
  explain [@name=Keyword],
1736
+ expunge [@name=Keyword],
1294
1737
  extend_candidates [@name=Keyword],
1295
1738
  fetch [@name=Keyword],
1296
1739
  field [@name=Keyword],
@@ -1299,12 +1742,16 @@ piped<content> {
1299
1742
  flexible [@name=Keyword],
1300
1743
  for [@name=Keyword],
1301
1744
  from [@name=Keyword],
1745
+ functions [@name=Keyword],
1746
+ get [@name=Keyword],
1747
+ graphql [@name=Keyword],
1302
1748
  group [@name=Keyword],
1303
1749
  highlights [@name=Keyword],
1304
1750
  hnsw [@name=Keyword],
1305
1751
  if [@name=Keyword],
1306
1752
  ignore [@name=Keyword],
1307
1753
  in [@name=Keyword],
1754
+ include [@name=Keyword],
1308
1755
  index [@name=Keyword],
1309
1756
  info [@name=Keyword],
1310
1757
  insert [@name=Keyword],
@@ -1321,6 +1768,7 @@ piped<content> {
1321
1768
  m [@name=Keyword],
1322
1769
  m0 [@name=Keyword],
1323
1770
  merge [@name=Keyword],
1771
+ middleware [@name=Keyword],
1324
1772
  mtree [@name=Keyword],
1325
1773
  mtree_cache [@name=Keyword],
1326
1774
  namespace [@name=Keyword],
@@ -1328,6 +1776,8 @@ piped<content> {
1328
1776
  normal [@name=Keyword],
1329
1777
  not [@name=Keyword],
1330
1778
  ns [@name=Keyword],
1779
+ numeric [@name=Keyword],
1780
+ omit [@name=Keyword],
1331
1781
  on [@name=Keyword],
1332
1782
  only [@name=Keyword],
1333
1783
  option [@name=Keyword],
@@ -1340,14 +1790,19 @@ piped<content> {
1340
1790
  password [@name=Keyword],
1341
1791
  patch [@name=Keyword],
1342
1792
  permissions [@name=Keyword],
1793
+ post [@name=Keyword],
1343
1794
  postings_cache [@name=Keyword],
1344
1795
  postings_order [@name=Keyword],
1796
+ put [@name=Keyword],
1345
1797
  readonly [@name=Keyword],
1346
1798
  rebuild [@name=Keyword],
1347
1799
  record [@name=Keyword],
1800
+ reference [@name=Keyword],
1801
+ reject [@name=Keyword],
1348
1802
  relate [@name=Keyword],
1349
1803
  relation [@name=Keyword],
1350
1804
  remove [@name=Keyword],
1805
+ replace [@name=Keyword],
1351
1806
  return [@name=Keyword],
1352
1807
  roles [@name=Keyword],
1353
1808
  root [@name=Keyword],
@@ -1368,6 +1823,7 @@ piped<content> {
1368
1823
  start [@name=Keyword],
1369
1824
  structure [@name=Keyword],
1370
1825
  table [@name=Keyword],
1826
+ tables [@name=Keyword],
1371
1827
  tb [@name=Keyword],
1372
1828
  tempfiles [@name=Keyword],
1373
1829
  terms_cache [@name=Keyword],
@@ -1378,6 +1834,7 @@ piped<content> {
1378
1834
  to [@name=Keyword],
1379
1835
  token [@name=Keyword],
1380
1836
  tokenizers [@name=Keyword],
1837
+ trace [@name=Keyword],
1381
1838
  transaction [@name=Keyword],
1382
1839
  typeKeyword [@name=Keyword],
1383
1840
  unique [@name=Keyword],
@@ -1389,6 +1846,7 @@ piped<content> {
1389
1846
  user [@name=Keyword],
1390
1847
  valueKeyword [@name=Keyword],
1391
1848
  values [@name=Keyword],
1849
+ version [@name=Keyword],
1392
1850
  when [@name=Keyword],
1393
1851
  where [@name=Keyword],
1394
1852
  with [@name=Keyword],
@@ -1403,243 +1861,22 @@ piped<content> {
1403
1861
  null [@name=None],
1404
1862
  true [@name=Bool],
1405
1863
 
1406
- f32 [@name=Literal],
1407
- f64 [@name=Literal],
1408
- i16 [@name=Literal],
1409
- i32 [@name=Literal],
1410
- i64 [@name=Literal],
1411
-
1412
- createPermissions [@name=PermissionTarget],
1413
- deletePermissions [@name=PermissionTarget],
1414
- selectPermissions [@name=PermissionTarget],
1415
- updatePermissions [@name=PermissionTarget],
1416
-
1417
- jwks [@name=TokenType],
1418
- eddsa [@name=TokenType],
1419
- es256 [@name=TokenType],
1420
- es384 [@name=TokenType],
1421
- es512 [@name=TokenType],
1422
- ps256 [@name=TokenType],
1423
- ps384 [@name=TokenType],
1424
- ps512 [@name=TokenType],
1425
- rs256 [@name=TokenType],
1426
- rs384 [@name=TokenType],
1427
- rs512 [@name=TokenType],
1864
+ IndexTypeClause,
1865
+ TokenType,
1428
1866
 
1429
1867
  // Operators
1430
- allinside,
1431
- and,
1432
- anyinside,
1433
- contains,
1434
- containsall,
1435
- containsany,
1436
- containsnone,
1437
- containsnot,
1438
- inside,
1439
- intersects,
1868
+ binaryOperatorKeyword,
1440
1869
  is,
1441
- noneinside,
1442
- notinside,
1443
1870
  opIn,
1444
1871
  opNot,
1445
- or,
1446
- outside,
1447
-
1448
- chebyshev [@name=Distance],
1449
- cosine [@name=Distance],
1450
- euclidean [@name=Distance],
1451
- hamming [@name=Distance],
1452
- jaccard [@name=Distance],
1453
- manhattan [@name=Distance],
1454
- minkowski [@name=Distance],
1455
- pearson [@name=Distance],
1456
1872
 
1457
- ascii [@name=Filter],
1458
- edgengram [@name=Filter],
1459
- lowercase [@name=Filter],
1460
- ngram [@name=Filter],
1461
- snowball [@name=Filter],
1462
- uppercase [@name=Filter],
1873
+ Distance,
1874
+ minkowski [@name=Distance],
1875
+ Filter,
1463
1876
 
1464
- blank [@name=Tokenizer],
1465
- camel [@name=Tokenizer],
1466
- class [@name=Tokenizer],
1467
- punct [@name=Tokenizer],
1877
+ AnalyzerTokenizer,
1468
1878
 
1469
1879
  function,
1470
1880
  rand [@name=FunctionName],
1471
1881
  count [@name=FunctionName]
1472
- }
1473
-
1474
- anyKeyword {
1475
- access |
1476
- algorithm |
1477
- alter |
1478
- analyzer |
1479
- any |
1480
- as |
1481
- asc |
1482
- assert |
1483
- at |
1484
- authenticate |
1485
- begin |
1486
- bm25 |
1487
- break |
1488
- by |
1489
- cancel |
1490
- capacity |
1491
- changefeed |
1492
- changes |
1493
- columns |
1494
- comment |
1495
- commit |
1496
- content |
1497
- continue |
1498
- create |
1499
- database |
1500
- db |
1501
- default |
1502
- define |
1503
- delete |
1504
- desc |
1505
- dimension |
1506
- dist |
1507
- doc_ids_cache |
1508
- doc_ids_order |
1509
- doc_lengths_cache |
1510
- doc_lengths_order |
1511
- drop |
1512
- duplicate |
1513
- duration |
1514
- efc |
1515
- else |
1516
- end |
1517
- event |
1518
- exists |
1519
- explain |
1520
- extend_candidates |
1521
- fetch |
1522
- field |
1523
- fields |
1524
- filters |
1525
- flexible |
1526
- for |
1527
- from |
1528
- group |
1529
- highlights |
1530
- hnsw |
1531
- if |
1532
- ignore |
1533
- in |
1534
- index |
1535
- info |
1536
- insert |
1537
- into |
1538
- issuer |
1539
- jwt |
1540
- keep_pruned_connections |
1541
- key |
1542
- kill |
1543
- let |
1544
- limit |
1545
- live |
1546
- lm |
1547
- m |
1548
- m0 |
1549
- merge |
1550
- mtree |
1551
- mtree_cache |
1552
- namespace |
1553
- noindex |
1554
- normal |
1555
- not |
1556
- ns |
1557
- on |
1558
- only |
1559
- option |
1560
- order |
1561
- out |
1562
- overwrite |
1563
- parallel |
1564
- param |
1565
- passhash |
1566
- password |
1567
- patch |
1568
- permissions |
1569
- postings_cache |
1570
- postings_order |
1571
- readonly |
1572
- rebuild |
1573
- record |
1574
- relate |
1575
- relation |
1576
- remove |
1577
- return |
1578
- roles |
1579
- root |
1580
- sc |
1581
- schemafull |
1582
- schemaless |
1583
- scope |
1584
- search |
1585
- select |
1586
- session |
1587
- set |
1588
- show |
1589
- signin |
1590
- signup |
1591
- since |
1592
- sleep |
1593
- split |
1594
- start |
1595
- structure |
1596
- table |
1597
- tb |
1598
- tempfiles |
1599
- terms_cache |
1600
- terms_order |
1601
- then |
1602
- throw |
1603
- timeout |
1604
- to |
1605
- token |
1606
- tokenizers |
1607
- transaction |
1608
- typeKeyword |
1609
- unique |
1610
- unset |
1611
- update |
1612
- upsert |
1613
- url |
1614
- use |
1615
- user |
1616
- valueKeyword |
1617
- values |
1618
- when |
1619
- where |
1620
- with
1621
- }
1622
-
1623
- anyLiteral {
1624
- after |
1625
- before |
1626
- diff |
1627
- false |
1628
- full |
1629
- none |
1630
- null |
1631
- true |
1632
-
1633
- f32 |
1634
- f64 |
1635
- i16 |
1636
- i32 |
1637
- i64
1638
- }
1639
-
1640
- anyPermission {
1641
- createPermissions |
1642
- deletePermissions |
1643
- selectPermissions |
1644
- updatePermissions
1645
- }
1882
+ }