-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtremor.js
86 lines (85 loc) · 2.62 KB
/
tremor.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
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
// @ts-nocheck
/**
* @import {Refractor} from '../lib/core.js'
*/
tremor.displayName = 'tremor'
tremor.aliases = ['trickle', 'troy']
/** @param {Refractor} Prism */
export default function tremor(Prism) {
;(function (Prism) {
Prism.languages.tremor = {
comment: {
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
lookbehind: true
},
'interpolated-string': null,
// see below
extractor: {
pattern: /\b[a-z_]\w*\|(?:[^\r\n\\|]|\\(?:\r\n|[\s\S]))*\|/i,
greedy: true,
inside: {
regex: {
pattern: /(^re)\|[\s\S]+/,
lookbehind: true
},
function: /^\w+/,
value: /\|[\s\S]+/
}
},
identifier: {
pattern: /`[^`]*`/,
greedy: true
},
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())\b/,
keyword:
/\b(?:args|as|by|case|config|connect|connector|const|copy|create|default|define|deploy|drop|each|emit|end|erase|event|flow|fn|for|from|group|having|insert|into|intrinsic|let|links|match|merge|mod|move|of|operator|patch|pipeline|recur|script|select|set|sliding|state|stream|to|tumbling|update|use|when|where|window|with)\b/,
boolean: /\b(?:false|null|true)\b/i,
number:
/\b(?:0b[01_]*|0x[0-9a-fA-F_]*|\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee][+-]?[\d_]+)?)\b/,
'pattern-punctuation': {
pattern: /%(?=[({[])/,
alias: 'punctuation'
},
operator:
/[-+*\/%~!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?>?=?|(?:absent|and|not|or|present|xor)\b/,
punctuation: /::|[;\[\]()\{\},.:]/
}
var interpolationPattern =
/#\{(?:[^"{}]|\{[^{}]*\}|"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*")*\}/.source
Prism.languages.tremor['interpolated-string'] = {
pattern: RegExp(
/(^|[^\\])/.source +
'(?:' +
'"""(?:' +
/[^"\\#]|\\[\s\S]|"(?!"")|#(?!\{)/.source +
'|' +
interpolationPattern +
')*"""' +
'|' +
'"(?:' +
/[^"\\\r\n#]|\\(?:\r\n|[\s\S])|#(?!\{)/.source +
'|' +
interpolationPattern +
')*"' +
')'
),
lookbehind: true,
greedy: true,
inside: {
interpolation: {
pattern: RegExp(interpolationPattern),
inside: {
punctuation: /^#\{|\}$/,
expression: {
pattern: /[\s\S]+/,
inside: Prism.languages.tremor
}
}
},
string: /[\s\S]+/
}
}
Prism.languages.troy = Prism.languages['tremor']
Prism.languages.trickle = Prism.languages['tremor']
})(Prism)
}