Prism.languages.qore = Prism.languages.extend('clike', { comment: { pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:\/\/|#).*)/, lookbehind: true, }, // Overridden to allow unescaped multi-line strings string: { pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/, greedy: true, }, keyword: /\b(?:abstract|any|assert|binary|bool|boolean|break|byte|case|catch|char|class|code|const|continue|data|default|do|double|else|enum|extends|final|finally|float|for|goto|hash|if|implements|import|inherits|instanceof|int|interface|long|my|native|new|nothing|null|object|our|own|private|reference|rethrow|return|short|soft(?:bool|date|float|int|list|number|string)|static|strictfp|string|sub|super|switch|synchronized|this|throw|throws|transient|try|void|volatile|while)\b/, boolean: /\b(?:false|true)\b/i, function: /\$?\b(?!\d)\w+(?=\()/, number: /\b(?:0b[01]+|0x(?:[\da-f]*\.)?[\da-fp\-]+|(?:\d+(?:\.\d+)?|\.\d+)(?:e\d+)?[df]|(?:\d+(?:\.\d+)?|\.\d+))\b/i, operator: { pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|[!=](?:==?|~)?|>>?=?|<(?:=>?|<=?)?|&[&=]?|\|[|=]?|[*\/%^]=?|[~?])/, lookbehind: true, }, variable: /\$(?!\d)\w+\b/, }); he frontend of my personal website.Armand Philippot
summaryrefslogtreecommitdiffstats
path: root/public/prism/prism-dhall.js
blob: 102a5bdc616364b32d6ccb4365dce2ed6e650e6c (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ABNF grammar:
// https://github.com/dhall-lang/dhall-lang/blob/master/standard/dhall.abnf

Prism.languages.dhall = {
  // Multi-line comments can be nested. E.g. {- foo {- bar -} -}
  // The multi-line pattern is essentially this:
  //   \{-(?:[^-{]|-(?!\})|\{(?!-)|<SELF>)*-\}
  comment:
    /--.*|\{-(?:[^-{]|-(?!\})|\{(?!-)|\{-(?:[^-{]|-(?!\})|\{(?!-))*-\})*-\}/,
  string: {
    pattern: /"(?:[^"\\]|\\.)*"|''(?:[^']|'(?!')|'''|''\$\{)*''(?!'|\$)/,
    greedy: true,
    inside: {
      interpolation: {
        pattern: /\$\{[^{}]*\}/,
        inside: {
          expression: {
            pattern: /(^\$\{)[\s\S]+(?=\}$)/,
            lookbehind: true,
            alias: 'language-dhall',
            inside: null, // see blow
          },
          punctuation: /\$\{|\}/,
        },
      },
    },
  },
  label: {
    pattern: /`[^`]*`/,
    greedy: true,
  },
  url: {
    // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L596
    pattern:
      /\bhttps?:\/\/[\w.:%!$&'*+;=@~-]+(?:\/[\w.:%!$&'*+;=@~-]*)*(?:\?[/?\w.:%!$&'*+;=@~-]*)?/,
    greedy: true,
  },
  env: {
    // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L661
    pattern: /\benv:(?:(?!\d)\w+|"(?:[^"\\=]|\\.)*")/,
    greedy: true,
    inside: {
      function: /^env/,
      operator: /^:/,
      variable: /[\s\S]+/,
    },
  },
  hash: {
    // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L725
    pattern: /\bsha256:[\da-fA-F]{64}\b/,
    inside: {
      function: /sha256/,
      operator: /:/,
      number: /[\da-fA-F]{64}/,
    },
  },

  // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L359
  keyword:
    /\b(?:as|assert|else|forall|if|in|let|merge|missing|then|toMap|using|with)\b|\u2200/,
  builtin: /\b(?:None|Some)\b/,

  boolean: /\b(?:False|True)\b/,
  number:
    /\bNaN\b|-?\bInfinity\b|[+-]?\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/,
  operator:
    /\/\\|\/\/\\\\|&&|\|\||===|[!=]=|\/\/|->|\+\+|::|[+*#@=:?<>|\\\u2227\u2a53\u2261\u2afd\u03bb\u2192]/,
  punctuation: /\.\.|[{}\[\](),./]/,

  // we'll just assume that every capital word left is a type name
  'class-name': /\b[A-Z]\w*\b/,
};

Prism.languages.dhall.string.inside.interpolation.inside.expression.inside =
  Prism.languages.dhall;