|
44 | 44 | ;; ------------------------------------------------------------------- |
45 | 45 |
|
46 | 46 | [ |
47 | | - "module" |
48 | | - "import" |
49 | | - "assert" |
50 | | - "class" |
51 | | - "datatype" |
52 | | - "dimension" |
53 | | - "entity" |
54 | | - "enum" |
55 | | - "event" |
56 | | - "property" |
57 | | - "rdf" |
58 | | - "structure" |
59 | | - "union" |
60 | 47 | "is" |
61 | 48 | "of" |
62 | 49 | "end" |
63 | | - ] @keyword |
| 50 | + ] @keyword |
64 | 51 |
|
65 | 52 | ;; ------------------------------------------------------------------- |
66 | 53 | ;; Operators |
67 | 54 | ;; ------------------------------------------------------------------- |
68 | 55 |
|
69 | 56 | [ |
70 | 57 | "=" |
71 | | - ":=" |
72 | | - "≔" |
73 | | - "¬" |
74 | | - "∧" |
75 | | - "∨" |
76 | | - "⊻" |
77 | | - "==>" |
78 | | - "⇒" |
79 | | - "<==>" |
80 | | - "⇔" |
81 | | - "∀" |
82 | | - "∃" |
83 | | - "∈" |
84 | 58 | "->" |
85 | 59 | "→" |
86 | 60 | "<-" |
|
92 | 66 | ;; Module & Imports (Note module => type; definition => scope) |
93 | 67 | ;; ------------------------------------------------------------------- |
94 | 68 |
|
95 | | - (module name: (identifier) @module.definition) |
| 69 | + (module "module" @keyword name: (identifier) @module.definition) |
96 | 70 | (module "version" @keyword) |
97 | 71 |
|
| 72 | + (from_clause "from" @keyword) |
| 73 | + |
| 74 | + (module_path_root_only "::" @punctuation.separator) |
| 75 | + (module_path_relative "::" @punctuation.separator) |
| 76 | + (module_path_relative segment: (identifier) @module.special) |
| 77 | + (module_path_absolute "::" @punctuation.separator |
| 78 | + segment: (identifier) @module.special) |
| 79 | + |
| 80 | + (import_statement "import" @keyword) |
98 | 81 | (import_statement [ "[" "]" ] @punctuation.bracket) |
99 | 82 |
|
100 | 83 | (member_import name: (qualified_identifier) @type) |
101 | | - (member_import "as" @keyword) |
102 | | - (member_import rename: (identifier) @type) |
| 84 | + (member_import "as" @keyword rename: (identifier) @type) |
103 | 85 |
|
104 | 86 | (module_import name: (identifier) @module) |
105 | | - (module_import "as" @keyword) |
106 | | - (module_import rename: (identifier) @module) |
| 87 | + (module_import "as" @keyword rename: (identifier) @module) |
107 | 88 |
|
108 | 89 | ;; ------------------------------------------------------------------- |
109 | 90 | ;; Annotations and Constraints (Note property => label) |
|
115 | 96 |
|
116 | 97 | (annotation_property value: (value (identifier_reference) @type)) |
117 | 98 |
|
118 | | - (constraint name: (identifier) @label) |
| 99 | + (constraint "assert" @keyword name: (identifier) @label) |
119 | 100 |
|
120 | 101 | (informal_constraint (quoted_string) @embedded) |
121 | | - (informal_constraint language: (controlled_language_tag) @property) |
| 102 | + (informal_constraint language: (controlled_language_tag) @label) |
122 | 103 |
|
123 | | - (constraint_environment (constraint_environment_end) @keyword) |
| 104 | + (constraint_environment "with" @keyword) |
124 | 105 |
|
125 | | - (environment_def "def" @keyword) |
126 | | - (environment_def (identifier) @function.definition \. (function_def)) |
127 | | - (environment_def (identifier) @constant \. (constant_def)) |
| 106 | + (function_def |
| 107 | + (function_signature name: (identifier) @function.definition)) |
128 | 108 |
|
| 109 | + (function_signature "def" @keyword) |
129 | 110 | (function_signature target: (_) @type) |
130 | 111 | (function_signature [ "(" ")" ] @punctuation.bracket) |
131 | 112 |
|
|
136 | 117 | (function_cardinality_expression (sequence_uniqueness) @keyword) |
137 | 118 | (function_cardinality_expression [ "{" "}" ] @punctuation.bracket) |
138 | 119 |
|
| 120 | + (function_body (function_op_by_definition) @operator) |
| 121 | + |
139 | 122 | (function_composition subject: (reserved_self) @variable.builtin) |
140 | 123 | (function_composition name: (identifier) @function.call) |
141 | | - (function_composition "." @punctuation.delimiter) |
| 124 | + (function_composition [ "·" "." ] @operator) |
142 | 125 |
|
143 | 126 | (constraint_sentence [ "(" ")" ] @punctuation.bracket) |
144 | 127 |
|
|
157 | 140 |
|
158 | 141 | (quantified_sentence "," @punctuation.separator) |
159 | 142 |
|
160 | | - (quantified_variable source: (reserved_self) @variable.builtin) |
161 | | - (quantified_variable name: (identifier) @variable.parameter) |
162 | | - (quantified_variable "in" @keyword) |
| 143 | + (variable (identifier) @variable) |
163 | 144 |
|
164 | 145 | (functional_term |
165 | 146 | function: (term (identifier_reference) @function.call)) |
166 | 147 |
|
167 | 148 | (sequence_builder [ "{" "}" ] @punctuation.bracket |
168 | | - "|" @punctuation.separator) |
169 | | - |
170 | | - (named_variable_set (identifier) @variable) |
171 | | - |
172 | | - (mapping_variable |
173 | | - domain: (identifier) @variable range: (identifier) @variable) |
174 | | - |
175 | | - (sequence_builder_body [ "(" ")" ] @punctuation.bracket) |
| 149 | + (set_op_builder) @punctuation.separator) |
176 | 150 |
|
| 151 | + (sequence_of_predicate_values [ "{" "}" ] @punctuation.bracket) |
| 152 | + (sequence_of_predicate_values (sequence_ordering) @keyword) |
| 153 | + (sequence_of_predicate_values (sequence_uniqueness) @keyword) |
| 154 | + (sequence_of_predicate_values [ "[" "]" ] @punctuation.bracket) |
177 | 155 | (sequence_of_predicate_values (identifier_reference) @type) |
178 | | - (sequence_of_predicate_values [ "[" "]" ] @punctuation.bracket) |
179 | | - |
180 | | - (negation "not" @keyword) |
181 | | - (conjunction "and" @keyword) |
182 | | - (disjunction "or" @keyword) |
183 | | - (exclusive_disjunction "xor" @keyword) |
184 | | - (implication "implies" @keyword) |
185 | | - (biconditional "iff" @keyword) |
186 | 156 |
|
187 | | - (universal "forall" @keyword) |
188 | | - (existential "exists" @keyword) |
| 157 | + (unary_boolean_sentence |
| 158 | + [ (logical_op_negation "¬" @operator) |
| 159 | + (logical_op_negation "not" @keyword) ]) |
| 160 | + |
| 161 | + (binary_boolean_sentence |
| 162 | + [ (logical_op_conjunction "∧" @operator) |
| 163 | + (logical_op_conjunction "and" @keyword) |
| 164 | + (logical_op_disjunction "∨" @operator) |
| 165 | + (logical_op_disjunction "or" @keyword) |
| 166 | + (logical_op_exclusive_disjunction "⊻" @operator) |
| 167 | + (logical_op_exclusive_disjunction "xor" @keyword) |
| 168 | + (logical_op_implication [ "==>" "⇒" ] @operator) |
| 169 | + (logical_op_implication "implies" @keyword) |
| 170 | + (logical_op_biconditional [ "<==>" "⇔" ] @operator) |
| 171 | + (logical_op_biconditional "iff" @keyword) ]) |
| 172 | + |
| 173 | + (quantified_variable_binding |
| 174 | + [ (logical_quantifier_universal "∀" @operator) |
| 175 | + (logical_quantifier_universal "forall" @keyword) |
| 176 | + (logical_quantifier_existential "∃" @operator) |
| 177 | + (logical_quantifier_existential "exists" @keyword) ]) |
| 178 | + |
| 179 | + (quantified_variable |
| 180 | + [ (set_op_membership "∈" @operator) |
| 181 | + (set_op_membership "in" @keyword) ]) |
189 | 182 |
|
190 | 183 | ;; ------------------------------------------------------------------- |
191 | 184 | ;; Types |
|
196 | 189 | (unknown_type) |
197 | 190 | ] @type.builtin |
198 | 191 |
|
199 | | - (data_type_def name: (identifier) @type.definition) |
| 192 | + (data_type_def |
| 193 | + "datatype" @keyword |
| 194 | + name: (identifier) @type.definition) |
200 | 195 | (data_type_def base: (identifier_reference) @type) |
| 196 | + (data_type_def base: (builtin_simple_type) @type.builtin) |
201 | 197 | (data_type_def opaque: (opaque) @keyword) |
202 | 198 |
|
203 | | - (dimension_def name: (identifier) @type.definition) |
| 199 | + (datatype_def_restriction [ "{" "}" ] @punctuation.bracket) |
| 200 | + (length_restriction_facet |
| 201 | + [ "length" |
| 202 | + "maxLength" |
| 203 | + "minLength" ] @property |
| 204 | + "=" @operator) |
| 205 | + (digit_restriction_facet |
| 206 | + [ "fractionDigits" |
| 207 | + "totalDigits" ] @property |
| 208 | + "=" @operator) |
| 209 | + (value_restriction_facet |
| 210 | + [ "maxExclusive" |
| 211 | + "maxInclusive" |
| 212 | + "minExclusive" |
| 213 | + "minInclusive" ] @property |
| 214 | + "=" @operator) |
| 215 | + (tz_restriction_facet |
| 216 | + "explicitTimezone" @property |
| 217 | + "=" @operator) |
| 218 | + (pattern_restriction_facet [ "[" "]" ] @punctuation.bracket) |
| 219 | + (pattern_restriction_facet |
| 220 | + "pattern" @property |
| 221 | + "=" @operator |
| 222 | + (quoted_string) @string) |
204 | 223 |
|
205 | | - (entity_def name: (identifier) @type.definition) |
| 224 | + (kw_is_fixed) @keyword |
206 | 225 |
|
207 | | - (enum_def name: (identifier) @type.definition) |
| 226 | + (tz_restriction_value) @keyword |
208 | 227 |
|
209 | | - (event_def name: (identifier) @type.definition) |
| 228 | + (dimension_def "dimension" @keyword name: (identifier) @type.definition) |
210 | 229 |
|
211 | | - (structure_def name: (identifier) @type.definition) |
| 230 | + (entity_def "entity" @keyword name: (identifier) @type.definition) |
212 | 231 |
|
213 | | - (union_def name: (identifier) @type.definition) |
| 232 | + (enum_def "enum" @keyword name: (identifier) @type.definition) |
| 233 | + |
| 234 | + (event_def "event" @keyword name: (identifier) @type.definition) |
| 235 | + |
| 236 | + (property_def "property" @keyword) |
| 237 | + |
| 238 | + (structure_def "structure" @keyword name: (identifier) @type.definition) |
| 239 | + |
| 240 | + (union_def "union" @keyword name: (identifier) @type.definition) |
214 | 241 |
|
215 | 242 | (source_entity "source" @keyword entity: (identifier_reference) @type) |
216 | 243 | (source_entity "with" @keyword) |
| 244 | + (source_entity [ "[" "]" ] @punctuation.bracket) |
217 | 245 | (source_entity member: (identifier) @variable.field) |
218 | 246 |
|
219 | 247 | ;; ------------------------------------------------------------------- |
220 | 248 | ;; RDF Definitions |
221 | 249 | ;; ------------------------------------------------------------------- |
222 | 250 |
|
223 | | - (rdf_def name: (identifier) @type.definition) |
| 251 | + (rdf_def "rdf" @keyword name: (identifier) @type.definition) |
224 | 252 | (rdf_types "type" @keyword type: (identifier_reference) @type) |
225 | 253 | (rdf_types [ "[" "]" ] @punctuation.bracket) |
226 | 254 |
|
227 | 255 | ;; ------------------------------------------------------------------- |
228 | 256 | ;; Type Classes |
229 | 257 | ;; ------------------------------------------------------------------- |
230 | 258 |
|
231 | | - (type_class_def name: (identifier) @type.definition) |
| 259 | + (type_class_def "class" @keyword name: (identifier) @type.definition) |
232 | 260 | (type_class_def [ "(" ")" ] @punctuation.bracket) |
233 | 261 |
|
234 | 262 | (type_variable name: (identifier) @type) |
235 | | - (type_variable "+" @operator) |
| 263 | + (type_variable (type_op_combiner) @operator) |
236 | 264 |
|
237 | 265 | (type_class_reference name: (identifier_reference) @type) |
238 | 266 |
|
239 | 267 | (type_class_arguments [ "(" ")" ] @punctuation.bracket) |
240 | 268 |
|
241 | | - (method_def "def" @keyword) |
242 | | - (method_def name: (identifier) @method.definition) |
| 269 | + (method_def |
| 270 | + (function_signature name: (identifier) @method.definition)) |
243 | 271 |
|
244 | 272 | (wildcard) @type.builtin |
245 | 273 |
|
|
265 | 293 | (value_variant name: (identifier) @constant) |
266 | 294 |
|
267 | 295 | (type_variant (identifier_reference) @type) |
268 | | - (type_variant rename: (identifier) @type) |
269 | | - (type_variant "as" @keyword) |
| 296 | + (type_variant "as" @keyword rename: (identifier) @type) |
270 | 297 |
|
271 | 298 | (cardinality_expression ordering: (sequence_ordering) @keyword) |
272 | 299 | (cardinality_expression uniqueness: (sequence_uniqueness) @keyword) |
|
284 | 311 | (binary) @string.special |
285 | 312 |
|
286 | 313 | [ |
| 314 | + (rational) |
287 | 315 | (decimal) |
288 | 316 | (double) |
289 | 317 | (integer) |
|
297 | 325 |
|
298 | 326 | (value (identifier_reference) @type) |
299 | 327 |
|
300 | | - (sequence_of_values (identifier_reference) @type) |
| 328 | + (sequence_of_values [ "{" "}" ] @punctuation.bracket) |
| 329 | + (sequence_of_values (sequence_ordering) @keyword) |
| 330 | + (sequence_of_values (sequence_uniqueness) @keyword) |
301 | 331 | (sequence_of_values [ "[" "]" ] @punctuation.bracket) |
| 332 | + (sequence_of_values (identifier_reference) @type) |
302 | 333 |
|
303 | 334 | ;; ------------------------------------------------------------------- |
304 | 335 | ;; Errors |
|
0 commit comments