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 /$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))))))
|
||||
|
|
|
@ -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: ($) =>
|
||||
|
|
|
@ -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": [
|
||||
|
|
|
@ -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
|
||||
|
|
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 uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const char **symbol_names;
|
||||
const char **field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
|
|
Loading…
Reference in a new issue