[d24f17c] | 1 | (function (Prism) {
|
---|
| 2 | var interpolationExpr = {
|
---|
| 3 | pattern: /[\s\S]+/,
|
---|
| 4 | inside: null
|
---|
| 5 | };
|
---|
| 6 |
|
---|
| 7 | Prism.languages.v = Prism.languages.extend('clike', {
|
---|
| 8 | 'string': {
|
---|
| 9 | pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
---|
| 10 | alias: 'quoted-string',
|
---|
| 11 | greedy: true,
|
---|
| 12 | inside: {
|
---|
| 13 | 'interpolation': {
|
---|
| 14 | pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,
|
---|
| 15 | lookbehind: true,
|
---|
| 16 | inside: {
|
---|
| 17 | 'interpolation-variable': {
|
---|
| 18 | pattern: /^\$\w[\s\S]*$/,
|
---|
| 19 | alias: 'variable'
|
---|
| 20 | },
|
---|
| 21 | 'interpolation-punctuation': {
|
---|
| 22 | pattern: /^\$\{|\}$/,
|
---|
| 23 | alias: 'punctuation'
|
---|
| 24 | },
|
---|
| 25 | 'interpolation-expression': interpolationExpr
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | },
|
---|
| 30 | 'class-name': {
|
---|
| 31 | pattern: /(\b(?:enum|interface|struct|type)\s+)(?:C\.)?\w+/,
|
---|
| 32 | lookbehind: true
|
---|
| 33 | },
|
---|
| 34 | 'keyword': /(?:\b(?:__global|as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:else|for|if)|#(?:flag|include))\b/,
|
---|
| 35 | 'number': /\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,
|
---|
| 36 | 'operator': /~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/,
|
---|
| 37 | 'builtin': /\b(?:any(?:_float|_int)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|64|128|nt)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/
|
---|
| 38 | });
|
---|
| 39 |
|
---|
| 40 | interpolationExpr.inside = Prism.languages.v;
|
---|
| 41 |
|
---|
| 42 | Prism.languages.insertBefore('v', 'string', {
|
---|
| 43 | 'char': {
|
---|
| 44 | pattern: /`(?:\\`|\\?[^`]{1,2})`/, // using {1,2} instead of `u` flag for compatibility
|
---|
| 45 | alias: 'rune'
|
---|
| 46 | }
|
---|
| 47 | });
|
---|
| 48 |
|
---|
| 49 | Prism.languages.insertBefore('v', 'operator', {
|
---|
| 50 | 'attribute': {
|
---|
| 51 | pattern: /(^[\t ]*)\[(?:deprecated|direct_array_access|flag|inline|live|ref_only|typedef|unsafe_fn|windows_stdcall)\]/m,
|
---|
| 52 | lookbehind: true,
|
---|
| 53 | alias: 'annotation',
|
---|
| 54 | inside: {
|
---|
| 55 | 'punctuation': /[\[\]]/,
|
---|
| 56 | 'keyword': /\w+/
|
---|
| 57 | }
|
---|
| 58 | },
|
---|
| 59 | 'generic': {
|
---|
| 60 | pattern: /<\w+>(?=\s*[\)\{])/,
|
---|
| 61 | inside: {
|
---|
| 62 | 'punctuation': /[<>]/,
|
---|
| 63 | 'class-name': /\w+/
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | });
|
---|
| 67 |
|
---|
| 68 | Prism.languages.insertBefore('v', 'function', {
|
---|
| 69 | 'generic-function': {
|
---|
| 70 | // e.g. foo<T>( ...
|
---|
| 71 | pattern: /\b\w+\s*<\w+>(?=\()/,
|
---|
| 72 | inside: {
|
---|
| 73 | 'function': /^\w+/,
|
---|
| 74 | 'generic': {
|
---|
| 75 | pattern: /<\w+>/,
|
---|
| 76 | inside: Prism.languages.v.generic.inside
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 | });
|
---|
| 81 | }(Prism));
|
---|