fix: allow empty value for env_pair
This commit is contained in:
parent
dd2673d44c
commit
44be8fbf72
299
corpus/vars.txt
299
corpus/vars.txt
|
@ -1,221 +1,252 @@
|
||||||
==================
|
================================================================================
|
||||||
Add
|
Add
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ADD /$FOO ./${bar}
|
ADD /$FOO ./${bar}
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(add_instruction
|
(add_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Copy
|
Copy
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
COPY $FOO ./${bar}
|
COPY $FOO ./${bar}
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(copy_instruction
|
(copy_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Special chars
|
Special chars
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
COPY $FOO ./${bar:-abc}
|
COPY $FOO ./${bar:-abc}
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(copy_instruction
|
(copy_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Env
|
Env
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST="foo$BAR" \
|
ENV TEST="foo$BAR" \
|
||||||
TEST_2=foo\ bar$BAZ \
|
TEST_2=foo\ bar$BAZ \
|
||||||
TEST_3="foo${bar}" \
|
TEST_3="foo${bar}" \
|
||||||
TEST_4=foo\ ${baz}bar
|
TEST_4=foo\ ${baz}bar
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string
|
value: (double_quoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
(line_continuation)
|
(line_continuation)
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (unquoted_string
|
value: (unquoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
(line_continuation)
|
(line_continuation)
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string
|
value: (double_quoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
(line_continuation)
|
(line_continuation)
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (unquoted_string
|
value: (unquoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))))
|
(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
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
EXPOSE $FOO
|
EXPOSE $FOO
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(expose_instruction
|
(expose_instruction
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
From
|
From
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
|
FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(from_instruction
|
(from_instruction
|
||||||
(image_spec
|
(image_spec
|
||||||
name: (image_name
|
name: (image_name
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
tag: (image_tag
|
tag: (image_tag
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
digest: (image_digest
|
digest: (image_digest
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
as: (image_alias
|
as: (image_alias
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Label
|
Label
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
LABEL key="value$FOO"
|
LABEL key="value$FOO"
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(label_instruction
|
(label_instruction
|
||||||
(label_pair
|
(label_pair
|
||||||
key: (unquoted_string)
|
key: (unquoted_string)
|
||||||
value: (double_quoted_string
|
value: (double_quoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))))
|
(variable))))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Stopsignal
|
Stopsignal
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
STOPSIGNAL $FOO
|
STOPSIGNAL $FOO
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(stopsignal_instruction
|
(stopsignal_instruction
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))
|
(variable))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
User
|
User
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
USER foo$FOO:bar${bar}
|
USER foo$FOO:bar${bar}
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(user_instruction
|
(user_instruction
|
||||||
user: (unquoted_string
|
user: (unquoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
group: (unquoted_string
|
group: (unquoted_string
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Volume
|
Volume
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
volume /my$FOO /my${bar}
|
volume /my$FOO /my${bar}
|
||||||
|
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(volume_instruction
|
(volume_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Workdir
|
Workdir
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
WORKDIR /tmp/$FOO
|
WORKDIR /tmp/$FOO
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(workdir_instruction
|
(workdir_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))))
|
(variable)))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
==================
|
|
||||||
Onbuild
|
Onbuild
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ONBUILD ADD /$FOO ./${bar}
|
ONBUILD ADD /$FOO ./${bar}
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(onbuild_instruction
|
(onbuild_instruction
|
||||||
(add_instruction
|
(add_instruction
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable)))
|
(variable)))
|
||||||
(path
|
(path
|
||||||
(expansion
|
(expansion
|
||||||
(variable))))))
|
(variable))))))
|
||||||
|
|
|
@ -180,7 +180,7 @@ module.exports = grammar({
|
||||||
seq(
|
seq(
|
||||||
field("name", $._env_key),
|
field("name", $._env_key),
|
||||||
token.immediate("="),
|
token.immediate("="),
|
||||||
field("value", choice($.double_quoted_string, $.unquoted_string))
|
optional(field("value", choice($.double_quoted_string, $.unquoted_string)))
|
||||||
),
|
),
|
||||||
|
|
||||||
_spaced_env_pair: ($) =>
|
_spaced_env_pair: ($) =>
|
||||||
|
|
|
@ -858,21 +858,29 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "CHOICE",
|
||||||
"name": "value",
|
"members": [
|
||||||
"content": {
|
{
|
||||||
"type": "CHOICE",
|
"type": "FIELD",
|
||||||
"members": [
|
"name": "value",
|
||||||
{
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "CHOICE",
|
||||||
"name": "double_quoted_string"
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "SYMBOL",
|
||||||
"type": "SYMBOL",
|
"name": "double_quoted_string"
|
||||||
"name": "unquoted_string"
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "unquoted_string"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1045,20 +1053,38 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"image_name": {
|
"image_name": {
|
||||||
"type": "REPEAT1",
|
"type": "SEQ",
|
||||||
"content": {
|
"members": [
|
||||||
"type": "CHOICE",
|
{
|
||||||
"members": [
|
"type": "CHOICE",
|
||||||
{
|
"members": [
|
||||||
"type": "PATTERN",
|
{
|
||||||
"value": "[^@:\\s\\$]+"
|
"type": "PATTERN",
|
||||||
},
|
"value": "[^@:\\s\\$-]"
|
||||||
{
|
},
|
||||||
"type": "SYMBOL",
|
{
|
||||||
"name": "expansion"
|
"type": "SYMBOL",
|
||||||
|
"name": "expansion"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[^@:\\s\\$]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expansion"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"image_tag": {
|
"image_tag": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
@ -1235,8 +1261,13 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "ALIAS",
|
||||||
"name": "line_continuation"
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "required_line_continuation"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "line_continuation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
|
@ -1274,6 +1305,10 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "\\\n"
|
"value": "\\\n"
|
||||||
},
|
},
|
||||||
|
"required_line_continuation": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\\\n"
|
||||||
|
},
|
||||||
"_comment_line": {
|
"_comment_line": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "double_quoted_string",
|
"type": "double_quoted_string",
|
||||||
|
@ -408,6 +408,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "line_continuation",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "maintainer_instruction",
|
"type": "maintainer_instruction",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -910,6 +915,10 @@
|
||||||
"type": "[",
|
"type": "[",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "\\\n",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "\\ ",
|
"type": "\\ ",
|
||||||
"named": false
|
"named": false
|
||||||
|
@ -922,10 +931,6 @@
|
||||||
"type": "escape_sequence",
|
"type": "escape_sequence",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "line_continuation",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "variable",
|
"type": "variable",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
7260
src/parser.c
7260
src/parser.c
File diff suppressed because it is too large
Load diff
|
@ -102,8 +102,8 @@ struct TSLanguage {
|
||||||
const uint16_t *small_parse_table;
|
const uint16_t *small_parse_table;
|
||||||
const uint32_t *small_parse_table_map;
|
const uint32_t *small_parse_table_map;
|
||||||
const TSParseActionEntry *parse_actions;
|
const TSParseActionEntry *parse_actions;
|
||||||
const char * const *symbol_names;
|
const char **symbol_names;
|
||||||
const char * const *field_names;
|
const char **field_names;
|
||||||
const TSFieldMapSlice *field_map_slices;
|
const TSFieldMapSlice *field_map_slices;
|
||||||
const TSFieldMapEntry *field_map_entries;
|
const TSFieldMapEntry *field_map_entries;
|
||||||
const TSSymbolMetadata *symbol_metadata;
|
const TSSymbolMetadata *symbol_metadata;
|
||||||
|
|
Loading…
Reference in a new issue