source: node_modules/refractor/lang/chaiscript.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1'use strict'
2var refractorCpp = require('./cpp.js')
3module.exports = chaiscript
4chaiscript.displayName = 'chaiscript'
5chaiscript.aliases = []
6function chaiscript(Prism) {
7 Prism.register(refractorCpp)
8 Prism.languages.chaiscript = Prism.languages.extend('clike', {
9 string: {
10 pattern: /(^|[^\\])'(?:[^'\\]|\\[\s\S])*'/,
11 lookbehind: true,
12 greedy: true
13 },
14 'class-name': [
15 {
16 // e.g. class Rectangle { ... }
17 pattern: /(\bclass\s+)\w+/,
18 lookbehind: true
19 },
20 {
21 // e.g. attr Rectangle::height, def Rectangle::area() { ... }
22 pattern: /(\b(?:attr|def)\s+)\w+(?=\s*::)/,
23 lookbehind: true
24 }
25 ],
26 keyword:
27 /\b(?:attr|auto|break|case|catch|class|continue|def|default|else|finally|for|fun|global|if|return|switch|this|try|var|while)\b/,
28 number: [Prism.languages.cpp.number, /\b(?:Infinity|NaN)\b/],
29 operator:
30 />>=?|<<=?|\|\||&&|:[:=]?|--|\+\+|[=!<>+\-*/%|&^]=?|[?~]|`[^`\r\n]{1,4}`/
31 })
32 Prism.languages.insertBefore('chaiscript', 'operator', {
33 'parameter-type': {
34 // e.g. def foo(int x, Vector y) {...}
35 pattern: /([,(]\s*)\w+(?=\s+\w)/,
36 lookbehind: true,
37 alias: 'class-name'
38 }
39 })
40 Prism.languages.insertBefore('chaiscript', 'string', {
41 'string-interpolation': {
42 pattern:
43 /(^|[^\\])"(?:[^"$\\]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*"/,
44 lookbehind: true,
45 greedy: true,
46 inside: {
47 interpolation: {
48 pattern:
49 /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/,
50 lookbehind: true,
51 inside: {
52 'interpolation-expression': {
53 pattern: /(^\$\{)[\s\S]+(?=\}$)/,
54 lookbehind: true,
55 inside: Prism.languages.chaiscript
56 },
57 'interpolation-punctuation': {
58 pattern: /^\$\{|\}$/,
59 alias: 'punctuation'
60 }
61 }
62 },
63 string: /[\s\S]+/
64 }
65 }
66 })
67}
Note: See TracBrowser for help on using the repository browser.