Skip to content

Commit

Permalink
support for space in ARG and ENV values and quoted strings in strings
Browse files Browse the repository at this point in the history
fix: #3 #7
  • Loading branch information
glehmann committed Mar 19, 2024
1 parent 28c93f8 commit 5cb2c3e
Show file tree
Hide file tree
Showing 24 changed files with 90,110 additions and 53,141 deletions.
158 changes: 117 additions & 41 deletions grammar.js

Large diffs are not rendered by default.

471 changes: 409 additions & 62 deletions src/grammar.json

Large diffs are not rendered by default.

391 changes: 70 additions & 321 deletions src/node-types.json

Large diffs are not rendered by default.

141,961 changes: 89,335 additions & 52,626 deletions src/parser.c

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions test/corpus/arg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ ARG foo=aaa
(source_file
(arg_command
name: (variable)
default_value: (unquoted_string)))
default_value: (string
(unquoted_string))))

==================
arg command default value single quoted
Expand All @@ -60,7 +61,8 @@ ARG foo='auie tsrn'
(source_file
(arg_command
name: (variable)
default_value: (single_quoted_string)))
default_value: (string
(single_quoted_string))))

==================
arg command default value double quoted
Expand All @@ -73,7 +75,8 @@ ARG foo="it's ok"
(source_file
(arg_command
name: (variable)
default_value: (double_quoted_string)))
default_value: (string
(double_quoted_string))))

==================
arg command default value expr
Expand Down Expand Up @@ -111,7 +114,8 @@ ARG foo = bar
(source_file
(arg_command
name: (variable)
default_value: (unquoted_string)))
default_value: (string
(unquoted_string))))

==================
arg command with value starting with a sharp
Expand All @@ -124,4 +128,20 @@ ARG foo="#123456"
(source_file
(arg_command
name: (variable)
default_value: (double_quoted_string)))
default_value: (string
(double_quoted_string))))

==================
arg command unquoted with spaces
==================

ARG foo=a bb ccc dddd # comment

---

(source_file
(arg_command
name: (variable)
default_value: (string
(unquoted_string))
(comment)))
44 changes: 26 additions & 18 deletions test/corpus/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ foo:
(build_command
(line_continuation)
option: (platform
value: (unquoted_string))
value: (string
(unquoted_string)))
(line_continuation)
option: (platform
value: (unquoted_string))
value: (string
(unquoted_string)))
(line_continuation)
(target_ref
name: (identifier)))))
Expand All @@ -58,14 +60,16 @@ foo:
(build_command
(line_continuation)
option: (platform
value: (unquoted_string
(expansion
(variable))))
value: (string
(unquoted_string
(expansion
(variable)))))
(line_continuation)
option: (platform
value: (unquoted_string
(expansion
(variable))))
value: (string
(unquoted_string
(expansion
(variable)))))
(line_continuation)
(target_ref
name: (identifier
Expand All @@ -90,14 +94,16 @@ foo:
(build_command
(line_continuation)
option: (platform
value: (unquoted_string
(expansion
(variable))))
value: (string
(unquoted_string
(expansion
(variable)))))
(line_continuation)
option: (platform
value: (unquoted_string
(expansion
(variable))))
value: (string
(unquoted_string
(expansion
(variable)))))
(line_continuation)
(target_ref
name: (identifier
Expand All @@ -117,9 +123,10 @@ foo:
(target
name: (identifier)
(build_command
(unquoted_string
(expansion
(variable))))))
(string
(unquoted_string
(expansion
(variable)))))))

==================
build command deprecated build arg
Expand All @@ -135,7 +142,8 @@ foo:
name: (identifier)
(build_command
option: (build_arg_deprecated
value: (unquoted_string))
value: (string
(unquoted_string)))
(target_ref
name: (identifier)))))

Expand Down
3 changes: 2 additions & 1 deletion test/corpus/cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ foo:
name: (identifier)
(cache_command
option: (persist)
mount_point: (unquoted_string))))
mount_point: (string
(unquoted_string)))))
64 changes: 40 additions & 24 deletions test/corpus/copy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ foo:
(target
name: (identifier)
(copy_command
src: (unquoted_string)
dest: (unquoted_string))))
src: (string
(unquoted_string))
dest: (string
(unquoted_string)))))

==================
copy multi sources
Expand All @@ -27,9 +29,12 @@ foo:
(target
name: (identifier)
(copy_command
src: (double_quoted_string)
src: (unquoted_string)
dest: (unquoted_string))))
src: (string
(double_quoted_string))
src: (string
(unquoted_string))
dest: (string
(unquoted_string)))))

==================
copy with options
Expand All @@ -47,9 +52,12 @@ foo:
option: (dir)
option: (keep_ts)
option: (platform
value: (unquoted_string))
src: (unquoted_string)
dest: (unquoted_string))))
value: (string
(unquoted_string)))
src: (string
(unquoted_string))
dest: (string
(unquoted_string)))))

==================
copy target artifacts
Expand All @@ -70,12 +78,14 @@ foo:
(unquoted_string)
(build_arg
name: (variable)
value: (unquoted_string)))
value: (string
(unquoted_string))))
src: (target_artifact
(target_ref
name: (identifier))
(unquoted_string))
dest: (unquoted_string))))
dest: (string
(unquoted_string)))))

==================
copy target artifacts with expansions
Expand Down Expand Up @@ -112,13 +122,15 @@ foo:
(variable))))
(unquoted_string))
(line_continuation)
src: (unquoted_string
(expansion
(variable)))
src: (string
(unquoted_string
(expansion
(variable))))
(line_continuation)
src: (unquoted_string
(expansion
(variable)))
src: (string
(unquoted_string
(expansion
(variable))))
(line_continuation)
src: (target_artifact_build_args
(target_ref
Expand All @@ -130,16 +142,20 @@ foo:
(variable)))
(build_arg
name: (variable)
value: (unquoted_string)))
value: (string
(unquoted_string))))
(line_continuation)
src: (target_artifact_build_args
(unquoted_string
(expansion
(variable))
(expansion
(variable)))
(string
(unquoted_string
(expansion
(variable))
(expansion
(variable))))
(build_arg
name: (variable)
value: (unquoted_string)))
value: (string
(unquoted_string))))
(line_continuation)
dest: (unquoted_string))))
dest: (string
(unquoted_string)))))
3 changes: 2 additions & 1 deletion test/corpus/do.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ foo:
name: (identifier))
(build_arg
name: (variable)
value: (unquoted_string)))))
value: (string
(unquoted_string))))))
9 changes: 6 additions & 3 deletions test/corpus/env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ foo:
name: (identifier)
(env_command
key: (variable)
value: (unquoted_string))))
value: (string
(unquoted_string)))))

==================
env command with spaces around =
Expand All @@ -28,7 +29,8 @@ foo:
name: (identifier)
(env_command
key: (variable)
value: (unquoted_string))))
value: (string
(unquoted_string)))))

==================
env command without =
Expand All @@ -44,4 +46,5 @@ foo:
name: (identifier)
(env_command
key: (variable)
value: (unquoted_string))))
value: (string
(unquoted_string)))))
15 changes: 10 additions & 5 deletions test/corpus/for.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ foo:
name: (identifier)
(for_command
name: (variable)
value: (unquoted_string)
value: (string
(unquoted_string))
value: (expr)
value: (unquoted_string)
value: (string
(unquoted_string))
(run_command
option: (no_cache)
command: (shell_fragment)))))
Expand All @@ -38,8 +40,11 @@ foo:
(for_command
option: (ssh)
name: (variable)
value: (unquoted_string)
value: (unquoted_string)
value: (unquoted_string)
value: (string
(unquoted_string))
value: (string
(unquoted_string))
value: (string
(unquoted_string))
(run_command
command: (shell_fragment)))))
12 changes: 8 additions & 4 deletions test/corpus/from.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ FROM +build --foo=bar
name: (identifier))
(build_arg
name: (variable)
value: (unquoted_string))))
value: (string
(unquoted_string)))))

==================
from target with space build arg
Expand All @@ -83,7 +84,8 @@ FROM +build --foo bar
name: (identifier))
(build_arg
name: (variable)
value: (unquoted_string))))
value: (string
(unquoted_string)))))

==================
from target with platform
Expand All @@ -95,7 +97,8 @@ FROM --platform=linux/arm64 +build
(source_file
(from_command
option: (platform
value: (unquoted_string))
value: (string
(unquoted_string)))
(target_ref
name: (identifier))))

Expand All @@ -109,7 +112,8 @@ FROM --platform linux/arm64 +build
(source_file
(from_command
option: (platform
value: (unquoted_string))
value: (string
(unquoted_string)))
(target_ref
name: (identifier))))

Expand Down
12 changes: 8 additions & 4 deletions test/corpus/from_dockerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ foo:
(target
name: (identifier)
(from_dockerfile_command
context: (unquoted_string))))
context: (string
(unquoted_string)))))

==================
from dockerfile command with options
Expand All @@ -32,13 +33,16 @@ foo:
(from_dockerfile_command
(line_continuation)
option: (docker_file
value: (unquoted_string))
value: (string
(unquoted_string)))
(line_continuation)
option: (docker_build_arg
key: (identifier)
value: (unquoted_string))
value: (string
(unquoted_string)))
(line_continuation)
option: (docker_target
value: (identifier))
(line_continuation)
context: (unquoted_string))))
context: (string
(unquoted_string)))))
Loading

0 comments on commit 5cb2c3e

Please sign in to comment.