Expose 'condition' node

This commit is contained in:
Bruno BELANYI 2024-04-23 15:47:30 +00:00
parent d01bcf0f6d
commit ff40b39dcf
6 changed files with 1032 additions and 1038 deletions

View file

@ -132,11 +132,11 @@ module.exports = grammar({
), ),
select_value: ($) => choice( select_value: ($) => choice(
$._select_value, $.condition,
seq("(", commaSeparatedOptTrailing($._select_value), ")"), seq("(", commaSeparatedOptTrailing($.condition), ")"),
), ),
_select_value: ($) => seq( condition: ($) => seq(
field("name", $.identifier), field("name", $.identifier),
"(", "(",
field("arguments", optional(commaSeparatedNoTrailing($._string_literal))), field("arguments", optional(commaSeparatedNoTrailing($._string_literal))),

View file

@ -51,7 +51,7 @@
(unset) (unset)
(default) (default)
] @variable.builtin ] @variable.builtin
(select_value (condition
name: (identifier) @function.builtin) name: (identifier) @function.builtin)
; }}} ; }}}

8
src/grammar.json generated
View file

@ -491,7 +491,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_select_value" "name": "condition"
}, },
{ {
"type": "SEQ", "type": "SEQ",
@ -505,7 +505,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_select_value" "name": "condition"
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
@ -518,7 +518,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_select_value" "name": "condition"
} }
] ]
} }
@ -545,7 +545,7 @@
} }
] ]
}, },
"_select_value": { "condition": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {

59
src/node-types.json generated
View file

@ -177,6 +177,40 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "condition",
"named": true,
"fields": {
"arguments": {
"multiple": true,
"required": false,
"types": [
{
"type": ",",
"named": false
},
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "raw_string_literal",
"named": true
}
]
},
"name": {
"multiple": false,
"required": true,
"types": [
{
"type": "identifier",
"named": true
}
]
}
}
},
{ {
"type": "integer_literal", "type": "integer_literal",
"named": true, "named": true,
@ -471,36 +505,17 @@
{ {
"type": "select_value", "type": "select_value",
"named": true, "named": true,
"fields": { "fields": {},
"arguments": { "children": {
"multiple": true,
"required": false,
"types": [
{
"type": ",",
"named": false
},
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "raw_string_literal",
"named": true
}
]
},
"name": {
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "identifier", "type": "condition",
"named": true "named": true
} }
] ]
} }
}
}, },
{ {
"type": "source_file", "type": "source_file",

1915
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -15,8 +15,9 @@ foo = select(release_variable("RELEASE_TEST"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -44,9 +45,10 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal) (interpreted_string_literal)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -76,8 +78,9 @@ foo = select(variant("arch"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -110,8 +113,9 @@ foo = select(variant("VARIANT"), {})
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases)))) (select_cases))))
================================================================================ ================================================================================
@ -134,8 +138,9 @@ foo = select(variant("VARIANT"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -175,7 +180,8 @@ foo = select(variant(), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(identifier)) (condition
(identifier)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -203,8 +209,9 @@ foo = select(some_unknown_type("CONDITION"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -232,9 +239,10 @@ foo = select(release_variable("ONE", "TWO"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal) (interpreted_string_literal)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -262,9 +270,10 @@ foo = select(some_boolean("VALUE",), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal) (interpreted_string_literal)
(ERROR)) (ERROR)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -294,8 +303,10 @@ foo = select((
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(identifier) (condition
(identifier)) (identifier))
(condition
(identifier)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -319,8 +330,10 @@ foo = select((arch(), os()), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(identifier) (condition
(identifier)) (identifier))
(condition
(identifier)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern
@ -345,8 +358,9 @@ foo = select(some_boolean("IS_TRUE"), {
(operator) (operator)
(select_expression (select_expression
(select_value (select_value
(condition
(identifier) (identifier)
(interpreted_string_literal)) (interpreted_string_literal)))
(select_cases (select_cases
(select_case (select_case
(select_pattern (select_pattern