Skip to content

Commit 899574e

Browse files
Simran-BRunDevelopment
authored andcommitted
AQL: More pseudo keywords (#2055)
This adds `COUNT`, `CURRENT`, `KEEP`, and `PRUNE` to the list of keywords such that false positives are (mostly) avoided.
1 parent 32a4c42 commit 899574e

File tree

4 files changed

+85
-15
lines changed

4 files changed

+85
-15
lines changed

components/prism-aql.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ Prism.languages.aql = {
1111
},
1212
'variable': /@@?\w+/,
1313
'keyword': [
14+
{
15+
pattern: /(\bWITH\s+)COUNT(?=\s+INTO\b)/i,
16+
lookbehind: true
17+
},
1418
/\b(?:AGGREGATE|ALL|AND|ANY|ASC|COLLECT|DESC|DISTINCT|FILTER|FOR|GRAPH|IN|INBOUND|INSERT|INTO|K_SHORTEST_PATHS|LET|LIKE|LIMIT|NONE|NOT|NULL|OR|OUTBOUND|REMOVE|REPLACE|RETURN|SHORTEST_PATH|SORT|UPDATE|UPSERT|WITH)\b/i,
1519
// pseudo keywords get a lookbehind to avoid false positives
1620
{
17-
pattern: /(^|[^\w.[])(?:OPTIONS|SEARCH|TO)\b/i,
21+
pattern: /(^|[^\w.[])(?:KEEP|PRUNE|SEARCH|TO)\b/i,
1822
lookbehind: true
1923
},
2024
{
21-
pattern: /(^|[^\w.[])(?:NEW|OLD)\b/,
25+
pattern: /(^|[^\w.[])(?:CURRENT|NEW|OLD)\b/,
2226
lookbehind: true
2327
},
28+
{
29+
pattern: /\bOPTIONS(?=\s*{)/i
30+
}
2431
],
2532
'function': /(?!\d)\w+(?=\s*\()/,
2633
'boolean': /(?:true|false)/i,

components/prism-aql.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/aql/keyword_feature.test

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
WITH COUNT INTO
2+
COUNT
3+
14
AGGREGATE
25
ALL
36
AND
@@ -31,16 +34,26 @@ UPDATE
3134
UPSERT
3235
WITH
3336

34-
OPTIONS
37+
KEEP
38+
PRUNE
3539
SEARCH
3640
TO
3741

38-
OLD
42+
CURRENT
3943
NEW
44+
OLD
45+
46+
OPTIONS {}
47+
OPTIONS
4048

4149
----------------------------------------------------
4250

4351
[
52+
["keyword", "WITH"],
53+
["keyword", "COUNT"],
54+
["keyword", "INTO"],
55+
"\r\nCOUNT\r\n\r\n",
56+
4457
["keyword", "AGGREGATE"],
4558
["keyword", "ALL"],
4659
["keyword", "AND"],
@@ -74,12 +87,19 @@ NEW
7487
["keyword", "UPSERT"],
7588
["keyword", "WITH"],
7689

77-
["keyword", "OPTIONS"],
90+
["keyword", "KEEP"],
91+
["keyword", "PRUNE"],
7892
["keyword", "SEARCH"],
7993
["keyword", "TO"],
8094

95+
["keyword", "CURRENT"],
96+
["keyword", "NEW"],
8197
["keyword", "OLD"],
82-
["keyword", "NEW"]
98+
99+
["keyword", "OPTIONS"],
100+
["punctuation", "{"],
101+
["punctuation", "}"],
102+
"\r\nOPTIONS"
83103
]
84104

85105
----------------------------------------------------

tests/languages/aql/property_feature.test

+51-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// not a property
88
LET opType = IS_NULL(OLD) ? "insert" : "update"
99

10-
LET foo = { to: 5, search: 6, options: 7 }
11-
LET bar = foo.search + foo[options] + foo["to"]
10+
LET foo = { CURRENT: 1, keep: 2, NEW: 3, OLD: 4, options: 5, prune: 6, search: 7, to: 8 }
11+
LET bar = foo[CURRENT] + foo.NEW + foo["OLD"] + foo[keep] + foo.options + foo["prune"] + foo.search + foo[to]
1212

1313
----------------------------------------------------
1414

@@ -56,33 +56,76 @@ LET bar = foo.search + foo[options] + foo["to"]
5656
" foo ",
5757
["operator", "="],
5858
["punctuation", "{"],
59-
["property", "to"],
59+
["property", "CURRENT"],
60+
["punctuation", ":"],
61+
["number", "1"],
62+
["punctuation", ","],
63+
["property", "keep"],
64+
["punctuation", ":"],
65+
["number", "2"],
66+
["punctuation", ","],
67+
["property", "NEW"],
68+
["punctuation", ":"],
69+
["number", "3"],
70+
["punctuation", ","],
71+
["property", "OLD"],
72+
["punctuation", ":"],
73+
["number", "4"],
74+
["punctuation", ","],
75+
["property", "options"],
6076
["punctuation", ":"],
6177
["number", "5"],
6278
["punctuation", ","],
63-
["property", "search"],
79+
["property", "prune"],
6480
["punctuation", ":"],
6581
["number", "6"],
6682
["punctuation", ","],
67-
["property", "options"],
83+
["property", "search"],
6884
["punctuation", ":"],
6985
["number", "7"],
86+
["punctuation", ","],
87+
["property", "to"],
88+
["punctuation", ":"],
89+
["number", "8"],
7090
["punctuation", "}"],
7191
["keyword", "LET"],
7292
" bar ",
7393
["operator", "="],
7494
" foo",
95+
["punctuation", "["],
96+
"CURRENT",
97+
["punctuation", "]"],
98+
["operator", "+"],
99+
" foo",
75100
["punctuation", "."],
76-
"search ",
101+
"NEW ",
102+
["operator", "+"],
103+
" foo",
104+
["punctuation", "["],
105+
["string", "\"OLD\""],
106+
["punctuation", "]"],
107+
["operator", "+"],
108+
" foo",
109+
["punctuation", "["],
110+
"keep",
111+
["punctuation", "]"],
112+
["operator", "+"],
113+
" foo",
114+
["punctuation", "."],
115+
"options ",
77116
["operator", "+"],
78117
" foo",
79118
["punctuation", "["],
80-
"options",
119+
["string", "\"prune\""],
81120
["punctuation", "]"],
82121
["operator", "+"],
83122
" foo",
123+
["punctuation", "."],
124+
"search ",
125+
["operator", "+"],
126+
" foo",
84127
["punctuation", "["],
85-
["string", "\"to\""],
128+
"to",
86129
["punctuation", "]"]
87130
]
88131

0 commit comments

Comments
 (0)