support multiple parameters to ADD and COPY
This commit adds support for parsing multiple parameters to both `ADD` and `COPY` commands. For example, tree-sitter-dockerfile now correctly parses both of these lines from the dockerfile reference[^1]: ```dockerfile ADD --chown=myuser:mygroup --chmod=655 files* /somedir/ COPY --chown=myuser:mygroup --chmod=644 files* /somedir/ ``` Closes #43 [^1]: https://docs.docker.com/engine/reference/builder/
This commit is contained in:
parent
1800d5a067
commit
c9351d9009
|
@ -38,3 +38,18 @@ ADD src1 src2 dst
|
||||||
(path)
|
(path)
|
||||||
(path)
|
(path)
|
||||||
(path)))
|
(path)))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Multiple params
|
||||||
|
==================
|
||||||
|
|
||||||
|
ADD --chown=a:b --chmod=644 src dst
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(add_instruction
|
||||||
|
(param)
|
||||||
|
(param)
|
||||||
|
(path)
|
||||||
|
(path)))
|
||||||
|
|
|
@ -38,3 +38,18 @@ COPY src1 src2 dst
|
||||||
(path)
|
(path)
|
||||||
(path)
|
(path)
|
||||||
(path)))
|
(path)))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Multiple params
|
||||||
|
==================
|
||||||
|
|
||||||
|
COPY --chown=a:b --chmod=644 src dst
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(copy_instruction
|
||||||
|
(param)
|
||||||
|
(param)
|
||||||
|
(path)
|
||||||
|
(path)))
|
||||||
|
|
|
@ -73,7 +73,7 @@ module.exports = grammar({
|
||||||
add_instruction: ($) =>
|
add_instruction: ($) =>
|
||||||
seq(
|
seq(
|
||||||
alias(/[aA][dD][dD]/, "ADD"),
|
alias(/[aA][dD][dD]/, "ADD"),
|
||||||
optional($.param),
|
repeat($.param),
|
||||||
repeat1(
|
repeat1(
|
||||||
seq($.path, $._non_newline_whitespace)
|
seq($.path, $._non_newline_whitespace)
|
||||||
),
|
),
|
||||||
|
@ -83,7 +83,7 @@ module.exports = grammar({
|
||||||
copy_instruction: ($) =>
|
copy_instruction: ($) =>
|
||||||
seq(
|
seq(
|
||||||
alias(/[cC][oO][pP][yY]/, "COPY"),
|
alias(/[cC][oO][pP][yY]/, "COPY"),
|
||||||
optional($.param),
|
repeat($.param),
|
||||||
repeat1(
|
repeat1(
|
||||||
seq($.path, $._non_newline_whitespace)
|
seq($.path, $._non_newline_whitespace)
|
||||||
),
|
),
|
||||||
|
|
|
@ -336,16 +336,11 @@
|
||||||
"value": "ADD"
|
"value": "ADD"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "REPEAT",
|
||||||
"members": [
|
"content": {
|
||||||
{
|
"type": "SYMBOL",
|
||||||
"type": "SYMBOL",
|
"name": "param"
|
||||||
"name": "param"
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
|
@ -382,16 +377,11 @@
|
||||||
"value": "COPY"
|
"value": "COPY"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "REPEAT",
|
||||||
"members": [
|
"content": {
|
||||||
{
|
"type": "SYMBOL",
|
||||||
"type": "SYMBOL",
|
"name": "param"
|
||||||
"name": "param"
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
|
|
8110
src/parser.c
8110
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue