Skip to content

Commit

Permalink
AQL: Update for ArangoDB 3.8 (#2842)
Browse files Browse the repository at this point in the history
- Add `K_PATHS` and `WINDOW` keywords
- Support binary and hexadecimal number literals
  • Loading branch information
Simran-B authored Apr 1, 2021
1 parent 1c6c0bf commit ea82478
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions components/prism-aql.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Prism.languages.aql = {
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,
/\b(?:AGGREGATE|ALL|AND|ANY|ASC|COLLECT|DESC|DISTINCT|FILTER|FOR|GRAPH|IN|INBOUND|INSERT|INTO|K_PATHS|K_SHORTEST_PATHS|LET|LIKE|LIMIT|NONE|NOT|NULL|OR|OUTBOUND|REMOVE|REPLACE|RETURN|SHORTEST_PATH|SORT|UPDATE|UPSERT|WINDOW|WITH)\b/i,
// pseudo keywords get a lookbehind to avoid false positives
{
pattern: /(^|[^\w.[])(?:KEEP|PRUNE|SEARCH|TO)\b/i,
Expand All @@ -35,7 +35,11 @@ Prism.languages.aql = {
pattern: /\.\./,
alias: 'operator'
},
'number': /(?:\B\.\d+|\b(?:0|[1-9]\d*)(?:\.\d+)?)(?:e[+-]?\d+)?/i,
'number': [
/\b0b[01]+/i,
/\b0x[0-9a-f]+/i,
/(?:\B\.\d+|\b(?:0|[1-9]\d*)(?:\.\d+)?)(?:e[+-]?\d+)?/i
],
'operator': /\*{2,}|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,
'punctuation': /::|[?.:,;()[\]{}]/
};
2 changes: 1 addition & 1 deletion components/prism-aql.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/languages/aql/keyword_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ IN
INBOUND
INSERT
INTO
K_PATHS
K_SHORTEST_PATHS
LET
LIKE
Expand All @@ -32,6 +33,7 @@ SHORTEST_PATH
SORT
UPDATE
UPSERT
WINDOW
WITH

KEEP
Expand Down Expand Up @@ -69,6 +71,7 @@ OPTIONS
["keyword", "INBOUND"],
["keyword", "INSERT"],
["keyword", "INTO"],
["keyword", "K_PATHS"],
["keyword", "K_SHORTEST_PATHS"],
["keyword", "LET"],
["keyword", "LIKE"],
Expand All @@ -85,6 +88,7 @@ OPTIONS
["keyword", "SORT"],
["keyword", "UPDATE"],
["keyword", "UPSERT"],
["keyword", "WINDOW"],
["keyword", "WITH"],

["keyword", "KEEP"],
Expand Down
6 changes: 5 additions & 1 deletion tests/languages/aql/number_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
.5
4.87e103
4.87E103
0b10101110
0xabcdef02

----------------------------------------------------

Expand All @@ -17,7 +19,9 @@
["number", "0.5"],
["number", ".5"],
["number", "4.87e103"],
["number", "4.87E103"]
["number", "4.87E103"],
["number", "0b10101110"],
["number", "0xabcdef02"]
]

----------------------------------------------------
Expand Down

0 comments on commit ea82478

Please sign in to comment.