summaryrefslogtreecommitdiffstats
path: root/public/prism/prism-go.js
blob: 213ac7b2129b51cd0f23441ad06634254c87248c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Prism.languages.go = Prism.languages.extend('clike', {
  string: {
    pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
    lookbehind: true,
    greedy: true,
  },
  keyword:
    /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
  boolean: /\b(?:_|false|iota|nil|true)\b/,
  number: [
    // binary and octal integers
    /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
    // hexadecimal integers and floats
    /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
    // decimal integers and floats
    /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i,
  ],
  operator:
    /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  builtin:
    /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/,
});

Prism.languages.insertBefore('go', 'string', {
  char: {
    pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
    greedy: true,
  },
});

delete Prism.languages.go['class-name'];
/\$F:[-\w.]+\?[-\w.]+(?:,(?:(?:@[-#]*\w+\.[\w+.]\.*)*\|)*(?:(?:[\w+]|[-#*.~^]+[\w+]|=\S)(?:[^$=]|=+[^=])*=*|(?:@[-#]*\w+\.[\w+.]\.*)+(?:(?:[\w+]|[-#*~^][-#*.~^]*[\w+]|=\S)(?:[^$=]|=+[^=])*=*)?)?)?\$/, inside: { variable: { pattern: /(?:[,|])@?(?:#+|[-+*~=^])?[\w.]+/, inside: { punctuation: { pattern: /[,.|]/ }, operator: { pattern: /#+|[-+*~=^@]/ }, }, }, punctuation: { pattern: /\$\w:|[$:?.,|]/ }, }, alias: 'function', }, 'function-block': { pattern: /\$XF:\{[-\w.]+\?[-\w.]+(?:,(?:(?:@[-#]*\w+\.[\w+.]\.*)*\|)*(?:(?:[\w+]|[-#*.~^]+[\w+]|=\S)(?:[^$=]|=+[^=])*=*|(?:@[-#]*\w+\.[\w+.]\.*)+(?:(?:[\w+]|[-#*~^][-#*.~^]*[\w+]|=\S)(?:[^$=]|=+[^=])*=*)?)?)?\}:XF\$/, inside: { punctuation: { pattern: /[$:{}?.,|]/ } }, alias: 'function', }, 'directive-inline': { pattern: /\$\w(?:#\d+\+?)?(?:\[[-\w.]+\])?:[-\/\w.]+\$/, inside: { punctuation: { pattern: /\$(?:\w:|C(?:\[|#\d))?|[:{[\]]/, inside: { tag: { pattern: /#\d/ } }, }, }, alias: 'function', }, 'directive-block-open': { pattern: /\$\w+:\{|\$\w(?:#\d+\+?)?(?:\[[-\w.]+\])?:[-\w.]+:\{(?:![A-Z]+)?/, inside: { punctuation: { pattern: /\$(?:\w:|C(?:\[|#\d))?|[:{[\]]/, inside: { tag: { pattern: /#\d/ } }, }, attribute: { pattern: /![A-Z]+$/, inside: { punctuation: { pattern: /!/ } }, alias: 'keyword', }, }, alias: 'function', }, 'directive-block-separator': { pattern: /\}:[-\w.]+:\{/, inside: { punctuation: { pattern: /[:{}]/ } }, alias: 'function', }, 'directive-block-close': { pattern: /\}:[-\w.]+\$/, inside: { punctuation: { pattern: /[:{}$]/ } }, alias: 'function', }, })), n.languages.insertBefore( 'inside', 'punctuation', { variable: n.languages.xeora['function-inline'].inside.variable }, n.languages.xeora['function-block'] ), (n.languages.xeoracube = n.languages.xeora); })(Prism);