Add support for space-separated env instruction

This commit is contained in:
Camden Cheek 2021-05-10 20:27:22 -06:00
parent 3693a2fd05
commit 732a4f0e4f
No known key found for this signature in database
GPG key ID: 595BFFE3A04E48B9
4 changed files with 4285 additions and 4105 deletions

View file

@ -80,3 +80,17 @@ ENV TEST2="bar"
(env_pair (env_pair
name: (unquoted_string) name: (unquoted_string)
value: (double_quoted_string)))) value: (double_quoted_string))))
==================
Space syntax
==================
ENV TEST1 foo
---
(source_file
(env_instruction
(env_pair
name: (unquoted_string)
value: (unquoted_string))))

View file

@ -70,7 +70,10 @@ module.exports = grammar({
env_instruction: $ => seq( env_instruction: $ => seq(
alias(/[eE][nN][vV]/, "ENV"), alias(/[eE][nN][vV]/, "ENV"),
$._non_newline_whitespace, $._non_newline_whitespace,
repeat1($.env_pair), choice(
repeat1($.env_pair),
alias($._spaced_env_pair, $.env_pair),
)
), ),
add_instruction: $ => seq( add_instruction: $ => seq(
@ -212,6 +215,15 @@ module.exports = grammar({
)), )),
), ),
_spaced_env_pair: $ => seq(
field("name", alias(/[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]/, $.unquoted_string)),
token.immediate(/\s+/),
field("value", choice(
$.double_quoted_string,
$.unquoted_string,
)),
),
expose_port: $ => choice( expose_port: $ => choice(
seq( seq(
/\d+/, /\d+/,

View file

@ -283,11 +283,25 @@
"name": "_non_newline_whitespace" "name": "_non_newline_whitespace"
}, },
{ {
"type": "REPEAT1", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "env_pair" "type": "REPEAT1",
} "content": {
"type": "SYMBOL",
"name": "env_pair"
}
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_spaced_env_pair"
},
"named": true,
"value": "env_pair"
}
]
} }
] ]
}, },
@ -882,6 +896,48 @@
} }
] ]
}, },
"_spaced_env_pair": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]"
},
"named": true,
"value": "unquoted_string"
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "\\s+"
}
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "double_quoted_string"
},
{
"type": "SYMBOL",
"name": "unquoted_string"
}
]
}
}
]
},
"expose_port": { "expose_port": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

File diff suppressed because it is too large Load diff