[d24f17c] | 1 | 'use strict'
|
---|
| 2 | var refractorRuby = require('./ruby.js')
|
---|
| 3 | module.exports = crystal
|
---|
| 4 | crystal.displayName = 'crystal'
|
---|
| 5 | crystal.aliases = []
|
---|
| 6 | function crystal(Prism) {
|
---|
| 7 | Prism.register(refractorRuby)
|
---|
| 8 | ;(function (Prism) {
|
---|
| 9 | Prism.languages.crystal = Prism.languages.extend('ruby', {
|
---|
| 10 | keyword: [
|
---|
| 11 | /\b(?:__DIR__|__END_LINE__|__FILE__|__LINE__|abstract|alias|annotation|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|ptr|require|rescue|return|select|self|sizeof|struct|super|then|type|typeof|undef|uninitialized|union|unless|until|when|while|with|yield)\b/,
|
---|
| 12 | {
|
---|
| 13 | pattern: /(\.\s*)(?:is_a|responds_to)\?/,
|
---|
| 14 | lookbehind: true
|
---|
| 15 | }
|
---|
| 16 | ],
|
---|
| 17 | number:
|
---|
| 18 | /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/,
|
---|
| 19 | operator: [/->/, Prism.languages.ruby.operator],
|
---|
| 20 | punctuation: /[(){}[\].,;\\]/
|
---|
| 21 | })
|
---|
| 22 | Prism.languages.insertBefore('crystal', 'string-literal', {
|
---|
| 23 | attribute: {
|
---|
| 24 | pattern: /@\[.*?\]/,
|
---|
| 25 | inside: {
|
---|
| 26 | delimiter: {
|
---|
| 27 | pattern: /^@\[|\]$/,
|
---|
| 28 | alias: 'punctuation'
|
---|
| 29 | },
|
---|
| 30 | attribute: {
|
---|
| 31 | pattern: /^(\s*)\w+/,
|
---|
| 32 | lookbehind: true,
|
---|
| 33 | alias: 'class-name'
|
---|
| 34 | },
|
---|
| 35 | args: {
|
---|
| 36 | pattern: /\S(?:[\s\S]*\S)?/,
|
---|
| 37 | inside: Prism.languages.crystal
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | },
|
---|
| 41 | expansion: {
|
---|
| 42 | pattern: /\{(?:\{.*?\}|%.*?%)\}/,
|
---|
| 43 | inside: {
|
---|
| 44 | content: {
|
---|
| 45 | pattern: /^(\{.)[\s\S]+(?=.\}$)/,
|
---|
| 46 | lookbehind: true,
|
---|
| 47 | inside: Prism.languages.crystal
|
---|
| 48 | },
|
---|
| 49 | delimiter: {
|
---|
| 50 | pattern: /^\{[\{%]|[\}%]\}$/,
|
---|
| 51 | alias: 'operator'
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | },
|
---|
| 55 | char: {
|
---|
| 56 | pattern:
|
---|
| 57 | /'(?:[^\\\r\n]{1,2}|\\(?:.|u(?:[A-Fa-f0-9]{1,4}|\{[A-Fa-f0-9]{1,6}\})))'/,
|
---|
| 58 | greedy: true
|
---|
| 59 | }
|
---|
| 60 | })
|
---|
| 61 | })(Prism)
|
---|
| 62 | }
|
---|