Merge pull request #23 from marciomazza/variables-can-start-or-end-with-underscores

Allow variables to begin or end with underscores
This commit is contained in:
Camden Cheek 2022-11-05 10:20:01 -06:00 committed by GitHub
commit e808beaf1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 955 additions and 612 deletions

View file

@ -40,6 +40,23 @@ ENV X=42
(unquoted_string) (unquoted_string)
(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 Multiple
================================================================================ ================================================================================

View file

@ -86,6 +86,24 @@ ENV TEST="foo$BAR" \
(expansion (expansion
(variable)))))) (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 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: ($) => env_pair: ($) =>
seq( seq(
@ -228,7 +228,7 @@ module.exports = grammar({
), ),
_env_key: ($) => _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"))), expose_port: ($) => seq(/\d+/, optional(choice("/tcp", "/udp"))),

View file

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

File diff suppressed because it is too large Load diff