Merge pull request #8 from theHamsta/empty-env

fix: allow empty value for env_pair
This commit is contained in:
Camden Cheek 2022-01-13 18:12:28 -07:00 committed by GitHub
commit 22bdef3e27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 4243 additions and 3394 deletions

View file

@ -1,221 +1,252 @@
==================
================================================================================
Add
==================
================================================================================
ADD /$FOO ./${bar}
---
--------------------------------------------------------------------------------
(source_file
(add_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
(add_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
==================
================================================================================
Copy
==================
================================================================================
COPY $FOO ./${bar}
---
--------------------------------------------------------------------------------
(source_file
(copy_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
(copy_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
==================
================================================================================
Special chars
==================
================================================================================
COPY $FOO ./${bar:-abc}
---
--------------------------------------------------------------------------------
(source_file
(copy_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
(copy_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
==================
================================================================================
Env
==================
================================================================================
ENV TEST="foo$BAR" \
TEST_2=foo\ bar$BAZ \
TEST_3="foo${bar}" \
TEST_4=foo\ ${baz}bar
---
--------------------------------------------------------------------------------
(source_file
(env_instruction
(env_pair
name: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (unquoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (unquoted_string
(expansion
(variable))))))
(env_instruction
(env_pair
name: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (unquoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
name: (unquoted_string)
value: (unquoted_string
(expansion
(variable))))))
==================
================================================================================
Empty Env
================================================================================
ENV TEST= \
TEST_2= \
TEST_3="foo${bar}" \
TEST_4=
ENV FOO=
--------------------------------------------------------------------------------
(source_file
(env_instruction
(env_pair
(unquoted_string))
(line_continuation)
(env_pair
(unquoted_string))
(line_continuation)
(env_pair
(unquoted_string)
(double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
(unquoted_string)))
(env_instruction
(env_pair
(unquoted_string))))
================================================================================
Expose
==================
================================================================================
EXPOSE $FOO
---
--------------------------------------------------------------------------------
(source_file
(expose_instruction
(expansion
(variable))))
(expose_instruction
(expansion
(variable))))
==================
================================================================================
From
==================
================================================================================
FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
---
--------------------------------------------------------------------------------
(source_file
(from_instruction
(image_spec
name: (image_name
(expansion
(variable)))
tag: (image_tag
(expansion
(variable)))
digest: (image_digest
(expansion
(variable))))
as: (image_alias
(expansion
(variable)))))
(from_instruction
(image_spec
name: (image_name
(expansion
(variable)))
tag: (image_tag
(expansion
(variable)))
digest: (image_digest
(expansion
(variable))))
as: (image_alias
(expansion
(variable)))))
==================
================================================================================
Label
==================
================================================================================
LABEL key="value$FOO"
---
--------------------------------------------------------------------------------
(source_file
(label_instruction
(label_pair
key: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))))
(label_instruction
(label_pair
key: (unquoted_string)
value: (double_quoted_string
(expansion
(variable))))))
==================
================================================================================
Stopsignal
==================
================================================================================
STOPSIGNAL $FOO
---
--------------------------------------------------------------------------------
(source_file
(stopsignal_instruction
(expansion
(variable))))
(stopsignal_instruction
(expansion
(variable))))
==================
================================================================================
User
==================
================================================================================
USER foo$FOO:bar${bar}
---
--------------------------------------------------------------------------------
(source_file
(user_instruction
user: (unquoted_string
(expansion
(variable)))
group: (unquoted_string
(expansion
(variable)))))
(user_instruction
user: (unquoted_string
(expansion
(variable)))
group: (unquoted_string
(expansion
(variable)))))
==================
================================================================================
Volume
==================
================================================================================
volume /my$FOO /my${bar}
---
--------------------------------------------------------------------------------
(source_file
(volume_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
(volume_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable)))))
==================
================================================================================
Workdir
==================
================================================================================
WORKDIR /tmp/$FOO
---
--------------------------------------------------------------------------------
(source_file
(workdir_instruction
(path
(expansion
(variable)))))
(workdir_instruction
(path
(expansion
(variable)))))
==================
================================================================================
Onbuild
==================
================================================================================
ONBUILD ADD /$FOO ./${bar}
---
--------------------------------------------------------------------------------
(source_file
(onbuild_instruction
(add_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable))))))
(onbuild_instruction
(add_instruction
(path
(expansion
(variable)))
(path
(expansion
(variable))))))

View file

@ -180,7 +180,7 @@ module.exports = grammar({
seq(
field("name", $._env_key),
token.immediate("="),
field("value", choice($.double_quoted_string, $.unquoted_string))
optional(field("value", choice($.double_quoted_string, $.unquoted_string)))
),
_spaced_env_pair: ($) =>

View file

@ -12,6 +12,6 @@
"nan": "^2.14.2"
},
"devDependencies": {
"tree-sitter-cli": "^0.19.4"
"tree-sitter-cli": "^0.20.1"
}
}

View file

@ -858,21 +858,29 @@
}
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "double_quoted_string"
},
{
"type": "SYMBOL",
"name": "unquoted_string"
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "value",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "double_quoted_string"
},
{
"type": "SYMBOL",
"name": "unquoted_string"
}
]
}
]
}
},
{
"type": "BLANK"
}
]
}
]
},
@ -1045,20 +1053,38 @@
]
},
"image_name": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[^@:\\s\\$]+"
},
{
"type": "SYMBOL",
"name": "expansion"
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[^@:\\s\\$-]"
},
{
"type": "SYMBOL",
"name": "expansion"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[^@:\\s\\$]+"
},
{
"type": "SYMBOL",
"name": "expansion"
}
]
}
]
}
}
]
},
"image_tag": {
"type": "SEQ",
@ -1235,8 +1261,13 @@
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "line_continuation"
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "required_line_continuation"
},
"named": true,
"value": "line_continuation"
},
{
"type": "REPEAT",
@ -1274,6 +1305,10 @@
"type": "STRING",
"value": "\\\n"
},
"required_line_continuation": {
"type": "STRING",
"value": "\\\n"
},
"_comment_line": {
"type": "SEQ",
"members": [

View file

@ -165,7 +165,7 @@
},
"value": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "double_quoted_string",
@ -408,6 +408,11 @@
}
}
},
{
"type": "line_continuation",
"named": true,
"fields": {}
},
{
"type": "maintainer_instruction",
"named": true,
@ -910,6 +915,10 @@
"type": "[",
"named": false
},
{
"type": "\\\n",
"named": false
},
{
"type": "\\ ",
"named": false
@ -922,10 +931,6 @@
"type": "escape_sequence",
"named": true
},
{
"type": "line_continuation",
"named": true
},
{
"type": "variable",
"named": true

File diff suppressed because it is too large Load diff