@surrealdb/lezer 1.0.3 → 1.0.5
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.
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-run-tests.log +500 -42
- package/dist/index.cjs +68 -66
- package/dist/index.js +68 -66
- package/package.json +1 -1
- package/src/parser.js +18 -18
- package/src/parser.terms.js +234 -231
- package/src/surrealql.grammar +88 -80
- package/src/tokens.js +2 -0
- package/test/misc/comments.txt +44 -0
- package/test/misc/functions.txt +63 -0
- package/test/misc/identifiers.txt +22 -0
- package/test/misc/javascript.txt +34 -0
- package/test/misc/operators.txt +213 -0
- package/test/misc/parameters.txt +23 -0
- package/test/misc/subqueries.txt +23 -0
- package/test/statements/alter.txt +47 -0
- package/test/statements/break-continue.txt +15 -0
- package/test/statements/create.txt +103 -0
- package/test/statements/define.txt +281 -0
- package/test/statements/delete.txt +63 -0
- package/test/statements/for.txt +19 -0
- package/test/statements/if-else.txt +47 -0
- package/test/statements/info.txt +63 -0
- package/test/statements/insert.txt +63 -0
- package/test/statements/let.txt +39 -0
- package/test/statements/live.txt +47 -0
- package/test/statements/option.txt +23 -0
- package/test/statements/rebuild.txt +15 -0
- package/test/statements/relate.txt +63 -0
- package/test/statements/remove.txt +95 -0
- package/test/statements/return.txt +39 -0
- package/test/statements/select.txt +231 -0
- package/test/statements/show.txt +31 -0
- package/test/statements/sleep.txt +23 -0
- package/test/statements/throw.txt +23 -0
- package/test/statements/transactions.txt +47 -0
- package/test/statements/update.txt +87 -0
- package/test/statements/upsert.txt +55 -0
- package/test/statements/use.txt +39 -0
- package/test/test-surrealql.js +81 -9
- package/test/values/arrays.txt +47 -0
- package/test/values/casting.txt +95 -0
- package/test/values/closures.txt +39 -0
- package/test/values/durations.txt +41 -0
- package/test/values/format-strings.txt +39 -0
- package/test/values/geometries.txt +23 -0
- package/test/values/idioms.txt +228 -0
- package/test/values/literals.txt +46 -0
- package/test/values/numbers.txt +75 -0
- package/test/values/objects.txt +64 -0
- package/test/values/ranges.txt +31 -0
- package/test/values/record-ids.txt +71 -0
- package/test/values/regex.txt +31 -0
- package/test/values/sets.txt +31 -0
- package/test/values/strings.txt +69 -0
- package/test/statement.txt +0 -132
- package/test/value.txt +0 -259
package/src/surrealql.grammar
CHANGED
|
@@ -345,7 +345,8 @@ defineEventOptions {
|
|
|
345
345
|
|
|
346
346
|
defineDatabaseOptions {
|
|
347
347
|
(IfNotExistsClause | OverwriteClause)?
|
|
348
|
-
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
|
-
|
|
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?
|
|
@@ -777,7 +778,7 @@ ShowStatement {
|
|
|
777
778
|
show changes for table
|
|
778
779
|
Ident
|
|
779
780
|
( since String )?
|
|
780
|
-
( limit
|
|
781
|
+
( limit Number )?
|
|
781
782
|
}
|
|
782
783
|
|
|
783
784
|
// Sleep statement
|
|
@@ -815,30 +816,34 @@ RebuildStatement[since=1_5_0] {
|
|
|
815
816
|
|
|
816
817
|
// Values
|
|
817
818
|
|
|
818
|
-
|
|
819
|
+
computedValue[@isGroup=Value] {
|
|
819
820
|
String |
|
|
820
821
|
prefixedString |
|
|
821
|
-
|
|
822
|
-
number |
|
|
822
|
+
Number |
|
|
823
823
|
true |
|
|
824
824
|
false |
|
|
825
825
|
null |
|
|
826
826
|
none |
|
|
827
|
-
Regex |
|
|
828
|
-
VariableName |
|
|
829
|
-
Ident[@dynamicPrecedence=-1] { rawident } |
|
|
830
827
|
Array |
|
|
831
828
|
Set |
|
|
832
829
|
RecordId |
|
|
830
|
+
Object |
|
|
831
|
+
Duration |
|
|
832
|
+
Point { "(" Number "," Number ")" }
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
baseValue[@isGroup=Value] {
|
|
836
|
+
computedValue |
|
|
837
|
+
FormatString |
|
|
838
|
+
Regex |
|
|
839
|
+
VariableName |
|
|
840
|
+
Ident[@dynamicPrecedence=-1] { rawident } |
|
|
833
841
|
FunctionJs |
|
|
834
842
|
FunctionCall |
|
|
835
843
|
SubQuery |
|
|
836
844
|
Block |
|
|
837
845
|
Closure |
|
|
838
|
-
|
|
839
|
-
TypeCast |
|
|
840
|
-
Duration |
|
|
841
|
-
Point { "(" number "," number ")" }
|
|
846
|
+
TypeCast
|
|
842
847
|
}
|
|
843
848
|
|
|
844
849
|
value[@isGroup=Value] {
|
|
@@ -939,11 +944,11 @@ Recurse[since=2_1_0] {
|
|
|
939
944
|
}
|
|
940
945
|
|
|
941
946
|
RecurseRange {
|
|
942
|
-
|
|
947
|
+
Number |
|
|
943
948
|
rangeOpOpenBoth |
|
|
944
|
-
|
|
945
|
-
rangeOpOpenLeft
|
|
946
|
-
|
|
949
|
+
Number rangeOpOpenRight |
|
|
950
|
+
rangeOpOpenLeft Number |
|
|
951
|
+
Number rangeOp Number
|
|
947
952
|
}
|
|
948
953
|
|
|
949
954
|
RecurseOptions[since=2_2_0] {
|
|
@@ -1004,7 +1009,7 @@ RecordTbIdent {
|
|
|
1004
1009
|
bracketIdent
|
|
1005
1010
|
}
|
|
1006
1011
|
|
|
1007
|
-
// Ideally we match "
|
|
1012
|
+
// Ideally we match "Number" here, but I cannot for the life of me get it to
|
|
1008
1013
|
// fall back to numberident after. This will suffice for now.
|
|
1009
1014
|
RecordIdIdent {
|
|
1010
1015
|
numberident |
|
|
@@ -1198,15 +1203,15 @@ SearchAnalyzerClause {
|
|
|
1198
1203
|
)*
|
|
1199
1204
|
}
|
|
1200
1205
|
|
|
1201
|
-
Bm25Clause { bm25 ( "("
|
|
1202
|
-
DocIdsCacheClause { doc_ids_cache
|
|
1203
|
-
DocIdsOrderClause { doc_ids_order
|
|
1204
|
-
DocLenghtsCacheClause { doc_lengths_cache
|
|
1205
|
-
DocLenghtsOrderClause { doc_lengths_order
|
|
1206
|
-
PostingsCacheClause { postings_cache
|
|
1207
|
-
PostingsOrderClause { postings_order
|
|
1208
|
-
TermsCacheClause { terms_cache
|
|
1209
|
-
TermsOrderClause { terms_order
|
|
1206
|
+
Bm25Clause { bm25 ( "(" Number "," Number ")")? }
|
|
1207
|
+
DocIdsCacheClause { doc_ids_cache Number }
|
|
1208
|
+
DocIdsOrderClause { doc_ids_order Number }
|
|
1209
|
+
DocLenghtsCacheClause { doc_lengths_cache Number }
|
|
1210
|
+
DocLenghtsOrderClause { doc_lengths_order Number }
|
|
1211
|
+
PostingsCacheClause { postings_cache Number }
|
|
1212
|
+
PostingsOrderClause { postings_order Number }
|
|
1213
|
+
TermsCacheClause { terms_cache Number }
|
|
1214
|
+
TermsOrderClause { terms_order Number }
|
|
1210
1215
|
|
|
1211
1216
|
MtreeClause[since=1_3_0] {
|
|
1212
1217
|
mtree
|
|
@@ -1221,7 +1226,7 @@ MtreeClause[since=1_3_0] {
|
|
|
1221
1226
|
)*
|
|
1222
1227
|
}
|
|
1223
1228
|
|
|
1224
|
-
MtreeCacheClause { mtree_cache
|
|
1229
|
+
MtreeCacheClause { mtree_cache Number }
|
|
1225
1230
|
MtreeDistClause { dist ( Distance ) }
|
|
1226
1231
|
|
|
1227
1232
|
HnswClause[since=1_5_0] {
|
|
@@ -1240,14 +1245,14 @@ IndexDimensionClause
|
|
|
1240
1245
|
)*
|
|
1241
1246
|
}
|
|
1242
1247
|
|
|
1243
|
-
HnswDistClause { dist ( Distance | ( minkowski
|
|
1248
|
+
HnswDistClause { dist ( Distance | ( minkowski Number )) }
|
|
1244
1249
|
|
|
1245
|
-
IndexDimensionClause { dimension
|
|
1246
|
-
IndexCapacityClause { capacity
|
|
1247
|
-
IndexLmClause { lm
|
|
1248
|
-
IndexM0Clause { m0
|
|
1249
|
-
IndexMClause { m
|
|
1250
|
-
IndexEfcClause { efc
|
|
1250
|
+
IndexDimensionClause { dimension Number }
|
|
1251
|
+
IndexCapacityClause { capacity Number }
|
|
1252
|
+
IndexLmClause { lm Number }
|
|
1253
|
+
IndexM0Clause { m0 Number }
|
|
1254
|
+
IndexMClause { m Number }
|
|
1255
|
+
IndexEfcClause { efc Number }
|
|
1251
1256
|
IndexExtendCandidatesClause { extend_candidates }
|
|
1252
1257
|
IndexKeepPrunedConnectionsClause { keep_pruned_connections }
|
|
1253
1258
|
|
|
@@ -1303,19 +1308,19 @@ TempfilesClause[since=2_0_0] {
|
|
|
1303
1308
|
|
|
1304
1309
|
FetchClause {
|
|
1305
1310
|
fetch
|
|
1306
|
-
commaSep<
|
|
1311
|
+
commaSep<Idiom>
|
|
1307
1312
|
}
|
|
1308
1313
|
|
|
1309
1314
|
StartClause {
|
|
1310
1315
|
start
|
|
1311
1316
|
at?
|
|
1312
|
-
(
|
|
1317
|
+
(Number | VariableName)
|
|
1313
1318
|
}
|
|
1314
1319
|
|
|
1315
1320
|
LimitClause {
|
|
1316
1321
|
limit
|
|
1317
1322
|
by?
|
|
1318
|
-
(
|
|
1323
|
+
(Number | VariableName)
|
|
1319
1324
|
}
|
|
1320
1325
|
|
|
1321
1326
|
LimitStartComboClause {
|
|
@@ -1414,15 +1419,17 @@ ComputedClause {
|
|
|
1414
1419
|
value
|
|
1415
1420
|
}
|
|
1416
1421
|
|
|
1422
|
+
PermissionGroup {
|
|
1423
|
+
for
|
|
1424
|
+
commaSep<select | create | update | delete>
|
|
1425
|
+
( WhereClause | none | full )
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1417
1428
|
PermissionsForClause {
|
|
1418
1429
|
permissions
|
|
1419
1430
|
(
|
|
1420
1431
|
none | full |
|
|
1421
|
-
|
|
1422
|
-
for
|
|
1423
|
-
commaSep<select | create | update | delete>
|
|
1424
|
-
( WhereClause | none | full )
|
|
1425
|
-
)+
|
|
1432
|
+
PermissionGroup+
|
|
1426
1433
|
)
|
|
1427
1434
|
}
|
|
1428
1435
|
|
|
@@ -1462,7 +1469,7 @@ BackendClause {
|
|
|
1462
1469
|
// Support
|
|
1463
1470
|
|
|
1464
1471
|
AnalyzerFilters {
|
|
1465
|
-
Filter ("(" (
|
|
1472
|
+
Filter ("(" (Number "," Number | Ident) ")")?
|
|
1466
1473
|
}
|
|
1467
1474
|
|
|
1468
1475
|
Order {
|
|
@@ -1485,11 +1492,11 @@ inclusivePredicate {
|
|
|
1485
1492
|
|
|
1486
1493
|
LiteralType[since=2_0_0] {
|
|
1487
1494
|
String |
|
|
1488
|
-
|
|
1495
|
+
Number |
|
|
1489
1496
|
Duration |
|
|
1490
1497
|
ArrayType { "[" commaSep<type> "]" } |
|
|
1491
1498
|
ObjectType { objectOpen ObjectTypeContent? "}" }
|
|
1492
|
-
// TODO support
|
|
1499
|
+
// TODO support Number and duration types
|
|
1493
1500
|
}
|
|
1494
1501
|
|
|
1495
1502
|
singleType {
|
|
@@ -1524,7 +1531,7 @@ Ident {
|
|
|
1524
1531
|
tickIdent
|
|
1525
1532
|
}
|
|
1526
1533
|
|
|
1527
|
-
|
|
1534
|
+
Number { ("-" | "+")? (Int | Float | Decimal) }
|
|
1528
1535
|
|
|
1529
1536
|
Operator {
|
|
1530
1537
|
binaryOperator |
|
|
@@ -1533,11 +1540,11 @@ Operator {
|
|
|
1533
1540
|
is | ( is opNot ) |
|
|
1534
1541
|
in | ( opNot opIn ) |
|
|
1535
1542
|
|
|
1536
|
-
( "@"
|
|
1543
|
+
( "@" Number "@" ) |
|
|
1537
1544
|
(
|
|
1538
1545
|
"<|"
|
|
1539
|
-
|
|
1540
|
-
( "," (
|
|
1546
|
+
Number
|
|
1547
|
+
( "," ( Number | Distance | ( minkowski Number ) ) )
|
|
1541
1548
|
"|>"
|
|
1542
1549
|
)
|
|
1543
1550
|
}
|
|
@@ -1821,6 +1828,7 @@ piped<content> {
|
|
|
1821
1828
|
sleep [@name=Keyword],
|
|
1822
1829
|
split [@name=Keyword],
|
|
1823
1830
|
start [@name=Keyword],
|
|
1831
|
+
strict [@name=Keyword],
|
|
1824
1832
|
structure [@name=Keyword],
|
|
1825
1833
|
table [@name=Keyword],
|
|
1826
1834
|
tables [@name=Keyword],
|
package/src/tokens.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Hash comment
|
|
2
|
+
|
|
3
|
+
# this is a comment
|
|
4
|
+
42
|
|
5
|
+
|
|
6
|
+
==>
|
|
7
|
+
|
|
8
|
+
SurrealQL(Comment,Number(Int))
|
|
9
|
+
|
|
10
|
+
# Dash comment
|
|
11
|
+
|
|
12
|
+
-- this is a comment
|
|
13
|
+
42
|
|
14
|
+
|
|
15
|
+
==>
|
|
16
|
+
|
|
17
|
+
SurrealQL(Comment,Number(Int))
|
|
18
|
+
|
|
19
|
+
# Slash comment
|
|
20
|
+
|
|
21
|
+
// this is a comment
|
|
22
|
+
42
|
|
23
|
+
|
|
24
|
+
==>
|
|
25
|
+
|
|
26
|
+
SurrealQL(Comment,Number(Int))
|
|
27
|
+
|
|
28
|
+
# Block comment
|
|
29
|
+
|
|
30
|
+
1 /* this is
|
|
31
|
+
a block
|
|
32
|
+
comment */ + 2
|
|
33
|
+
|
|
34
|
+
==>
|
|
35
|
+
|
|
36
|
+
SurrealQL(BinaryExpression(Number(Int),BlockComment,Operator,Number(Int)))
|
|
37
|
+
|
|
38
|
+
# Block comment standalone
|
|
39
|
+
|
|
40
|
+
/* block */ 42
|
|
41
|
+
|
|
42
|
+
==>
|
|
43
|
+
|
|
44
|
+
SurrealQL(BlockComment,Number(Int))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Namespaced function call
|
|
2
|
+
|
|
3
|
+
a::b()
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList))
|
|
8
|
+
|
|
9
|
+
# Custom function call
|
|
10
|
+
|
|
11
|
+
fn::one::two(1, a)
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(Number(Int),Ident)))
|
|
16
|
+
|
|
17
|
+
# Rand function
|
|
18
|
+
|
|
19
|
+
rand(3)
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(Number(Int))))
|
|
24
|
+
|
|
25
|
+
# Count function
|
|
26
|
+
|
|
27
|
+
count(x)
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(Ident)))
|
|
32
|
+
|
|
33
|
+
# Versioned function call
|
|
34
|
+
|
|
35
|
+
some::versioned::function<1.2.3>(a)
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(FunctionCall(FunctionName,Version("<",VersionNumber,">"),ArgumentList(Ident)))
|
|
40
|
+
|
|
41
|
+
# No-argument function call
|
|
42
|
+
|
|
43
|
+
a::b()
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList))
|
|
48
|
+
|
|
49
|
+
# Multiple argument function call
|
|
50
|
+
|
|
51
|
+
string::concat("hello", " ", "world")
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(String,String,String)))
|
|
56
|
+
|
|
57
|
+
# Variable function call
|
|
58
|
+
|
|
59
|
+
$func(1)
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(FunctionCall(VariableName,ArgumentList(Number(Int))))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Raw identifiers
|
|
2
|
+
|
|
3
|
+
theVar;
|
|
4
|
+
theVar2
|
|
5
|
+
|
|
6
|
+
==>
|
|
7
|
+
|
|
8
|
+
SurrealQL(Ident,Ident)
|
|
9
|
+
|
|
10
|
+
# Keywords used as identifiers in field position
|
|
11
|
+
|
|
12
|
+
create bla set true = 1, false = 2, null = 3, none = 4
|
|
13
|
+
|
|
14
|
+
==>
|
|
15
|
+
|
|
16
|
+
SurrealQL(CreateStatement(
|
|
17
|
+
Keyword,Ident,
|
|
18
|
+
SetClause( Keyword,
|
|
19
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
20
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
21
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
22
|
+
FieldAssignment(Ident,Operator,Number(Int)))))
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# JavaScript function with args
|
|
2
|
+
|
|
3
|
+
function(123, 1d2h) {
|
|
4
|
+
const number = 123;
|
|
5
|
+
if (test("{")) {
|
|
6
|
+
return number.toString();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
==>
|
|
11
|
+
|
|
12
|
+
SurrealQL(
|
|
13
|
+
FunctionJs(
|
|
14
|
+
FunctionName,
|
|
15
|
+
ArgumentList(Number(Int),Duration(DurationPart,DurationPart)),
|
|
16
|
+
JavaScriptBlock(BraceOpen,JavaScriptContent,BraceClose)
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Simple JavaScript function
|
|
21
|
+
|
|
22
|
+
function() {
|
|
23
|
+
return 42;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
==>
|
|
27
|
+
|
|
28
|
+
SurrealQL(
|
|
29
|
+
FunctionJs(
|
|
30
|
+
FunctionName,
|
|
31
|
+
ArgumentList,
|
|
32
|
+
JavaScriptBlock(BraceOpen,JavaScriptContent,BraceClose)
|
|
33
|
+
)
|
|
34
|
+
)
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Addition
|
|
2
|
+
|
|
3
|
+
1 + 2
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
8
|
+
|
|
9
|
+
# Subtraction
|
|
10
|
+
|
|
11
|
+
5 - 3
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
16
|
+
|
|
17
|
+
# Multiplication
|
|
18
|
+
|
|
19
|
+
2 * 3
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
24
|
+
|
|
25
|
+
# Division
|
|
26
|
+
|
|
27
|
+
10 / 2
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
32
|
+
|
|
33
|
+
# Power
|
|
34
|
+
|
|
35
|
+
2 ** 3
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
40
|
+
|
|
41
|
+
# Equality
|
|
42
|
+
|
|
43
|
+
a == b
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
48
|
+
|
|
49
|
+
# Inequality
|
|
50
|
+
|
|
51
|
+
a != b
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
56
|
+
|
|
57
|
+
# Less than
|
|
58
|
+
|
|
59
|
+
a < b
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
64
|
+
|
|
65
|
+
# Greater than
|
|
66
|
+
|
|
67
|
+
a > b
|
|
68
|
+
|
|
69
|
+
==>
|
|
70
|
+
|
|
71
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
72
|
+
|
|
73
|
+
# Less than or equal
|
|
74
|
+
|
|
75
|
+
a <= b
|
|
76
|
+
|
|
77
|
+
==>
|
|
78
|
+
|
|
79
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
80
|
+
|
|
81
|
+
# Greater than or equal
|
|
82
|
+
|
|
83
|
+
a >= b
|
|
84
|
+
|
|
85
|
+
==>
|
|
86
|
+
|
|
87
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
88
|
+
|
|
89
|
+
# Logical AND
|
|
90
|
+
|
|
91
|
+
a && b
|
|
92
|
+
|
|
93
|
+
==>
|
|
94
|
+
|
|
95
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
96
|
+
|
|
97
|
+
# Logical OR
|
|
98
|
+
|
|
99
|
+
a || b
|
|
100
|
+
|
|
101
|
+
==>
|
|
102
|
+
|
|
103
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
104
|
+
|
|
105
|
+
# Null coalescing
|
|
106
|
+
|
|
107
|
+
a ?? b
|
|
108
|
+
|
|
109
|
+
==>
|
|
110
|
+
|
|
111
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
112
|
+
|
|
113
|
+
# Elvis operator
|
|
114
|
+
|
|
115
|
+
a ?: b
|
|
116
|
+
|
|
117
|
+
==>
|
|
118
|
+
|
|
119
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
120
|
+
|
|
121
|
+
# Unicode containment operators
|
|
122
|
+
|
|
123
|
+
a ∈ z;
|
|
124
|
+
x ∉ y;
|
|
125
|
+
a ⊆ b
|
|
126
|
+
|
|
127
|
+
==>
|
|
128
|
+
|
|
129
|
+
SurrealQL(
|
|
130
|
+
BinaryExpression(Ident,Operator,Ident),
|
|
131
|
+
BinaryExpression(Ident,Operator,Ident),
|
|
132
|
+
BinaryExpression(Ident,Operator,Ident)
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Keyword operator containsnot
|
|
136
|
+
|
|
137
|
+
x containsnot y
|
|
138
|
+
|
|
139
|
+
==>
|
|
140
|
+
|
|
141
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
142
|
+
|
|
143
|
+
# IS operator
|
|
144
|
+
|
|
145
|
+
x IS y
|
|
146
|
+
|
|
147
|
+
==>
|
|
148
|
+
|
|
149
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
150
|
+
|
|
151
|
+
# IN keyword operator
|
|
152
|
+
|
|
153
|
+
x IN y
|
|
154
|
+
|
|
155
|
+
==>
|
|
156
|
+
|
|
157
|
+
SurrealQL(BinaryExpression(Ident,Operator(Keyword),Ident))
|
|
158
|
+
|
|
159
|
+
# Fuzzy match
|
|
160
|
+
|
|
161
|
+
x ?= y
|
|
162
|
+
|
|
163
|
+
==>
|
|
164
|
+
|
|
165
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
166
|
+
|
|
167
|
+
# All match
|
|
168
|
+
|
|
169
|
+
x *= y
|
|
170
|
+
|
|
171
|
+
==>
|
|
172
|
+
|
|
173
|
+
SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
174
|
+
|
|
175
|
+
# Unicode multiplication
|
|
176
|
+
|
|
177
|
+
2 × 3
|
|
178
|
+
|
|
179
|
+
==>
|
|
180
|
+
|
|
181
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
182
|
+
|
|
183
|
+
# Unicode division
|
|
184
|
+
|
|
185
|
+
10 ÷ 2
|
|
186
|
+
|
|
187
|
+
==>
|
|
188
|
+
|
|
189
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
190
|
+
|
|
191
|
+
# Matches operator with distance
|
|
192
|
+
|
|
193
|
+
x @1@ y
|
|
194
|
+
|
|
195
|
+
==>
|
|
196
|
+
|
|
197
|
+
SurrealQL(BinaryExpression(Ident,Operator(Number(Int)),Ident))
|
|
198
|
+
|
|
199
|
+
# Addition assignment in expression
|
|
200
|
+
|
|
201
|
+
a += 1
|
|
202
|
+
|
|
203
|
+
==>
|
|
204
|
+
|
|
205
|
+
SurrealQL(BinaryExpression(Ident,Operator,Number(Int)))
|
|
206
|
+
|
|
207
|
+
# Subtraction assignment in expression
|
|
208
|
+
|
|
209
|
+
a -= 1
|
|
210
|
+
|
|
211
|
+
==>
|
|
212
|
+
|
|
213
|
+
SurrealQL(BinaryExpression(Ident,Operator,Number(Int)))
|