[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = bicep
|
---|
| 4 | bicep.displayName = 'bicep'
|
---|
| 5 | bicep.aliases = []
|
---|
| 6 | function bicep(Prism) {
|
---|
| 7 | // based loosely upon: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage
|
---|
| 8 | Prism.languages.bicep = {
|
---|
| 9 | comment: [
|
---|
| 10 | {
|
---|
| 11 | // multiline comments eg /* ASDF */
|
---|
| 12 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
---|
| 13 | lookbehind: true,
|
---|
| 14 | greedy: true
|
---|
| 15 | },
|
---|
| 16 | {
|
---|
| 17 | // singleline comments eg // ASDF
|
---|
| 18 | pattern: /(^|[^\\:])\/\/.*/,
|
---|
| 19 | lookbehind: true,
|
---|
| 20 | greedy: true
|
---|
| 21 | }
|
---|
| 22 | ],
|
---|
| 23 | property: [
|
---|
| 24 | {
|
---|
| 25 | pattern: /([\r\n][ \t]*)[a-z_]\w*(?=[ \t]*:)/i,
|
---|
| 26 | lookbehind: true
|
---|
| 27 | },
|
---|
| 28 | {
|
---|
| 29 | pattern: /([\r\n][ \t]*)'(?:\\.|\$(?!\{)|[^'\\\r\n$])*'(?=[ \t]*:)/,
|
---|
| 30 | lookbehind: true,
|
---|
| 31 | greedy: true
|
---|
| 32 | }
|
---|
| 33 | ],
|
---|
| 34 | string: [
|
---|
| 35 | {
|
---|
| 36 | pattern: /'''[^'][\s\S]*?'''/,
|
---|
| 37 | greedy: true
|
---|
| 38 | },
|
---|
| 39 | {
|
---|
| 40 | pattern: /(^|[^\\'])'(?:\\.|\$(?!\{)|[^'\\\r\n$])*'/,
|
---|
| 41 | lookbehind: true,
|
---|
| 42 | greedy: true
|
---|
| 43 | }
|
---|
| 44 | ],
|
---|
| 45 | 'interpolated-string': {
|
---|
| 46 | pattern: /(^|[^\\'])'(?:\\.|\$(?:(?!\{)|\{[^{}\r\n]*\})|[^'\\\r\n$])*'/,
|
---|
| 47 | lookbehind: true,
|
---|
| 48 | greedy: true,
|
---|
| 49 | inside: {
|
---|
| 50 | interpolation: {
|
---|
| 51 | pattern: /\$\{[^{}\r\n]*\}/,
|
---|
| 52 | inside: {
|
---|
| 53 | expression: {
|
---|
| 54 | pattern: /(^\$\{)[\s\S]+(?=\}$)/,
|
---|
| 55 | lookbehind: true
|
---|
| 56 | },
|
---|
| 57 | punctuation: /^\$\{|\}$/
|
---|
| 58 | }
|
---|
| 59 | },
|
---|
| 60 | string: /[\s\S]+/
|
---|
| 61 | }
|
---|
| 62 | },
|
---|
| 63 | datatype: {
|
---|
| 64 | pattern: /(\b(?:output|param)\b[ \t]+\w+[ \t]+)\w+\b/,
|
---|
| 65 | lookbehind: true,
|
---|
| 66 | alias: 'class-name'
|
---|
| 67 | },
|
---|
| 68 | boolean: /\b(?:false|true)\b/,
|
---|
| 69 | // https://github.com/Azure/bicep/blob/114a3251b4e6e30082a58729f19a8cc4e374ffa6/src/textmate/bicep.tmlanguage#L184
|
---|
| 70 | keyword:
|
---|
| 71 | /\b(?:existing|for|if|in|module|null|output|param|resource|targetScope|var)\b/,
|
---|
| 72 | decorator: /@\w+\b/,
|
---|
| 73 | function: /\b[a-z_]\w*(?=[ \t]*\()/i,
|
---|
| 74 | number: /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
|
---|
| 75 | operator:
|
---|
| 76 | /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
|
---|
| 77 | punctuation: /[{}[\];(),.:]/
|
---|
| 78 | }
|
---|
| 79 | Prism.languages.bicep['interpolated-string'].inside['interpolation'].inside[
|
---|
| 80 | 'expression'
|
---|
| 81 | ].inside = Prism.languages.bicep
|
---|
| 82 | }
|
---|