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 209 210
|
# Barebones Dockerfile syntax for JOE. Doesn't handle more sophisticated sh syntax.
=Idle
=Command bold
=Comment green
=Constant cyan
=Ident cyan
=Escape magenta
=Keyword bold
=Var bold cyan
=Bad bold red
# Start of line is special
:start Idle
* idle
" \t" start
"#" comment noeat
"A-Za-z" command buffer noeat
"\n" start
# Comments between commands
:comment Comment
* comment
"\n" start
# Comments in the middle of a command
:comment_idle Comment
* comment_idle
"\n" idle
# Start of line in the middle of "idle" mode (skips command recognition in case a comment
# comes in the middle of a RUN)
:start_idle Idle
* idle noeat
"#" comment_idle recolor=-1
# Generic middle-of-a-command
:idle Idle
* idle
"$" idle recolor=-1 call=.variable()
"\n" start
"\\" escape recolor=-1
:escape Escape
* idle recolor=-2 noeat
"\\\"" idle
"\r" escape
"\n" start_idle
:command Idle
* idle noeat istrings
"FROM" from
"MAINTAINER" string_command
"RUN" list_command
"CMD" list_command
"SHELL" list_command
"LABEL" label
"EXPOSE" generic_command
"ENV" generic_command
"ADD" list_command
"COPY" list_command
"ENTRYPOINT" list_command
"VOLUME" list_command
"USER" string_command
"WORKDIR" string_command
"ARG" generic_command
"ONBUILD" generic_command
"STOPSIGNAL" generic_command
"HEALTHCHECK" healthcheck_command
done
"a-zA-Z" command
# EXPOSE, ENV, ARG, ONBUILD, STOPSIGNAL
:generic_command Command
* idle
# MAINTAINER, USER, WORKDIR
:string_command Command
* string_command_data
:string_command_data Ident
* string_command_data
"$" string_command_data recolor=-1 call=.variable()
"\n" start
# FROM
:from Command
* from_image noeat
:from_image Ident
* from_image
":@" from_tag noeat
"\n" start
:from_tag Idle
* from_tag
"\n" start
# RUN, CMD, ADD, COPY, ENTRYPOINT, VOLUME
:list_command Command
* idle noeat
" \t" list_command
"[" array noeat
"\n" start
:array Idle
* array
"[]" bracket noeat
"\"" array recolor=-1 call=.string() save_c
"'" array_bad noeat
"\n" start
:array_bad Bad
* array
:comma Idle
* array noeat
:bracket Escape
"]" idle
"[" array
# LABEL
:label Command
* label_key
"\n" start
:label_key Ident
* label_key
"=" label_value noeat
"\n" start
:label_value Idle
* label_value
"\"" label_value recolor=-1 call=.string() save_c
"\n" start
# HEALTHCHECK
:healthcheck_command Command
* idle noeat
"a-zA-Z" healthcheck_argument buffer noeat
"\-" healthcheck_option recolor=-1
" \t" healthcheck_command
"\\" healthcheck_escape recolor=-1
:healthcheck_argument Idle
* idle noeat istrings
"NONE" healthcheck_none
"CMD" list_command
done
"a-zA-Z" healthcheck_argument
:healthcheck_option Ident
* healthcheck_option
"\n" start
"\\" healthcheck_escape recolor=-1
" \t" healthcheck_command
"=" healthcheck_value
:healthcheck_value Idle
* healthcheck_value
"\n" start
"\\" healthcheck_escape
" \t" healthcheck_command
:healthcheck_escape Escape
"\r" healthcheck_escape
* healthcheck_command
:healthcheck_none Command
* idle noeat
.subr variable
:variable Var
* variable recolor=-2 return noeat
"A-Za-z_" variable_name
"{" variable_long
:variable_name Var
* variable_name return noeat
"A-Za-z0-9_" variable_name
:variable_long Var
* variable_long
& variable return noeat
"\n" variable return noeat
"}" variable return
":" variable_after
:variable_after Idle
* variable_after
& variable_after return noeat
"}" variable_long noeat
.end
.subr string
:string Constant
* string
& string return
"\n" string return noeat
"\\" string_escape recolor=-1
"$" string recolor=-1 call=.variable()
:string_escape Escape
* string
.end
|