UNPKG

1.59 kBJavaScriptView Raw
1Prism.languages.chaiscript = Prism.languages.extend('clike', {
2 'string': {
3 pattern: /(^|[^\\])'(?:[^'\\]|\\[\s\S])*'/,
4 lookbehind: true,
5 greedy: true
6 },
7 'class-name': [
8 {
9 // e.g. class Rectangle { ... }
10 pattern: /(\bclass\s+)\w+/,
11 lookbehind: true
12 },
13 {
14 // e.g. attr Rectangle::height, def Rectangle::area() { ... }
15 pattern: /(\b(?:attr|def)\s+)\w+(?=\s*::)/,
16 lookbehind: true
17 }
18 ],
19 'keyword': /\b(?:attr|auto|break|case|catch|class|continue|def|default|else|finally|for|fun|global|if|return|switch|this|try|var|while)\b/,
20 'number': [
21 Prism.languages.cpp.number,
22 /\b(?:Infinity|NaN)\b/
23 ],
24 'operator': />>=?|<<=?|\|\||&&|:[:=]?|--|\+\+|[=!<>+\-*/%|&^]=?|[?~]|`[^`\r\n]{1,4}`/,
25});
26
27Prism.languages.insertBefore('chaiscript', 'operator', {
28 'parameter-type': {
29 // e.g. def foo(int x, Vector y) {...}
30 pattern: /([,(]\s*)\w+(?=\s+\w)/,
31 lookbehind: true,
32 alias: 'class-name'
33 },
34});
35
36Prism.languages.insertBefore('chaiscript', 'string', {
37 'string-interpolation': {
38 pattern: /(^|[^\\])"(?:[^"$\\]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*"/,
39 lookbehind: true,
40 greedy: true,
41 inside: {
42 'interpolation': {
43 pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/,
44 lookbehind: true,
45 inside: {
46 'interpolation-expression': {
47 pattern: /(^\$\{)[\s\S]+(?=\}$)/,
48 lookbehind: true,
49 inside: Prism.languages.chaiscript
50 },
51 'interpolation-punctuation': {
52 pattern: /^\$\{|\}$/,
53 alias: 'punctuation'
54 }
55 }
56 },
57 'string': /[\s\S]+/
58 }
59 },
60});