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
|
# Barebones Dockerfile syntax for JOE. Doesn't handle more sophisticated sh syntax.
=Idle
=Command +Statement +Keyword
=Comment
=Constant
=String +Constant
=Ident
=Escape
=Brace
=StringEscape +Escape
=Variable +DefinedIdent
# 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
* comment
"BFHNTX" comment noeat call=comment_todo.comment_todo()
"\n" start
# Comments in the middle of a command
:comment_idle Comment 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
"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
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 Constant
* string_command_data
"$" string_command_data recolor=-1 call=.variable()
"\n" start
# FROM
:from Command
* from_image noeat
:from_image Constant
* 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
"\n" start
:comma Idle
* array noeat
:bracket Brace
"]" idle
"[" array
# LABEL
:label Command
* label_key
"\n" start
:label_key Variable
* label_key
"=" label_value noeat
"\n" start
:label_value Constant
* label_value
"\"" label_value recolor=-1 call=.string() save_c
"\n" start
.subr variable
:variable Variable
* variable recolor=-2 return noeat
"A-Za-z_" variable_name
"{" variable_long
:variable_name Variable
* variable_name return noeat
"A-Za-z0-9_" variable_name
:variable_long Variable
* 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 String string
* string
& string return
"\n" string return noeat
"\\" string_escape recolor=-1
"$" string recolor=-1 call=.variable()
:string_escape StringEscape string
* string
.end
|