[d24f17c] | 1 | Prism.languages.rescript = {
|
---|
| 2 | 'comment': {
|
---|
| 3 | pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
---|
| 4 | greedy: true
|
---|
| 5 | },
|
---|
| 6 | 'char': { pattern: /'(?:[^\r\n\\]|\\(?:.|\w+))'/, greedy: true },
|
---|
| 7 | 'string': {
|
---|
| 8 | pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
|
---|
| 9 | greedy: true
|
---|
| 10 | },
|
---|
| 11 | 'class-name': /\b[A-Z]\w*|@[a-z.]*|#[A-Za-z]\w*|#\d/,
|
---|
| 12 | 'function': {
|
---|
| 13 | pattern: /[a-zA-Z]\w*(?=\()|(\.)[a-z]\w*/,
|
---|
| 14 | lookbehind: true,
|
---|
| 15 | },
|
---|
| 16 | 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
---|
| 17 | 'boolean': /\b(?:false|true)\b/,
|
---|
| 18 | 'attr-value': /[A-Za-z]\w*(?==)/,
|
---|
| 19 | 'constant': {
|
---|
| 20 | pattern: /(\btype\s+)[a-z]\w*/,
|
---|
| 21 | lookbehind: true
|
---|
| 22 | },
|
---|
| 23 | 'tag': {
|
---|
| 24 | pattern: /(<)[a-z]\w*|(?:<\/)[a-z]\w*/,
|
---|
| 25 | lookbehind: true,
|
---|
| 26 | inside: {
|
---|
| 27 | 'operator': /<|>|\//,
|
---|
| 28 | },
|
---|
| 29 | },
|
---|
| 30 | 'keyword': /\b(?:and|as|assert|begin|bool|class|constraint|do|done|downto|else|end|exception|external|float|for|fun|function|if|in|include|inherit|initializer|int|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|string|switch|then|to|try|type|when|while|with)\b/,
|
---|
| 31 | 'operator': /\.{3}|:[:=]?|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/,
|
---|
| 32 | 'punctuation': /[(){}[\],;.]/
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | Prism.languages.insertBefore('rescript', 'string', {
|
---|
| 36 | 'template-string': {
|
---|
| 37 | pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
---|
| 38 | greedy: true,
|
---|
| 39 | inside: {
|
---|
| 40 | 'template-punctuation': {
|
---|
| 41 | pattern: /^`|`$/,
|
---|
| 42 | alias: 'string'
|
---|
| 43 | },
|
---|
| 44 | 'interpolation': {
|
---|
| 45 | pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
---|
| 46 | lookbehind: true,
|
---|
| 47 | inside: {
|
---|
| 48 | 'interpolation-punctuation': {
|
---|
| 49 | pattern: /^\$\{|\}$/,
|
---|
| 50 | alias: 'tag'
|
---|
| 51 | },
|
---|
| 52 | rest: Prism.languages.rescript
|
---|
| 53 | }
|
---|
| 54 | },
|
---|
| 55 | 'string': /[\s\S]+/
|
---|
| 56 | }
|
---|
| 57 | },
|
---|
| 58 | });
|
---|
| 59 |
|
---|
| 60 | Prism.languages.res = Prism.languages.rescript;
|
---|