aboutsummaryrefslogtreecommitdiffstats
path: root/queries/tlaplus/highlights.scm
blob: a94a91f4e6382d2761f21b9758d86041462c7494 (plain) (blame)
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
; ; Intended for consumption by nvim-treesitter 
; ; Default capture names for nvim-treesitter found here:
; ; https://github.com/nvim-treesitter/nvim-treesitter/blob/e473630fe0872cb0ed97cd7085e724aa58bc1c84/lua/nvim-treesitter/highlight.lua#L14-L104
; ; In this file, captures defined later take precedence over captures defined earlier

; Keywords
[
  "ACTION"
  "ASSUME"
  "ASSUMPTION"
  "AXIOM"
  "BY"
  "CASE"
  "CHOOSE"
  "CONSTANT"
  "CONSTANTS"
  "COROLLARY"
  "DEF"
  "DEFINE"
  "DEFS"
  "DOMAIN"
  "ELSE"
  "ENABLED"
  "EXCEPT"
  "EXTENDS"
  "HAVE"
  "HIDE"
  "IF"
  "IN"
  "INSTANCE"
  "LAMBDA"
  "LEMMA"
  "LET"
  "LOCAL"
  "MODULE"
  "NEW"
  "OBVIOUS"
  "OMITTED"
  "ONLY"
  "OTHER"
  "PICK"
  "PROOF"
  "PROPOSITION"
  "PROVE"
  "QED"
  "RECURSIVE"
  "SF_"
  "STATE"
  "SUBSET"
  "SUFFICES"
  "TAKE"
  "TEMPORAL"
  "THEN"
  "THEOREM"
  "UNCHANGED"
  "UNION"
  "USE"
  "VARIABLE"
  "VARIABLES"
  "WF_"
  "WITH"
  "WITNESS"
  (address)
  (all_map_to)
  (assign)
  (case_arrow)
  (case_box)
  (def_eq)
  (exists)
  (forall)
  (gets)
  (label_as)
  (maps_to)
  (set_in)
  (temporal_exists)
  (temporal_forall)
] @keyword

;  Pluscal keywords
[
  (pcal_algorithm_start)
  "algorithm"
  "assert"
  "await"
  "begin"
  "call"
  "define"
  "end"
  "fair"
  "goto"
  "macro"
  "or"
  "procedure"
  "process"
  "skip"
  "variable"
  "variables"
  "when"
  "with"
] @keyword
(pcal_with ("=") @keyword)
(pcal_process ("=") @keyword)
[ 
  "if" 
  "then" 
  "else" 
  "elsif"
  (pcal_end_if)
  "either"
  (pcal_end_either)
] @conditional
[ 
  "while" 
  "do" 
  (pcal_end_while) 
  "with" 
  (pcal_end_with)
] @repeat
("return") @keyword.return
("print") @function.macro


; Literals
(binary_number (format) @keyword)
(binary_number (value) @number)
(boolean) @boolean
(boolean_set) @type
(hex_number (format) @keyword)
(hex_number (value) @number)
(int_number_set) @type
(nat_number) @number
(nat_number_set) @type
(octal_number (format) @keyword)
(octal_number (value) @number)
(real_number) @number
(real_number_set) @type
(string) @string
(escape_char) @string.escape
(string_set) @type

; Namespaces
(extends (identifier_ref) @namespace)
(instance (identifier_ref) @namespace)
(module name: (identifier) @namespace)
(pcal_algorithm name: (identifier) @namespace)

; Operators, functions, and macros
(bound_infix_op symbol: (_) @operator)
(bound_nonfix_op symbol: (_) @operator)
(bound_postfix_op symbol: (_) @operator)
(bound_prefix_op symbol: (_) @operator)
((prefix_op_symbol) @operator)
((infix_op_symbol) @operator)
((postfix_op_symbol) @operator)
(function_definition name: (identifier) @function)
(module_definition name: (_) @include)
(operator_definition name: (_) @function.macro)
(pcal_macro_decl name: (identifier) @function.macro)
(pcal_macro_call name: (identifier) @function.macro)
(pcal_proc_decl name: (identifier) @function.macro)
(pcal_process name: (identifier) @function)
(recursive_declaration (identifier) @function.macro)
(recursive_declaration (operator_declaration name: (_) @function.macro))

; Constants and variables
(constant_declaration (identifier) @constant)
(constant_declaration (operator_declaration name: (_) @constant))
(pcal_var_decl (identifier) @variable)
(pcal_with (identifier) @parameter)
((".") . (identifier) @attribute)
(record_literal (identifier) @attribute)
(set_of_records (identifier) @attribute)
(variable_declaration (identifier) @variable)

; Parameters
(choose (identifier) @parameter)
(choose (tuple_of_identifiers (identifier) @parameter))
(lambda (identifier) @parameter)
(module_definition (operator_declaration name: (_) @parameter))
(module_definition parameter: (identifier) @parameter)
(operator_definition (operator_declaration name: (_) @parameter))
(operator_definition parameter: (identifier) @parameter)
(pcal_macro_decl parameter: (identifier) @parameter)
(pcal_proc_var_decl (identifier) @parameter)
(quantifier_bound (identifier) @parameter)
(quantifier_bound (tuple_of_identifiers (identifier) @parameter))
(unbounded_quantification (identifier) @parameter)

; Delimiters
[
  (langle_bracket)
  (rangle_bracket)
  (rangle_bracket_sub)
  "{"
  "}"
  "["
  "]"
  "]_"
  "("
  ")"
] @punctuation.bracket
[
  ","
  ":"
  "."
  "!"
  ";"
  (bullet_conj)
  (bullet_disj)
  (prev_func_val)
  (placeholder)
] @punctuation.delimiter

; Proofs
(assume_prove (new (identifier) @parameter))
(assume_prove (new (operator_declaration name: (_) @parameter)))
(assumption name: (identifier) @constant)
(pick_proof_step (identifier) @parameter)
(proof_step_id "<" @punctuation.bracket)
(proof_step_id (level) @label)
(proof_step_id (name) @label)
(proof_step_id ">" @punctuation.bracket)
(proof_step_ref "<" @punctuation.bracket)
(proof_step_ref (level) @label)
(proof_step_ref (name) @label)
(proof_step_ref ">" @punctuation.bracket)
(take_proof_step (identifier) @parameter)
(theorem name: (identifier) @constant)

; Comments and tags
(block_comment "(*" @comment)
(block_comment "*)" @comment)
(block_comment_text) @comment
(comment) @comment
(single_line) @comment
(_ label: (identifier) @label)
(label name: (_) @label)
(pcal_goto statement: (identifier) @label)

; Reference highlighting with the same color as declarations.
; `constant`, `operator`, and others are custom captures defined in locals.scm
((identifier_ref) @constant (#is? @constant constant))
((identifier_ref) @function (#is? @function function))
((identifier_ref) @function.macro (#is? @function.macro macro))
((identifier_ref) @include (#is? @include import))
((identifier_ref) @parameter (#is? @parameter parameter))
((identifier_ref) @variable (#is? @variable var))
((prefix_op_symbol) @constant (#is? @constant constant))
((prefix_op_symbol) @function.macro (#is? @function.macro macro))
((prefix_op_symbol) @parameter (#is? @parameter parameter))
((infix_op_symbol) @constant (#is? @constant constant))
((infix_op_symbol) @function.macro (#is? @function.macro macro))
((infix_op_symbol) @parameter (#is? @parameter parameter))
((postfix_op_symbol) @constant (#is? @constant constant))
((postfix_op_symbol) @function.macro (#is? @function.macro macro))
((postfix_op_symbol) @parameter (#is? @parameter parameter))
(bound_prefix_op symbol: (_) @constant (#is? @constant constant))
(bound_prefix_op symbol: (_) @function.macro (#is? @function.macro macro))
(bound_prefix_op symbol: (_) @parameter (#is? @parameter parameter))
(bound_infix_op symbol: (_) @constant (#is? @constant constant))
(bound_infix_op symbol: (_) @function.macro (#is? @function.macro macro))
(bound_infix_op symbol: (_) @parameter (#is? @parameter parameter))
(bound_postfix_op symbol: (_) @constant (#is? @constant constant))
(bound_postfix_op symbol: (_) @function.macro (#is? @function.macro macro))
(bound_postfix_op symbol: (_) @parameter (#is? @parameter parameter))
(bound_nonfix_op symbol: (_) @constant (#is? @constant constant))
(bound_nonfix_op symbol: (_) @function.macro (#is? @function.macro macro))
(bound_nonfix_op symbol: (_) @parameter (#is? @parameter parameter))