Add empty environment variable values
This commit is contained in:
parent
6d341b8314
commit
66693d7575
|
@ -79,6 +79,19 @@ VAR1=a VAR2="ok" git diff --word-diff=color
|
||||||
(argument)
|
(argument)
|
||||||
(argument)))
|
(argument)))
|
||||||
|
|
||||||
|
===================================
|
||||||
|
Empty environment variables
|
||||||
|
===================================
|
||||||
|
|
||||||
|
VAR1=
|
||||||
|
VAR2= echo
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(environment_variable_assignment (variable_name))
|
||||||
|
(command (environment_variable_assignment (variable_name)) (command_name)))
|
||||||
|
|
||||||
===================================
|
===================================
|
||||||
Pipelines
|
Pipelines
|
||||||
===================================
|
===================================
|
||||||
|
|
|
@ -8,7 +8,8 @@ module.exports = grammar({
|
||||||
$._heredoc_beginning,
|
$._heredoc_beginning,
|
||||||
$._heredoc_middle,
|
$._heredoc_middle,
|
||||||
$._heredoc_end,
|
$._heredoc_end,
|
||||||
$.file_descriptor
|
$.file_descriptor,
|
||||||
|
$._empty_value
|
||||||
],
|
],
|
||||||
|
|
||||||
extras: $ => [
|
extras: $ => [
|
||||||
|
@ -149,7 +150,10 @@ module.exports = grammar({
|
||||||
environment_variable_assignment: $ => seq(
|
environment_variable_assignment: $ => seq(
|
||||||
rename($.leading_word, 'variable_name'),
|
rename($.leading_word, 'variable_name'),
|
||||||
'=',
|
'=',
|
||||||
$.value
|
choice(
|
||||||
|
$.value,
|
||||||
|
$._empty_value
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
value: $ => choice(
|
value: $ => choice(
|
||||||
|
|
|
@ -546,9 +546,18 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "="
|
"value": "="
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_empty_value"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -927,6 +936,10 @@
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "file_descriptor"
|
"name": "file_descriptor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_empty_value"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inline": [
|
"inline": [
|
||||||
|
|
16597
src/parser.c
16597
src/parser.c
File diff suppressed because it is too large
Load Diff
|
@ -12,6 +12,7 @@ enum TokenType {
|
||||||
HEREDOC_MIDDLE,
|
HEREDOC_MIDDLE,
|
||||||
HEREDOC_END,
|
HEREDOC_END,
|
||||||
FILE_DESCRIPTOR,
|
FILE_DESCRIPTOR,
|
||||||
|
EMPTY_VALUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Scanner {
|
struct Scanner {
|
||||||
|
@ -75,7 +76,9 @@ struct Scanner {
|
||||||
bool scan(TSLexer *lexer, const bool *valid_symbols) {
|
bool scan(TSLexer *lexer, const bool *valid_symbols) {
|
||||||
if (valid_symbols[HEREDOC_MIDDLE]) {
|
if (valid_symbols[HEREDOC_MIDDLE]) {
|
||||||
return scan_heredoc_content(lexer, HEREDOC_MIDDLE, HEREDOC_END);
|
return scan_heredoc_content(lexer, HEREDOC_MIDDLE, HEREDOC_END);
|
||||||
} else if (valid_symbols[HEREDOC_BEGINNING]) {
|
}
|
||||||
|
|
||||||
|
if (valid_symbols[HEREDOC_BEGINNING]) {
|
||||||
heredoc_identifier.clear();
|
heredoc_identifier.clear();
|
||||||
while (iswalpha(lexer->lookahead)) {
|
while (iswalpha(lexer->lookahead)) {
|
||||||
heredoc_identifier += lexer->lookahead;
|
heredoc_identifier += lexer->lookahead;
|
||||||
|
@ -91,7 +94,9 @@ struct Scanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
return scan_heredoc_content(lexer, HEREDOC_BEGINNING, SIMPLE_HEREDOC);
|
return scan_heredoc_content(lexer, HEREDOC_BEGINNING, SIMPLE_HEREDOC);
|
||||||
} else if (valid_symbols[FILE_DESCRIPTOR]) {
|
}
|
||||||
|
|
||||||
|
if (valid_symbols[FILE_DESCRIPTOR]) {
|
||||||
while (lexer->lookahead == ' ' || lexer->lookahead == '\t') skip(lexer);
|
while (lexer->lookahead == ' ' || lexer->lookahead == '\t') skip(lexer);
|
||||||
if (iswdigit(lexer->lookahead)) {
|
if (iswdigit(lexer->lookahead)) {
|
||||||
advance(lexer);
|
advance(lexer);
|
||||||
|
@ -103,6 +108,13 @@ struct Scanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (valid_symbols[EMPTY_VALUE]) {
|
||||||
|
if (iswspace(lexer->lookahead)) {
|
||||||
|
lexer->result_symbol = EMPTY_VALUE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue