@@ -0,0 +1,97 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: Rego
5+file_extensions:
6+ - rego
7+scope: source.rego
8+contexts:
9+ main:
10+ - include: comment
11+ - include: keyword
12+ - include: operator
13+ - include: head
14+ - include: term
15+ comment:
16+ - match: (#).*$\n?
17+ scope: comment.line.number-sign.rego
18+ captures:
19+ 1: punctuation.definition.comment.rego
20+ call:
21+ - match: '([a-zA-Z_][a-zA-Z0-9_]*)\('
22+ scope: meta.function-call.rego
23+ captures:
24+ 1: support.function.any-method.rego
25+ constant:
26+ - match: \b(?:true|false|null)\b
27+ scope: constant.language.rego
28+ head:
29+ - match: "^([[:alpha:]_][[:alnum:]_]*)"
30+ captures:
31+ 1: entity.name.function.declaration
32+ push:
33+ - meta_scope: meta.function.rego
34+ - match: '(=|{|\n)'
35+ pop: true
36+ - include: term
37+ keyword:
38+ - match: (^|\s+)(?:(default|not|package|import|as|with|else|some))\s+
39+ scope: keyword.other.rego
40+ number:
41+ - match: |-
42+ (?x: # turn on extended mode
43+ -? # an optional minus
44+ (?:
45+ 0 # a zero
46+ | # ...or...
47+ [1-9] # a 1-9 character
48+ \d* # followed by zero or more digits
49+ )
50+ (?:
51+ (?:
52+ \. # a period
53+ \d+ # followed by one or more digits
54+ )?
55+ (?:
56+ [eE] # an e character
57+ [+-]? # followed by an option +/-
58+ \d+ # followed by one or more digits
59+ )? # make exponent optional
60+ )? # make decimal portion optional
61+ )
62+ scope: constant.numeric.rego
63+ operator:
64+ - match: \=|\!\=|>|<|<\=|>\=|\+|-|\*|%|/|\||&|:\=
65+ scope: keyword.operator.comparison.rego
66+ string:
67+ - match: '"'
68+ captures:
69+ 0: punctuation.definition.string.begin.rego
70+ push:
71+ - meta_scope: string.quoted.double.rego
72+ - match: '"'
73+ captures:
74+ 0: punctuation.definition.string.end.rego
75+ pop: true
76+ - match: |-
77+ (?x: # turn on extended mode
78+ \\ # a literal backslash
79+ (?: # ...followed by...
80+ ["\\/bfnrt] # one of these characters
81+ | # ...or...
82+ u # a u
83+ [0-9a-fA-F]{4} # and four hex digits
84+ )
85+ )
86+ scope: constant.character.escape.rego
87+ - match: \\.
88+ scope: invalid.illegal.unrecognized-string-escape.rego
89+ term:
90+ - include: constant
91+ - include: string
92+ - include: number
93+ - include: call
94+ - include: variable
95+ variable:
96+ - match: '\b[[:alpha:]_][[:alnum:]_]*\b'
97+ scope: meta.identifier.rego