Compare commits
23 commits
playground
...
main
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 4e60cf3c2e | ||
Bruno BELANYI | 6b0cdd9122 | ||
Bruno BELANYI | 1fd9b67dbe | ||
Bruno BELANYI | 3e685cb691 | ||
Bruno BELANYI | 970241b323 | ||
Bruno BELANYI | 2326d709fb | ||
Bruno BELANYI | bf783d99bc | ||
Bruno BELANYI | c5031e2c16 | ||
Bruno BELANYI | f228904ed0 | ||
Bruno BELANYI | 5cbdf5e3ac | ||
Bruno BELANYI | 533c82cdf3 | ||
Bruno BELANYI | d25b07cae0 | ||
Bruno BELANYI | ff40b39dcf | ||
Bruno BELANYI | d01bcf0f6d | ||
Bruno BELANYI | 0816633d9a | ||
Bruno BELANYI | 6ca4592d84 | ||
Bruno BELANYI | afdfbff7bc | ||
Bruno BELANYI | f6bc0f887a | ||
Bruno BELANYI | 2649422636 | ||
Bruno BELANYI | 1c1387fee0 | ||
Bruno BELANYI | 8137fd3e5b | ||
Bruno BELANYI | 9e46303a1d | ||
Bruno BELANYI | 1af33aeea1 |
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tree-sitter-bp"
|
name = "tree-sitter-bp"
|
||||||
description = "Blueprint grammar for the tree-sitter parsing library"
|
description = "Blueprint grammar for the tree-sitter parsing library"
|
||||||
version = "0.3.0"
|
version = "0.5.0"
|
||||||
keywords = ["incremental", "parsing", "android", "blueprint"]
|
keywords = ["incremental", "parsing", "android", "blueprint"]
|
||||||
categories = ["parsing", "text-editors"]
|
categories = ["parsing", "text-editors"]
|
||||||
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-bp"
|
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-bp"
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -14,5 +14,5 @@ update-tests: all
|
||||||
|
|
||||||
.PHONY: playground
|
.PHONY: playground
|
||||||
playground:
|
playground:
|
||||||
nix shell pkgs#emscripten --command tree-sitter build --wasm
|
nix shell pkgs#emscripten --command tree-sitter build-wasm
|
||||||
tree-sitter playground
|
tree-sitter playground
|
||||||
|
|
|
@ -35,10 +35,11 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
||||||
|
|
||||||
// Uncomment these to include any queries that this grammar contains
|
// Uncomment these to include any queries that this grammar contains
|
||||||
|
|
||||||
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
pub const FOLDS_QUERY: &'static str = include_str!("../../queries/folds.scm");
|
||||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||||
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
pub const INDENTS_QUERY: &'static str = include_str!("../../queries/indents.scm");
|
||||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||||
|
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
11
flake.nix
11
flake.nix
|
@ -61,6 +61,10 @@
|
||||||
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
||||||
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
|
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
|
||||||
|
|
||||||
|
# FIXME: not sure why, but I get different behaviour when left untouched
|
||||||
|
XDG_CONFIG_HOME=$(mktemp -d)
|
||||||
|
export XDG_CONFIG_HOME
|
||||||
|
|
||||||
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
|
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
|
||||||
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
||||||
'';
|
'';
|
||||||
|
@ -74,8 +78,9 @@
|
||||||
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
|
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
|
||||||
mv package.json.tmp package.json
|
mv package.json.tmp package.json
|
||||||
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
|
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
|
||||||
|
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" pyproject.toml
|
||||||
|
|
||||||
git add Cargo.toml package.json
|
git add Cargo.toml package.json pyproject.toml
|
||||||
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
||||||
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
||||||
'';
|
'';
|
||||||
|
@ -140,7 +145,9 @@
|
||||||
bump-version
|
bump-version
|
||||||
nodejs
|
nodejs
|
||||||
nvim-test-runner
|
nvim-test-runner
|
||||||
(tree-sitter.override { webUISupport = true; })
|
# FIXME: waiting on #301336
|
||||||
|
# (tree-sitter.override { webUISupport = true; })
|
||||||
|
tree-sitter
|
||||||
];
|
];
|
||||||
|
|
||||||
inherit (checks.pre-commit) shellHook;
|
inherit (checks.pre-commit) shellHook;
|
||||||
|
|
69
grammar.js
69
grammar.js
|
@ -1,8 +1,12 @@
|
||||||
function commaSeparated(elem) {
|
function commaSeparatedOptTrailing(elem) {
|
||||||
return seq(elem, repeat(seq(",", elem)), optional(","))
|
return seq(elem, repeat(seq(",", elem)), optional(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
function trailingCommaSeparated(elem) {
|
function commaSeparatedNoTrailing(elem) {
|
||||||
|
return seq(elem, repeat(seq(",", elem)))
|
||||||
|
}
|
||||||
|
|
||||||
|
function commaSeparatedTrailing(elem) {
|
||||||
return repeat(seq(elem, ","))
|
return repeat(seq(elem, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +48,7 @@ module.exports = grammar({
|
||||||
_old_module: ($) => seq(
|
_old_module: ($) => seq(
|
||||||
field("type", $.identifier),
|
field("type", $.identifier),
|
||||||
"{",
|
"{",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._colon_property), $.property)
|
alias(field("property", $._colon_property), $.property)
|
||||||
)),
|
)),
|
||||||
"}",
|
"}",
|
||||||
|
@ -53,7 +57,7 @@ module.exports = grammar({
|
||||||
_new_module: ($) => seq(
|
_new_module: ($) => seq(
|
||||||
field("type", $.identifier),
|
field("type", $.identifier),
|
||||||
"(",
|
"(",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._equal_property), $.property)
|
alias(field("property", $._equal_property), $.property)
|
||||||
)),
|
)),
|
||||||
")",
|
")",
|
||||||
|
@ -121,54 +125,53 @@ module.exports = grammar({
|
||||||
select_expression: ($) => seq(
|
select_expression: ($) => seq(
|
||||||
"select",
|
"select",
|
||||||
"(",
|
"(",
|
||||||
choice($.select_value, $.soong_config_variable),
|
$.select_value,
|
||||||
",",
|
",",
|
||||||
$.select_cases,
|
$.select_cases,
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_value: ($) => seq(
|
select_value: ($) => choice(
|
||||||
field("type", alias(
|
$.condition,
|
||||||
choice("product_variable", "release_variable", "variant"),
|
seq("(", commaSeparatedOptTrailing($.condition), ")"),
|
||||||
$.selection_type,
|
|
||||||
)),
|
|
||||||
"(",
|
|
||||||
field("condition", $._string_literal),
|
|
||||||
")",
|
|
||||||
),
|
),
|
||||||
|
|
||||||
soong_config_variable: ($) => seq(
|
condition: ($) => seq(
|
||||||
field("type", alias("soong_config_variable", $.selection_type)),
|
field("name", $.identifier),
|
||||||
"(",
|
"(",
|
||||||
field(
|
field("arguments", optional(commaSeparatedNoTrailing($._string_literal))),
|
||||||
"condition",
|
|
||||||
seq(
|
|
||||||
field("namespace", $._string_literal),
|
|
||||||
",",
|
|
||||||
field("variable", $._string_literal),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_cases: ($) => seq(
|
select_cases: ($) => seq(
|
||||||
"{",
|
"{",
|
||||||
optional(trailingCommaSeparated($.select_case)),
|
optional(commaSeparatedTrailing($.select_case)),
|
||||||
// default *must* be the last one, enforced at parse-time...
|
|
||||||
optional(seq(alias($.default_case, $.select_case), ",")),
|
|
||||||
"}",
|
"}",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_case: ($) => seq(
|
select_case: ($) => seq(
|
||||||
field("pattern", $._string_literal),
|
field("pattern", $.select_pattern),
|
||||||
":",
|
":",
|
||||||
field("value", $._case_value)
|
field("value", $._case_value)
|
||||||
),
|
),
|
||||||
|
|
||||||
default_case: ($) => seq(
|
select_pattern: ($) => choice(
|
||||||
field("pattern", alias("default", $.default)),
|
$._select_pattern,
|
||||||
":",
|
seq("(", commaSeparatedOptTrailing($._select_pattern), ")"),
|
||||||
field("value", $._case_value),
|
),
|
||||||
|
|
||||||
|
_select_pattern: ($) => choice(
|
||||||
|
$._string_literal,
|
||||||
|
$.boolean_literal,
|
||||||
|
alias("any", $.any),
|
||||||
|
$.pattern_binding,
|
||||||
|
alias("default", $.default),
|
||||||
|
),
|
||||||
|
|
||||||
|
pattern_binding: ($) => seq(
|
||||||
|
field("value", alias("any", $.any)),
|
||||||
|
field("operator", alias("@", $.operator)),
|
||||||
|
field("binding", $.identifier),
|
||||||
),
|
),
|
||||||
|
|
||||||
_case_value: ($) => choice(
|
_case_value: ($) => choice(
|
||||||
|
@ -178,13 +181,13 @@ module.exports = grammar({
|
||||||
|
|
||||||
list_expression: ($) => seq(
|
list_expression: ($) => seq(
|
||||||
"[",
|
"[",
|
||||||
optional(commaSeparated(field("element", $._expr))),
|
optional(commaSeparatedOptTrailing(field("element", $._expr))),
|
||||||
"]",
|
"]",
|
||||||
),
|
),
|
||||||
|
|
||||||
map_expression: ($) => seq(
|
map_expression: ($) => seq(
|
||||||
"{",
|
"{",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._colon_property), $.property)
|
alias(field("property", $._colon_property), $.property)
|
||||||
)),
|
)),
|
||||||
"}",
|
"}",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tree-sitter-bp",
|
"name": "tree-sitter-bp",
|
||||||
"version": "0.3.0",
|
"version": "0.5.0",
|
||||||
"description": "Blueprint grammar for tree-sitter",
|
"description": "Blueprint grammar for tree-sitter",
|
||||||
"main": "bindings/node",
|
"main": "bindings/node",
|
||||||
"types": "bindings/node",
|
"types": "bindings/node",
|
||||||
|
@ -43,6 +43,11 @@
|
||||||
"file-types": [
|
"file-types": [
|
||||||
"bp"
|
"bp"
|
||||||
],
|
],
|
||||||
|
"folds": "queries/folds.scm",
|
||||||
|
"highlights": "queries/highlights.scm",
|
||||||
|
"indents": "queries/indents.scm",
|
||||||
|
"injections": "queries/injections.scm",
|
||||||
|
"tags": "queries/tags.scm",
|
||||||
"injection-regex": "bp"
|
"injection-regex": "bp"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
||||||
[project]
|
[project]
|
||||||
name = "tree-sitter-bp"
|
name = "tree-sitter-bp"
|
||||||
description = "Bp grammar for tree-sitter"
|
description = "Bp grammar for tree-sitter"
|
||||||
version = "0.0.1"
|
version = "0.5.0"
|
||||||
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
|
|
|
@ -50,8 +50,10 @@
|
||||||
[
|
[
|
||||||
(unset)
|
(unset)
|
||||||
(default)
|
(default)
|
||||||
|
(any)
|
||||||
] @variable.builtin
|
] @variable.builtin
|
||||||
(selection_type) @function.builtin
|
(condition
|
||||||
|
name: (identifier) @function.builtin)
|
||||||
; }}}
|
; }}}
|
||||||
|
|
||||||
; Expressions {{{
|
; Expressions {{{
|
||||||
|
|
|
@ -11,6 +11,15 @@
|
||||||
(select_expression
|
(select_expression
|
||||||
")" @indent.branch)
|
")" @indent.branch)
|
||||||
|
|
||||||
|
(select_value) @indent.begin
|
||||||
|
(select_value
|
||||||
|
")" @indent.branch)
|
||||||
|
|
||||||
|
(select_pattern
|
||||||
|
"(" @indent.begin)
|
||||||
|
(select_pattern
|
||||||
|
")" @indent.branch)
|
||||||
|
|
||||||
(select_cases) @indent.begin
|
(select_cases) @indent.begin
|
||||||
(select_cases
|
(select_cases
|
||||||
"}" @indent.branch)
|
"}" @indent.branch)
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
(assignment
|
(assignment
|
||||||
left: (identifier) @local.definition.var)
|
left: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(pattern_binding
|
||||||
|
binding: (identifier) @local.definition.var)
|
||||||
|
|
||||||
(identifier) @local.reference
|
(identifier) @local.reference
|
||||||
|
|
||||||
; vim: sw=2 foldmethod=marker
|
; vim: sw=2 foldmethod=marker
|
||||||
|
|
259
src/grammar.json
generated
259
src/grammar.json
generated
|
@ -468,19 +468,10 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "select_value"
|
"name": "select_value"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "soong_config_variable"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": ","
|
"value": ","
|
||||||
|
@ -496,66 +487,73 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"select_value": {
|
"select_value": {
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "type",
|
|
||||||
"content": {
|
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "SYMBOL",
|
||||||
"value": "product_variable"
|
"name": "condition"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "SEQ",
|
||||||
"value": "release_variable"
|
"members": [
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "variant"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "selection_type"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "SEQ",
|
||||||
"name": "condition",
|
"members": [
|
||||||
"content": {
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "condition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "condition"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": ")"
|
"value": ")"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"soong_config_variable": {
|
"condition": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "type",
|
"name": "name",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "ALIAS",
|
"type": "SYMBOL",
|
||||||
"content": {
|
"name": "identifier"
|
||||||
"type": "STRING",
|
|
||||||
"value": "soong_config_variable"
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "selection_type"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -564,29 +562,37 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "condition",
|
"name": "arguments",
|
||||||
"content": {
|
"content": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
|
||||||
"name": "namespace",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "_string_literal"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": ","
|
"value": ","
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
|
||||||
"name": "variable",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "_string_literal"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -628,32 +634,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "default_case"
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "select_case"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ","
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "}"
|
"value": "}"
|
||||||
|
@ -668,7 +648,7 @@
|
||||||
"name": "pattern",
|
"name": "pattern",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "select_pattern"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -685,13 +665,90 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default_case": {
|
"select_pattern": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_select_pattern"
|
||||||
|
},
|
||||||
|
{
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "STRING",
|
||||||
"name": "pattern",
|
"value": "("
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_select_pattern"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_select_pattern"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_select_pattern": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_string_literal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "boolean_literal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "any"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "pattern_binding"
|
||||||
|
},
|
||||||
|
{
|
||||||
"type": "ALIAS",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
@ -700,17 +757,43 @@
|
||||||
"named": true,
|
"named": true,
|
||||||
"value": "default"
|
"value": "default"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
"pattern_binding": {
|
||||||
"type": "STRING",
|
"type": "SEQ",
|
||||||
"value": ":"
|
"members": [
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "value",
|
"name": "value",
|
||||||
|
"content": {
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "any"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "any"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "operator",
|
||||||
|
"content": {
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "@"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "operator"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "binding",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_case_value"
|
"name": "identifier"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
198
src/node-types.json
generated
198
src/node-types.json
generated
|
@ -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,
|
||||||
|
@ -287,6 +321,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "pattern_binding",
|
||||||
|
"named": true,
|
||||||
|
"fields": {
|
||||||
|
"binding": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "operator",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "property",
|
"type": "property",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -354,15 +424,7 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": "select_pattern",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "interpreted_string_literal",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "raw_string_literal",
|
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -445,9 +507,40 @@
|
||||||
{
|
{
|
||||||
"type": "select_value",
|
"type": "select_value",
|
||||||
"named": true
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "soong_config_variable",
|
"type": "select_pattern",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean_literal",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "default",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "interpreted_string_literal",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pattern_binding",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "raw_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -456,85 +549,16 @@
|
||||||
{
|
{
|
||||||
"type": "select_value",
|
"type": "select_value",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {
|
"fields": {},
|
||||||
"condition": {
|
"children": {
|
||||||
"multiple": false,
|
"multiple": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "interpreted_string_literal",
|
"type": "condition",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "raw_string_literal",
|
|
||||||
"named": true
|
"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,
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -604,6 +628,10 @@
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -632,10 +660,6 @@
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "selection_type",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "true",
|
"type": "true",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
5276
src/parser.c
generated
5276
src/parser.c
generated
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,7 @@ Select
|
||||||
|
|
||||||
foo = select(release_variable("RELEASE_TEST"), {
|
foo = select(release_variable("RELEASE_TEST"), {
|
||||||
"d": "d2",
|
"d": "d2",
|
||||||
|
any: unset,
|
||||||
default: unset,
|
default: unset,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -15,14 +16,21 @@ foo = select(release_variable("RELEASE_TEST"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(default)
|
(select_pattern
|
||||||
|
(any))
|
||||||
|
(unset))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
(unset))))))
|
(unset))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -32,6 +40,7 @@ Select (soong config variable)
|
||||||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
"foo": unset,
|
"foo": unset,
|
||||||
"default": "bar",
|
"default": "bar",
|
||||||
|
any @ foo: unset,
|
||||||
})
|
})
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -41,17 +50,27 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
(identifier)
|
(identifier)
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(soong_config_variable
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
|
(identifier)
|
||||||
(interpreted_string_literal)
|
(interpreted_string_literal)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(unset))
|
(unset))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(pattern_binding
|
||||||
|
(any)
|
||||||
|
(operator)
|
||||||
|
(identifier)))
|
||||||
|
(unset))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select (no default)
|
Select (no default)
|
||||||
|
@ -72,20 +91,25 @@ foo = select(variant("arch"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -102,8 +126,9 @@ foo = select(variant("VARIANT"), {})
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases))))
|
(select_cases))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -126,24 +151,29 @@ foo = select(variant("VARIANT"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(ERROR
|
|
||||||
(select_case
|
|
||||||
(default)
|
|
||||||
(unset)))
|
|
||||||
(select_case
|
|
||||||
(interpreted_string_literal)
|
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(unset))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -163,14 +193,16 @@ foo = select(variant(), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(MISSING raw_string_literal))
|
(identifier)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(unset))
|
(unset))
|
||||||
(select_case
|
(select_case
|
||||||
(default)
|
(select_pattern
|
||||||
|
(default))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -188,14 +220,20 @@ foo = select(some_unknown_type("CONDITION"), {
|
||||||
(assignment
|
(assignment
|
||||||
(identifier)
|
(identifier)
|
||||||
(operator)
|
(operator)
|
||||||
(ERROR
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
(identifier)
|
(identifier)
|
||||||
(identifier)
|
(interpreted_string_literal)))
|
||||||
(interpreted_string_literal)
|
(select_cases
|
||||||
(interpreted_string_literal)
|
(select_case
|
||||||
(default))
|
(select_pattern
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(ERROR))
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select (multiple type arguments)
|
Select (multiple type arguments)
|
||||||
|
@ -214,16 +252,136 @@ foo = select(release_variable("ONE", "TWO"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(ERROR
|
(identifier)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (trailing comma in arguments)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select(some_boolean("VALUE",), {
|
||||||
|
true: "true",
|
||||||
|
false: "false",
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier)
|
||||||
|
(interpreted_string_literal)
|
||||||
|
(ERROR)))
|
||||||
|
(select_cases
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(boolean_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(boolean_literal))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (trailing comma in values)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select((
|
||||||
|
arch(),
|
||||||
|
os(),
|
||||||
|
), {
|
||||||
|
(default, default): "true",
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier))
|
||||||
|
(condition
|
||||||
|
(identifier)))
|
||||||
|
(select_cases
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
(default)
|
(default)
|
||||||
|
(default))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (trailing comma in pattern)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select((arch(), os()), {
|
||||||
|
(default, default,): "true",
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier))
|
||||||
|
(condition
|
||||||
|
(identifier)))
|
||||||
|
(select_cases
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default)
|
||||||
|
(default))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (boolean typed)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select(some_boolean("IS_TRUE"), {
|
||||||
|
true: "true",
|
||||||
|
false: "false",
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
|
(select_cases
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(boolean_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(boolean_literal))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
@ -2,6 +2,8 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
// ^ function.builtin
|
// ^ function.builtin
|
||||||
"foo": unset,
|
"foo": unset,
|
||||||
// ^ variable.builtin
|
// ^ variable.builtin
|
||||||
|
any: unset,
|
||||||
|
// <- variable.builtin
|
||||||
default: select(variant("VARIANT"), {}),
|
default: select(variant("VARIANT"), {}),
|
||||||
// <- variable.builtin
|
// <- variable.builtin
|
||||||
// ^ function.builtin
|
// ^ function.builtin
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
// ^ keyword.conditional
|
// ^ keyword.conditional
|
||||||
"foo": unset,
|
"foo": unset,
|
||||||
|
any @ foo: unset,
|
||||||
|
// ^ operator
|
||||||
|
// ^ variable
|
||||||
default: "bar",
|
default: "bar",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -26,3 +26,35 @@ foo = select(
|
||||||
default: 0,
|
default: 0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
foo = select((
|
||||||
|
arch(),
|
||||||
|
os(),
|
||||||
|
), {
|
||||||
|
(default, default): [],
|
||||||
|
})
|
||||||
|
|
||||||
|
foo = select(
|
||||||
|
(arch(), os()),
|
||||||
|
{
|
||||||
|
(default, default): [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// We're really getting into more and more unlikely choices here...
|
||||||
|
foo = select(
|
||||||
|
(
|
||||||
|
arch(),
|
||||||
|
os(),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
(default, default): [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
foo = select((arch(), os()), {
|
||||||
|
(
|
||||||
|
default,
|
||||||
|
default,
|
||||||
|
): [],
|
||||||
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
||||||
|
|
||||||
local Runner = require("tests.indent.common").Runner
|
local Runner = require("tests.indent.common").Runner
|
||||||
|
local XFAIL = require("tests.indent.common").XFAIL
|
||||||
|
|
||||||
-- FIXME: path to root
|
-- FIXME: path to root
|
||||||
local runner = Runner:new(it, ".", {
|
local runner = Runner:new(it, ".", {
|
||||||
|
@ -19,7 +20,7 @@ describe("indent Blueprint:", function()
|
||||||
})
|
})
|
||||||
runner:whole_file("test/indent/", {
|
runner:whole_file("test/indent/", {
|
||||||
expected_failures = {
|
expected_failures = {
|
||||||
-- NOTE: none for now
|
"test/indent/select.bp",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
@ -39,9 +40,22 @@ describe("indent Blueprint:", function()
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 1, text = 'default: "value"', indent = 4 }, "default case")
|
runner:new_line("test/indent/select.bp", { on_line = 1, text = 'default: "value"', indent = 4 }, "default case")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 11, text = '"case": "value"', indent = 4 }, "select case, trailing")
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = '"case": "value"', indent = 4 }, "select case, trailing")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 11, text = 'default: "value"', indent = 4 }, "default case, trailing")
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = 'default: "value"', indent = 4 }, "default case, trailing")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = '}', indent = 0 }, "select cases closing delimiter")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 16, text = '"case": "value"', indent = 8 }, "select case, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 16, text = '"case": "value"', indent = 8 }, "select case, alternate formatting")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 16, text = 'default: "value"', indent = 8 }, "default case, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 16, text = 'default: "value"', indent = 8 }, "default case, alternate formatting")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 26, text = '"case": "value"', indent = 8 }, "select case, trailing, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 26, text = '"case": "value"', indent = 8 }, "select case, trailing, alternate formatting")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 26, text = '}', indent = 4 }, "select cases closing delimiter, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 30, text = 'device()', indent = 4 }, "multi-valued select condition, begin")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 31, text = 'device()', indent = 4 }, "multi-valued select condition, middle")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 32, text = 'device()', indent = 4 }, "multi-valued select condition, end")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 46, text = 'device()', indent = 8 }, "multi-valued select condition, begin, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 47, text = 'device()', indent = 8 }, "multi-valued select condition, middle, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 48, text = 'device()', indent = 8 }, "multi-valued select condition, end, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 56, text = 'default,', indent = 8 }, "multi-valued select case, begin", XFAIL)
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 57, text = 'default,', indent = 8 }, "multi-valued select case, middle", XFAIL)
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 58, text = 'default,', indent = 8 }, "multi-valued select case, end", XFAIL)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue