Merge soong_config_variable
into select_value
All checks were successful
ci/woodpecker/push/check Pipeline was successful
All checks were successful
ci/woodpecker/push/check Pipeline was successful
It makes the parse tree easier to use, and I don't think we need to care for the lax parsing.
This commit is contained in:
parent
b04cd92189
commit
1f9bce5c01
33
grammar.js
33
grammar.js
|
@ -6,6 +6,15 @@ function trailingCommaSeparated(elem) {
|
||||||
return repeat(seq(elem, ","))
|
return repeat(seq(elem, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SELECTION_TYPES = [
|
||||||
|
// One argument
|
||||||
|
"product_variable",
|
||||||
|
"release_variable",
|
||||||
|
"variant",
|
||||||
|
// Two arguments
|
||||||
|
"soong_config_variable",
|
||||||
|
]
|
||||||
|
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: "bp",
|
name: "bp",
|
||||||
|
|
||||||
|
@ -121,33 +130,17 @@ module.exports = grammar({
|
||||||
select_expression: ($) => seq(
|
select_expression: ($) => seq(
|
||||||
"select",
|
"select",
|
||||||
"(",
|
"(",
|
||||||
choice($.select_value, $.soong_config_variable),
|
$.select_value,
|
||||||
",",
|
",",
|
||||||
$.select_cases,
|
$.select_cases,
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Allow for some incorrect usage, to make the parse tree simpler
|
||||||
select_value: ($) => seq(
|
select_value: ($) => seq(
|
||||||
field("type", alias(
|
field("type", alias(choice(...SELECTION_TYPES), $.selection_type)),
|
||||||
choice("product_variable", "release_variable", "variant"),
|
|
||||||
$.selection_type,
|
|
||||||
)),
|
|
||||||
"(",
|
"(",
|
||||||
field("condition", $._string_literal),
|
field("condition", commaSeparated($._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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
91
src/grammar.json
generated
91
src/grammar.json
generated
|
@ -469,17 +469,8 @@
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "SYMBOL",
|
||||||
"members": [
|
"name": "select_value"
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_value"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "soong_config_variable"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
@ -517,6 +508,10 @@
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "variant"
|
"value": "variant"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "soong_config_variable"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -528,40 +523,6 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"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",
|
"type": "FIELD",
|
||||||
"name": "condition",
|
"name": "condition",
|
||||||
|
@ -569,24 +530,36 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "SYMBOL",
|
||||||
"name": "namespace",
|
"name": "_string_literal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SEQ",
|
||||||
"name": "_string_literal"
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_string_literal"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "CHOICE",
|
||||||
"value": ","
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "STRING",
|
||||||
"type": "FIELD",
|
"value": ","
|
||||||
"name": "variable",
|
},
|
||||||
"content": {
|
{
|
||||||
"type": "SYMBOL",
|
"type": "BLANK"
|
||||||
"name": "_string_literal"
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
58
src/node-types.json
generated
58
src/node-types.json
generated
|
@ -445,10 +445,6 @@
|
||||||
{
|
{
|
||||||
"type": "select_value",
|
"type": "select_value",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "soong_config_variable",
|
|
||||||
"named": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -458,49 +454,13 @@
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {
|
"fields": {
|
||||||
"condition": {
|
"condition": {
|
||||||
"multiple": false,
|
"multiple": true,
|
||||||
"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,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": ",",
|
"type": ",",
|
||||||
"named": false
|
"named": false
|
||||||
}
|
},
|
||||||
]
|
|
||||||
},
|
|
||||||
"namespace": {
|
|
||||||
"multiple": false,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
{
|
||||||
"type": "interpreted_string_literal",
|
"type": "interpreted_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -520,20 +480,6 @@
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"variable": {
|
|
||||||
"multiple": false,
|
|
||||||
"required": true,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "interpreted_string_literal",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "raw_string_literal",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
1754
src/parser.c
generated
1754
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)
|
(identifier)
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(soong_config_variable
|
(select_value
|
||||||
(selection_type)
|
(selection_type)
|
||||||
(interpreted_string_literal)
|
(interpreted_string_literal)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
|
@ -215,8 +215,7 @@ foo = select(release_variable("ONE", "TWO"), {
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(selection_type)
|
||||||
(ERROR
|
(interpreted_string_literal)
|
||||||
(interpreted_string_literal))
|
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
|
|
Loading…
Reference in a new issue