Add boolean-typed select values

This commit is contained in:
Bruno BELANYI 2024-04-23 15:00:13 +00:00
parent f6bc0f887a
commit afdfbff7bc
5 changed files with 1237 additions and 1155 deletions

View file

@ -143,6 +143,7 @@ module.exports = grammar({
select_case: ($) => seq( select_case: ($) => seq(
field("pattern", choice( field("pattern", choice(
$._string_literal, $._string_literal,
$.boolean_literal,
alias("default", $.default), alias("default", $.default),
)), )),
":", ":",

4
src/grammar.json generated
View file

@ -606,6 +606,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "_string_literal" "name": "_string_literal"
}, },
{
"type": "SYMBOL",
"name": "boolean_literal"
},
{ {
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {

4
src/node-types.json generated
View file

@ -353,6 +353,10 @@
"multiple": false, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{
"type": "boolean_literal",
"named": true
},
{ {
"type": "default", "type": "default",
"named": true "named": true

2356
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -226,6 +226,33 @@ foo = select(release_variable("ONE", "TWO"), {
(default) (default)
(interpreted_string_literal)))))) (interpreted_string_literal))))))
================================================================================
Select (boolean typed)
================================================================================
foo = select(some_boolean("IS_TRUE"), {
true: "true",
false: "false",
})
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(identifier)
(interpreted_string_literal))
(select_cases
(select_case
(boolean_literal)
(interpreted_string_literal))
(select_case
(boolean_literal)
(interpreted_string_literal))))))
================================================================================ ================================================================================
Select as an identifier Select as an identifier
================================================================================ ================================================================================