-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathrego.js
36 lines (34 loc) · 983 Bytes
/
rego.js
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
// @ts-nocheck
rego.displayName = 'rego'
rego.aliases = []
/** @type {import('../core.js').Syntax} */
export default function rego(Prism) {
// https://www.openpolicyagent.org/docs/latest/policy-reference/
Prism.languages.rego = {
comment: /#.*/,
property: {
pattern:
/(^|[^\\.])(?:"(?:\\.|[^\\"\r\n])*"|`[^`]*`|\b[a-z_]\w*\b)(?=\s*:(?!=))/i,
lookbehind: true,
greedy: true
},
string: {
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"|`[^`]*`/,
lookbehind: true,
greedy: true
},
keyword:
/\b(?:as|default|else|import|not|null|package|set(?=\s*\()|some|with)\b/,
boolean: /\b(?:false|true)\b/,
function: {
pattern: /\b[a-z_]\w*\b(?:\s*\.\s*\b[a-z_]\w*\b)*(?=\s*\()/i,
inside: {
namespace: /\b\w+\b(?=\s*\.)/,
punctuation: /\./
}
},
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
operator: /[-+*/%|&]|[<>:=]=?|!=|\b_\b/,
punctuation: /[,;.\[\]{}()]/
}
}