-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlanguage-definition.ts
38 lines (37 loc) · 1.13 KB
/
language-definition.ts
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
import { OpenFgaDslThemeTokenType } from "../../theme/theme.typings";
export const languageDefinition = {
[OpenFgaDslThemeTokenType.MODULE]: {
pattern: /(module\s+)[\w_-]+/i,
lookbehind: true,
},
[OpenFgaDslThemeTokenType.TYPE]: {
pattern: /(\btype\s+)[\w_-]+/i,
lookbehind: true,
},
[OpenFgaDslThemeTokenType.EXTEND]: {
pattern: /(\bextend type\s+)[\w_-]+/i,
lookbehind: true,
},
[OpenFgaDslThemeTokenType.RELATION]: {
pattern: /(\bdefine\s+)[\w_-]+/i,
lookbehind: true,
},
[OpenFgaDslThemeTokenType.DIRECTLY_ASSIGNABLE]: /\[.*]|self/,
[OpenFgaDslThemeTokenType.CONDITION]: {
pattern: /(\bcondition\s+)[\w_-]+/i,
lookbehind: true,
},
"condition-params": {
pattern: /\(.*\)\s*{/,
inside: {
"condition-param": /\b([\w_-]+)\s*:/i,
"condition-param-type": /\b(string|int|map|uint|list|timestamp|bool|duration|double|ipaddress)\b/,
},
},
[OpenFgaDslThemeTokenType.COMMENT]: {
pattern: /(^\s*|\s+)#.*/,
},
[OpenFgaDslThemeTokenType.KEYWORD]: {
pattern: /\b(type|relations|define|and|or|but not|from|as|model|schema|condition|module|extend)\b/,
},
};