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,
seq("(", commaSeparatedOptTrailing($._select_value), ")"),
$.condition,
seq("(", commaSeparatedOptTrailing($.condition), ")"),
),
_select_value: ($) => seq(
condition: ($) => seq(
field("name", $.identifier),
"(",
field("arguments", optional(commaSeparatedNoTrailing($._string_literal))),

View file

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

8
src/grammar.json generated
View file

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

59
src/node-types.json generated
View file

@ -177,6 +177,40 @@
"named": true,
"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",
"named": true,
@ -471,36 +505,17 @@
{
"type": "select_value",
"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": {
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "identifier",
"type": "condition",
"named": true
}
]
}
}
},
{
"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)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -44,9 +45,10 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -76,8 +78,9 @@ foo = select(variant("arch"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -110,8 +113,9 @@ foo = select(variant("VARIANT"), {})
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases))))
================================================================================
@ -134,8 +138,9 @@ foo = select(variant("VARIANT"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -175,7 +180,8 @@ foo = select(variant(), {
(operator)
(select_expression
(select_value
(identifier))
(condition
(identifier)))
(select_cases
(select_case
(select_pattern
@ -203,8 +209,9 @@ foo = select(some_unknown_type("CONDITION"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -232,9 +239,10 @@ foo = select(release_variable("ONE", "TWO"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern
@ -262,9 +270,10 @@ foo = select(some_boolean("VALUE",), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal)
(ERROR))
(ERROR)))
(select_cases
(select_case
(select_pattern
@ -294,8 +303,10 @@ foo = select((
(operator)
(select_expression
(select_value
(identifier)
(condition
(identifier))
(condition
(identifier)))
(select_cases
(select_case
(select_pattern
@ -319,8 +330,10 @@ foo = select((arch(), os()), {
(operator)
(select_expression
(select_value
(identifier)
(condition
(identifier))
(condition
(identifier)))
(select_cases
(select_case
(select_pattern
@ -345,8 +358,9 @@ foo = select(some_boolean("IS_TRUE"), {
(operator)
(select_expression
(select_value
(condition
(identifier)
(interpreted_string_literal))
(interpreted_string_literal)))
(select_cases
(select_case
(select_pattern