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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
diff --git a/components/prism-aql.js b/components/prism-aql.js
index 2947e73..2de1522 100644
--- a/components/prism-aql.js
+++ b/components/prism-aql.js
@@ -11,16 +11,23 @@ Prism.languages.aql = {
},
'variable': /@@?\w+/,
'keyword': [
+ {
+ pattern: /(\bWITH\s+)COUNT(?=\s+INTO\b)/i,
+ lookbehind: true
+ },
/\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,
// pseudo keywords get a lookbehind to avoid false positives
{
- pattern: /(^|[^\w.[])(?:OPTIONS|SEARCH|TO)\b/i,
+ pattern: /(^|[^\w.[])(?:KEEP|PRUNE|SEARCH|TO)\b/i,
lookbehind: true
},
{
- pattern: /(^|[^\w.[])(?:NEW|OLD)\b/,
+ pattern: /(^|[^\w.[])(?:CURRENT|NEW|OLD)\b/,
lookbehind: true
},
+ {
+ pattern: /\bOPTIONS(?=\s*{)/i
+ }
],
'function': /(?!\d)\w+(?=\s*\()/,
'boolean': /(?:true|false)/i,
diff --git a/components/prism-aql.min.js b/components/prism-aql.min.js
index 4994fd7..5fa9a63 100644
--- a/components/prism-aql.min.js
+++ b/components/prism-aql.min.js
@@ -1 +1 @@
-Prism.languages.aql={comment:/\/\/.*|\/\*[\s\S]*?\*\//,property:{pattern:/([{,]\s*)(?:(?!\d)\w+|(["'´`])(?:(?!\2)[^\\\r\n]|\\.)*\2)(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(["'´`])(?:(?!\1)[^\\\r\n]|\\.)*\1/,greedy:!0},variable:/@@?\w+/,keyword:[/\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,{pattern:/(^|[^\w.[])(?:OPTIONS|SEARCH|TO)\b/i,lookbehind:!0},{pattern:/(^|[^\w.[])(?:NEW|OLD)\b/,lookbehind:!0}],function:/(?!\d)\w+(?=\s*\()/,boolean:/(?:true|false)/i,range:{pattern:/\.\./,alias:"operator"},number:/(?:\B\.\d+|\b(?:0|[1-9]\d*)(?:\.\d+)?)(?:e[+-]?\d+)?/i,operator:/\*{2,}|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,punctuation:/::|[?.:,;()[\]{}]/};
\ No newline at end of file
+Prism.languages.aql={comment:/\/\/.*|\/\*[\s\S]*?\*\//,property:{pattern:/([{,]\s*)(?:(?!\d)\w+|(["'´`])(?:(?!\2)[^\\\r\n]|\\.)*\2)(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(["'´`])(?:(?!\1)[^\\\r\n]|\\.)*\1/,greedy:!0},variable:/@@?\w+/,keyword:[{pattern:/(\bWITH\s+)COUNT(?=\s+INTO\b)/i,lookbehind:!0},/\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,{pattern:/(^|[^\w.[])(?:KEEP|PRUNE|SEARCH|TO)\b/i,lookbehind:!0},{pattern:/(^|[^\w.[])(?:CURRENT|NEW|OLD)\b/,lookbehind:!0},{pattern:/\bOPTIONS(?=\s*{)/i}],function:/(?!\d)\w+(?=\s*\()/,boolean:/(?:true|false)/i,range:{pattern:/\.\./,alias:"operator"},number:/(?:\B\.\d+|\b(?:0|[1-9]\d*)(?:\.\d+)?)(?:e[+-]?\d+)?/i,operator:/\*{2,}|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,punctuation:/::|[?.:,;()[\]{}]/};
\ No newline at end of file
diff --git a/tests/languages/aql/keyword_feature.test b/tests/languages/aql/keyword_feature.test
index 99645e0..204d457 100644
--- a/tests/languages/aql/keyword_feature.test
+++ b/tests/languages/aql/keyword_feature.test
@@ -1,3 +1,6 @@
+WITH COUNT INTO
+COUNT
+
AGGREGATE
ALL
AND
@@ -31,16 +34,26 @@ UPDATE
UPSERT
WITH
-OPTIONS
+KEEP
+PRUNE
SEARCH
TO
-OLD
+CURRENT
NEW
+OLD
+
+OPTIONS {}
+OPTIONS
----------------------------------------------------
[
+ ["keyword", "WITH"],
+ ["keyword", "COUNT"],
+ ["keyword", "INTO"],
+ "\r\nCOUNT\r\n\r\n",
+
["keyword", "AGGREGATE"],
["keyword", "ALL"],
["keyword", "AND"],
@@ -74,12 +87,19 @@ NEW
["keyword", "UPSERT"],
["keyword", "WITH"],
- ["keyword", "OPTIONS"],
+ ["keyword", "KEEP"],
+ ["keyword", "PRUNE"],
["keyword", "SEARCH"],
["keyword", "TO"],
+ ["keyword", "CURRENT"],
+ ["keyword", "NEW"],
["keyword", "OLD"],
- ["keyword", "NEW"]
+
+ ["keyword", "OPTIONS"],
+ ["punctuation", "{"],
+ ["punctuation", "}"],
+ "\r\nOPTIONS"
]
----------------------------------------------------
diff --git a/tests/languages/aql/property_feature.test b/tests/languages/aql/property_feature.test
index 6c9c468..9783aa3 100644
--- a/tests/languages/aql/property_feature.test
+++ b/tests/languages/aql/property_feature.test
@@ -7,8 +7,8 @@
// not a property
LET opType = IS_NULL(OLD) ? "insert" : "update"
-LET foo = { to: 5, search: 6, options: 7 }
-LET bar = foo.search + foo[options] + foo["to"]
+LET foo = { CURRENT: 1, keep: 2, NEW: 3, OLD: 4, options: 5, prune: 6, search: 7, to: 8 }
+LET bar = foo[CURRENT] + foo.NEW + foo["OLD"] + foo[keep] + foo.options + foo["prune"] + foo.search + foo[to]
----------------------------------------------------
@@ -56,33 +56,76 @@ LET bar = foo.search + foo[options] + foo["to"]
" foo ",
["operator", "="],
["punctuation", "{"],
- ["property", "to"],
+ ["property", "CURRENT"],
+ ["punctuation", ":"],
+ ["number", "1"],
+ ["punctuation", ","],
+ ["property", "keep"],
+ ["punctuation", ":"],
+ ["number", "2"],
+ ["punctuation", ","],
+ ["property", "NEW"],
+ ["punctuation", ":"],
+ ["number", "3"],
+ ["punctuation", ","],
+ ["property", "OLD"],
+ ["punctuation", ":"],
+ ["number", "4"],
+ ["punctuation", ","],
+ ["property", "options"],
["punctuation", ":"],
["number", "5"],
["punctuation", ","],
- ["property", "search"],
+ ["property", "prune"],
["punctuation", ":"],
["number", "6"],
["punctuation", ","],
- ["property", "options"],
+ ["property", "search"],
["punctuation", ":"],
["number", "7"],
+ ["punctuation", ","],
+ ["property", "to"],
+ ["punctuation", ":"],
+ ["number", "8"],
["punctuation", "}"],
["keyword", "LET"],
" bar ",
["operator", "="],
" foo",
+ ["punctuation", "["],
+ "CURRENT",
+ ["punctuation", "]"],
+ ["operator", "+"],
+ " foo",
["punctuation", "."],
- "search ",
+ "NEW ",
+ ["operator", "+"],
+ " foo",
+ ["punctuation", "["],
+ ["string", "\"OLD\""],
+ ["punctuation", "]"],
+ ["operator", "+"],
+ " foo",
+ ["punctuation", "["],
+ "keep",
+ ["punctuation", "]"],
+ ["operator", "+"],
+ " foo",
+ ["punctuation", "."],
+ "options ",
["operator", "+"],
" foo",
["punctuation", "["],
- "options",
+ ["string", "\"prune\""],
["punctuation", "]"],
["operator", "+"],
" foo",
+ ["punctuation", "."],
+ "search ",
+ ["operator", "+"],
+ " foo",
["punctuation", "["],
- ["string", "\"to\""],
+ "to",
["punctuation", "]"]
]