Debian Codegraph @

runtime/queries/ocaml/highlights.scm

raw symbols SCIP
1 ; Punctuation
2 ;------------
3
4 "%" @punctuation.special
5
6 ["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>" "[:" ":]"] @punctuation.bracket
7
8 [
9 "," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
10 "->" ";;" ":>" "+=" ":=" ".."
11 ] @punctuation.delimiter
12
13 (object_type ["<" ">"] @punctuation.bracket)
14
15 (attribute ["[@" "]"] @punctuation.special)
16 (item_attribute ["[@@" "]"] @punctuation.special)
17 (floating_attribute ["[@@@" "]"] @punctuation.special)
18 (extension ["[%" "]"] @punctuation.special)
19 (item_extension ["[%%" "]"] @punctuation.special)
20 (quoted_extension ["{%" "}"] @punctuation.special)
21 (quoted_item_extension ["{%%" "}"] @punctuation.special)
22
23 ; Modules
24 ;--------
25
26 [(module_name) (module_type_name)] @namespace
27
28 ; Types
29 ;------
30
31 (
32 (type_constructor) @type.builtin
33 (#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$")
34 )
35
36 [(class_name) (class_type_name) (type_constructor)] @type
37
38 [(constructor_name) (tag)] @constructor
39
40 ; Variables
41 ;----------
42
43 [(value_name) (type_variable)] @variable
44
45 (value_pattern) @variable.parameter
46
47 ; Functions
48 ;----------
49
50 (let_binding
51 pattern: (value_name) @function
52 (parameter))
53
54 (let_binding
55 pattern: (value_name) @function
56 body: [(fun_expression) (function_expression)])
57
58 (value_specification (value_name) @function)
59
60 (external (value_name) @function)
61
62 (method_name) @function.method
63
64 ; Application
65 ;------------
66
67 (
68 (value_name) @function.builtin
69 (#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
70 )
71
72 (infix_expression
73 left: (value_path (value_name) @function)
74 operator: (concat_operator) @operator
75 (#eq? @operator "@@"))
76
77 (infix_expression
78 operator: (rel_operator) @operator
79 right: (value_path (value_name) @function)
80 (#eq? @operator "|>"))
81
82 (application_expression
83 function: (value_path (value_name) @function))
84
85 ; Properties
86 ;-----------
87
88 [(label_name) (field_name) (instance_variable_name)] @variable.other.member
89
90 ; Constants
91 ;----------
92
93 (boolean) @constant.builtin.boolean
94
95 [(number) (signed_number)] @constant.numeric
96
97 [(string) (character)] @string
98
99 (quoted_string "{" @string "}" @string) @string
100
101 (escape_sequence) @constant.character.escape
102
103 (conversion_specification) @string.special
104
105 ; Operators
106 ;----------
107
108 ["*" "#" "::" "<-"] @operator
109
110 [
111 (prefix_operator)
112 (sign_operator)
113 (pow_operator)
114 (mult_operator)
115 (add_operator)
116 (concat_operator)
117 (rel_operator)
118 (and_operator)
119 (or_operator)
120 (assign_operator)
121 (hash_operator)
122 (indexing_operator)
123 (let_operator)
124 (let_and_operator)
125 (match_operator)
126 ] @operator
127
128 (match_expression (match_operator) @keyword)
129
130 (value_definition [(let_operator) (let_and_operator)] @keyword)
131
132 ; Keywords
133 ;---------
134
135 [
136 "and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else"
137 "end" "exception" "external" "for" "fun" "function" "functor" "if" "in"
138 "include" "inherit" "initializer" "lazy" "let" "match" "method" "module"
139 "mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct"
140 "then" "to" "try" "type" "val" "virtual" "when" "while" "with"
141 ; OCaml 5 effects and OxCaml locality/mode keywords.
142 "effect" "exclave_" "stack_" "global_"
143 ] @keyword
144
145 ; Attributes
146 ;-----------
147
148 (attribute_id) @tag
149
150 ; Comments
151 ;---------
152
153 ; `shebang` is intentionally not captured here: this file is inherited by
154 ; ocaml-interface (`.mli`), whose grammar has no `shebang` symbol, so capturing
155 ; it would fail to compile the interface highlights.
156 [(comment) (line_number_directive) (directive)] @comment