Simplify 'select_value' rule
Upstream has greatly simplified the parsing of `select` expressions, in order to add multi-valued `select`. To this end, we remove the hard-coded list of function names, and accept an arbitrary number of arguments.
This commit is contained in:
parent
8137fd3e5b
commit
1c1387fee0
23
grammar.js
23
grammar.js
|
@ -121,33 +121,16 @@ module.exports = grammar({
|
|||
select_expression: ($) => seq(
|
||||
"select",
|
||||
"(",
|
||||
choice($.select_value, $.soong_config_variable),
|
||||
$.select_value,
|
||||
",",
|
||||
$.select_cases,
|
||||
")",
|
||||
),
|
||||
|
||||
select_value: ($) => seq(
|
||||
field("type", alias(
|
||||
choice("product_variable", "release_variable", "variant"),
|
||||
$.selection_type,
|
||||
)),
|
||||
field("type", alias($.identifier, $.selection_type)),
|
||||
"(",
|
||||
field("condition", $._string_literal),
|
||||
")",
|
||||
),
|
||||
|
||||
soong_config_variable: ($) => seq(
|
||||
field("type", alias("soong_config_variable", $.selection_type)),
|
||||
"(",
|
||||
field(
|
||||
"condition",
|
||||
seq(
|
||||
field("namespace", $._string_literal),
|
||||
",",
|
||||
field("variable", $._string_literal),
|
||||
),
|
||||
),
|
||||
field("condition", optional(commaSeparated($._string_literal))),
|
||||
")",
|
||||
),
|
||||
|
||||
|
|
118
src/grammar.json
generated
118
src/grammar.json
generated
|
@ -469,17 +469,8 @@
|
|||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_value"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "soong_config_variable"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "select_value"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -504,21 +495,8 @@
|
|||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "product_variable"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "release_variable"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "variant"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
"named": true,
|
||||
"value": "selection_type"
|
||||
|
@ -532,61 +510,47 @@
|
|||
"type": "FIELD",
|
||||
"name": "condition",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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",
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "namespace",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "variable",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
60
src/node-types.json
generated
60
src/node-types.json
generated
|
@ -445,10 +445,6 @@
|
|||
{
|
||||
"type": "select_value",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "soong_config_variable",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -458,49 +454,13 @@
|
|||
"named": true,
|
||||
"fields": {
|
||||
"condition": {
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "soong_config_variable",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"condition": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": ",",
|
||||
"named": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"namespace": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
},
|
||||
{
|
||||
"type": "interpreted_string_literal",
|
||||
"named": true
|
||||
|
@ -520,20 +480,6 @@
|
|||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"variable": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "interpreted_string_literal",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "raw_string_literal",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
4082
src/parser.c
generated
4082
src/parser.c
generated
File diff suppressed because it is too large
Load diff
|
@ -41,7 +41,7 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
|||
(identifier)
|
||||
(operator)
|
||||
(select_expression
|
||||
(soong_config_variable
|
||||
(select_value
|
||||
(selection_type)
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
|
@ -162,8 +162,7 @@ foo = select(variant(), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(selection_type)
|
||||
(MISSING raw_string_literal))
|
||||
(selection_type))
|
||||
(select_cases
|
||||
(select_case
|
||||
(interpreted_string_literal)
|
||||
|
@ -187,14 +186,17 @@ foo = select(some_unknown_type("CONDITION"), {
|
|||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(ERROR
|
||||
(identifier)
|
||||
(identifier)
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal)
|
||||
(default))
|
||||
(interpreted_string_literal))
|
||||
(ERROR))
|
||||
(select_expression
|
||||
(select_value
|
||||
(selection_type)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(default)
|
||||
(interpreted_string_literal))))))
|
||||
|
||||
================================================================================
|
||||
Select (multiple type arguments)
|
||||
|
@ -214,8 +216,7 @@ foo = select(release_variable("ONE", "TWO"), {
|
|||
(select_expression
|
||||
(select_value
|
||||
(selection_type)
|
||||
(ERROR
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
|
|
Loading…
Reference in a new issue