Compare commits
No commits in common. "main" and "v0.4.0" have entirely different histories.
24 changed files with 4601 additions and 2572 deletions
|
|
@ -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.7.0"
|
version = "0.4.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"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//! let code = "";
|
//! let code = "";
|
||||||
//! let mut parser = tree_sitter::Parser::new();
|
//! 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();
|
//! let tree = parser.parse(code, None).unwrap();
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -21,11 +21,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731533236,
|
"lastModified": 1710146030,
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -58,11 +58,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1741802033,
|
"lastModified": 1713687659,
|
||||||
"narHash": "sha256-AOazEmkhbKnNQi0LqJdAcqPQx711L84a0Vkaos/ZW/A=",
|
"narHash": "sha256-Yd8KuOBpZ0Slau/NxFhMPJI0gBxeax0vq/FD0rqKwuQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8c1f3147639f009f09d2bfffc64bcf8485bf3fd2",
|
"rev": "f2d7a289c5a5ece8521dd082b81ac7e4a57c2c5c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -75,17 +75,23 @@
|
||||||
"pre-commit-hooks": {
|
"pre-commit-hooks": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
"gitignore": "gitignore",
|
"gitignore": "gitignore",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": [
|
||||||
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735882644,
|
"lastModified": 1713775815,
|
||||||
"narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=",
|
"narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
|
"rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@
|
||||||
repo = "pre-commit-hooks.nix";
|
repo = "pre-commit-hooks.nix";
|
||||||
ref = "master";
|
ref = "master";
|
||||||
inputs = {
|
inputs = {
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
nixpkgs.follows = "nixpkgs";
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
nixpkgs-stable.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -75,14 +77,10 @@
|
||||||
|
|
||||||
${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.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}\"/" Cargo.toml
|
||||||
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" pyproject.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
|
||||||
|
|
||||||
git add Cargo.toml package.json pyproject.toml tree-sitter.json src/parser.c
|
|
||||||
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}"
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
11
grammar.js
11
grammar.js
|
|
@ -145,7 +145,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
select_cases: ($) => seq(
|
select_cases: ($) => seq(
|
||||||
"{",
|
"{",
|
||||||
optional(commaSeparatedOptTrailing($.select_case)),
|
optional(commaSeparatedTrailing($.select_case)),
|
||||||
"}",
|
"}",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -163,18 +163,9 @@ module.exports = grammar({
|
||||||
_select_pattern: ($) => choice(
|
_select_pattern: ($) => choice(
|
||||||
$._string_literal,
|
$._string_literal,
|
||||||
$.boolean_literal,
|
$.boolean_literal,
|
||||||
$.integer_literal,
|
|
||||||
alias("any", $.any),
|
|
||||||
$.pattern_binding,
|
|
||||||
alias("default", $.default),
|
alias("default", $.default),
|
||||||
),
|
),
|
||||||
|
|
||||||
pattern_binding: ($) => seq(
|
|
||||||
field("value", alias("any", $.any)),
|
|
||||||
field("operator", alias("@", $.operator)),
|
|
||||||
field("binding", $.identifier),
|
|
||||||
),
|
|
||||||
|
|
||||||
_case_value: ($) => choice(
|
_case_value: ($) => choice(
|
||||||
alias("unset", $.unset),
|
alias("unset", $.unset),
|
||||||
$._expr,
|
$._expr,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tree-sitter-bp",
|
"name": "tree-sitter-bp",
|
||||||
"version": "0.7.0",
|
"version": "0.4.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",
|
||||||
|
|
|
||||||
|
|
@ -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.7.0"
|
version = "0.4.0"
|
||||||
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,5 @@
|
||||||
(module)
|
(module)
|
||||||
(select_expression)
|
(select_expression)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
||||||
|
; vim: sw=2 foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
|
; Operators {{{
|
||||||
(operator) @operator
|
(operator) @operator
|
||||||
|
|
||||||
(integer_literal
|
(integer_literal ("-") @operator)
|
||||||
"-" @operator)
|
; }}}
|
||||||
|
|
||||||
|
; Punctuation {{{
|
||||||
[
|
[
|
||||||
","
|
","
|
||||||
":"
|
":"
|
||||||
|
|
@ -18,7 +20,9 @@
|
||||||
"{"
|
"{"
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; Literal {{{
|
||||||
(boolean_literal) @boolean
|
(boolean_literal) @boolean
|
||||||
|
|
||||||
(integer_literal) @number
|
(integer_literal) @number
|
||||||
|
|
@ -29,7 +33,9 @@
|
||||||
] @string
|
] @string
|
||||||
|
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; Declarations {{{
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
(module
|
(module
|
||||||
|
|
@ -38,19 +44,24 @@
|
||||||
(module
|
(module
|
||||||
(property
|
(property
|
||||||
field: (identifier) @variable.parameter))
|
field: (identifier) @variable.parameter))
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; Built-ins {{{
|
||||||
[
|
[
|
||||||
(unset)
|
(unset)
|
||||||
(default)
|
(default)
|
||||||
(any)
|
|
||||||
] @variable.builtin
|
] @variable.builtin
|
||||||
|
|
||||||
(condition
|
(condition
|
||||||
name: (identifier) @function.builtin)
|
name: (identifier) @function.builtin)
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; Expressions {{{
|
||||||
(map_expression
|
(map_expression
|
||||||
(property
|
(property
|
||||||
field: (identifier) @property))
|
field: (identifier) @property))
|
||||||
|
|
||||||
(select_expression
|
(select_expression
|
||||||
"select" @keyword.conditional)
|
"select" @keyword.conditional)
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; vim: sw=2 foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,36 @@
|
||||||
|
; Expressions {{{
|
||||||
(list_expression) @indent.begin
|
(list_expression) @indent.begin
|
||||||
|
|
||||||
(list_expression
|
(list_expression
|
||||||
"]" @indent.branch)
|
"]" @indent.branch)
|
||||||
|
|
||||||
(map_expression) @indent.begin
|
(map_expression) @indent.begin
|
||||||
|
|
||||||
(map_expression
|
(map_expression
|
||||||
"}" @indent.branch)
|
"}" @indent.branch)
|
||||||
|
|
||||||
(select_expression) @indent.begin
|
(select_expression) @indent.begin
|
||||||
|
|
||||||
(select_expression
|
(select_expression
|
||||||
")" @indent.branch)
|
")" @indent.branch)
|
||||||
|
|
||||||
(select_value) @indent.begin
|
(select_value) @indent.begin
|
||||||
|
|
||||||
(select_value
|
(select_value
|
||||||
")" @indent.branch)
|
")" @indent.branch)
|
||||||
|
|
||||||
(select_pattern
|
(select_pattern
|
||||||
"(" @indent.begin)
|
"(" @indent.begin)
|
||||||
|
|
||||||
(select_pattern
|
(select_pattern
|
||||||
")" @indent.branch)
|
")" @indent.branch)
|
||||||
|
|
||||||
(select_cases) @indent.begin
|
(select_cases) @indent.begin
|
||||||
|
|
||||||
(select_cases
|
(select_cases
|
||||||
"}" @indent.branch)
|
"}" @indent.branch)
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; Declarations {{{
|
||||||
(module) @indent.begin
|
(module) @indent.begin
|
||||||
|
|
||||||
(module
|
(module
|
||||||
")" @indent.branch)
|
")" @indent.branch)
|
||||||
|
|
||||||
(module
|
(module
|
||||||
"}" @indent.branch)
|
"}" @indent.branch)
|
||||||
|
; }}}
|
||||||
|
|
||||||
|
; vim: sw=2 foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; vim: sw=2 foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
(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
|
||||||
|
|
|
||||||
81
src/grammar.json
generated
81
src/grammar.json
generated
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
|
|
||||||
"name": "bp",
|
"name": "bp",
|
||||||
"rules": {
|
"rules": {
|
||||||
"source_file": {
|
"source_file": {
|
||||||
|
|
@ -614,42 +613,21 @@
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_case"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ","
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "select_case"
|
"name": "select_case"
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": ","
|
"value": ","
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
|
|
@ -757,23 +735,6 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "boolean_literal"
|
"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",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -785,45 +746,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"pattern_binding": {
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_case_value": {
|
"_case_value": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
@ -1087,6 +1009,5 @@
|
||||||
"precedences": [],
|
"precedences": [],
|
||||||
"externals": [],
|
"externals": [],
|
||||||
"inline": [],
|
"inline": [],
|
||||||
"supertypes": [],
|
"supertypes": []
|
||||||
"reserved": {}
|
|
||||||
}
|
}
|
||||||
53
src/node-types.json
generated
53
src/node-types.json
generated
|
|
@ -321,42 +321,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",
|
"type": "property",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -519,10 +483,6 @@
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
|
||||||
"type": "any",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "boolean_literal",
|
"type": "boolean_literal",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -531,18 +491,10 @@
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "integer_literal",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "interpreted_string_literal",
|
"type": "interpreted_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "pattern_binding",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "raw_string_literal",
|
"type": "raw_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -568,7 +520,6 @@
|
||||||
{
|
{
|
||||||
"type": "source_file",
|
"type": "source_file",
|
||||||
"named": true,
|
"named": true,
|
||||||
"root": true,
|
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
|
|
@ -633,10 +584,6 @@
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "any",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
|
||||||
6643
src/parser.c
generated
6643
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
|
// Allow clients to override allocation functions
|
||||||
#ifdef TREE_SITTER_REUSE_ALLOCATOR
|
#ifdef TREE_SITTER_REUSE_ALLOCATOR
|
||||||
|
|
||||||
extern void *(*ts_current_malloc)(size_t size);
|
extern void *(*ts_current_malloc)(size_t);
|
||||||
extern void *(*ts_current_calloc)(size_t count, size_t size);
|
extern void *(*ts_current_calloc)(size_t, size_t);
|
||||||
extern void *(*ts_current_realloc)(void *ptr, size_t size);
|
extern void *(*ts_current_realloc)(void *, size_t);
|
||||||
extern void (*ts_current_free)(void *ptr);
|
extern void (*ts_current_free)(void *);
|
||||||
|
|
||||||
#ifndef ts_malloc
|
#ifndef ts_malloc
|
||||||
#define ts_malloc ts_current_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>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable : 4101)
|
#pragma warning(disable : 4101)
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#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))
|
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(default : 4101)
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
73
src/tree_sitter/parser.h
generated
73
src/tree_sitter/parser.h
generated
|
|
@ -18,12 +18,6 @@ typedef uint16_t TSStateId;
|
||||||
typedef uint16_t TSSymbol;
|
typedef uint16_t TSSymbol;
|
||||||
typedef uint16_t TSFieldId;
|
typedef uint16_t TSFieldId;
|
||||||
typedef struct TSLanguage TSLanguage;
|
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
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -32,11 +26,10 @@ typedef struct {
|
||||||
bool inherited;
|
bool inherited;
|
||||||
} TSFieldMapEntry;
|
} TSFieldMapEntry;
|
||||||
|
|
||||||
// Used to index the field and supertype maps.
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
} TSMapSlice;
|
} TSFieldMapSlice;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool visible;
|
bool visible;
|
||||||
|
|
@ -54,7 +47,6 @@ struct TSLexer {
|
||||||
uint32_t (*get_column)(TSLexer *);
|
uint32_t (*get_column)(TSLexer *);
|
||||||
bool (*is_at_included_range_start)(const TSLexer *);
|
bool (*is_at_included_range_start)(const TSLexer *);
|
||||||
bool (*eof)(const TSLexer *);
|
bool (*eof)(const TSLexer *);
|
||||||
void (*log)(const TSLexer *, const char *, ...);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
@ -86,12 +78,6 @@ typedef struct {
|
||||||
uint16_t external_lex_state;
|
uint16_t external_lex_state;
|
||||||
} TSLexMode;
|
} TSLexMode;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t lex_state;
|
|
||||||
uint16_t external_lex_state;
|
|
||||||
uint16_t reserved_word_set_id;
|
|
||||||
} TSLexerMode;
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
TSParseAction action;
|
TSParseAction action;
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -100,13 +86,8 @@ typedef union {
|
||||||
} entry;
|
} entry;
|
||||||
} TSParseActionEntry;
|
} TSParseActionEntry;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t start;
|
|
||||||
int32_t end;
|
|
||||||
} TSCharacterRange;
|
|
||||||
|
|
||||||
struct TSLanguage {
|
struct TSLanguage {
|
||||||
uint32_t abi_version;
|
uint32_t version;
|
||||||
uint32_t symbol_count;
|
uint32_t symbol_count;
|
||||||
uint32_t alias_count;
|
uint32_t alias_count;
|
||||||
uint32_t token_count;
|
uint32_t token_count;
|
||||||
|
|
@ -122,13 +103,13 @@ struct TSLanguage {
|
||||||
const TSParseActionEntry *parse_actions;
|
const TSParseActionEntry *parse_actions;
|
||||||
const char * const *symbol_names;
|
const char * const *symbol_names;
|
||||||
const char * const *field_names;
|
const char * const *field_names;
|
||||||
const TSMapSlice *field_map_slices;
|
const TSFieldMapSlice *field_map_slices;
|
||||||
const TSFieldMapEntry *field_map_entries;
|
const TSFieldMapEntry *field_map_entries;
|
||||||
const TSSymbolMetadata *symbol_metadata;
|
const TSSymbolMetadata *symbol_metadata;
|
||||||
const TSSymbol *public_symbol_map;
|
const TSSymbol *public_symbol_map;
|
||||||
const uint16_t *alias_map;
|
const uint16_t *alias_map;
|
||||||
const TSSymbol *alias_sequences;
|
const TSSymbol *alias_sequences;
|
||||||
const TSLexerMode *lex_modes;
|
const TSLexMode *lex_modes;
|
||||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||||
TSSymbol keyword_capture_token;
|
TSSymbol keyword_capture_token;
|
||||||
|
|
@ -142,34 +123,8 @@ struct TSLanguage {
|
||||||
void (*deserialize)(void *, const char *, unsigned);
|
void (*deserialize)(void *, const char *, unsigned);
|
||||||
} external_scanner;
|
} external_scanner;
|
||||||
const TSStateId *primary_state_ids;
|
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
|
* Lexer Macros
|
||||||
*/
|
*/
|
||||||
|
|
@ -199,17 +154,6 @@ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, in
|
||||||
goto next_state; \
|
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) \
|
#define SKIP(state_value) \
|
||||||
{ \
|
{ \
|
||||||
skip = true; \
|
skip = true; \
|
||||||
|
|
@ -259,14 +203,13 @@ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, in
|
||||||
} \
|
} \
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||||
{{ \
|
{{ \
|
||||||
.reduce = { \
|
.reduce = { \
|
||||||
.type = TSParseActionTypeReduce, \
|
.type = TSParseActionTypeReduce, \
|
||||||
.symbol = symbol_name, \
|
.symbol = symbol_val, \
|
||||||
.child_count = children, \
|
.child_count = child_count_val, \
|
||||||
.dynamic_precedence = precedence, \
|
__VA_ARGS__ \
|
||||||
.production_id = prod_id \
|
|
||||||
}, \
|
}, \
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,19 +116,6 @@ Block comment is not recursive
|
||||||
(source_file
|
(source_file
|
||||||
(comment))
|
(comment))
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Block comment is not recursive (error)
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
/* /* */ */
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(source_file
|
|
||||||
(comment)
|
|
||||||
(ERROR
|
|
||||||
(UNEXPECTED '*')))
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Unterminated comment
|
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
|
(source_file
|
||||||
(assignment
|
(assignment
|
||||||
(identifier)
|
(identifier)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ Select
|
||||||
|
|
||||||
foo = select(release_variable("RELEASE_TEST"), {
|
foo = select(release_variable("RELEASE_TEST"), {
|
||||||
"d": "d2",
|
"d": "d2",
|
||||||
any: unset,
|
|
||||||
default: unset,
|
default: unset,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -24,35 +23,6 @@ foo = select(release_variable("RELEASE_TEST"), {
|
||||||
(select_pattern
|
(select_pattern
|
||||||
(interpreted_string_literal))
|
(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_case
|
||||||
(select_pattern
|
(select_pattern
|
||||||
(default))
|
(default))
|
||||||
|
|
@ -65,7 +35,6 @@ 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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
@ -88,14 +57,7 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
(select_case
|
(select_case
|
||||||
(select_pattern
|
(select_pattern
|
||||||
(interpreted_string_literal))
|
(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)
|
||||||
|
|
@ -409,46 +371,6 @@ foo = select(some_boolean("IS_TRUE"), {
|
||||||
(boolean_literal))
|
(boolean_literal))
|
||||||
(interpreted_string_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))
|
|
||||||
(interpreted_string_literal))))))
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select as an identifier
|
Select as an identifier
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ 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,9 +1,6 @@
|
||||||
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",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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