[d24f17c] | 1 | 'use strict'
|
---|
| 2 | var refractorScheme = require('./scheme.js')
|
---|
| 3 | module.exports = lilypond
|
---|
| 4 | lilypond.displayName = 'lilypond'
|
---|
| 5 | lilypond.aliases = []
|
---|
| 6 | function lilypond(Prism) {
|
---|
| 7 | Prism.register(refractorScheme)
|
---|
| 8 | ;(function (Prism) {
|
---|
| 9 | var schemeExpression =
|
---|
| 10 | /\((?:[^();"#\\]|\\[\s\S]|;.*(?!.)|"(?:[^"\\]|\\.)*"|#(?:\{(?:(?!#\})[\s\S])*#\}|[^{])|<expr>)*\)/
|
---|
| 11 | .source // allow for up to pow(2, recursivenessLog2) many levels of recursive brace expressions
|
---|
| 12 | // For some reason, this can't be 4
|
---|
| 13 | var recursivenessLog2 = 5
|
---|
| 14 | for (var i = 0; i < recursivenessLog2; i++) {
|
---|
| 15 | schemeExpression = schemeExpression.replace(/<expr>/g, function () {
|
---|
| 16 | return schemeExpression
|
---|
| 17 | })
|
---|
| 18 | }
|
---|
| 19 | schemeExpression = schemeExpression.replace(/<expr>/g, /[^\s\S]/.source)
|
---|
| 20 | var lilypond = (Prism.languages.lilypond = {
|
---|
| 21 | comment: /%(?:(?!\{).*|\{[\s\S]*?%\})/,
|
---|
| 22 | 'embedded-scheme': {
|
---|
| 23 | pattern: RegExp(
|
---|
| 24 | /(^|[=\s])#(?:"(?:[^"\\]|\\.)*"|[^\s()"]*(?:[^\s()]|<expr>))/.source.replace(
|
---|
| 25 | /<expr>/g,
|
---|
| 26 | function () {
|
---|
| 27 | return schemeExpression
|
---|
| 28 | }
|
---|
| 29 | ),
|
---|
| 30 | 'm'
|
---|
| 31 | ),
|
---|
| 32 | lookbehind: true,
|
---|
| 33 | greedy: true,
|
---|
| 34 | inside: {
|
---|
| 35 | scheme: {
|
---|
| 36 | pattern: /^(#)[\s\S]+$/,
|
---|
| 37 | lookbehind: true,
|
---|
| 38 | alias: 'language-scheme',
|
---|
| 39 | inside: {
|
---|
| 40 | 'embedded-lilypond': {
|
---|
| 41 | pattern: /#\{[\s\S]*?#\}/,
|
---|
| 42 | greedy: true,
|
---|
| 43 | inside: {
|
---|
| 44 | punctuation: /^#\{|#\}$/,
|
---|
| 45 | lilypond: {
|
---|
| 46 | pattern: /[\s\S]+/,
|
---|
| 47 | alias: 'language-lilypond',
|
---|
| 48 | inside: null // see below
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | },
|
---|
| 52 | rest: Prism.languages.scheme
|
---|
| 53 | }
|
---|
| 54 | },
|
---|
| 55 | punctuation: /#/
|
---|
| 56 | }
|
---|
| 57 | },
|
---|
| 58 | string: {
|
---|
| 59 | pattern: /"(?:[^"\\]|\\.)*"/,
|
---|
| 60 | greedy: true
|
---|
| 61 | },
|
---|
| 62 | 'class-name': {
|
---|
| 63 | pattern: /(\\new\s+)[\w-]+/,
|
---|
| 64 | lookbehind: true
|
---|
| 65 | },
|
---|
| 66 | keyword: {
|
---|
| 67 | pattern: /\\[a-z][-\w]*/i,
|
---|
| 68 | inside: {
|
---|
| 69 | punctuation: /^\\/
|
---|
| 70 | }
|
---|
| 71 | },
|
---|
| 72 | operator: /[=|]|<<|>>/,
|
---|
| 73 | punctuation: {
|
---|
| 74 | pattern:
|
---|
| 75 | /(^|[a-z\d])(?:'+|,+|[_^]?-[_^]?(?:[-+^!>._]|(?=\d))|[_^]\.?|[.!])|[{}()[\]<>^~]|\\[()[\]<>\\!]|--|__/,
|
---|
| 76 | lookbehind: true
|
---|
| 77 | },
|
---|
| 78 | number: /\b\d+(?:\/\d+)?\b/
|
---|
| 79 | })
|
---|
| 80 | lilypond['embedded-scheme'].inside['scheme'].inside[
|
---|
| 81 | 'embedded-lilypond'
|
---|
| 82 | ].inside['lilypond'].inside = lilypond
|
---|
| 83 | Prism.languages.ly = lilypond
|
---|
| 84 | })(Prism)
|
---|
| 85 | }
|
---|