aboutsummaryrefslogtreecommitdiffstats
path: root/public/prism/prism-mel.js
blob: 7381d42de641006e0e6cbf232aed0845dfa7e116 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Prism.languages.mel = {
  comment: {
    pattern: /\/\/.*|\/\*[\s\S]*?\*\//,
    greedy: true,
  },
  code: {
    pattern: /`(?:\\.|[^\\`])*`/,
    greedy: true,
    alias: 'italic',
    inside: {
      delimiter: {
        pattern: /^`|`$/,
        alias: 'punctuation',
      },
      statement: {
        pattern: /[\s\S]+/,
        inside: null, // see below
      },
    },
  },
  string: {
    pattern: /"(?:\\.|[^\\"\r\n])*"/,
    greedy: true,
  },
  variable: /\$\w+/,
  number: /\b0x[\da-fA-F]+\b|\b\d+(?:\.\d*)?|\B\.\d+/,
  flag: {
    pattern: /-[^\d\W]\w*/,
    alias: 'operator',
  },
  keyword:
    /\b(?:break|case|continue|default|do|else|float|for|global|if|in|int|matrix|proc|return|string|switch|vector|while)\b/,
  function: {
    pattern:
      /((?:^|[{;])[ \t]*)[a-z_]\w*\b(?!\s*(?:\.(?!\.)|[[{=]))|\b[a-z_]\w*(?=[ \t]*\()/im,
    lookbehind: true,
    greedy: true,
  },

  'tensor-punctuation': {
    pattern: /<<|>>/,
    alias: 'punctuation',
  },
  operator: /\+[+=]?|-[-=]?|&&|\|\||[<>]=?|[*\/!=]=?|[%^]/,
  punctuation: /[.,:;?\[\](){}]/,
};

Prism.languages.mel['code'].inside['statement'].inside = Prism.languages.mel;