Compare commits
3 commits
main
...
playground
| Author | SHA1 | Date | |
|---|---|---|---|
| 9012a19840 | |||
| 93a71d095b | |||
| bc4db561ca |
27 changed files with 6457 additions and 3490 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tree-sitter-bp"
|
||||
description = "Blueprint grammar for the tree-sitter parsing library"
|
||||
version = "0.7.0"
|
||||
version = "0.3.0"
|
||||
keywords = ["incremental", "parsing", "android", "blueprint"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-bp"
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -14,5 +14,5 @@ update-tests: all
|
|||
|
||||
.PHONY: playground
|
||||
playground:
|
||||
nix shell pkgs#emscripten --command tree-sitter build-wasm
|
||||
nix shell pkgs#emscripten --command tree-sitter build --wasm
|
||||
tree-sitter playground
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//! ```
|
||||
//! let code = "";
|
||||
//! let mut parser = tree_sitter::Parser::new();
|
||||
//! parser.set_language(tree_sitter_bp::language()).expect("Error loading bp grammar");
|
||||
//! parser.set_language(tree_sitter_bp::language()).expect("Error loading txtpb grammar");
|
||||
//! let tree = parser.parse(code, None).unwrap();
|
||||
//! ```
|
||||
//!
|
||||
|
|
@ -35,11 +35,10 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
|||
|
||||
// Uncomment these to include any queries that this grammar contains
|
||||
|
||||
pub const FOLDS_QUERY: &'static str = include_str!("../../queries/folds.scm");
|
||||
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||
pub const INDENTS_QUERY: &'static str = include_str!("../../queries/indents.scm");
|
||||
pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
|
|||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -21,11 +21,11 @@
|
|||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -58,11 +58,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1741802033,
|
||||
"narHash": "sha256-AOazEmkhbKnNQi0LqJdAcqPQx711L84a0Vkaos/ZW/A=",
|
||||
"lastModified": 1713687659,
|
||||
"narHash": "sha256-Yd8KuOBpZ0Slau/NxFhMPJI0gBxeax0vq/FD0rqKwuQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8c1f3147639f009f09d2bfffc64bcf8485bf3fd2",
|
||||
"rev": "f2d7a289c5a5ece8521dd082b81ac7e4a57c2c5c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -75,17 +75,23 @@
|
|||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1735882644,
|
||||
"narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=",
|
||||
"lastModified": 1713775815,
|
||||
"narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
|
||||
"rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
17
flake.nix
17
flake.nix
|
|
@ -22,7 +22,9 @@
|
|||
repo = "pre-commit-hooks.nix";
|
||||
ref = "master";
|
||||
inputs = {
|
||||
flake-utils.follows = "flake-utils";
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs-stable.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -59,10 +61,6 @@
|
|||
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
||||
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} \
|
||||
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
||||
'';
|
||||
|
|
@ -75,14 +73,9 @@
|
|||
|
||||
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
|
||||
mv package.json.tmp package.json
|
||||
${pkgs.jq}/bin/jq ".metadata.version = \"''${NEW_VERSION}\"" tree-sitter.json > tree-sitter.json.tmp
|
||||
mv tree-sitter.json.tmp tree-sitter.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}\"/" pyproject.toml
|
||||
|
||||
make
|
||||
|
||||
git add Cargo.toml package.json pyproject.toml tree-sitter.json src/parser.c
|
||||
git add Cargo.toml package.json
|
||||
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
||||
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
||||
'';
|
||||
|
|
@ -147,9 +140,7 @@
|
|||
bump-version
|
||||
nodejs
|
||||
nvim-test-runner
|
||||
# FIXME: waiting on #301336
|
||||
# (tree-sitter.override { webUISupport = true; })
|
||||
tree-sitter
|
||||
(tree-sitter.override { webUISupport = true; })
|
||||
];
|
||||
|
||||
inherit (checks.pre-commit) shellHook;
|
||||
|
|
|
|||
70
grammar.js
70
grammar.js
|
|
@ -1,12 +1,8 @@
|
|||
function commaSeparatedOptTrailing(elem) {
|
||||
function commaSeparated(elem) {
|
||||
return seq(elem, repeat(seq(",", elem)), optional(","))
|
||||
}
|
||||
|
||||
function commaSeparatedNoTrailing(elem) {
|
||||
return seq(elem, repeat(seq(",", elem)))
|
||||
}
|
||||
|
||||
function commaSeparatedTrailing(elem) {
|
||||
function trailingCommaSeparated(elem) {
|
||||
return repeat(seq(elem, ","))
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +44,7 @@ module.exports = grammar({
|
|||
_old_module: ($) => seq(
|
||||
field("type", $.identifier),
|
||||
"{",
|
||||
optional(commaSeparatedOptTrailing(
|
||||
optional(commaSeparated(
|
||||
alias(field("property", $._colon_property), $.property)
|
||||
)),
|
||||
"}",
|
||||
|
|
@ -57,7 +53,7 @@ module.exports = grammar({
|
|||
_new_module: ($) => seq(
|
||||
field("type", $.identifier),
|
||||
"(",
|
||||
optional(commaSeparatedOptTrailing(
|
||||
optional(commaSeparated(
|
||||
alias(field("property", $._equal_property), $.property)
|
||||
)),
|
||||
")",
|
||||
|
|
@ -125,54 +121,54 @@ module.exports = grammar({
|
|||
select_expression: ($) => seq(
|
||||
"select",
|
||||
"(",
|
||||
$.select_value,
|
||||
choice($.select_value, $.soong_config_variable),
|
||||
",",
|
||||
$.select_cases,
|
||||
")",
|
||||
),
|
||||
|
||||
select_value: ($) => choice(
|
||||
$.condition,
|
||||
seq("(", commaSeparatedOptTrailing($.condition), ")"),
|
||||
select_value: ($) => seq(
|
||||
field("type", alias(
|
||||
choice("product_variable", "release_variable", "variant"),
|
||||
$.selection_type,
|
||||
)),
|
||||
"(",
|
||||
field("condition", $._string_literal),
|
||||
")",
|
||||
),
|
||||
|
||||
condition: ($) => seq(
|
||||
field("name", $.identifier),
|
||||
soong_config_variable: ($) => seq(
|
||||
field("type", alias("soong_config_variable", $.selection_type)),
|
||||
"(",
|
||||
field("arguments", optional(commaSeparatedNoTrailing($._string_literal))),
|
||||
field(
|
||||
"condition",
|
||||
seq(
|
||||
field("namespace", $._string_literal),
|
||||
",",
|
||||
field("variable", $._string_literal),
|
||||
),
|
||||
),
|
||||
")",
|
||||
),
|
||||
|
||||
select_cases: ($) => seq(
|
||||
"{",
|
||||
optional(commaSeparatedOptTrailing($.select_case)),
|
||||
optional(trailingCommaSeparated($.select_case)),
|
||||
// default *must* be the last one, enforced at parse-time...
|
||||
optional(seq(alias($.default_case, $.select_case), ",")),
|
||||
"}",
|
||||
),
|
||||
|
||||
select_case: ($) => seq(
|
||||
field("pattern", $.select_pattern),
|
||||
field("pattern", $._string_literal),
|
||||
":",
|
||||
field("value", $._case_value)
|
||||
),
|
||||
|
||||
select_pattern: ($) => choice(
|
||||
$._select_pattern,
|
||||
seq("(", commaSeparatedOptTrailing($._select_pattern), ")"),
|
||||
),
|
||||
|
||||
_select_pattern: ($) => choice(
|
||||
$._string_literal,
|
||||
$.boolean_literal,
|
||||
$.integer_literal,
|
||||
alias("any", $.any),
|
||||
$.pattern_binding,
|
||||
alias("default", $.default),
|
||||
),
|
||||
|
||||
pattern_binding: ($) => seq(
|
||||
field("value", alias("any", $.any)),
|
||||
field("operator", alias("@", $.operator)),
|
||||
field("binding", $.identifier),
|
||||
default_case: ($) => seq(
|
||||
field("pattern", alias("default", $.default)),
|
||||
":",
|
||||
field("value", $._case_value),
|
||||
),
|
||||
|
||||
_case_value: ($) => choice(
|
||||
|
|
@ -182,13 +178,13 @@ module.exports = grammar({
|
|||
|
||||
list_expression: ($) => seq(
|
||||
"[",
|
||||
optional(commaSeparatedOptTrailing(field("element", $._expr))),
|
||||
optional(commaSeparated(field("element", $._expr))),
|
||||
"]",
|
||||
),
|
||||
|
||||
map_expression: ($) => seq(
|
||||
"{",
|
||||
optional(commaSeparatedOptTrailing(
|
||||
optional(commaSeparated(
|
||||
alias(field("property", $._colon_property), $.property)
|
||||
)),
|
||||
"}",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tree-sitter-bp",
|
||||
"version": "0.7.0",
|
||||
"version": "0.3.0",
|
||||
"description": "Blueprint grammar for tree-sitter",
|
||||
"main": "bindings/node",
|
||||
"types": "bindings/node",
|
||||
|
|
@ -43,11 +43,6 @@
|
|||
"file-types": [
|
||||
"bp"
|
||||
],
|
||||
"folds": "queries/folds.scm",
|
||||
"highlights": "queries/highlights.scm",
|
||||
"indents": "queries/indents.scm",
|
||||
"injections": "queries/injections.scm",
|
||||
"tags": "queries/tags.scm",
|
||||
"injection-regex": "bp"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||
[project]
|
||||
name = "tree-sitter-bp"
|
||||
description = "Bp grammar for tree-sitter"
|
||||
version = "0.7.0"
|
||||
version = "0.0.1"
|
||||
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
||||
classifiers = [
|
||||
"Intended Audience :: Developers",
|
||||
|
|
|
|||
|
|
@ -4,3 +4,5 @@
|
|||
(module)
|
||||
(select_expression)
|
||||
] @fold
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
|||
|
|
@ -1,35 +1,41 @@
|
|||
(comment) @comment
|
||||
|
||||
; Operators {{{
|
||||
(operator) @operator
|
||||
|
||||
(integer_literal
|
||||
"-" @operator)
|
||||
(integer_literal ("-") @operator)
|
||||
; }}}
|
||||
|
||||
; Punctuation {{{
|
||||
[
|
||||
","
|
||||
":"
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
; }}}
|
||||
|
||||
; Literal {{{
|
||||
(boolean_literal) @boolean
|
||||
|
||||
(integer_literal) @number
|
||||
|
||||
[
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
; }}}
|
||||
|
||||
; Declarations {{{
|
||||
(identifier) @variable
|
||||
|
||||
(module
|
||||
|
|
@ -38,19 +44,23 @@
|
|||
(module
|
||||
(property
|
||||
field: (identifier) @variable.parameter))
|
||||
; }}}
|
||||
|
||||
; Built-ins {{{
|
||||
[
|
||||
(unset)
|
||||
(default)
|
||||
(any)
|
||||
(unset)
|
||||
(default)
|
||||
] @variable.builtin
|
||||
(selection_type) @function.builtin
|
||||
; }}}
|
||||
|
||||
(condition
|
||||
name: (identifier) @function.builtin)
|
||||
|
||||
; Expressions {{{
|
||||
(map_expression
|
||||
(property
|
||||
field: (identifier) @property))
|
||||
|
||||
(select_expression
|
||||
"select" @keyword.conditional)
|
||||
; }}}
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
|||
|
|
@ -1,38 +1,27 @@
|
|||
; Expressions {{{
|
||||
(list_expression) @indent.begin
|
||||
|
||||
(list_expression
|
||||
"]" @indent.branch)
|
||||
|
||||
(map_expression) @indent.begin
|
||||
|
||||
(map_expression
|
||||
"}" @indent.branch)
|
||||
|
||||
(select_expression) @indent.begin
|
||||
|
||||
(select_expression
|
||||
")" @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.branch)
|
||||
; }}}
|
||||
|
||||
; Declarations {{{
|
||||
(module) @indent.begin
|
||||
|
||||
(module
|
||||
")" @indent.branch)
|
||||
|
||||
(module
|
||||
"}" @indent.branch)
|
||||
; }}}
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
(assignment
|
||||
left: (identifier) @local.definition.var)
|
||||
|
||||
(pattern_binding
|
||||
binding: (identifier) @local.definition.var)
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
|||
386
src/grammar.json
generated
386
src/grammar.json
generated
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
|
||||
"name": "bp",
|
||||
"rules": {
|
||||
"source_file": {
|
||||
|
|
@ -470,8 +469,17 @@
|
|||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_value"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_value"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "soong_config_variable"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
|
@ -488,73 +496,32 @@
|
|||
]
|
||||
},
|
||||
"select_value": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "condition"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"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",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"name": "type",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "product_variable"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "release_variable"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
"named": true,
|
||||
"value": "selection_type"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -563,37 +530,63 @@
|
|||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "arguments",
|
||||
"name": "condition",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"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",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
"type": "FIELD",
|
||||
"name": "namespace",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "variable",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -611,6 +604,30 @@
|
|||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_case"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
|
@ -618,36 +635,17 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_case"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "select_case"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "SYMBOL",
|
||||
"name": "default_case"
|
||||
},
|
||||
"named": true,
|
||||
"value": "select_case"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -670,7 +668,7 @@
|
|||
"name": "pattern",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "select_pattern"
|
||||
"name": "_string_literal"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -687,139 +685,32 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"select_pattern": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_select_pattern"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_select_pattern"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"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": "SYMBOL",
|
||||
"name": "integer_literal"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "any"
|
||||
},
|
||||
"named": true,
|
||||
"value": "any"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "pattern_binding"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "default"
|
||||
},
|
||||
"named": true,
|
||||
"value": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pattern_binding": {
|
||||
"default_case": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "pattern",
|
||||
"content": {
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "default"
|
||||
},
|
||||
"named": true,
|
||||
"value": "default"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"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": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"name": "_case_value"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -1087,6 +978,5 @@
|
|||
"precedences": [],
|
||||
"externals": [],
|
||||
"inline": [],
|
||||
"supertypes": [],
|
||||
"reserved": {}
|
||||
}
|
||||
"supertypes": []
|
||||
}
|
||||
|
|
|
|||
215
src/node-types.json
generated
215
src/node-types.json
generated
|
|
@ -177,40 +177,6 @@
|
|||
"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,
|
||||
|
|
@ -321,42 +287,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"named": true,
|
||||
|
|
@ -424,7 +354,15 @@
|
|||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "select_pattern",
|
||||
"type": "default",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "interpreted_string_literal",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "raw_string_literal",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
|
@ -507,44 +445,9 @@
|
|||
{
|
||||
"type": "select_value",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"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": "integer_literal",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "interpreted_string_literal",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "pattern_binding",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "raw_string_literal",
|
||||
"type": "soong_config_variable",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
|
@ -553,22 +456,90 @@
|
|||
{
|
||||
"type": "select_value",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "condition",
|
||||
"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,
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "source_file",
|
||||
"named": true,
|
||||
"root": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
|
|
@ -633,10 +604,6 @@
|
|||
"type": "]",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "default",
|
||||
"named": true
|
||||
|
|
@ -665,6 +632,10 @@
|
|||
"type": "select",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "selection_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "true",
|
||||
"named": false
|
||||
|
|
|
|||
8593
src/parser.c
generated
8593
src/parser.c
generated
File diff suppressed because it is too large
Load diff
8
src/tree_sitter/alloc.h
generated
8
src/tree_sitter/alloc.h
generated
|
|
@ -12,10 +12,10 @@ extern "C" {
|
|||
// Allow clients to override allocation functions
|
||||
#ifdef TREE_SITTER_REUSE_ALLOCATOR
|
||||
|
||||
extern void *(*ts_current_malloc)(size_t size);
|
||||
extern void *(*ts_current_calloc)(size_t count, size_t size);
|
||||
extern void *(*ts_current_realloc)(void *ptr, size_t size);
|
||||
extern void (*ts_current_free)(void *ptr);
|
||||
extern void *(*ts_current_malloc)(size_t);
|
||||
extern void *(*ts_current_calloc)(size_t, size_t);
|
||||
extern void *(*ts_current_realloc)(void *, size_t);
|
||||
extern void (*ts_current_free)(void *);
|
||||
|
||||
#ifndef ts_malloc
|
||||
#define ts_malloc ts_current_malloc
|
||||
|
|
|
|||
3
src/tree_sitter/array.h
generated
3
src/tree_sitter/array.h
generated
|
|
@ -14,7 +14,6 @@ extern "C" {
|
|||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
|
|
@ -279,7 +278,7 @@ static inline void _array__splice(Array *self, size_t element_size,
|
|||
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#pragma warning(default : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
|
|
|||
81
src/tree_sitter/parser.h
generated
81
src/tree_sitter/parser.h
generated
|
|
@ -18,12 +18,6 @@ typedef uint16_t TSStateId;
|
|||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
typedef struct TSLanguageMetadata TSLanguageMetadata;
|
||||
typedef struct TSLanguageMetadata {
|
||||
uint8_t major_version;
|
||||
uint8_t minor_version;
|
||||
uint8_t patch_version;
|
||||
} TSLanguageMetadata;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -32,11 +26,10 @@ typedef struct {
|
|||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
// Used to index the field and supertype maps.
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSMapSlice;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
|
|
@ -54,7 +47,6 @@ struct TSLexer {
|
|||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
void (*log)(const TSLexer *, const char *, ...);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -86,12 +78,6 @@ typedef struct {
|
|||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
uint16_t reserved_word_set_id;
|
||||
} TSLexerMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
|
|
@ -100,13 +86,8 @@ typedef union {
|
|||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
typedef struct {
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
} TSCharacterRange;
|
||||
|
||||
struct TSLanguage {
|
||||
uint32_t abi_version;
|
||||
uint32_t version;
|
||||
uint32_t symbol_count;
|
||||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
|
|
@ -122,13 +103,13 @@ struct TSLanguage {
|
|||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSMapSlice *field_map_slices;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexerMode *lex_modes;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
|
|
@ -142,34 +123,8 @@ struct TSLanguage {
|
|||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
const char *name;
|
||||
const TSSymbol *reserved_words;
|
||||
uint16_t max_reserved_word_set_size;
|
||||
uint32_t supertype_count;
|
||||
const TSSymbol *supertype_symbols;
|
||||
const TSMapSlice *supertype_map_slices;
|
||||
const TSSymbol *supertype_map_entries;
|
||||
TSLanguageMetadata metadata;
|
||||
};
|
||||
|
||||
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||
uint32_t index = 0;
|
||||
uint32_t size = len - index;
|
||||
while (size > 1) {
|
||||
uint32_t half_size = size / 2;
|
||||
uint32_t mid_index = index + half_size;
|
||||
const TSCharacterRange *range = &ranges[mid_index];
|
||||
if (lookahead >= range->start && lookahead <= range->end) {
|
||||
return true;
|
||||
} else if (lookahead > range->end) {
|
||||
index = mid_index;
|
||||
}
|
||||
size -= half_size;
|
||||
}
|
||||
const TSCharacterRange *range = &ranges[index];
|
||||
return (lookahead >= range->start && lookahead <= range->end);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
|
@ -199,17 +154,6 @@ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, in
|
|||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ADVANCE_MAP(...) \
|
||||
{ \
|
||||
static const uint16_t map[] = { __VA_ARGS__ }; \
|
||||
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
|
||||
if (map[i] == lookahead) { \
|
||||
state = map[i + 1]; \
|
||||
goto next_state; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
|
|
@ -259,15 +203,14 @@ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, in
|
|||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_name, \
|
||||
.child_count = children, \
|
||||
.dynamic_precedence = precedence, \
|
||||
.production_id = prod_id \
|
||||
}, \
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
|
|
|
|||
|
|
@ -116,19 +116,6 @@ Block comment is not recursive
|
|||
(source_file
|
||||
(comment))
|
||||
|
||||
================================================================================
|
||||
Block comment is not recursive (error)
|
||||
================================================================================
|
||||
|
||||
/* /* */ */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(comment)
|
||||
(ERROR
|
||||
(UNEXPECTED '*')))
|
||||
|
||||
================================================================================
|
||||
Unterminated comment
|
||||
================================================================================
|
||||
|
|
|
|||
|
|
@ -20,35 +20,6 @@ foo = 42
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(integer_literal)))
|
||||
|
||||
================================================================================
|
||||
Integer literal (negative)
|
||||
================================================================================
|
||||
|
||||
foo = -42
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(integer_literal)))
|
||||
|
||||
|
||||
================================================================================
|
||||
Integer literal (negative space)
|
||||
================================================================================
|
||||
|
||||
foo = - 42
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(assignment
|
||||
(identifier)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ Select
|
|||
|
||||
foo = select(release_variable("RELEASE_TEST"), {
|
||||
"d": "d2",
|
||||
any: unset,
|
||||
default: unset,
|
||||
})
|
||||
|
||||
|
|
@ -16,46 +15,14 @@ foo = select(release_variable("RELEASE_TEST"), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(selection_type)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(any))
|
||||
(unset))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(default))
|
||||
(unset))))))
|
||||
|
||||
================================================================================
|
||||
Select (no trailing comma)
|
||||
================================================================================
|
||||
|
||||
foo = select(release_variable("RELEASE_TEST"), {
|
||||
default: unset
|
||||
})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(default))
|
||||
(default)
|
||||
(unset))))))
|
||||
|
||||
================================================================================
|
||||
|
|
@ -65,7 +32,6 @@ Select (soong config variable)
|
|||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||
"foo": unset,
|
||||
"default": "bar",
|
||||
any @ foo: unset,
|
||||
})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
@ -75,27 +41,17 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
|||
(identifier)
|
||||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal)))
|
||||
(soong_config_variable
|
||||
(selection_type)
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(unset))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(pattern_binding
|
||||
(any)
|
||||
(operator)
|
||||
(identifier)))
|
||||
(unset))))))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))))))
|
||||
|
||||
================================================================================
|
||||
Select (no default)
|
||||
|
|
@ -116,25 +72,20 @@ foo = select(variant("arch"), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(selection_type)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))))))
|
||||
|
||||
================================================================================
|
||||
|
|
@ -151,9 +102,8 @@ foo = select(variant("VARIANT"), {})
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(selection_type)
|
||||
(interpreted_string_literal))
|
||||
(select_cases))))
|
||||
|
||||
================================================================================
|
||||
|
|
@ -176,29 +126,24 @@ foo = select(variant("VARIANT"), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(selection_type)
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(ERROR
|
||||
(select_case
|
||||
(default)
|
||||
(unset)))
|
||||
(select_case
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(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))))))
|
||||
|
||||
================================================================================
|
||||
|
|
@ -218,16 +163,14 @@ foo = select(variant(), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)))
|
||||
(selection_type)
|
||||
(MISSING raw_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal)
|
||||
(unset))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(default))
|
||||
(default)
|
||||
(interpreted_string_literal))))))
|
||||
|
||||
================================================================================
|
||||
|
|
@ -245,20 +188,14 @@ foo = select(some_unknown_type("CONDITION"), {
|
|||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(default))
|
||||
(interpreted_string_literal))))))
|
||||
(ERROR
|
||||
(identifier)
|
||||
(identifier)
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal)
|
||||
(default))
|
||||
(interpreted_string_literal))
|
||||
(ERROR))
|
||||
|
||||
================================================================================
|
||||
Select (multiple type arguments)
|
||||
|
|
@ -277,176 +214,16 @@ foo = select(release_variable("ONE", "TWO"), {
|
|||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(selection_type)
|
||||
(ERROR
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_cases
|
||||
(select_case
|
||||
(interpreted_string_literal)
|
||||
(interpreted_string_literal)))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(interpreted_string_literal))
|
||||
(interpreted_string_literal))
|
||||
(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))
|
||||
(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))))))
|
||||
|
||||
================================================================================
|
||||
Select (integer typed)
|
||||
================================================================================
|
||||
|
||||
foo = select(some_integer("VALUE"), {
|
||||
0: "0",
|
||||
-1: "-1",
|
||||
1: "1",
|
||||
default: "default",
|
||||
})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(assignment
|
||||
(identifier)
|
||||
(operator)
|
||||
(select_expression
|
||||
(select_value
|
||||
(condition
|
||||
(identifier)
|
||||
(interpreted_string_literal)))
|
||||
(select_cases
|
||||
(select_case
|
||||
(select_pattern
|
||||
(integer_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(integer_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(integer_literal))
|
||||
(interpreted_string_literal))
|
||||
(select_case
|
||||
(select_pattern
|
||||
(default))
|
||||
(default)
|
||||
(interpreted_string_literal))))))
|
||||
|
||||
================================================================================
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
|||
// ^ function.builtin
|
||||
"foo": unset,
|
||||
// ^ variable.builtin
|
||||
any: unset,
|
||||
// <- variable.builtin
|
||||
default: select(variant("VARIANT"), {}),
|
||||
// <- variable.builtin
|
||||
// ^ function.builtin
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||
// ^ keyword.conditional
|
||||
"foo": unset,
|
||||
any @ foo: unset,
|
||||
// ^ operator
|
||||
// ^ variable
|
||||
default: "bar",
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -26,35 +26,3 @@ foo = select(
|
|||
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,7 +1,6 @@
|
|||
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
||||
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
-- FIXME: path to root
|
||||
local runner = Runner:new(it, ".", {
|
||||
|
|
@ -20,7 +19,7 @@ describe("indent Blueprint:", function()
|
|||
})
|
||||
runner:whole_file("test/indent/", {
|
||||
expected_failures = {
|
||||
"test/indent/select.bp",
|
||||
-- NOTE: none for now
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
|
@ -40,22 +39,9 @@ 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 = 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 = '}', 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 = '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 = '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)
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"grammars": [
|
||||
{
|
||||
"name": "bp",
|
||||
"camelcase": "Bp",
|
||||
"scope": "source.bp",
|
||||
"path": ".",
|
||||
"file-types": [
|
||||
"bp"
|
||||
],
|
||||
"injection-regex": "^bp$"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"version": "0.7.0",
|
||||
"license": "MIT",
|
||||
"description": "Blueprint grammar for tree-sitter",
|
||||
"links": {
|
||||
"repository": "https://github.com/tree-sitter/tree-sitter-bp"
|
||||
}
|
||||
},
|
||||
"bindings": {
|
||||
"c": true,
|
||||
"go": true,
|
||||
"node": true,
|
||||
"python": true,
|
||||
"rust": true,
|
||||
"swift": true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue