-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtree-sitter-dockerfile.ebnf
209 lines (148 loc) · 5.05 KB
/
tree-sitter-dockerfile.ebnf
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//
// From tree-sitter-dockerfile/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
( ( _instruction | comment ) '\n' )*
_instruction ::=
from_instruction
| run_instruction
| cmd_instruction
| label_instruction
| expose_instruction
| env_instruction
| add_instruction
| copy_instruction
| entrypoint_instruction
| volume_instruction
| user_instruction
| workdir_instruction
| arg_instruction
| onbuild_instruction
| stopsignal_instruction
| healthcheck_instruction
| shell_instruction
| maintainer_instruction
| cross_build_instruction
from_instruction ::=
[fF][rR][oO][mM] param? image_spec ( [aA][sS] image_alias )?
run_instruction ::=
[rR][uU][nN] ( param | mount_param )* ( json_string_array | shell_command )
cmd_instruction ::=
[cC][mM][dD] ( json_string_array | shell_command )
label_instruction ::=
[lL][aA][bB][eE][lL] label_pair+
expose_instruction ::=
[eE][xX][pP][oO][sS][eE] ( expose_port | expansion )+
env_instruction ::=
[eE][nN][vV] ( env_pair+ | _spaced_env_pair )
add_instruction ::=
[aA][dD][dD] param* ( path _non_newline_whitespace )+ path
copy_instruction ::=
[cC][oO][pP][yY] param* ( path _non_newline_whitespace )+ path
entrypoint_instruction ::=
[eE][nN][tT][rR][yY][pP][oO][iI][nN][tT] ( json_string_array | shell_command )
volume_instruction ::=
[vV][oO][lL][uU][mM][eE] ( json_string_array | path ( _non_newline_whitespace path )* )
user_instruction ::=
[uU][sS][eE][rR] _user_name_or_group ( ':' _immediate_user_name_or_group )?
_user_name_or_group ::=
( ([a-zA-Z][-A-Za-z0-9_]*|[0-9]+) | expansion ) _immediate_user_name_or_group_fragment*
_immediate_user_name_or_group ::=
_immediate_user_name_or_group_fragment+
_immediate_user_name_or_group_fragment ::=
([a-zA-Z][-a-zA-Z0-9_]*|[0-9]+)
| _immediate_expansion
workdir_instruction ::=
[wW][oO][rR][kK][dD][iI][rR] path
arg_instruction ::=
[aA][rR][gG] [a-zA-Z0-9_]+ ( '=' ( double_quoted_string | single_quoted_string | unquoted_string ) )?
onbuild_instruction ::=
[oO][nN][bB][uU][iI][lL][dD] _instruction
stopsignal_instruction ::=
[sS][tT][oO][pP][sS][iI][gG][nN][aA][lL] _stopsignal_value
_stopsignal_value ::=
( [A-Z0-9]+ | expansion ) ( [A-Z0-9]+ | _immediate_expansion )*
healthcheck_instruction ::=
[hH][eE][aA][lL][tT][hH][cC][hH][eE][cC][kK] ( 'NONE' | param* cmd_instruction )
shell_instruction ::=
[sS][hH][eE][lL][lL] json_string_array
maintainer_instruction ::=
[mM][aA][iI][nN][tT][aA][iI][nN][eE][rR] '.'*
cross_build_instruction ::=
[cC][rR][oO][sS][sS]'_'[bB][uU][iI][lL][dD][a-zA-Z_]* '.'*
path ::=
( [^- #x09#x0A#x0B#x0C#x0D\$] | expansion ) ( [^ #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )*
expansion ::=
'$' _expansion_body
_immediate_expansion ::=
_imm_expansion
_imm_expansion ::=
'$' _expansion_body
_expansion_body ::=
variable
| '{' [^\}]+ '}'
variable ::=
[a-zA-Z_][a-zA-Z0-9_]*
env_pair ::=
_env_key '=' ( double_quoted_string | single_quoted_string | unquoted_string )?
_spaced_env_pair ::=
_env_key [ #x09#x0A#x0B#x0C#x0D]+ ( double_quoted_string | single_quoted_string | unquoted_string )
_env_key ::=
[a-zA-Z_][a-zA-Z0-9_]*
expose_port ::=
[0-9]+ ( '/tcp' | '/udp' )?
label_pair ::=
( [-a-zA-Z0-9._]+ | double_quoted_string | single_quoted_string ) '=' ( double_quoted_string | single_quoted_string | unquoted_string )
image_spec ::=
image_name image_tag? image_digest?
image_name ::=
( [^@: #x09#x0A#x0B#x0C#x0D\$-] | expansion ) ( [^@: #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )*
image_tag ::=
':' ( [^@ #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )+
image_digest ::=
'@' ( [a-zA-Z0-9:]+ | _immediate_expansion )+
param ::=
'--' [a-z][-a-z]* '=' [^ #x09#x0A#x0B#x0C#x0D]+
mount_param ::=
'--' 'mount' '=' ( mount_param_param ( ',' mount_param_param )* )
mount_param_param ::=
[^ #x09#x0A#x0B#x0C#x0D=,]+ '=' [^ #x09#x0A#x0B#x0C#x0D=,]+
image_alias ::=
( [-a-zA-Z0-9_]+ | expansion ) ( [-a-zA-Z0-9_]+ | _immediate_expansion )*
shell_command ::=
_comment_line* shell_fragment ( required_line_continuation _comment_line* shell_fragment )*
shell_fragment ::=
( [,=-] | [^\#x5B#x0A#x23 #x09#x0A#x0B#x0C#x0D,=-][^\#x0A]* | '\'[^#x0A,=-] )+
line_continuation ::=
'\\n'
required_line_continuation ::=
'\\n'
_comment_line ::=
_anon_comment '\n'
_anon_comment ::=
'#' '.'*
json_string_array ::=
'[' ( json_string ( ',' json_string )* )? ']'
json_string ::=
'"' ( [^"\]+ | json_escape_sequence )* '"'
json_escape_sequence ::=
'\'(?':'["\/bfnrt]|'u'[0-9A-Fa-f]'{4}')
double_quoted_string ::=
'"' ( [^"#x0A\\$]+ | double_quoted_escape_sequence | '\\' | _immediate_expansion )* '"'
single_quoted_string ::=
"'" ( [^'#x0A\]+ | single_quoted_escape_sequence | '\\' )* "'"
unquoted_string ::=
( [^ #x09#x0A#x0B#x0C#x0D#x0A\"'\\$]+ | '\ ' | _immediate_expansion )+
double_quoted_escape_sequence ::=
( '\\' | '\"' )
single_quoted_escape_sequence ::=
( '\\' | "\'" )
_non_newline_whitespace ::=
[#x09 ]+
comment ::=
'#.'*