Debian Codegraph @

data/syntax/earthfile.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language SYSTEM "language.dtd"
3 [
4 <!ENTITY var_name_re "[A-Za-z_][_0-9A-Za-z]*">
5 <!ENTITY unary_operators "\B-[abcdefghkprstuwxGLNOSovRnz]\b">
6 <!ENTITY binary_operators "\B(?:-(?:e[fq]|[nolg]t|[nlg]e)|==?|!=)\b">
7 ]>
8 <!--
9 This file is part of KDE's kate project.
10
11 SPDX-FileCopyrightText: 2022-2023 Alex Turbov <[email protected]>
12
13 SPDX-License-Identifier: MIT
14 -->
15 <language
16 name="Earthfile"
17 section="Other"
18 version="1"
19 kateversion="5.79"
20 extensions="Earthfile"
21 author="Alex Turbov ([email protected])"
22 license="MIT"
23 >
24 <highlighting>
25
26 <!-- https://docs.earthly.dev/docs/earthfile/builtin-args -->
27 <list name="variables">
28 <item>EARTHLY_TARGET_TAG</item>
29 <item>EARTHLY_TARGET_PROJECT</item>
30 <item>EARTHLY_TARGET_PROJECT_NO_TAG</item>
31 <item>EARTHLY_TARGET_NAME</item>
32 <item>EARTHLY_TARGET_TAG</item>
33 <item>EARTHLY_TARGET_TAG_DOCKER</item>
34 <item>EARTHLY_GIT_HASH</item>
35 <item>EARTHLY_GIT_SHORT_HASH</item>
36 <item>EARTHLY_GIT_ORIGIN_URL</item>
37 <item>EARTHLY_GIT_PROJECT_NAME</item>
38 <item>EARTHLY_GIT_COMMIT_TIMESTAMP</item>
39 <item>EARTHLY_GIT_COMMIT_AUTHOR_TIMESTAMP</item>
40 <item>EARTHLY_VERSION</item>
41 <item>EARTHLY_BUILD_SHA</item>
42 <item>TARGETPLATFORM</item>
43 <item>TARGETOS</item>
44 <item>TARGETARCH</item>
45 <item>TARGETVARIANT</item>
46 <item>EARTHLY_SOURCE_DATE_EPOCH</item>
47 <item>USERPLATFORM</item>
48 <item>USEROS</item>
49 <item>USERARCH</item>
50 <item>USERVARIANT</item>
51 </list>
52
53 <!--
54 See `RUN` and `mount` option description
55 https://docs.earthly.dev/docs/earthfile#run
56 -->
57 <list name="mount_keys">
58 <item>type</item>
59 <item>target</item>
60 <item>mode</item>
61 <item>id</item>
62 <item>sharing</item>
63 </list>
64
65 <contexts>
66 <context name="Base" attribute="Normal Text" lineEndContext="#stay">
67 <RegExpr
68 String="^[A-Z_][A-Z_0-9]+:"
69 column="0"
70 context="#stay"
71 attribute="User Defined Command"
72 endRegion="Recipe"
73 beginRegion="Recipe"
74 />
75 <RegExpr
76 String="^[a-z][a-z\-_0-9]+:"
77 column="0"
78 context="#stay"
79 attribute="Target Name"
80 endRegion="Recipe"
81 beginRegion="Recipe"
82 />
83 <DetectSpaces />
84 <IncludeRules context="RecipeCommands" />
85 </context>
86
87 <context name="RecipeCommands" attribute="Normal Text" lineEndContext="#pop">
88 <DetectSpaces />
89 <DetectChar char="#" attribute="Comment" context="Comment" />
90 <!-- The whole file is a collection of recipes -->
91 <WordDetect String="ARG" attribute="Command" context="ARG_ctx" />
92 <WordDetect String="FROM" attribute="Command" context="FROM_ctx" />
93 <WordDetect String="BUILD" attribute="Command" context="BUILD_ctx" />
94 <WordDetect String="VERSION" attribute="Command" context="VERSION_ctx" />
95 <WordDetect String="GIT" attribute="Command" context="GIT_ctx" />
96 <WordDetect String="CACHE" attribute="Command" context="CACHE_ctx" />
97 <WordDetect String="LOCALLY" attribute="Command" context="#stay" />
98 <WordDetect String="COMMAND" attribute="Command" context="#stay" />
99 <WordDetect String="IMPORT" attribute="Command" context="IMPORT_ctx" />
100 <WordDetect String="CMD" attribute="Command" context="CMD_ctx" />
101 <WordDetect String="LABEL" attribute="Command" context="LABEL_ctx" />
102 <WordDetect String="EXPOSE" attribute="Command" context="EXPOSE_ctx" />
103 <WordDetect String="ENV" attribute="Command" context="BashOneLine##Bash" />
104 <WordDetect String="ENTRYPOINT" attribute="Command" context="ENTRYPOINT_ctx" />
105 <WordDetect String="VOLUME" attribute="Command" context="VOLUME_ctx" />
106 <WordDetect String="USER" attribute="Command" context="USER_ctx" />
107 <WordDetect String="WORKDIR" attribute="Command" context="WORKDIR_ctx" />
108 <WordDetect String="HEALTHCHECK" attribute="Command" context="HEALTHCHECK_ctx" />
109 <WordDetect String="HOST" attribute="Command" context="HOST_ctx" />
110 <WordDetect String="DO" attribute="Command" context="DO_ctx" />
111 <WordDetect String="COPY" attribute="Command" context="COPY_ctx" />
112 <WordDetect String="SAVE" attribute="Command" context="SAVE_ctx" />
113 <WordDetect String="WAIT" attribute="Command" context="WAIT_ctx" beginRegion="WAIT" />
114 <WordDetect String="WITH" attribute="Command" context="WITH_ctx" beginRegion="WITH" />
115 <WordDetect String="FOR" attribute="Command" context="FOR_ctx" beginRegion="FOR" />
116 <WordDetect String="RUN" attribute="Command" context="RUN_ctx" />
117 <WordDetect String="IF" attribute="Command" context="IF_ctx" beginRegion="IF" />
118 </context>
119
120 <context name="RecipeContent" attribute="Normal Text" lineEndContext="#pop">
121 <LineContinue />
122
123 <DetectChar char="'" attribute="String SingleQ" context="StringSQ" />
124 <DetectChar char="&quot;" attribute="String DoubleQ" context="StringDQ" />
125
126 <!-- See https://docs.earthly.dev/docs/guides/target-ref#target-reference -->
127 <RegExpr
128 context="DetectReference"
129 lookAhead="true"
130 String="([a-z0-9_\-\./]+(:[A-Za-z0-9_\-\./]+)?)?(\+[A-Za-z0-9_\-]+)(/[^ ,]*)?"
131 />
132 <RegExpr String="--&var_name_re;=" lookAhead="true" context="BuildArg" />
133 <DetectChar char="$" lookAhead="1" context="DispatchVariables" />
134 <Int attribute="Integer" />
135 </context>
136
137 <context name="BuildArg" attribute="Normal Text" lineEndContext="#pop">
138 <DetectChar char="=" attribute="Operator" context="#pop" />
139 <RegExpr String="--&var_name_re;" attribute="Build Arg" />
140 </context>
141
142 <context name="DispatchVariables" attribute="Normal Text" lineEndContext="#pop">
143 <IncludeRules context="DispatchVariablesBase" />
144 <DetectChar char="$" context="#pop" />
145 </context>
146
147 <context name="DispatchVariablesBase" attribute="Normal Text" lineEndContext="#pop">
148 <Detect2Chars char="$" char1="$" attribute="Variable" context="#pop" />
149 <Detect2Chars char="$" char1="?" attribute="Variable" context="#pop" />
150 <Detect2Chars char="$" char1="*" attribute="Variable" context="#pop" />
151 <Detect2Chars char="$" char1="@" attribute="Variable" context="#pop" />
152 <Detect2Chars char="$" char1="{" attribute="Variable" context="VarSubst" />
153 <Detect2Chars char="$" char1="(" attribute="Variable" context="CommandSubst" />
154 <RegExpr String="\$&var_name_re;" lookAhead="true" context="VarName" />
155 </context>
156
157 <context name="VarName" attribute="Normal Text" lineEndContext="#pop">
158 <DetectChar char="$" attribute="Variable" context="#stay" />
159 <RegExpr String="_&var_name_re;" attribute="Internal/Local Variable" context="#pop" />
160 <keyword String="variables" insensitive="false" attribute="Builtin Variable" context="#pop" />
161 <DetectIdentifier attribute="Variable" context="#pop" />
162 </context>
163
164 <context name="VarSubst" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
165 <DetectChar char="}" attribute="Variable" context="#pop#pop" />
166 <RegExpr String="_&var_name_re;" attribute="Internal/Local Variable" context="#stay" />
167 <keyword String="variables" insensitive="false" attribute="Builtin Variable" context="#stay" />
168 <DetectIdentifier attribute="Variable" />
169 <Detect2Chars char=":" char1="+" attribute="Variable" context="#stay" />
170 <Detect2Chars char=":" char1="-" attribute="Variable" context="#stay" />
171 </context>
172
173 <context name="DetectReference" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
174 <StringDetect String="%1" dynamic="true" attribute="Reference" context="#stay" />
175 <StringDetect String="%3" lookAhead="true" dynamic="true" context="TargetOrCommand" />
176 <StringDetect String="%4" dynamic="true" attribute="Artifact Name" context="#stay" />
177 </context>
178
179 <context name="TargetOrCommand" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
180 <RegExpr String="\+[A-Z_][A-Z_0-9]+" context="#pop" attribute="User Defined Command" />
181 <RegExpr String="\+[a-z][a-z\-_0-9]+" context="#pop" attribute="Target Name" />
182 </context>
183
184 <!-- StringSQ consumes anything till ' -->
185 <context name="StringSQ" attribute="String SingleQ" lineEndContext="#stay">
186 <DetectSpaces />
187 <DetectIdentifier />
188 <LineContinue context="#stay" />
189 <DetectChar char="'" attribute="String SingleQ" context="#pop" />
190 </context>
191
192 <!-- StringDQ consumes anything till ", substitutes vars and expressions -->
193 <context name="StringDQ" attribute="String DoubleQ" lineEndContext="#stay">
194 <DetectSpaces />
195 <DetectIdentifier />
196 <DetectChar char="&quot;" attribute="String DoubleQ" context="#pop" />
197 <LineContinue context="#stay" />
198 <DetectChar char="\" lookAhead="1" context="StringDQEscape" />
199 <DetectChar char="$" lookAhead="1" context="StringDQDispatchVariables" />
200 </context>
201
202 <context name="StringDQEscape" attribute="String DoubleQ" lineEndContext="#pop">
203 <Detect2Chars char="\" char1="&quot;" attribute="String Escape" context="#pop" />
204 <Detect2Chars char="\" char1="$" attribute="String Escape" context="#pop" />
205 <Detect2Chars char="\" char1="n" attribute="String Escape" context="#pop" />
206 <Detect2Chars char="\" char1="r" attribute="String Escape" context="#pop" />
207 <Detect2Chars char="\" char1="t" attribute="String Escape" context="#pop" />
208 <Detect2Chars char="\" char1="\" attribute="String Escape" context="#pop" />
209 <!-- TODO REALLY? -->
210 <LineContinue attribute="String Escape" context="#pop" />
211 <DetectChar char="\" attribute="String DoubleQ" context="#pop" />
212 </context>
213
214 <context name="StringDQDispatchVariables" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
215 <IncludeRules context="DispatchVariablesBase" />
216 <DetectChar char="$" attribute="String DoubleQ" context="#pop" />
217 </context>
218
219 <!-- SubstCommand is called after a $( is encountered -->
220 <context name="CommandSubst" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop">
221 <LineContinue context="#stay" />
222 <DetectChar char=")" attribute="Variable" context="#pop" />
223 <!-- TODO Need a FIX for this:
224
225 ARG _python_ver = $(${python_bin} -c \"import sys; print(\'{}.{}\'.format(*sys.version_info))\")
226 -->
227 <IncludeRules context="BashOneLine##Bash" />
228 </context>
229
230 <context name="Comment" attribute="Comment" lineEndContext="#pop">
231 <LineContinue context="#stay" />
232 <IncludeRules context="##Comments" />
233 </context>
234
235 <!--
236 Earthly Commands
237 -->
238
239 <!-- https://docs.earthly.dev/docs/earthfile#arg -->
240 <context name="ARG_ctx" attribute="Normal Text" lineEndContext="#pop">
241 <StringDetect String="--required" attribute="Command Option" context="#stay" />
242 <RegExpr String="_&var_name_re;" attribute="Internal/Local Variable" context="#stay" />
243 <keyword String="variables" insensitive="false" attribute="Builtin Variable" context="#stay" />
244 <DetectIdentifier attribute="Variable" context="#stay" />
245 <DetectChar char="=" attribute="Operator" context="#pop!RecipeContent" />
246 </context>
247
248 <!-- https://docs.earthly.dev/docs/earthfile#build -->
249 <context name="BUILD_ctx" attribute="Normal Text" lineEndContext="#pop">
250 <StringDetect String="--platform" attribute="Command Option" context="#stay" />
251 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
252 <IncludeRules context="RecipeContent" />
253 </context>
254
255 <!-- https://docs.earthly.dev/docs/earthfile#do -->
256 <context name="DO_ctx" attribute="Normal Text" lineEndContext="#pop">
257 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
258 <IncludeRules context="RecipeContent" />
259 </context>
260
261 <!-- https://docs.earthly.dev/docs/earthfile#copy -->
262 <context name="COPY_ctx" attribute="Normal Text" lineEndContext="#pop">
263 <StringDetect String="--dir" attribute="Command Option" context="#stay" />
264 <StringDetect String="--keep-ts" attribute="Command Option" context="#stay" />
265 <StringDetect String="--keep-own" attribute="Command Option" context="#stay" />
266 <StringDetect String="--if-exists" attribute="Command Option" context="#stay" />
267 <StringDetect String="--platform" attribute="Command Option" context="#stay" />
268 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
269 <IncludeRules context="RecipeContent" />
270 </context>
271
272 <!-- https://docs.earthly.dev/docs/earthfile#cache-beta -->
273 <context name="CACHE_ctx" attribute="Normal Text" lineEndContext="#pop">
274 <StringDetect String="--sharing" attribute="Command Option" context="#stay" />
275 <IncludeRules context="RecipeContent" />
276 </context>
277
278 <!-- https://docs.earthly.dev/docs/earthfile#expose-same-as-dockerfile-expose -->
279 <context name="EXPOSE_ctx" attribute="Normal Text" lineEndContext="#pop">
280 <IncludeRules context="RecipeContent" />
281 </context>
282
283 <!-- https://docs.earthly.dev/docs/earthfile#user-same-as-dockerfile-user -->
284 <context name="USER_ctx" attribute="Normal Text" lineEndContext="#pop">
285 <IncludeRules context="RecipeContent" />
286 </context>
287
288 <!-- https://docs.earthly.dev/docs/earthfile#workdir-same-as-dockerfile-workdir -->
289 <context name="WORKDIR_ctx" attribute="Normal Text" lineEndContext="#pop">
290 <IncludeRules context="RecipeContent" />
291 </context>
292
293 <!-- https://docs.earthly.dev/docs/earthfile#healthcheck-same-as-dockerfile-workdir -->
294 <context name="HEALTHCHECK_ctx" attribute="Normal Text" lineEndContext="#pop">
295 <IncludeRules context="RecipeContent" />
296 </context>
297
298 <!-- https://docs.earthly.dev/docs/earthfile#host-same-as-dockerfile-workdir -->
299 <context name="HOST_ctx" attribute="Normal Text" lineEndContext="#pop">
300 <IncludeRules context="RecipeContent" />
301 </context>
302
303 <!-- https://docs.earthly.dev/docs/earthfile#cmd-same-as-dockerfile-cmd -->
304 <context name="CMD_ctx" attribute="Normal Text" lineEndContext="#pop">
305 <AnyChar String="[," attribute="Operator" context="#stay" />
306 <DetectChar attribute="Operator" context="#pop" char="]" />
307 <IncludeRules context="RecipeContent" />
308 </context>
309
310 <!-- https://docs.earthly.dev/docs/earthfile#entrypoint-same-as-dockerfile-entrypoint -->
311 <!-- TODO Deduplicate? -->
312 <context name="ENTRYPOINT_ctx" attribute="Normal Text" lineEndContext="#pop">
313 <AnyChar String="[," attribute="Operator" context="#stay" />
314 <DetectChar char="]" attribute="Operator" context="#pop" />
315 <IncludeRules context="RecipeContent" />
316 </context>
317
318 <!-- https://docs.earthly.dev/docs/earthfile#volume-same-as-dockerfile-volume -->
319 <!-- TODO Deduplicate? -->
320 <context name="VOLUME_ctx" attribute="Normal Text" lineEndContext="#pop">
321 <AnyChar String="[," attribute="Operator" context="#stay" />
322 <DetectChar char="]" attribute="Operator" context="#pop" />
323 <IncludeRules context="RecipeContent" />
324 </context>
325
326 <!-- https://docs.earthly.dev/docs/earthfile#label-same-as-dockerfile-label -->
327 <context name="LABEL_ctx" attribute="Normal Text" lineEndContext="#pop">
328 <DetectChar char="=" attribute="Operator" context="#stay" />
329 <IncludeRules context="RecipeContent" />
330 <LineContinue context="#stay" />
331 </context>
332
333 <!-- https://docs.earthly.dev/docs/earthfile#import -->
334 <context name="IMPORT_ctx" attribute="Normal Text" lineEndContext="#pop">
335 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
336 <WordDetect String="AS" attribute="Command" context="#stay" />
337 <IncludeRules context="RecipeContent" />
338 </context>
339
340 <!-- https://docs.earthly.dev/docs/earthfile#version -->
341 <context name="VERSION_ctx" attribute="Normal Text" lineEndContext="#pop">
342 <!-- https://docs.earthly.dev/docs/earthfile/features#feature-flags -->
343 <StringDetect String="--use-copy-include-patterns" attribute="Command Option" context="#stay" />
344 <StringDetect String="--referenced-save-only" attribute="Command Option" context="#stay" />
345 <StringDetect String="--for-in" attribute="Command Option" context="#stay" />
346 <StringDetect String="--require-force-for-unsafe-saves" attribute="Command Option" context="#stay" />
347 <StringDetect String="--no-implicit-ignore" attribute="Command Option" context="#stay" />
348 <StringDetect String="--earthly-version-arg" attribute="Command Option" context="#stay" />
349 <StringDetect String="--shell-out-anywhere" attribute="Command Option" context="#stay" />
350 <StringDetect String="--use-registry-for-with-docker" attribute="Command Option" context="#stay" />
351 <!--Other not from the list -->
352 <StringDetect String="--wait-block" attribute="Command Option" context="#stay" />
353 <StringDetect String="--use-cache-command" attribute="Command Option" context="#stay" />
354 <RegExpr String="[0-9](\.[0-9])*" context="#pop" />
355 </context>
356
357 <!-- https://docs.earthly.dev/docs/earthfile#git-clone -->
358 <context name="GIT_ctx" attribute="Normal Text" lineEndContext="#pop">
359 <WordDetect String="CLONE" attribute="Command" context="#stay" />
360 <StringDetect String="--branch" attribute="Command Option" context="#stay" />
361 <StringDetect String="--keep-ts" attribute="Command Option" context="#stay" />
362 <IncludeRules context="RecipeContent" />
363 </context>
364
365 <!-- https://docs.earthly.dev/docs/earthfile#wait-experimental -->
366 <context name="WAIT_ctx" attribute="Normal Text" lineEndContext="#stay">
367 <WordDetect String="END" attribute="Command" context="#pop" endRegion="WAIT" />
368 <IncludeRules context="RecipeCommands" />
369 </context>
370
371 <!-- https://docs.earthly.dev/docs/earthfile#with-docker -->
372 <context name="WITH_ctx" attribute="Normal Text" lineEndContext="#stay">
373 <WordDetect String="DOCKER" attribute="Command" context="#stay" />
374 <WordDetect String="END" attribute="Command" context="#pop" endRegion="WITH" />
375 <StringDetect String="--pull" attribute="Command Option" context="#stay" />
376 <StringDetect String="--load" attribute="Command Option" context="#stay" />
377 <StringDetect String="--compose" attribute="Command Option" context="#stay" />
378 <StringDetect String="--service" attribute="Command Option" context="#stay" />
379 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
380 <IncludeRules context="RecipeCommands" />
381 </context>
382
383 <!-- https://docs.earthly.dev/docs/earthfile#for -->
384 <context name="FOR_ctx" attribute="Normal Text" lineEndContext="#stay">
385 <WordDetect String="IN" attribute="Command" context="#stay" />
386 <WordDetect String="END" attribute="Command" context="#pop" endRegion="FOR" />
387 <StringDetect String="--sep" attribute="Command Option" context="#stay" />
388 <StringDetect String="--privileged" attribute="Command Option" context="#stay" />
389 <StringDetect String="--ssh" attribute="Command Option" context="#stay" />
390 <StringDetect String="--no-cache" attribute="Command Option" context="#stay" />
391 <StringDetect String="--secret" attribute="Command Option" context="#stay" />
392 <IncludeRules context="RecipeCommands" />
393 </context>
394
395 <!--
396 FROM [options] <target> [build-args]
397 FROM DOCKERFILE [options] <context>
398
399 https://docs.earthly.dev/docs/earthfile#from
400 https://docs.earthly.dev/docs/earthfile#from-dockerfile
401 -->
402 <context name="FROM_ctx" attribute="Normal Text" lineEndContext="#pop">
403 <WordDetect String="DOCKERFILE" attribute="Command" context="#stay" />
404
405 <!-- Options for the first form -->
406 <StringDetect String="--allow-privileged" attribute="Command Option" context="#stay" />
407 <StringDetect String="--platform" attribute="Command Option" context="#stay" />
408
409 <!-- Options for the second form -->
410 <StringDetect String="-f" attribute="Command Option" context="#stay" />
411 <StringDetect String="--target" attribute="Command Option" context="#stay" />
412
413 <IncludeRules context="RecipeContent" />
414 </context>
415
416 <!--
417 SAVE ARTIFACT
418 https://docs.earthly.dev/docs/earthfile#save-artifact
419
420 SAVE IMAGE
421 https://docs.earthly.dev/docs/earthfile#save-image
422 -->
423 <context name="SAVE_ctx" attribute="Normal Text" lineEndContext="#pop">
424 <WordDetect String="ARTIFACT" attribute="Command" context="#stay" />
425 <WordDetect String="AS" attribute="Command" context="#stay" />
426 <WordDetect String="LOCAL" attribute="Command" context="#stay" />
427 <WordDetect String="IMAGE" attribute="Command" context="#stay" />
428
429 <!-- Options for the first form -->
430 <StringDetect String="--keep-ts" attribute="Command Option" context="#stay" />
431 <StringDetect String="--keep-own" attribute="Command Option" context="#stay" />
432 <StringDetect String="--if-exists" attribute="Command Option" context="#stay" />
433 <StringDetect String="--force" attribute="Command Option" context="#stay" />
434
435 <!-- Options for the second form -->
436 <StringDetect String="--cache-hint" attribute="Command Option" context="#stay" />
437 <StringDetect String="--cache-from" attribute="Command Option" context="#stay" />
438 <StringDetect String="--push" attribute="Command Option" context="#stay" />
439
440 <IncludeRules context="RecipeContent" />
441 </context>
442
443 <!-- https://docs.earthly.dev/docs/earthfile#run -->
444 <context name="RUN_ctx" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop!BashOneLine##Bash">
445 <DetectSpaces />
446 <LineContinue context="#stay" />
447 <DetectChar char="[" attribute="Operator" context="#pop!RUN_exec" />
448 <StringDetect String="--push" attribute="Command Option" context="#stay" />
449 <StringDetect String="--no-cache" attribute="Command Option" context="#stay" />
450 <StringDetect String="--entrypoint" attribute="Command Option" context="#stay" />
451 <StringDetect String="--privileged" attribute="Command Option" context="#stay" />
452 <StringDetect String="--ssh" attribute="Command Option" context="#stay" />
453 <StringDetect String="--secret" attribute="Command Option" context="secret_opt" />
454 <StringDetect String="--mount" attribute="Command Option" context="mount_opt" />
455 <StringDetect String="--interactive-keep" attribute="Command Option" context="#stay" />
456 <StringDetect String="--interactive" attribute="Command Option" context="#stay" />
457 <Detect2Chars char="-" char1="-" attribute="Command Option" context="#pop!BashOneLine##Bash" />
458 </context>
459 <!-- Second form of `RUN` -->
460 <context name="RUN_exec" attribute="Normal Text" lineEndContext="#pop">
461 <DetectChar char="]" attribute="Operator" context="#pop" />
462 <IncludeRules context="RecipeContent" />
463 </context>
464
465 <!-- https://docs.earthly.dev/docs/earthfile#if -->
466 <context name="IF_ctx" attribute="Normal Text" lineEndContext="#stay">
467 <DetectSpaces />
468 <LineContinue context="#stay" />
469
470 <StringDetect String="ELSE IF" attribute="Command" context="#stay" />
471 <WordDetect String="ELSE" attribute="Command" context="#stay" />
472 <WordDetect String="END" attribute="Command" context="#pop" endRegion="IF" />
473
474 <StringDetect String="--privileged" attribute="Command Option" context="#stay" />
475 <StringDetect String="--ssh" attribute="Command Option" context="#stay" />
476 <StringDetect String="--no-cache" attribute="Command Option" context="#stay" />
477 <StringDetect String="--entrypoint" attribute="Command Option" context="#stay" />
478 <StringDetect String="--mount" attribute="Command Option" context="mount_opt" />
479 <StringDetect String="--secret" attribute="Command Option" context="secret_opt" />
480 <!-- start expression in single brackets -->
481 <DetectChar char="[" attribute="Operator" context="BracketExpression" />
482 <IncludeRules context="RecipeCommands" />
483 </context>
484
485 <context name="BracketExpression" attribute="Normal Text" lineEndContext="#pop">
486 <DetectChar char="]" attribute="Operator" context="#pop" />
487 <AnyChar String="!=" attribute="Operator" context="#stay" />
488 <RegExpr String="(&binary_operators;|&unary_operators;)" attribute="Operator" context="#stay" />
489 <DetectSpaces />
490 <IncludeRules context="RecipeContent" />
491 </context>
492
493 <context name="mount_opt" attribute="Command Option" lineEndContext="#stay" fallthroughContext="#pop!mount_arg">
494 <DetectSpaces context="#stay" />
495 </context>
496
497 <context name="mount_arg" attribute="Command Option" lineEndContext="#stay" fallthroughContext="#pop">
498 <keyword String="mount_keys" insensitive="false" attribute="Command Option" context="#stay" />
499 <AnyChar String=",=" attribute="Operator" context="#stay" />
500 <!--
501 ALERT A mount option arg must consume characters up to the next space
502 and stay in this context to match other rules. Typically there are characters
503 that could be found in file paths...
504
505 NOTE If you see "Normal Text" in the `mount` options, update the String below.
506
507 TODO Any better way?
508 -->
509 <AnyChar String="/.-" attribute="Command Option" context="#stay" />
510 <DetectIdentifier attribute="Command Option" />
511 <IncludeRules context="RecipeContent" includeAttrib="true" />
512 <DetectSpaces context="#pop" />
513 </context>
514
515 <context name="secret_opt" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop!secret_arg">
516 <DetectSpaces context="#stay" />
517 </context>
518
519 <context name="secret_arg" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop">
520 <DetectIdentifier attribute="Command Option" />
521 <DetectChar char="=" attribute="Operator" context="#stay" />
522 <IncludeRules context="RecipeContent" />
523 <DetectSpaces context="#pop" />
524 </context>
525
526 </contexts>
527
528 <itemDatas>
529 <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" />
530 <itemData name="Command" defStyleNum="dsKeyword" bold="true" spellChecking="false" />
531 <itemData name="User Defined Command" defStyleNum="dsFunction" spellChecking="false" />
532 <itemData name="Command Option" defStyleNum="dsAttribute" italic="true" spellChecking="false" />
533 <itemData name="Build Arg" defStyleNum="dsAttribute" italic="true" spellChecking="false" />
534 <itemData name="Reference" defStyleNum="dsExtension" spellChecking="false" />
535 <itemData name="Target Name" defStyleNum="dsImport" spellChecking="false" />
536 <itemData name="Operator" defStyleNum="dsOperator" spellChecking="false" />
537 <itemData name="Artifact Name" defStyleNum="dsExtension" spellChecking="false" />
538 <itemData name="Variable" defStyleNum="dsVariable" spellChecking="false" />
539 <itemData name="Builtin Variable" defStyleNum="dsVariable" spellChecking="false" color="#c09050" selColor="#c09050" />
540 <itemData name="Internal/Local Variable" defStyleNum="dsVariable" spellChecking="false" />
541 <itemData name="Comment" defStyleNum="dsComment" />
542 <itemData name="String SingleQ" defStyleNum="dsString" />
543 <itemData name="String DoubleQ" defStyleNum="dsString" />
544 <itemData name="String Escape" defStyleNum="dsSpecialChar" />
545 <itemData name="Integer" defStyleNum="dsDecVal" />
546 </itemDatas>
547
548 </highlighting>
549
550 <general>
551 <comments>
552 <comment name="singleLine" start="#" position="afterwhitespace"/>
553 </comments>
554 </general>
555
556 </language>