summaryrefslogtreecommitdiffstats
path: root/public/prism/prism-rego.js
blob: 3cf05c90acd56b54aa6119d80aa982d725eacfb7 (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
// https://www.openpolicyagent.org/docs/latest/policy-reference/

Prism.languages.rego = {
  comment: /#.*/,
  property: {
    pattern:
      /(^|[^\\.])(?:"(?:\\.|[^\\"\r\n])*"|`[^`]*`|\b[a-z_]\w*\b)(?=\s*:(?!=))/i,
    lookbehind: true,
    greedy: true,
  },
  string: {
    pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"|`[^`]*`/,
    lookbehind: true,
    greedy: true,
  },

  keyword:
    /\b(?:as|default|else|import|not|null|package|set(?=\s*\()|some|with)\b/,
  boolean: /\b(?:false|true)\b/,

  function: {
    pattern: /\b[a-z_]\w*\b(?:\s*\.\s*\b[a-z_]\w*\b)*(?=\s*\()/i,
    inside: {
      namespace: /\b\w+\b(?=\s*\.)/,
      punctuation: /\./,
    },
  },

  number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
  operator: /[-+*/%|&]|[<>:=]=?|!=|\b_\b/,
  punctuation: /[,;.\[\]{}()]/,
};
eftAnti|LeftOuter|RightAnti|RightOuter)\b/, /\bGroupKind\.(?:Global|Local)\b/, /\bExtraValues\.(?:Error|Ignore|List)\b/, /\bJoinAlgorithm\.(?:Dynamic|LeftHash|LeftIndex|PairwiseHash|RightHash|RightIndex|SortMerge)\b/, /\bJoinSide\.(?:Left|Right)\b/, /\bPrecision\.(?:Decimal|Double)\b/, /\bRelativePosition\.From(?:End|Start)\b/, /\bTextEncoding\.(?:Ascii|BigEndianUnicode|Unicode|Utf16|Utf8|Windows)\b/, /\b(?:Any|Binary|Date|DateTime|DateTimeZone|Duration|Function|Int16|Int32|Int64|Int8|List|Logical|None|Number|Record|Table|Text|Time)\.Type\b/, /\bnull\b/, ], boolean: /\b(?:false|true)\b/, keyword: /\b(?:and|as|each|else|error|if|in|is|let|meta|not|nullable|optional|or|otherwise|section|shared|then|try|type)\b|#(?:binary|date|datetime|datetimezone|duration|infinity|nan|sections|shared|table|time)\b/, function: { pattern: /(^|[^#\w.])[a-z_][\w.]*(?=\s*\()/i, lookbehind: true, }, 'data-type': { pattern: /\b(?:any|anynonnull|binary|date|datetime|datetimezone|duration|function|list|logical|none|number|record|table|text|time)\b/, alias: 'class-name', }, number: { pattern: /\b0x[\da-f]+\b|(?:[+-]?(?:\b\d+\.)?\b\d+|[+-]\.\d+|(^|[^.])\B\.\d+)(?:e[+-]?\d+)?\b/i, lookbehind: true, }, operator: /[-+*\/&?@^]|<(?:=>?|>)?|>=?|=>?|\.\.\.?/, punctuation: /[,;\[\](){}]/, }; Prism.languages.pq = Prism.languages['powerquery']; Prism.languages.mscript = Prism.languages['powerquery'];