-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
cfscript.js
55 lines (54 loc) · 1.87 KB
/
cfscript.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
// @ts-nocheck
import refractorClike from './clike.js'
cfscript.displayName = 'cfscript'
cfscript.aliases = ['cfc']
/** @type {import('../core.js').Syntax} */
export default function cfscript(Prism) {
Prism.register(refractorClike)
// https://cfdocs.org/script
Prism.languages.cfscript = Prism.languages.extend('clike', {
comment: [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
inside: {
annotation: {
pattern: /(?:^|[^.])@[\w\.]+/,
alias: 'punctuation'
}
}
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true
}
],
keyword:
/\b(?:abstract|break|catch|component|continue|default|do|else|extends|final|finally|for|function|if|in|include|package|private|property|public|remote|required|rethrow|return|static|switch|throw|try|var|while|xml)\b(?!\s*=)/,
operator: [
/\+\+|--|&&|\|\||::|=>|[!=]==|[-+*/%&|^!=<>]=?|\?(?:\.|:)?|:/,
/\b(?:and|contains|eq|equal|eqv|gt|gte|imp|is|lt|lte|mod|not|or|xor)\b/
],
scope: {
pattern:
/\b(?:application|arguments|cgi|client|cookie|local|session|super|this|variables)\b/,
alias: 'global'
},
type: {
pattern:
/\b(?:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid|void|xml)\b/,
alias: 'builtin'
}
})
Prism.languages.insertBefore('cfscript', 'keyword', {
// This must be declared before keyword because we use "function" inside the lookahead
'function-variable': {
pattern:
/[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
alias: 'function'
}
})
delete Prism.languages.cfscript['class-name']
Prism.languages.cfc = Prism.languages['cfscript']
}