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