Debian Codegraph @

data/syntax/nix.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language [
3 <!ENTITY ident "[a-zA-Z_][a-zA-Z0-9_\-']*">
4 ]>
5
6 <!--
7 SPDX-FileCopyrightText: 2021 Marco Rebhan <[email protected]>
8 SPDX-FileContributor: Tuan Le <[email protected]>
9
10 SPDX-License-Identifier: MIT
11 -->
12
13 <language
14 name="Nix"
15 version="2"
16 kateversion="5.79"
17 section="Scripts"
18 extensions="*.nix"
19 casesensitive="1"
20 author="Marco Rebhan &lt;[email protected]&gt;"
21 license="MIT"
22 priority="1"
23 >
24 <highlighting>
25 <list name="keywords">
26 <item>assert</item>
27 <item>rec</item>
28 <item>and</item>
29 <item>or</item>
30 </list>
31 <list name="builtins">
32 <item>abort</item>
33 <item>baseNameOf</item>
34 <item>builtins</item>
35 <item>derivation</item>
36 <item>dirOf</item>
37 <item>fetchTarball</item>
38 <item>import</item>
39 <item>isNull</item>
40 <item>map</item>
41 <item>removeAttrs</item>
42 <item>throw</item>
43 <item>toString</item>
44 </list>
45 <contexts>
46 <context name="Expression" attribute="Normal Text" lineEndContext="#stay">
47 <IncludeRules context="Single Expression" />
48
49 <keyword String="keywords" attribute="Keyword" />
50 <WordDetect String="let" attribute="Keyword" context="Let" />
51 <WordDetect String="if" attribute="Keyword" context="If" />
52 <WordDetect String="with" attribute="Keyword" context="With" />
53 <Detect2Chars char="/" char1="/" attribute="Operator" />
54 <Detect2Chars char="?" char1="?" attribute="Operator" />
55 <Detect2Chars char="+" char1="+" attribute="Operator" />
56 <Detect2Chars char="|" char1="|" attribute="Operator" />
57 <Detect2Chars char="&amp;" char1="&amp;" attribute="Operator" />
58 <AnyChar String="+-*/?!" attribute="Operator" />
59 <RegExpr String="\b&ident;(?=\s*:)" context="Function" attribute="Identifier" />
60
61 <DetectIdentifier />
62 </context>
63 <context name="Single Expression" attribute="Normal Text" lineEndContext="#stay">
64 <DetectSpaces />
65 <IncludeRules context="Comment Rules" />
66
67 <keyword String="builtins" attribute="Builtin" />
68 <DetectChar char="&quot;" attribute="String" context="String" />
69 <Detect2Chars char="'" char1="'" attribute="String" context="String2" />
70 <DetectChar char="{" attribute="Symbol" context="Any Brace" beginRegion="Set" />
71 <DetectChar char="[" attribute="Symbol" context="List" beginRegion="List" />
72 <DetectChar char="(" attribute="Symbol" context="Parentheses" />
73 <RegExpr String="[a-zA-Z0-9-_.]*(/[a-zA-Z0-9-_.]+)+" attribute="Path" />
74 <Float attribute="Float" />
75 <Int attribute="Int" />
76 <WordDetect String="true" attribute="Constant" />
77 <WordDetect String="false" attribute="Constant" />
78 <WordDetect String="null" attribute="Constant" />
79 </context>
80 <context name="Parentheses" attribute="Normal Text" lineEndContext="#stay">
81 <DetectChar char=")" attribute="Symbol" context="#pop" />
82
83 <IncludeRules context="Expression" />
84 </context>
85
86 <context name="Comment Rules" attribute="Normal Text" lineEndContext="#stay">
87 <DetectChar char="#" attribute="Comment" context="Comment" />
88 <Detect2Chars char="/" char1="*" attribute="Comment" context="Multi-Line Comment" beginRegion="Comment" />
89 </context>
90 <context name="Comment" attribute="Comment" lineEndContext="#pop">
91 <DetectSpaces attribute="Comment"/>
92 <IncludeRules context="##Comments"/>
93 <DetectIdentifier attribute="Comment" context="#stay" />
94 </context>
95 <context name="Multi-Line Comment" attribute="Comment" lineEndContext="#stay">
96 <Detect2Chars char="*" char1="/" attribute="Comment" context="#pop" endRegion="Comment" />
97 <IncludeRules context="Comment"/>
98 </context>
99
100 <context name="String" attribute="String" lineEndContext="#stay">
101 <RegExpr String="\\." attribute="Special Char" />
102 <DetectChar char="&quot;" attribute="String" context="#pop" />
103
104 <Detect2Chars char="$" char1="{" attribute="Special Char" context="Interpolated String" />
105 </context>
106 <context name="String2" attribute="String" lineEndContext="#stay">
107 <RegExpr String="''(?:['$]|\\.)" attribute="Special Char" />
108 <Detect2Chars char="'" char1="'" attribute="String" context="#pop" />
109
110 <Detect2Chars char="$" char1="{" attribute="Special Char" context="Interpolated String" />
111 </context>
112 <context name="Interpolated String" attribute="Normal Text" lineEndContext="#stay">
113 <DetectChar char="}" attribute="Special Char" context="#pop" />
114
115 <IncludeRules context="Expression" />
116 </context>
117
118 <!--
119 we don't know whether this is a set { k = v; k1 = v1; ... } or
120 the beginning of a function declaration { x1, x2, x3, ... }: ...
121 yet
122 -->
123 <context name="Any Brace" attribute="Normal Text" lineEndContext="#stay">
124 <DetectSpaces />
125 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set"/>
126
127 <WordDetect String="inherit" attribute="Keyword" context="Any Brace - Inherit" />
128 <DetectChar char=";" attribute="Symbol" context="#pop!Set" />
129 <DetectChar char="=" attribute="Operator" context="Any Brace - Set Value" />
130 <DetectChar char="&quot;" attribute="String" context="Any Brace - String" />
131 <Detect2Chars char="'" char1="'" attribute="String" context="Any Brace - String2" />
132
133 <DetectChar char="," attribute="Symbol" context="#pop!Set Expansion" />
134 <DetectChar char="?" attribute="Symbol" context="Any Brace - Default Value" />
135 <StringDetect String="..." attribute="Symbol" context="#pop!Set Expansion" />
136
137 <RegExpr String="&ident;" attribute="Identifier" />
138
139 <IncludeRules context="Comment Rules" />
140 </context>
141 <!--
142 can't push two contexts so we need separate ones specifically
143 for this
144 -->
145 <context name="Any Brace - Set Value" attribute="Normal Text" lineEndContext="#stay">
146 <DetectChar char=";" attribute="Symbol" context="#pop#pop!Set" />
147 <IncludeRules context="Set Value" />
148 </context>
149 <context name="Any Brace - String" attribute="Normal Text" lineEndContext="#stay">
150 <DetectChar char="&quot;" attribute="String" context="#pop#pop!Set" />
151 <IncludeRules context="String" />
152 </context>
153 <context name="Any Brace - String2" attribute="Normal Text" lineEndContext="#stay">
154 <Detect2Chars char="'" char1="'" attribute="String" context="#pop#pop!Set" />
155 <IncludeRules context="String" />
156 </context>
157 <context name="Any Brace - Inherit" attribute="Normal Text" lineEndContext="#stay">
158 <DetectChar char=";" attribute="Symbol" context="#pop#pop!Set" />
159 <IncludeRules context="Inherit" />
160 </context>
161 <context name="Any Brace - Default Value" attribute="Normal Text" lineEndContext="#stay">
162 <DetectChar char="," attribute="Symbol" context="#pop#pop!Set Expansion" />
163 <IncludeRules context="Default Value" />
164 </context>
165
166 <!-- include for sets and let expressions -->
167 <context name="Set-Like" attribute="Normal Text" lineEndContext="#stay">
168 <DetectChar char="&quot;" attribute="String" context="String" />
169 <Detect2Chars char="'" char1="'" attribute="String" context="String2" />
170 <DetectChar char="=" attribute="Operator" context="Set Value" />
171 <RegExpr String="&ident;" attribute="Identifier" />
172 <IncludeRules context="Comment Rules" />
173 </context>
174 <context name="Inherit" attribute="Normal Text" lineEndContext="#stay">
175 <DetectChar char=";" attribute="Symbol" context="#pop" />
176 <IncludeRules context="Single Expression" />
177 </context>
178
179 <context name="Set" attribute="Normal Text" lineEndContext="#stay">
180 <DetectSpaces />
181 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set" />
182 <WordDetect String="inherit" attribute="Keyword" context="Inherit" />
183
184 <IncludeRules context="Set-Like" />
185 </context>
186 <context name="Set Value" attribute="Normal Text" lineEndContext="#stay">
187 <DetectChar char=";" attribute="Symbol" context="#pop" />
188 <DetectChar char="}" attribute="Error" context="#pop#pop" endRegion="Set" />
189
190 <IncludeRules context="Expression" />
191 </context>
192
193 <context name="Set Expansion" attribute="Normal Text" lineEndContext="#stay">
194 <DetectSpaces />
195 <DetectChar char="}" attribute="Symbol" context="#pop" endRegion="Set"/>
196
197 <DetectChar char="," attribute="Symbol" />
198 <DetectChar char="?" attribute="Symbol" context="Default Value" />
199 <StringDetect String="..." attribute="Symbol" />
200 <RegExpr String="&ident;" attribute="Identifier" />
201 <IncludeRules context="Comment Rules" />
202 </context>
203 <context name="Default Value" attribute="Normal Text" lineEndContext="#stay">
204 <DetectChar char="," attribute="Symbol" context="#pop" />
205 <DetectChar char="}" attribute="Symbol" context="#pop#pop" />
206
207 <IncludeRules context="Expression" />
208 </context>
209
210 <context name="List" attribute="Normal Text" lineEndContext="#stay">
211 <DetectChar char="]" attribute="Symbol" context="#pop" endRegion="List" />
212
213 <IncludeRules context="Single Expression" />
214 </context>
215
216 <context name="Function" attribute="Normal Text" lineEndContext="#stay">
217 <DetectChar char=":" attribute="Symbol" context="#pop" />
218 <DetectSpaces attribute="Normal Text" />
219 </context>
220
221 <context name="Let" attribute="Normal Text" lineEndContext="#stay">
222 <DetectSpaces />
223 <WordDetect String="in" attribute="Keyword" context="#pop" />
224
225 <IncludeRules context="Set-Like" />
226 </context>
227
228 <context name="If" attribute="Normal Text" lineEndContext="#stay">
229 <WordDetect String="then" attribute="Keyword" context="#pop!Then" />
230
231 <IncludeRules context="Expression" />
232 </context>
233 <context name="Then" attribute="Normal Text" lineEndContext="#stay">
234 <WordDetect String="else" attribute="Keyword" context="#pop" />
235
236 <IncludeRules context="Expression" />
237 </context>
238
239 <context name="With" attribute="Normal Text" lineEndContext="#stay">
240 <DetectChar char=";" attribute="Symbol" context="#pop" />
241 <IncludeRules context="Expression" />
242 </context>
243 </contexts>
244 <itemDatas>
245 <itemData name="Normal Text" defStyleNum="dsNormal" />
246 <itemData name="Builtin" defStyleNum="dsBuiltIn" />
247 <itemData name="Int" defStyleNum="dsDecVal" />
248 <itemData name="Float" defStyleNum="dsFloat" />
249 <itemData name="Constant" defStyleNum="dsConstant" />
250 <itemData name="String" defStyleNum="dsString" />
251 <itemData name="Special Char" defStyleNum="dsSpecialChar" />
252 <itemData name="Path" defStyleNum="dsSpecialString" />
253 <itemData name="Keyword" defStyleNum="dsKeyword" />
254 <itemData name="Comment" defStyleNum="dsComment" />
255 <itemData name="Symbol" defStyleNum="dsOperator" />
256 <itemData name="Operator" defStyleNum="dsOperator" />
257 <itemData name="Identifier" defStyleNum="dsVariable" />
258 <itemData name="Error" defStyleNum="dsError" />
259 </itemDatas>
260 </highlighting>
261 <general>
262 <comments>
263 <comment name="singleLine" start="#" />
264 <comment name="multiLine" start="/*" end="*/" region="Comment" />
265 </comments>
266 <keywords casesensitive="1" />
267 </general>
268 </language>