[d24f17c] | 1 | 'use strict'
|
---|
| 2 | var refractorCpp = require('./cpp.js')
|
---|
| 3 | module.exports = chaiscript
|
---|
| 4 | chaiscript.displayName = 'chaiscript'
|
---|
| 5 | chaiscript.aliases = []
|
---|
| 6 | function 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 | }
|
---|