Compare commits

..

No commits in common. "c5d3860a83c9b42ae4e0b3bc8efaf8a409ee70b8" and "d61c050351794efc4ccc415528f38c079d83fb16" have entirely different histories.

10 changed files with 881 additions and 1274 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "tree-sitter-blueprint"
description = "Blueprint grammar for the tree-sitter parsing library"
version = "0.1.1"
version = "0.1.0"
keywords = ["incremental", "parsing", "android", "blueprint"]
categories = ["parsing", "text-editors"]
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-blueprint"

View file

@ -46,20 +46,6 @@
overlays = [ ];
};
bump-version = pkgs.writeShellScriptBin "bump-version" ''
set -eu
NEW_VERSION="''${1}"
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
mv package.json.tmp package.json
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
git add Cargo.toml package.json
echo "Release ''${NEW_VERSION}" | git commit -eF -
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
'';
tree-sitter-env = pkgs.stdenv.mkDerivation {
name = "tree-sitter-env";
@ -110,7 +96,6 @@
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
bump-version
nodejs
(tree-sitter.override { webUISupport = true; })
];

View file

@ -28,7 +28,7 @@ module.exports = grammar({
assignment: ($) => seq(
field("left", $.identifier),
field("operator", alias(choice("=", "+="), $.operator)),
field("operator", choice("=", "+=")),
field("right", $._expr),
),
@ -71,8 +71,6 @@ module.exports = grammar({
// Composites
$.list_expression,
$.map_expression,
// Operators
$.binary_expression,
),
// The Blueprint scanner makes use of Go's lexer, so copy their rule
@ -187,12 +185,6 @@ module.exports = grammar({
"}",
),
binary_expression: ($) => prec.left(seq(
field("left", $._expr),
field("operator", alias("+", $.operator)),
field("right", $._expr),
)),
// }}}
// Properties {{{

View file

@ -1,6 +1,6 @@
{
"name": "tree-sitter-blueprint",
"version": "0.1.1",
"version": "0.1.0",
"description": "Blueprint grammar for tree-sitter",
"main": "bindings/node",
"keywords": [

69
src/grammar.json generated
View file

@ -49,22 +49,17 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "ALIAS",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+="
}
]
},
"named": true,
"value": "operator"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+="
}
]
}
},
{
@ -284,10 +279,6 @@
{
"type": "SYMBOL",
"name": "map_expression"
},
{
"type": "SYMBOL",
"name": "binary_expression"
}
]
},
@ -839,44 +830,6 @@
}
]
},
"binary_expression": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "_expr"
}
},
{
"type": "FIELD",
"name": "operator",
"content": {
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "+"
},
"named": true,
"value": "operator"
}
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL",
"name": "_expr"
}
}
]
}
},
"_colon_property": {
"type": "SEQ",
"members": [

136
src/node-types.json generated
View file

@ -18,8 +18,12 @@
"required": true,
"types": [
{
"type": "operator",
"named": true
"type": "+=",
"named": false
},
{
"type": "=",
"named": false
}
]
},
@ -27,110 +31,6 @@
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "integer_literal",
"named": true
},
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "list_expression",
"named": true
},
{
"type": "map_expression",
"named": true
},
{
"type": "raw_string_literal",
"named": true
},
{
"type": "select_expression",
"named": true
}
]
}
}
},
{
"type": "binary_expression",
"named": true,
"fields": {
"left": {
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "integer_literal",
"named": true
},
{
"type": "interpreted_string_literal",
"named": true
},
{
"type": "list_expression",
"named": true
},
{
"type": "map_expression",
"named": true
},
{
"type": "raw_string_literal",
"named": true
},
{
"type": "select_expression",
"named": true
}
]
},
"operator": {
"multiple": false,
"required": true,
"types": [
{
"type": "operator",
"named": true
}
]
},
"right": {
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
@ -195,10 +95,6 @@
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
@ -267,10 +163,6 @@
"multiple": true,
"required": false,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
@ -377,10 +269,6 @@
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
@ -439,10 +327,6 @@
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "boolean_literal",
"named": true
@ -644,6 +528,10 @@
"type": ")",
"named": false
},
{
"type": "+=",
"named": false
},
{
"type": ",",
"named": false
@ -684,10 +572,6 @@
"type": "identifier",
"named": true
},
{
"type": "operator",
"named": true
},
{
"type": "raw_string_literal",
"named": true

1850
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,6 @@ foo = 42
(source_file
(assignment
(identifier)
(operator)
(integer_literal)))
================================================================================
@ -31,7 +30,6 @@ foo = bar
(source_file
(assignment
(identifier)
(operator)
(identifier)))
================================================================================
@ -45,7 +43,6 @@ foo += 12
(source_file
(assignment
(identifier)
(operator)
(integer_literal)))
================================================================================
@ -60,11 +57,9 @@ bar = 27
(source_file
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal)))
================================================================================
@ -83,25 +78,19 @@ qux += 1
(source_file
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal)))

View file

@ -10,11 +10,9 @@ foo = true
(source_file
(assignment
(identifier)
(operator)
(boolean_literal))
(assignment
(identifier)
(operator)
(boolean_literal)))
================================================================================
@ -29,11 +27,9 @@ false = true
(source_file
(assignment
(identifier)
(operator)
(boolean_literal))
(assignment
(identifier)
(operator)
(boolean_literal)))
================================================================================
@ -48,11 +44,9 @@ foo = 42
(source_file
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal)))
================================================================================
@ -67,11 +61,9 @@ foo = -42
(source_file
(assignment
(identifier)
(operator)
(integer_literal))
(assignment
(identifier)
(operator)
(integer_literal)))
================================================================================
@ -85,7 +77,6 @@ foo = "Hello World!"
(source_file
(assignment
(identifier)
(operator)
(interpreted_string_literal)))
================================================================================
@ -99,7 +90,6 @@ foo = "Hello\nWorld!"
(source_file
(assignment
(identifier)
(operator)
(interpreted_string_literal
(escape_sequence))))
@ -114,7 +104,6 @@ foo = `Hello\nWorld!`
(source_file
(assignment
(identifier)
(operator)
(raw_string_literal)))
================================================================================
@ -128,7 +117,6 @@ foo = []
(source_file
(assignment
(identifier)
(operator)
(list_expression)))
================================================================================
@ -142,7 +130,6 @@ foo = [42]
(source_file
(assignment
(identifier)
(operator)
(list_expression
(integer_literal))))
@ -159,7 +146,6 @@ foo = [
(source_file
(assignment
(identifier)
(operator)
(list_expression
(integer_literal))))
@ -176,7 +162,6 @@ foo = [
(source_file
(assignment
(identifier)
(operator)
(list_expression
(integer_literal))))
@ -194,7 +179,6 @@ foo = [
(source_file
(assignment
(identifier)
(operator)
(list_expression
(integer_literal)
(interpreted_string_literal))))
@ -214,7 +198,6 @@ foo = [
(source_file
(assignment
(identifier)
(operator)
(list_expression
(list_expression
(integer_literal))
@ -235,7 +218,6 @@ foo = [
(source_file
(assignment
(identifier)
(operator)
(list_expression
(ERROR))))
@ -250,7 +232,6 @@ foo = {}
(source_file
(assignment
(identifier)
(operator)
(map_expression)))
================================================================================
@ -264,7 +245,6 @@ foo = {foo:42}
(source_file
(assignment
(identifier)
(operator)
(map_expression
(property
(identifier)
@ -283,7 +263,6 @@ foo = {
(source_file
(assignment
(identifier)
(operator)
(map_expression
(property
(identifier)
@ -302,7 +281,6 @@ foo = {
(source_file
(assignment
(identifier)
(operator)
(map_expression
(property
(identifier)
@ -322,7 +300,6 @@ foo = {
(source_file
(assignment
(identifier)
(operator)
(map_expression
(property
(identifier)
@ -344,7 +321,6 @@ foo = {
(source_file
(assignment
(identifier)
(operator)
(map_expression
(property
(identifier)
@ -366,34 +342,5 @@ foo = {
(source_file
(assignment
(identifier)
(operator)
(map_expression
(ERROR))))
================================================================================
Binary operators
================================================================================
foo = [
-12 + -27 + 42,
"a" + "b",
]
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
(operator)
(list_expression
(binary_expression
(binary_expression
(integer_literal)
(operator)
(integer_literal))
(operator)
(integer_literal))
(binary_expression
(interpreted_string_literal)
(operator)
(interpreted_string_literal)))))

View file

@ -12,7 +12,6 @@ foo = select(release_variable("RELEASE_TEST"), {
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(selection_type)
@ -38,7 +37,6 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
(source_file
(assignment
(identifier)
(operator)
(select_expression
(soong_config_variable
(selection_type)
@ -68,7 +66,6 @@ foo = select(variant("arch"), {
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(selection_type)
@ -98,7 +95,6 @@ foo = select(variant("VARIANT"), {})
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(selection_type)
@ -122,7 +118,6 @@ foo = select(variant("VARIANT"), {
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(selection_type)
@ -158,7 +153,6 @@ foo = select(variant(), {
(source_file
(assignment
(identifier)
(operator)
(select_expression
(select_value
(selection_type)
@ -184,7 +178,6 @@ foo = select(some_unknown_type("CONDITION"), {
(source_file
(assignment
(identifier)
(operator)
(ERROR
(identifier)
(identifier)