summaryrefslogtreecommitdiff
path: root/data/language-specs/docker.lang
blob: b2a17c27fb5800beef43683db165f37c1bc00381 (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<!--

 Authors: David Perez Cabrera <dperezcabrera@gmail.com>
 Copyright (C) 2019 David Perez Cabrera <dperezcabrera@gmail.com>

 GtkSourceView is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 GtkSourceView is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, see <http://www.gnu.org/licenses/>.

-->
<language id="docker" name="Dockerfile" version="2.0" _section="Source">
  <metadata>
    <property name="mimetypes">application/docker;text/docker</property>
    <property name="globs">Dockerfile</property>
    <property name="line-comment-start">#</property>
  </metadata>

  <styles>
    <style id="comment" name="Comment" map-to="def:comment"/>
    <style id="keyword" name="Keyword" map-to="def:keyword"/>
    <style id="operator" name="Operator" map-to="def:operator"/>
    <style id="string" name="String" map-to="def:string"/>
    <style id="variable" name="Variable" map-to="def:special-char"/>
    <style id="variable-definition" name="Variable Definition" map-to="docker:variable"/>
    <style id="user" name="User" map-to="def:identifier"/>
    <style id="alias-definition" name="Alias definition" map-to="def:identifier"/>
    <style id="number" name="Number" map-to="def:number"/>
  </styles>

  <definitions>

    <context id="operator">
      <match>(\s*)(&amp;&amp;|\|\|)(\s*)</match>
      <include>
        <context sub-pattern="2" style-ref="operator"/>
      </include>
    </context>

    <context id="short-parameter-expansion" style-ref="variable">
      <match>\$([!@?*#\$0-9]|[a-zA-Z0-9_]+)</match>
    </context>

    <context id="parameter-expansion" style-ref="variable">
      <start>\$\{</start>
      <end>\}</end>
      <include>
        <context ref="single-quoted-string"/>
        <context ref="double-quoted-string"/>
        <context ref="variable"/>
      </include>
    </context>

    <context id="variable">
      <include>
        <context ref="short-parameter-expansion"/>
        <context ref="parameter-expansion"/>
      </include>
    </context>

    <context id="user">
      <match>^\s*(USER)\s+([a-zA-Z_][a-zA-Z0-9_]*)</match>
      <include>
        <context sub-pattern="2" style-ref="user"/>
        <context sub-pattern="1" style-ref="keyword"/>
      </include>
    </context>

    <context id="alias-definition">
      <match>\s+(AS)\s+([a-zA-Z][a-zA-Z0-9_]*)</match>
      <include>
        <context sub-pattern="2" style-ref="user"/>
        <context sub-pattern="1" style-ref="keyword"/>
      </include>
    </context>

    <context id="alias-usage">
      <match>^\s*(COPY\s+\-\-from)\=([a-zA-Z][a-zA-Z0-9_]*)</match>
      <include>
        <context sub-pattern="2" style-ref="user"/>
        <context sub-pattern="1" style-ref="keyword"/>
      </include>
    </context>


    <context id="from-image">
      <match>^\s*(FROM)\s+([a-zA-Z][a-zA-Z0-9_/\:\-\.]*)</match>
      <include>
        <context sub-pattern="2" style-ref="user"/>
        <context sub-pattern="1" style-ref="keyword"/>
      </include>
    </context>

    <context id="variable-definition">
      <match>^\s*(ARG|ENV)\s+([a-zA-Z_][a-zA-Z0-9_]*)(\=|\s+)</match>
      <include>
        <context sub-pattern="2" style-ref="variable-definition"/>
        <context sub-pattern="1" style-ref="keyword"/>
      </include>
    </context>

    <context id="comment" end-at-line-end="true" style-ref="comment" class-disabled="no-spell-check">
      <start>#</start>
    </context>

    <context id="single-quoted-string" style-ref="string">
      <start>'</start>
      <end>'</end>
    </context>

    <context id="double-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
      <start>"</start>
      <end>"</end>
    </context>

    <context id="numeric" style-ref="number">
      <match extended="true">
          (\b([0-9]+|0[xX][0-9a-fA-F]+)[Ll]?\b|
          \b(([0-9]+[Ee][-]?[0-9]+|
          ([0-9]*\.[0-9]+|[0-9]+\.)([Ee][-]?[0-9]+)?)[fFdD]?|
          [0-9]+[FfDd]))
      </match>
    </context>

    <context id="keywords" style-ref="keyword">
      <keyword>AS</keyword>
      <keyword>ADD</keyword>
      <keyword>ARG</keyword>
      <keyword>CMD</keyword>
      <keyword>COPY</keyword>
      <keyword>ENTRYPOINT</keyword>
      <keyword>ENV</keyword>
      <keyword>EXPOSE</keyword>
      <keyword>FROM</keyword>
      <keyword>HEALTHCHECK</keyword>
      <keyword>LABEL</keyword>
      <keyword>MAINTAINER</keyword>
      <keyword>ONBUILD</keyword>
      <keyword>RUN</keyword>
      <keyword>SHELL</keyword>
      <keyword>STOPSIGNAL</keyword>
      <keyword>USER</keyword>
      <keyword>VOLUME</keyword>
      <keyword>WORKDIR</keyword>
    </context>

    <context id="docker" class="no-spell-check">
      <include>
        <context ref="comment"/>
        <context ref="single-quoted-string"/>
        <context ref="double-quoted-string"/>
        <context ref="numeric"/>
        <context ref="variable"/>
        <context ref="variable-definition"/>
        <context ref="user"/>
        <context ref="alias-definition"/>
        <context ref="alias-usage"/>
        <context ref="from-image"/>
        <context ref="operator"/>
        <context ref="keywords"/>
      </include>
    </context>
  </definitions>
</language>