-
Notifications
You must be signed in to change notification settings - Fork 165
/
cadl-prism-lang.js
58 lines (51 loc) · 1.31 KB
/
cadl-prism-lang.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module.exports = {
comment: [
{
// multiline comments eg /* ASDF */
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
greedy: true,
},
{
// singleline comments eg // ASDF
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true,
},
],
directives: { pattern: /#.*/g, greedy: true, alias: "comment" },
decorator: {
pattern: /@[$\w\xA0-\uFFFF]+/,
inside: {
at: {
pattern: /^@/,
alias: "operator",
},
function: /^[\s\S]+/,
},
},
property: {
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
lookbehind: true,
alias: "property",
},
string: [
{
pattern: /"""[^"][\s\S]*?"""/,
greedy: true,
},
{
pattern: /(^|[^\\"])"(?:\\.|\$(?!\{)|[^"\\\r\n$])*"/,
lookbehind: true,
greedy: true,
},
],
boolean: /\b(?:false|true)\b/,
keyword:
/\b(?:import|model|namespace|op|interface|union|using|is|extends|enum|alias|return|void|never|if|else|projection)\b/,
function: /\b[a-z_]\w*(?=[ \t]*\()/i,
number: /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
operator:
/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
punctuation: /[{}[\];(),.:]/,
};