Allow variables to begin or end with underscores

This commit is contained in:
Marcio Mazza 2022-09-13 20:27:53 -03:00
parent 25c71d6a24
commit 4e512c60ef
5 changed files with 955 additions and 612 deletions

View file

@ -40,6 +40,23 @@ ENV X=42
(unquoted_string)
(unquoted_string))))
================================================================================
keys can begin or end with underscores
================================================================================
ENV _TEST="foo" TEST__=bar
--------------------------------------------------------------------------------
(source_file
(env_instruction
(env_pair
name: (unquoted_string)
value: (double_quoted_string))
(env_pair
name: (unquoted_string)
value: (unquoted_string))))
================================================================================
Multiple
================================================================================

View file

@ -86,6 +86,24 @@ ENV TEST="foo$BAR" \
(expansion
(variable))))))
================================================================================
Variables can begin or end with underscores
================================================================================
ENV TEST="$_foo${bar_}"
--------------------------------------------------------------------------------
(source_file
(env_instruction
(env_pair
(unquoted_string)
(double_quoted_string
(expansion
(variable))
(expansion
(variable))))))
================================================================================
Empty Env
================================================================================

View file

@ -209,7 +209,7 @@ module.exports = grammar({
)
),
variable: ($) => token.immediate(/[a-zA-Z][a-zA-Z0-9_]*/),
variable: ($) => token.immediate(/[a-zA-Z_][a-zA-Z0-9_]*/),
env_pair: ($) =>
seq(
@ -228,7 +228,7 @@ module.exports = grammar({
),
_env_key: ($) =>
alias(/[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?/, $.unquoted_string),
alias(/[a-zA-Z_][a-zA-Z0-9_]*/, $.unquoted_string),
expose_port: ($) => seq(/\d+/, optional(choice("/tcp", "/udp"))),

View file

@ -949,7 +949,7 @@
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z][a-zA-Z0-9_]*"
"value": "[a-zA-Z_][a-zA-Z0-9_]*"
}
},
"env_pair": {
@ -1038,7 +1038,7 @@
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?"
"value": "[a-zA-Z_][a-zA-Z0-9_]*"
},
"named": true,
"value": "unquoted_string"

File diff suppressed because it is too large Load diff