@surrealdb/lezer 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/.turbo/turbo-run-tests.log +500 -42
  3. package/dist/index.cjs +67 -65
  4. package/dist/index.js +67 -65
  5. package/package.json +2 -2
  6. package/src/parser.js +17 -17
  7. package/src/parser.terms.js +231 -229
  8. package/src/surrealql.grammar +41 -37
  9. package/src/tokens.js +2 -0
  10. package/test/misc/comments.txt +44 -0
  11. package/test/misc/functions.txt +63 -0
  12. package/test/misc/identifiers.txt +22 -0
  13. package/test/misc/javascript.txt +34 -0
  14. package/test/misc/operators.txt +213 -0
  15. package/test/misc/parameters.txt +23 -0
  16. package/test/misc/subqueries.txt +23 -0
  17. package/test/statements/alter.txt +47 -0
  18. package/test/statements/break-continue.txt +15 -0
  19. package/test/statements/create.txt +103 -0
  20. package/test/statements/define.txt +281 -0
  21. package/test/statements/delete.txt +63 -0
  22. package/test/statements/for.txt +19 -0
  23. package/test/statements/if-else.txt +47 -0
  24. package/test/statements/info.txt +63 -0
  25. package/test/statements/insert.txt +63 -0
  26. package/test/statements/let.txt +39 -0
  27. package/test/statements/live.txt +47 -0
  28. package/test/statements/option.txt +23 -0
  29. package/test/statements/rebuild.txt +15 -0
  30. package/test/statements/relate.txt +63 -0
  31. package/test/statements/remove.txt +95 -0
  32. package/test/statements/return.txt +39 -0
  33. package/test/statements/select.txt +231 -0
  34. package/test/statements/show.txt +31 -0
  35. package/test/statements/sleep.txt +23 -0
  36. package/test/statements/throw.txt +23 -0
  37. package/test/statements/transactions.txt +47 -0
  38. package/test/statements/update.txt +87 -0
  39. package/test/statements/upsert.txt +55 -0
  40. package/test/statements/use.txt +39 -0
  41. package/test/test-surrealql.js +81 -9
  42. package/test/values/arrays.txt +47 -0
  43. package/test/values/casting.txt +95 -0
  44. package/test/values/closures.txt +39 -0
  45. package/test/values/durations.txt +41 -0
  46. package/test/values/format-strings.txt +39 -0
  47. package/test/values/geometries.txt +23 -0
  48. package/test/values/idioms.txt +228 -0
  49. package/test/values/literals.txt +46 -0
  50. package/test/values/numbers.txt +75 -0
  51. package/test/values/objects.txt +64 -0
  52. package/test/values/ranges.txt +31 -0
  53. package/test/values/record-ids.txt +71 -0
  54. package/test/values/regex.txt +31 -0
  55. package/test/values/sets.txt +31 -0
  56. package/test/values/strings.txt +69 -0
  57. package/test/statement.txt +0 -132
  58. package/test/value.txt +0 -259
@@ -153,234 +153,236 @@ export const
153
153
  sleep = 151,
154
154
  split = 152,
155
155
  start = 153,
156
- structure = 154,
157
- table = 155,
158
- tables = 156,
159
- tb = 157,
160
- tempfiles = 158,
161
- terms_cache = 159,
162
- terms_order = 160,
163
- then = 161,
164
- _throw = 162,
165
- timeout = 163,
166
- to = 164,
167
- token = 165,
168
- tokenizers = 166,
169
- trace = 167,
170
- transaction = 168,
171
- typeKeyword = 169,
172
- unique = 170,
173
- unset = 171,
174
- update = 172,
175
- upsert = 173,
176
- url = 174,
177
- use = 175,
178
- user = 176,
179
- valueKeyword = 177,
180
- values = 178,
181
- version = 179,
182
- when = 180,
183
- where = 181,
184
- _with = 182,
185
- after = 183,
186
- before = 184,
187
- diff = 185,
188
- _false = 186,
189
- full = 187,
190
- none = 188,
191
- _null = 189,
192
- _true = 190,
193
- IndexTypeClause = 191,
194
- TokenType = 192,
195
- binaryOperatorKeyword = 492,
196
- is = 493,
197
- opIn = 494,
198
- opNot = 495,
199
- Distance = 193,
200
- minkowski = 194,
201
- Filter = 195,
202
- AnalyzerTokenizer = 196,
203
- _function = 496,
204
- rand = 197,
205
- count = 198,
206
- Comment = 199,
207
- BlockComment = 200,
208
- SurrealQL = 201,
209
- BeginStatement = 202,
210
- CancelStatement = 203,
211
- CommitStatement = 204,
212
- InfoForStatement = 205,
213
- Ident = 206,
214
- KillStatement = 207,
215
- String = 208,
216
- LiveSelectStatement = 209,
217
- Predicate = 210,
218
- prefixedString = 211,
219
- FormatString = 212,
220
- Interpolation = 215,
221
- Int = 216,
222
- Float = 217,
223
- Decimal = 218,
224
- Regex = 219,
225
- VariableName = 220,
226
- Array = 224,
227
- Set = 225,
228
- RecordId = 226,
229
- RecordTbIdent = 227,
230
- RecordIdIdent = 229,
231
- Object = 230,
232
- ObjectContent = 231,
233
- ObjectProperty = 232,
234
- ObjectKey = 233,
235
- RecordIdRange = 236,
236
- FunctionJs = 237,
237
- ArgumentList = 239,
238
- IfElseStatement = 240,
239
- Block = 242,
240
- SubQuery = 243,
241
- LetStatement = 245,
242
- paramDefinition = 246,
243
- LiteralType = 252,
244
- Duration = 253,
245
- DurationPart = 254,
246
- ObjectTypeContent = 257,
247
- ObjectTypeProperty = 258,
248
- DeleteStatement = 261,
249
- WhereClause = 262,
250
- ReturnClause = 263,
251
- Fields = 264,
252
- AnyStar = 265,
253
- TimeoutClause = 266,
254
- ParallelClause = 267,
255
- CreateStatement = 268,
256
- FunctionCall = 269,
257
- FunctionName = 270,
258
- customFunctionName = 271,
259
- VersionNumber = 273,
260
- ContentClause = 274,
261
- SetClause = 275,
262
- FieldAssignment = 276,
263
- assignmentOperator = 277,
264
- UnsetClause = 278,
265
- SelectStatement = 279,
266
- OmitClause = 280,
267
- WithClause = 281,
268
- SplitClause = 282,
269
- Idiom = 283,
270
- GroupClause = 284,
271
- OrderClause = 285,
272
- Order = 286,
273
- LimitStartComboClause = 287,
274
- StartClause = 288,
275
- LimitClause = 289,
276
- FetchClause = 290,
277
- Path = 291,
278
- Lookup = 292,
279
- Any = 297,
280
- LookupSelection = 298,
281
- GraphPredicate = 300,
282
- Optional = 306,
283
- At = 307,
284
- IdiomFunction = 308,
285
- Destructure = 310,
286
- Recurse = 311,
287
- RecurseRange = 312,
288
- RecurseOptions = 313,
289
- recurseOptionName = 314,
290
- TempfilesClause = 317,
291
- ExplainClause = 318,
292
- VersionClause = 319,
293
- RelateStatement = 320,
294
- UpdateStatement = 321,
295
- ReplaceClause = 322,
156
+ strict = 154,
157
+ structure = 155,
158
+ table = 156,
159
+ tables = 157,
160
+ tb = 158,
161
+ tempfiles = 159,
162
+ terms_cache = 160,
163
+ terms_order = 161,
164
+ then = 162,
165
+ _throw = 163,
166
+ timeout = 164,
167
+ to = 165,
168
+ token = 166,
169
+ tokenizers = 167,
170
+ trace = 168,
171
+ transaction = 169,
172
+ typeKeyword = 170,
173
+ unique = 171,
174
+ unset = 172,
175
+ update = 173,
176
+ upsert = 174,
177
+ url = 175,
178
+ use = 176,
179
+ user = 177,
180
+ valueKeyword = 178,
181
+ values = 179,
182
+ version = 180,
183
+ when = 181,
184
+ where = 182,
185
+ _with = 183,
186
+ after = 184,
187
+ before = 185,
188
+ diff = 186,
189
+ _false = 187,
190
+ full = 188,
191
+ none = 189,
192
+ _null = 190,
193
+ _true = 191,
194
+ IndexTypeClause = 192,
195
+ TokenType = 193,
196
+ binaryOperatorKeyword = 493,
197
+ is = 494,
198
+ opIn = 495,
199
+ opNot = 496,
200
+ Distance = 194,
201
+ minkowski = 195,
202
+ Filter = 196,
203
+ AnalyzerTokenizer = 197,
204
+ _function = 497,
205
+ rand = 198,
206
+ count = 199,
207
+ Comment = 200,
208
+ BlockComment = 201,
209
+ SurrealQL = 202,
210
+ BeginStatement = 203,
211
+ CancelStatement = 204,
212
+ CommitStatement = 205,
213
+ InfoForStatement = 206,
214
+ Ident = 207,
215
+ KillStatement = 208,
216
+ String = 209,
217
+ LiveSelectStatement = 210,
218
+ Predicate = 211,
219
+ prefixedString = 212,
220
+ FormatString = 213,
221
+ Interpolation = 216,
222
+ Int = 217,
223
+ Float = 218,
224
+ Decimal = 219,
225
+ Regex = 220,
226
+ VariableName = 221,
227
+ Array = 225,
228
+ Set = 226,
229
+ RecordId = 227,
230
+ RecordTbIdent = 228,
231
+ RecordIdIdent = 230,
232
+ Object = 231,
233
+ ObjectContent = 232,
234
+ ObjectProperty = 233,
235
+ ObjectKey = 234,
236
+ RecordIdRange = 237,
237
+ FunctionJs = 238,
238
+ ArgumentList = 240,
239
+ IfElseStatement = 241,
240
+ Block = 243,
241
+ SubQuery = 244,
242
+ LetStatement = 246,
243
+ paramDefinition = 247,
244
+ LiteralType = 253,
245
+ Duration = 254,
246
+ DurationPart = 255,
247
+ ObjectTypeContent = 258,
248
+ ObjectTypeProperty = 259,
249
+ DeleteStatement = 262,
250
+ WhereClause = 263,
251
+ ReturnClause = 264,
252
+ Fields = 265,
253
+ AnyStar = 266,
254
+ TimeoutClause = 267,
255
+ ParallelClause = 268,
256
+ CreateStatement = 269,
257
+ FunctionCall = 270,
258
+ FunctionName = 271,
259
+ customFunctionName = 272,
260
+ VersionNumber = 274,
261
+ ContentClause = 275,
262
+ SetClause = 276,
263
+ FieldAssignment = 277,
264
+ assignmentOperator = 278,
265
+ UnsetClause = 279,
266
+ SelectStatement = 280,
267
+ OmitClause = 281,
268
+ WithClause = 282,
269
+ SplitClause = 283,
270
+ Idiom = 284,
271
+ GroupClause = 285,
272
+ OrderClause = 286,
273
+ Order = 287,
274
+ LimitStartComboClause = 288,
275
+ StartClause = 289,
276
+ LimitClause = 290,
277
+ FetchClause = 291,
278
+ Path = 292,
279
+ Lookup = 293,
280
+ Any = 298,
281
+ LookupSelection = 299,
282
+ GraphPredicate = 301,
283
+ Optional = 307,
284
+ At = 308,
285
+ IdiomFunction = 309,
286
+ Destructure = 311,
287
+ Recurse = 312,
288
+ RecurseRange = 313,
289
+ RecurseOptions = 314,
290
+ recurseOptionName = 315,
291
+ TempfilesClause = 318,
292
+ ExplainClause = 319,
293
+ VersionClause = 320,
294
+ RelateStatement = 321,
295
+ UpdateStatement = 322,
296
296
  MergeClause = 323,
297
297
  PatchClause = 324,
298
- RemoveStatement = 325,
299
- IfExistsClause = 326,
300
- OnTableClause = 327,
301
- functionKw = 328,
302
- UpsertStatement = 329,
303
- ReturnStatement = 330,
304
- AlterStatement = 331,
305
- IfNotExistsClause = 332,
306
- PermissionsForClause = 333,
307
- CommentClause = 334,
308
- DefineStatement = 335,
309
- OverwriteClause = 337,
310
- OnRootNsDbClause = 338,
311
- AccessTypeClause = 339,
312
- JwtClause = 340,
313
- SignupClause = 341,
314
- SigninClause = 342,
315
- AuthenticateClause = 343,
316
- DurationClause = 344,
317
- DurationValue = 345,
318
- TokenTypeClause = 346,
319
- TypeClause = 349,
320
- DefaultClause = 350,
321
- ReadonlyClause = 352,
322
- ValueClause = 353,
323
- AssertClause = 354,
324
- ReferenceClause = 355,
325
- ComputedClause = 356,
326
- FieldsColumnsClause = 357,
327
- IndexClause = 358,
328
- UniqueClause = 359,
329
- SearchAnalyzerClause = 360,
330
- Bm25Clause = 361,
331
- DocIdsOrderClause = 362,
332
- DocLenghtsOrderClause = 363,
333
- PostingsOrderClause = 364,
334
- TermsOrderClause = 365,
335
- DocIdsCacheClause = 366,
336
- DocLenghtsCacheClause = 367,
337
- PostingsCacheClause = 368,
338
- TermsCacheClause = 369,
339
- MtreeClause = 370,
340
- IndexDimensionClause = 371,
341
- MtreeDistClause = 372,
342
- IndexCapacityClause = 373,
343
- MtreeCacheClause = 374,
344
- HnswClause = 375,
345
- HnswDistClause = 376,
346
- IndexLmClause = 377,
347
- IndexM0Clause = 378,
348
- IndexMClause = 379,
349
- IndexEfcClause = 380,
350
- IndexExtendCandidatesClause = 381,
351
- IndexKeepPrunedConnectionsClause = 382,
352
- TokenizersClause = 385,
353
- FiltersClause = 386,
354
- AnalyzerFilters = 387,
355
- FunctionClause = 388,
356
- PermissionsBasicClause = 389,
357
- SessionClause = 391,
358
- TableTypeClause = 392,
359
- TableViewClause = 394,
360
- ChangefeedClause = 395,
361
- ApiOptions = 396,
362
- MiddlewareClause = 397,
363
- HttpMethod = 398,
364
- BackendClause = 399,
365
- RebuildStatement = 400,
366
- InsertStatement = 401,
367
- JavaScriptBlock = 404,
368
- Closure = 406,
369
- escapedParamDefinition = 407,
370
- TypeCast = 409,
371
- BinaryExpression = 411,
372
- Operator = 412,
373
- Range = 413,
374
- ShowStatement = 414,
375
- SleepStatement = 415,
376
- UseStatement = 416,
377
- OptionStatement = 417,
378
- BreakStatement = 418,
379
- ContinueStatement = 419,
380
- ForStatement = 420,
381
- ThrowStatement = 421,
382
- PermissionInput = 422,
383
- IndexInput = 423,
384
- CombinedResults = 424,
385
- CommentResult = 426,
386
- Syntax = 428
298
+ ReplaceClause = 325,
299
+ RemoveStatement = 326,
300
+ IfExistsClause = 327,
301
+ OnTableClause = 328,
302
+ functionKw = 329,
303
+ UpsertStatement = 330,
304
+ ReturnStatement = 331,
305
+ AlterStatement = 332,
306
+ IfNotExistsClause = 333,
307
+ PermissionsForClause = 334,
308
+ PermissionGroup = 335,
309
+ CommentClause = 336,
310
+ DefineStatement = 337,
311
+ OverwriteClause = 339,
312
+ OnRootNsDbClause = 340,
313
+ AccessTypeClause = 341,
314
+ JwtClause = 342,
315
+ SignupClause = 343,
316
+ SigninClause = 344,
317
+ AuthenticateClause = 345,
318
+ DurationClause = 346,
319
+ DurationValue = 347,
320
+ TokenTypeClause = 348,
321
+ TypeClause = 351,
322
+ DefaultClause = 352,
323
+ ReadonlyClause = 354,
324
+ ValueClause = 355,
325
+ AssertClause = 356,
326
+ ReferenceClause = 357,
327
+ ComputedClause = 358,
328
+ FieldsColumnsClause = 359,
329
+ IndexClause = 360,
330
+ UniqueClause = 361,
331
+ SearchAnalyzerClause = 362,
332
+ Bm25Clause = 363,
333
+ DocIdsOrderClause = 364,
334
+ DocLenghtsOrderClause = 365,
335
+ PostingsOrderClause = 366,
336
+ TermsOrderClause = 367,
337
+ DocIdsCacheClause = 368,
338
+ DocLenghtsCacheClause = 369,
339
+ PostingsCacheClause = 370,
340
+ TermsCacheClause = 371,
341
+ MtreeClause = 372,
342
+ IndexDimensionClause = 373,
343
+ MtreeDistClause = 374,
344
+ IndexCapacityClause = 375,
345
+ MtreeCacheClause = 376,
346
+ HnswClause = 377,
347
+ HnswDistClause = 378,
348
+ IndexLmClause = 379,
349
+ IndexM0Clause = 380,
350
+ IndexMClause = 381,
351
+ IndexEfcClause = 382,
352
+ IndexExtendCandidatesClause = 383,
353
+ IndexKeepPrunedConnectionsClause = 384,
354
+ TokenizersClause = 387,
355
+ FiltersClause = 388,
356
+ AnalyzerFilters = 389,
357
+ FunctionClause = 390,
358
+ PermissionsBasicClause = 391,
359
+ SessionClause = 393,
360
+ TableTypeClause = 394,
361
+ TableViewClause = 396,
362
+ ChangefeedClause = 397,
363
+ ApiOptions = 398,
364
+ MiddlewareClause = 399,
365
+ HttpMethod = 400,
366
+ BackendClause = 401,
367
+ RebuildStatement = 402,
368
+ InsertStatement = 403,
369
+ JavaScriptBlock = 405,
370
+ Closure = 407,
371
+ escapedParamDefinition = 408,
372
+ TypeCast = 410,
373
+ BinaryExpression = 412,
374
+ Operator = 413,
375
+ Range = 414,
376
+ ShowStatement = 415,
377
+ SleepStatement = 416,
378
+ UseStatement = 417,
379
+ OptionStatement = 418,
380
+ BreakStatement = 419,
381
+ ContinueStatement = 420,
382
+ ForStatement = 421,
383
+ ThrowStatement = 422,
384
+ PermissionInput = 423,
385
+ IndexInput = 424,
386
+ CombinedResults = 425,
387
+ CommentResult = 427,
388
+ Syntax = 429
@@ -345,7 +345,8 @@ defineEventOptions {
345
345
 
346
346
  defineDatabaseOptions {
347
347
  (IfNotExistsClause | OverwriteClause)?
348
- value on value
348
+ value
349
+ strict?
349
350
  CommentClause?
350
351
  }
351
352
 
@@ -548,6 +549,33 @@ RemoveStatement {
548
549
  )
549
550
  }
550
551
 
552
+ // Clause groups
553
+
554
+ modifierClause[@isGroup=ModifierClause] {
555
+ WithClause |
556
+ WhereClause |
557
+ SplitClause |
558
+ GroupClause |
559
+ OrderClause |
560
+ LimitStartComboClause |
561
+ FetchClause |
562
+ TimeoutClause |
563
+ ParallelClause |
564
+ TempfilesClause |
565
+ ExplainClause |
566
+ VersionClause |
567
+ ReturnClause
568
+ }
569
+
570
+ dataClause[@isGroup=DataClause] {
571
+ ContentClause |
572
+ SetClause |
573
+ MergeClause |
574
+ PatchClause |
575
+ ReplaceClause |
576
+ UnsetClause
577
+ }
578
+
551
579
  // Data statements
552
580
 
553
581
  CreateStatement {
@@ -571,20 +599,7 @@ SelectStatement {
571
599
  statement |
572
600
  (
573
601
  commaSep<value>
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
- )*
602
+ modifierClause*
588
603
  )
589
604
  )
590
605
  }
@@ -629,7 +644,7 @@ InsertStatement {
629
644
  on duplicate key update
630
645
  commaSep<FieldAssignment>
631
646
  )?
632
- InsertReturnClause[since=2_0_0] { ReturnClause? }
647
+ ReturnClause?
633
648
  }
634
649
 
635
650
  UpdateStatement {
@@ -638,14 +653,7 @@ UpdateStatement {
638
653
  statement |
639
654
  (
640
655
  commaSep<value>
641
- (
642
- ContentClause |
643
- ReplaceClause |
644
- MergeClause |
645
- PatchClause |
646
- SetClause |
647
- UnsetClause
648
- )?
656
+ dataClause?
649
657
  updateOptionals {
650
658
  WhereClause?
651
659
  ReturnClause?
@@ -662,14 +670,7 @@ UpsertStatement[since=2_0_0] {
662
670
  statement |
663
671
  (
664
672
  commaSep<value>
665
- (
666
- ContentClause |
667
- ReplaceClause |
668
- MergeClause |
669
- PatchClause |
670
- SetClause |
671
- UnsetClause
672
- )?
673
+ dataClause?
673
674
  upsertOptionals {
674
675
  WhereClause?
675
676
  ReturnClause?
@@ -1414,15 +1415,17 @@ ComputedClause {
1414
1415
  value
1415
1416
  }
1416
1417
 
1418
+ PermissionGroup {
1419
+ for
1420
+ commaSep<select | create | update | delete>
1421
+ ( WhereClause | none | full )
1422
+ }
1423
+
1417
1424
  PermissionsForClause {
1418
1425
  permissions
1419
1426
  (
1420
1427
  none | full |
1421
- (
1422
- for
1423
- commaSep<select | create | update | delete>
1424
- ( WhereClause | none | full )
1425
- )+
1428
+ PermissionGroup+
1426
1429
  )
1427
1430
  }
1428
1431
 
@@ -1821,6 +1824,7 @@ piped<content> {
1821
1824
  sleep [@name=Keyword],
1822
1825
  split [@name=Keyword],
1823
1826
  start [@name=Keyword],
1827
+ strict [@name=Keyword],
1824
1828
  structure [@name=Keyword],
1825
1829
  table [@name=Keyword],
1826
1830
  tables [@name=Keyword],
package/src/tokens.js CHANGED
@@ -150,6 +150,7 @@ import {
150
150
  sleep,
151
151
  split,
152
152
  start,
153
+ strict,
153
154
  structure,
154
155
  table,
155
156
  tables,
@@ -356,6 +357,7 @@ const tokenMap = {
356
357
  sleep,
357
358
  split,
358
359
  start,
360
+ strict,
359
361
  structure,
360
362
  table,
361
363
  tables,
@@ -0,0 +1,44 @@
1
+ # Hash comment
2
+
3
+ # this is a comment
4
+ 42
5
+
6
+ ==>
7
+
8
+ SurrealQL(Comment,Int)
9
+
10
+ # Dash comment
11
+
12
+ -- this is a comment
13
+ 42
14
+
15
+ ==>
16
+
17
+ SurrealQL(Comment,Int)
18
+
19
+ # Slash comment
20
+
21
+ // this is a comment
22
+ 42
23
+
24
+ ==>
25
+
26
+ SurrealQL(Comment,Int)
27
+
28
+ # Block comment
29
+
30
+ 1 /* this is
31
+ a block
32
+ comment */ + 2
33
+
34
+ ==>
35
+
36
+ SurrealQL(BinaryExpression(Int,BlockComment,Operator,Int))
37
+
38
+ # Block comment standalone
39
+
40
+ /* block */ 42
41
+
42
+ ==>
43
+
44
+ SurrealQL(BlockComment,Int)