Add 'soong_config_variable' selection

This commit is contained in:
Bruno BELANYI 2024-04-08 01:25:09 +01:00
parent 12553c3bb8
commit a78ad8139f
5 changed files with 1440 additions and 1003 deletions

View file

@ -91,7 +91,7 @@ module.exports = grammar({
select_expression: ($) => seq(
"select",
"(",
$.select_value,
choice($.select_value, $.soong_config_variable),
",",
$.select_cases,
")",
@ -107,6 +107,20 @@ module.exports = grammar({
")",
),
soong_config_variable: ($) => seq(
field("type", alias("soong_config_variable", $.selection_type)),
"(",
field(
"condition",
seq(
field("namespace", $._string_literal),
",",
field("variable", $._string_literal),
),
),
")",
),
select_cases: ($) => seq(
"{",
optional(trailingCommaSeparated($.select_case)),

68
src/grammar.json generated
View file

@ -253,8 +253,17 @@
"value": "("
},
{
"type": "SYMBOL",
"name": "select_value"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "select_value"
},
{
"type": "SYMBOL",
"name": "soong_config_variable"
}
]
},
{
"type": "STRING",
@ -317,6 +326,61 @@
}
]
},
"soong_config_variable": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "type",
"content": {
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "soong_config_variable"
},
"named": true,
"value": "selection_type"
}
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "condition",
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "namespace",
"content": {
"type": "SYMBOL",
"name": "_string_literal"
}
},
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "variable",
"content": {
"type": "SYMBOL",
"name": "_string_literal"
}
}
]
}
},
{
"type": "STRING",
"value": ")"
}
]
},
"select_cases": {
"type": "SEQ",
"members": [

58
src/node-types.json generated
View file

@ -348,6 +348,10 @@
{
"type": "select_value",
"named": true
},
{
"type": "soong_config_variable",
"named": true
}
]
}
@ -382,6 +386,60 @@
}
}
},
{
"type": "soong_config_variable",
"named": true,
"fields": {
"condition": {
"multiple": false,
"required": true,
"types": [
{
"type": ",",
"named": false
}
]
},
"namespace": {
"multiple": false,
"required": true,
"types": [
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "raw_string_literal",
"named": true
}
]
},
"type": {
"multiple": false,
"required": true,
"types": [
{
"type": "selection_type",
"named": true
}
]
},
"variable": {
"multiple": false,
"required": true,
"types": [
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "raw_string_literal",
"named": true
}
]
}
}
},
{
"type": "source_file",
"named": true,

2274
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,33 @@ foo = select(release_variable("RELEASE_TEST"), {
(default_case
(unset))))))
================================================================================
Select (soong config variable)
================================================================================
foo = select(soong_config_variable("my_namespace", "my_var"), {
"foo": unset,
"default": "bar",
})
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
(select_expression
(soong_config_variable
(selection_type)
(interpreted_string_literal)
(interpreted_string_literal))
(select_cases
(select_case
(interpreted_string_literal)
(unset))
(select_case
(interpreted_string_literal)
(interpreted_string_literal))))))
================================================================================
Select (no default)
================================================================================