-
Notifications
You must be signed in to change notification settings - Fork 0
/
Polar.sublime-syntax
188 lines (171 loc) · 4.57 KB
/
Polar.sublime-syntax
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
%YAML 1.2
---
name: Polar
scope: source.polar
file_extensions: [polar]
version: 2
contexts:
main:
- include: comment
- include: rule
- include: rule-type
- include: inline-query
- include: resource-block
- include: test-block
comment:
- match: '#.*'
scope: comment.line.number-sign.polar
rule:
- include: rule-functor
- match: \bif\b
scope: keyword.control.if.polar
push:
- include: term
- match: ;
pop: true
- match: ;
rule-functor:
- match: ([a-zA-Z_][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)*)\s*\(
captures:
1: support.function.rule
push:
- include: specializer
- match: \,
scope: punctuation.separator.sequence.list.polar
- include: term
- match: \)
pop: true
specializer:
- match: "[a-zA-Z_][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)*\\s*:\\s*([a-zA-Z_][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)*)"
captures:
1: entity.name.type.resource
rule-type:
- match: \btype\b
captures:
1: keyword.other.type-decl
push:
- meta_scope: meta.rule-type.polar
- include: rule-functor
- match: ;
pop: true
inline-query:
- match: \?=
scope: meta.inline-query.polar
captures:
1: keyword.control
push:
- include: term
- match: ;
pop: true
resource-block:
- match: ((resource|actor)\s+([a-zA-Z_][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)*)|(global))\s*\{
captures:
2: keyword.control
3: entity.name.type
4: keyword.control
push:
- meta_scope: meta.resource-block.polar
- match: ;
scope: punctuation.separator.sequence.declarations.polar
- match: \{
push:
- meta_scope: meta.relation-declaration.polar
- include: specializer
- include: comment
- match: \,
scope: punctuation.separator.sequence.dict.polar
- match: \}
pop: true
- include: term
- match: \}
pop: true
test-block:
- match: (test)\s+(\"[^\"]*\")\s*\{
captures:
1: keyword.control
2: string.quoted.double
push:
- meta_scope: meta.test-block.polar
- match: (setup)\s*\{
captures:
1: keyword.control
push:
- meta_scope: meta.test-setup.polar
- include: rule
- include: comment
- match: \}
pop: true
- include: rule
- match: \b(assert|assert_not)\b
scope: keyword.other.polar
- include: comment
- match: \}
pop: true
term:
- include: comment
- include: string
- include: number
- include: keyword
- include: operator
- include: boolean
- include: object-literal
- match: \[
push:
- meta_scope: meta.bracket.list.polar
- include: term
- match: \,
scope: punctuation.separator.sequence.list.polar
- match: \]
pop: true
- match: \{
push:
- meta_scope: meta.bracket.dict.polar
- include: term
- match: \,
scope: punctuation.separator.sequence.dict.polar
- match: \}
pop: true
- match: \(
push:
- meta_scope: meta.parens.polar
- include: term
- match: \,
scope: punctuation.separator.sequence.list.polar
- match: \)
pop: true
string:
- match: '"'
push:
- meta_scope: string.quoted.double.polar
- match: \\.
scope: constant.character.escape.polar
- match: '"'
pop: true
number:
- match: \b[+-]?\d+(?:(\.)\d+(?:e[+-]?\d+)?|(?:e[+-]?\d+))\b
scope: constant.numeric.float.polar
- match: \b(\+|\-)[\d]+\b
scope: constant.numeric.integer.polar
- match: \b[\d]+\b
scope: constant.numeric.natural.polar
boolean:
- match: \b(true|false)\b
scope: constant.language.boolean.polar
keyword:
- match: \b(cut|or|debug|print|in|forall|if|and|of|not|matches|type|on|global)\b
scope: constant.character.polar
operator:
- match: (\+|\-|\*|\/|<|>|=|!)
scope: keyword.control.polar
object-literal:
- match: ([a-zA-Z_][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)*)\s*\{
captures:
0: constant.other.object-literal
1: entity.name.type.resource
push:
- include: string
- include: number
- include: boolean
- match: \}
scope: constant.other.object-literal.polar
pop: true