Compare commits
39 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee641d1539 | |||
| e6473f64ae | |||
| 2b7323eaf0 | |||
| 4c2a1d0012 | |||
| bb0d5d6a40 | |||
| f9dbeed40a | |||
| 9f5e6b0141 | |||
| 16c43068ec | |||
| aeb1fc2bb5 | |||
| fd92a31674 | |||
| 4e60cf3c2e | |||
| 6b0cdd9122 | |||
| 1fd9b67dbe | |||
| 3e685cb691 | |||
| 970241b323 | |||
| 2326d709fb | |||
| bf783d99bc | |||
| c5031e2c16 | |||
| f228904ed0 | |||
| 5cbdf5e3ac | |||
| 533c82cdf3 | |||
| d25b07cae0 | |||
| ff40b39dcf | |||
| d01bcf0f6d | |||
| 0816633d9a | |||
| 6ca4592d84 | |||
| afdfbff7bc | |||
| f6bc0f887a | |||
| 2649422636 | |||
| 1c1387fee0 | |||
| 8137fd3e5b | |||
| 9e46303a1d | |||
| 1af33aeea1 | |||
| b04cd92189 | |||
| 6d6d9fc03b | |||
| 6ece5d984a | |||
| e6a2757c51 | |||
| 8db7b053f5 | |||
| d297f38e6a |
45 changed files with 4119 additions and 6432 deletions
39
.editorconfig
Normal file
39
.editorconfig
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.{json,toml,yml,gyp}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.rs]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{c,cc,h}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{py,pyi}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.swift]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.go]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
2
.gitattributes
vendored
2
.gitattributes
vendored
|
|
@ -2,4 +2,6 @@
|
||||||
src/grammar.json linguist-generated=true
|
src/grammar.json linguist-generated=true
|
||||||
src/node-types.json linguist-generated=true
|
src/node-types.json linguist-generated=true
|
||||||
src/parser.c linguist-generated=true
|
src/parser.c linguist-generated=true
|
||||||
|
src/tree_sitter/alloc.h linguist-generated=true
|
||||||
|
src/tree_sitter/array.h linguist-generated=true
|
||||||
src/tree_sitter/parser.h linguist-generated=true
|
src/tree_sitter/parser.h linguist-generated=true
|
||||||
|
|
|
||||||
|
|
@ -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.2.0"
|
version = "0.7.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"
|
||||||
|
|
|
||||||
4
Makefile
4
Makefile
|
|
@ -4,12 +4,12 @@ all:
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: all
|
test: all
|
||||||
tree-sitter test --apply-all-captures
|
tree-sitter test
|
||||||
nvim-test-runner
|
nvim-test-runner
|
||||||
|
|
||||||
.PHONY: update-tests
|
.PHONY: update-tests
|
||||||
update-tests: all
|
update-tests: all
|
||||||
tree-sitter test -u --apply-all-captures
|
tree-sitter test -u
|
||||||
nvim-test-runner
|
nvim-test-runner
|
||||||
|
|
||||||
.PHONY: playground
|
.PHONY: playground
|
||||||
|
|
|
||||||
48
Package.swift
Normal file
48
Package.swift
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
// swift-tools-version:5.3
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "TreeSitterBp",
|
||||||
|
platforms: [.macOS(.v10_13), .iOS(.v11)],
|
||||||
|
products: [
|
||||||
|
.library(name: "TreeSitterBp", targets: ["TreeSitterBp"]),
|
||||||
|
],
|
||||||
|
dependencies: [],
|
||||||
|
targets: [
|
||||||
|
.target(name: "TreeSitterBp",
|
||||||
|
path: ".",
|
||||||
|
exclude: [
|
||||||
|
"Cargo.toml",
|
||||||
|
"Makefile",
|
||||||
|
"binding.gyp",
|
||||||
|
"bindings/c",
|
||||||
|
"bindings/go",
|
||||||
|
"bindings/node",
|
||||||
|
"bindings/python",
|
||||||
|
"bindings/rust",
|
||||||
|
"prebuilds",
|
||||||
|
"grammar.js",
|
||||||
|
"package.json",
|
||||||
|
"package-lock.json",
|
||||||
|
"pyproject.toml",
|
||||||
|
"setup.py",
|
||||||
|
"test",
|
||||||
|
"examples",
|
||||||
|
".editorconfig",
|
||||||
|
".github",
|
||||||
|
".gitignore",
|
||||||
|
".gitattributes",
|
||||||
|
".gitmodules",
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
"src/parser.c",
|
||||||
|
// NOTE: if your language has an external scanner, add it here.
|
||||||
|
],
|
||||||
|
resources: [
|
||||||
|
.copy("queries")
|
||||||
|
],
|
||||||
|
publicHeadersPath: "bindings/swift",
|
||||||
|
cSettings: [.headerSearchPath("src")])
|
||||||
|
],
|
||||||
|
cLanguageStandard: .c11
|
||||||
|
)
|
||||||
12
binding.gyp
12
binding.gyp
|
|
@ -2,18 +2,20 @@
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"target_name": "tree_sitter_bp_binding",
|
"target_name": "tree_sitter_bp_binding",
|
||||||
|
"dependencies": [
|
||||||
|
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
||||||
|
],
|
||||||
"include_dirs": [
|
"include_dirs": [
|
||||||
"<!(node -e \"require('nan')\")",
|
"src",
|
||||||
"src"
|
|
||||||
],
|
],
|
||||||
"sources": [
|
"sources": [
|
||||||
"bindings/node/binding.cc",
|
"bindings/node/binding.cc",
|
||||||
"src/parser.c",
|
"src/parser.c",
|
||||||
# If your language uses an external scanner, add it here.
|
# NOTE: if your language has an external scanner, add it here.
|
||||||
],
|
],
|
||||||
"cflags_c": [
|
"cflags_c": [
|
||||||
"-std=c99",
|
"-std=c11",
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
bindings/c/tree-sitter-bp.h
Normal file
16
bindings/c/tree-sitter-bp.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef TREE_SITTER_BP_H_
|
||||||
|
#define TREE_SITTER_BP_H_
|
||||||
|
|
||||||
|
typedef struct TSLanguage TSLanguage;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const TSLanguage *tree_sitter_bp(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TREE_SITTER_BP_H_
|
||||||
11
bindings/c/tree-sitter-bp.pc.in
Normal file
11
bindings/c/tree-sitter-bp.pc.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
prefix=@PREFIX@
|
||||||
|
libdir=@LIBDIR@
|
||||||
|
includedir=@INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: tree-sitter-bp
|
||||||
|
Description: Bp grammar for tree-sitter
|
||||||
|
URL: @URL@
|
||||||
|
Version: @VERSION@
|
||||||
|
Requires: @REQUIRES@
|
||||||
|
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-bp
|
||||||
|
Cflags: -I${includedir}
|
||||||
13
bindings/go/binding.go
Normal file
13
bindings/go/binding.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package tree_sitter_bp
|
||||||
|
|
||||||
|
// #cgo CFLAGS: -std=c11 -fPIC
|
||||||
|
// #include "../../src/parser.c"
|
||||||
|
// // NOTE: if your language has an external scanner, add it here.
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// Get the tree-sitter Language for this grammar.
|
||||||
|
func Language() unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(C.tree_sitter_bp())
|
||||||
|
}
|
||||||
15
bindings/go/binding_test.go
Normal file
15
bindings/go/binding_test.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package tree_sitter_bp_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
tree_sitter "github.com/smacker/go-tree-sitter"
|
||||||
|
"git.belanyi.fr/ambroisie/tree-sitter-bp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCanLoadGrammar(t *testing.T) {
|
||||||
|
language := tree_sitter.NewLanguage(tree_sitter_bp.Language())
|
||||||
|
if language == nil {
|
||||||
|
t.Errorf("Error loading Bp grammar")
|
||||||
|
}
|
||||||
|
}
|
||||||
5
bindings/go/go.mod
Normal file
5
bindings/go/go.mod
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
module git.belanyi.fr/ambroisie/tree-sitter-bp
|
||||||
|
|
||||||
|
go 1.22
|
||||||
|
|
||||||
|
require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8
|
||||||
|
|
@ -1,28 +1,20 @@
|
||||||
#include "tree_sitter/parser.h"
|
#include <napi.h>
|
||||||
#include <node.h>
|
|
||||||
#include "nan.h"
|
|
||||||
|
|
||||||
using namespace v8;
|
typedef struct TSLanguage TSLanguage;
|
||||||
|
|
||||||
extern "C" TSLanguage * tree_sitter_bp();
|
extern "C" TSLanguage *tree_sitter_bp();
|
||||||
|
|
||||||
namespace {
|
// "tree-sitter", "language" hashed with BLAKE2
|
||||||
|
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
||||||
|
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
|
||||||
|
};
|
||||||
|
|
||||||
NAN_METHOD(New) {}
|
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||||
|
exports["name"] = Napi::String::New(env, "bp");
|
||||||
void Init(Local<Object> exports, Local<Object> module) {
|
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_bp());
|
||||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
||||||
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
exports["language"] = language;
|
||||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
return exports;
|
||||||
|
|
||||||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
||||||
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
|
||||||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_bp());
|
|
||||||
|
|
||||||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("bp").ToLocalChecked());
|
|
||||||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_MODULE(tree_sitter_bp_binding, Init)
|
NODE_API_MODULE(tree_sitter_bp_binding, Init)
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
|
||||||
28
bindings/node/index.d.ts
vendored
Normal file
28
bindings/node/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
type BaseNode = {
|
||||||
|
type: string;
|
||||||
|
named: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ChildNode = {
|
||||||
|
multiple: boolean;
|
||||||
|
required: boolean;
|
||||||
|
types: BaseNode[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type NodeInfo =
|
||||||
|
| (BaseNode & {
|
||||||
|
subtypes: BaseNode[];
|
||||||
|
})
|
||||||
|
| (BaseNode & {
|
||||||
|
fields: { [name: string]: ChildNode };
|
||||||
|
children: ChildNode[];
|
||||||
|
});
|
||||||
|
|
||||||
|
type Language = {
|
||||||
|
name: string;
|
||||||
|
language: unknown;
|
||||||
|
nodeTypeInfo: NodeInfo[];
|
||||||
|
};
|
||||||
|
|
||||||
|
declare const language: Language;
|
||||||
|
export = language;
|
||||||
|
|
@ -1,18 +1,6 @@
|
||||||
try {
|
const root = require("path").join(__dirname, "..", "..");
|
||||||
module.exports = require("../../build/Release/tree_sitter_bp_binding");
|
|
||||||
} catch (error1) {
|
module.exports = require("node-gyp-build")(root);
|
||||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
|
||||||
throw error1;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
module.exports = require("../../build/Debug/tree_sitter_bp_binding");
|
|
||||||
} catch (error2) {
|
|
||||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
|
||||||
throw error2;
|
|
||||||
}
|
|
||||||
throw error1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||||
|
|
|
||||||
5
bindings/python/tree_sitter_bp/__init__.py
Normal file
5
bindings/python/tree_sitter_bp/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
"Bp grammar for tree-sitter"
|
||||||
|
|
||||||
|
from ._binding import language
|
||||||
|
|
||||||
|
__all__ = ["language"]
|
||||||
1
bindings/python/tree_sitter_bp/__init__.pyi
Normal file
1
bindings/python/tree_sitter_bp/__init__.pyi
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
def language() -> int: ...
|
||||||
27
bindings/python/tree_sitter_bp/binding.c
Normal file
27
bindings/python/tree_sitter_bp/binding.c
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
typedef struct TSLanguage TSLanguage;
|
||||||
|
|
||||||
|
TSLanguage *tree_sitter_bp(void);
|
||||||
|
|
||||||
|
static PyObject* _binding_language(PyObject *self, PyObject *args) {
|
||||||
|
return PyLong_FromVoidPtr(tree_sitter_bp());
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyMethodDef methods[] = {
|
||||||
|
{"language", _binding_language, METH_NOARGS,
|
||||||
|
"Get the tree-sitter language for this grammar."},
|
||||||
|
{NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct PyModuleDef module = {
|
||||||
|
.m_base = PyModuleDef_HEAD_INIT,
|
||||||
|
.m_name = "_binding",
|
||||||
|
.m_doc = NULL,
|
||||||
|
.m_size = -1,
|
||||||
|
.m_methods = methods
|
||||||
|
};
|
||||||
|
|
||||||
|
PyMODINIT_FUNC PyInit__binding(void) {
|
||||||
|
return PyModule_Create(&module);
|
||||||
|
}
|
||||||
0
bindings/python/tree_sitter_bp/py.typed
Normal file
0
bindings/python/tree_sitter_bp/py.typed
Normal file
|
|
@ -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 txtpb grammar");
|
//! parser.set_language(tree_sitter_bp::language()).expect("Error loading bp grammar");
|
||||||
//! let tree = parser.parse(code, None).unwrap();
|
//! let tree = parser.parse(code, None).unwrap();
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
@ -35,10 +35,11 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
||||||
|
|
||||||
// Uncomment these to include any queries that this grammar contains
|
// Uncomment these to include any queries that this grammar contains
|
||||||
|
|
||||||
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
pub const FOLDS_QUERY: &'static str = include_str!("../../queries/folds.scm");
|
||||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||||
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
pub const INDENTS_QUERY: &'static str = include_str!("../../queries/indents.scm");
|
||||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||||
|
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
||||||
16
bindings/swift/TreeSitterBp/bp.h
Normal file
16
bindings/swift/TreeSitterBp/bp.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef TREE_SITTER_BP_H_
|
||||||
|
#define TREE_SITTER_BP_H_
|
||||||
|
|
||||||
|
typedef struct TSLanguage TSLanguage;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const TSLanguage *tree_sitter_bp(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TREE_SITTER_BP_H_
|
||||||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -21,11 +21,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1731533236,
|
||||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -58,11 +58,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712482522,
|
"lastModified": 1741802033,
|
||||||
"narHash": "sha256-Ai/xNgZpbwGcw0TSXwEPwwbPi8Iu906sB9M9z3o6UgA=",
|
"narHash": "sha256-AOazEmkhbKnNQi0LqJdAcqPQx711L84a0Vkaos/ZW/A=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "efe8ce06ca261f370d672def5b1e0be300c726e1",
|
"rev": "8c1f3147639f009f09d2bfffc64bcf8485bf3fd2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -75,23 +75,17 @@
|
||||||
"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": 1712055707,
|
"lastModified": 1735882644,
|
||||||
"narHash": "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=",
|
"narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "e35aed5fda3cc79f88ed7f1795021e559582093a",
|
"rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
15
flake.nix
15
flake.nix
|
|
@ -22,9 +22,7 @@
|
||||||
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";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -61,6 +59,10 @@
|
||||||
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
||||||
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
|
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
|
||||||
|
|
||||||
|
# FIXME: not sure why, but I get different behaviour when left untouched
|
||||||
|
XDG_CONFIG_HOME=$(mktemp -d)
|
||||||
|
export XDG_CONFIG_HOME
|
||||||
|
|
||||||
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
|
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
|
||||||
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
||||||
'';
|
'';
|
||||||
|
|
@ -73,9 +75,14 @@
|
||||||
|
|
||||||
${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
|
||||||
|
|
||||||
git add Cargo.toml package.json
|
make
|
||||||
|
|
||||||
|
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}"
|
||||||
'';
|
'';
|
||||||
|
|
@ -120,7 +127,7 @@
|
||||||
tree-sitter = {
|
tree-sitter = {
|
||||||
enable = true;
|
enable = true;
|
||||||
name = "tree-sitter tests";
|
name = "tree-sitter tests";
|
||||||
entry = "${tree-sitter-env}/bin/tree-sitter test --apply-all-captures";
|
entry = "${tree-sitter-env}/bin/tree-sitter test";
|
||||||
pass_filenames = false;
|
pass_filenames = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
70
grammar.js
70
grammar.js
|
|
@ -1,8 +1,12 @@
|
||||||
function commaSeparated(elem) {
|
function commaSeparatedOptTrailing(elem) {
|
||||||
return seq(elem, repeat(seq(",", elem)), optional(","))
|
return seq(elem, repeat(seq(",", elem)), optional(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
function trailingCommaSeparated(elem) {
|
function commaSeparatedNoTrailing(elem) {
|
||||||
|
return seq(elem, repeat(seq(",", elem)))
|
||||||
|
}
|
||||||
|
|
||||||
|
function commaSeparatedTrailing(elem) {
|
||||||
return repeat(seq(elem, ","))
|
return repeat(seq(elem, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +48,7 @@ module.exports = grammar({
|
||||||
_old_module: ($) => seq(
|
_old_module: ($) => seq(
|
||||||
field("type", $.identifier),
|
field("type", $.identifier),
|
||||||
"{",
|
"{",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._colon_property), $.property)
|
alias(field("property", $._colon_property), $.property)
|
||||||
)),
|
)),
|
||||||
"}",
|
"}",
|
||||||
|
|
@ -53,7 +57,7 @@ module.exports = grammar({
|
||||||
_new_module: ($) => seq(
|
_new_module: ($) => seq(
|
||||||
field("type", $.identifier),
|
field("type", $.identifier),
|
||||||
"(",
|
"(",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._equal_property), $.property)
|
alias(field("property", $._equal_property), $.property)
|
||||||
)),
|
)),
|
||||||
")",
|
")",
|
||||||
|
|
@ -121,54 +125,54 @@ module.exports = grammar({
|
||||||
select_expression: ($) => seq(
|
select_expression: ($) => seq(
|
||||||
"select",
|
"select",
|
||||||
"(",
|
"(",
|
||||||
choice($.select_value, $.soong_config_variable),
|
$.select_value,
|
||||||
",",
|
",",
|
||||||
$.select_cases,
|
$.select_cases,
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_value: ($) => seq(
|
select_value: ($) => choice(
|
||||||
field("type", alias(
|
$.condition,
|
||||||
choice("product_variable", "release_variable", "variant"),
|
seq("(", commaSeparatedOptTrailing($.condition), ")"),
|
||||||
$.selection_type,
|
|
||||||
)),
|
|
||||||
"(",
|
|
||||||
field("condition", $._string_literal),
|
|
||||||
")",
|
|
||||||
),
|
),
|
||||||
|
|
||||||
soong_config_variable: ($) => seq(
|
condition: ($) => seq(
|
||||||
field("type", alias("soong_config_variable", $.selection_type)),
|
field("name", $.identifier),
|
||||||
"(",
|
"(",
|
||||||
field(
|
field("arguments", optional(commaSeparatedNoTrailing($._string_literal))),
|
||||||
"condition",
|
|
||||||
seq(
|
|
||||||
field("namespace", $._string_literal),
|
|
||||||
",",
|
|
||||||
field("variable", $._string_literal),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_cases: ($) => seq(
|
select_cases: ($) => seq(
|
||||||
"{",
|
"{",
|
||||||
optional(trailingCommaSeparated($.select_case)),
|
optional(commaSeparatedOptTrailing($.select_case)),
|
||||||
// default *must* be the last one, enforced at parse-time...
|
|
||||||
optional(seq($.default_case, ",")),
|
|
||||||
"}",
|
"}",
|
||||||
),
|
),
|
||||||
|
|
||||||
select_case: ($) => seq(
|
select_case: ($) => seq(
|
||||||
field("pattern", $._string_literal),
|
field("pattern", $.select_pattern),
|
||||||
":",
|
":",
|
||||||
field("value", $._case_value)
|
field("value", $._case_value)
|
||||||
),
|
),
|
||||||
|
|
||||||
default_case: ($) => seq(
|
select_pattern: ($) => choice(
|
||||||
field("pattern", "default"),
|
$._select_pattern,
|
||||||
":",
|
seq("(", commaSeparatedOptTrailing($._select_pattern), ")"),
|
||||||
field("value", $._case_value),
|
),
|
||||||
|
|
||||||
|
_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),
|
||||||
),
|
),
|
||||||
|
|
||||||
_case_value: ($) => choice(
|
_case_value: ($) => choice(
|
||||||
|
|
@ -178,13 +182,13 @@ module.exports = grammar({
|
||||||
|
|
||||||
list_expression: ($) => seq(
|
list_expression: ($) => seq(
|
||||||
"[",
|
"[",
|
||||||
optional(commaSeparated(field("element", $._expr))),
|
optional(commaSeparatedOptTrailing(field("element", $._expr))),
|
||||||
"]",
|
"]",
|
||||||
),
|
),
|
||||||
|
|
||||||
map_expression: ($) => seq(
|
map_expression: ($) => seq(
|
||||||
"{",
|
"{",
|
||||||
optional(commaSeparated(
|
optional(commaSeparatedOptTrailing(
|
||||||
alias(field("property", $._colon_property), $.property)
|
alias(field("property", $._colon_property), $.property)
|
||||||
)),
|
)),
|
||||||
"}",
|
"}",
|
||||||
|
|
|
||||||
34
package.json
34
package.json
|
|
@ -1,20 +1,41 @@
|
||||||
{
|
{
|
||||||
"name": "tree-sitter-bp",
|
"name": "tree-sitter-bp",
|
||||||
"version": "0.2.0",
|
"version": "0.7.0",
|
||||||
"description": "Blueprint grammar for tree-sitter",
|
"description": "Blueprint grammar for tree-sitter",
|
||||||
"main": "bindings/node",
|
"main": "bindings/node",
|
||||||
|
"types": "bindings/node",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"parsing",
|
"parsing",
|
||||||
"incremental"
|
"incremental"
|
||||||
],
|
],
|
||||||
|
"files": [
|
||||||
|
"grammar.js",
|
||||||
|
"binding.gyp",
|
||||||
|
"prebuilds/**",
|
||||||
|
"bindings/node/*",
|
||||||
|
"queries/*",
|
||||||
|
"src/**"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nan": "^2.12.1"
|
"node-addon-api": "^7.1.0",
|
||||||
|
"node-gyp-build": "^4.8.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"tree-sitter": "^0.21.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"tree_sitter": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tree-sitter-cli": "^0.20.6"
|
"tree-sitter-cli": "^0.20.6",
|
||||||
|
"prebuildify": "^6.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tree-sitter test"
|
"test": "tree-sitter test",
|
||||||
|
"install": "node-gyp-build",
|
||||||
|
"prebuildify": "prebuildify --napi --strip"
|
||||||
},
|
},
|
||||||
"tree-sitter": [
|
"tree-sitter": [
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +43,11 @@
|
||||||
"file-types": [
|
"file-types": [
|
||||||
"bp"
|
"bp"
|
||||||
],
|
],
|
||||||
|
"folds": "queries/folds.scm",
|
||||||
|
"highlights": "queries/highlights.scm",
|
||||||
|
"indents": "queries/indents.scm",
|
||||||
|
"injections": "queries/injections.scm",
|
||||||
|
"tags": "queries/tags.scm",
|
||||||
"injection-regex": "bp"
|
"injection-regex": "bp"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
29
pyproject.toml
Normal file
29
pyproject.toml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=42", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "tree-sitter-bp"
|
||||||
|
description = "Bp grammar for tree-sitter"
|
||||||
|
version = "0.7.0"
|
||||||
|
keywords = ["incremental", "parsing", "tree-sitter", "bp"]
|
||||||
|
classifiers = [
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Topic :: Software Development :: Compilers",
|
||||||
|
"Topic :: Text Processing :: Linguistic",
|
||||||
|
"Typing :: Typed"
|
||||||
|
]
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
license.text = "MIT"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://git.belanyi.fr/ambroisie/tree-sitter-bp"
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
core = ["tree-sitter~=0.21"]
|
||||||
|
|
||||||
|
[tool.cibuildwheel]
|
||||||
|
build = "cp38-*"
|
||||||
|
build-frontend = "build"
|
||||||
|
|
@ -4,5 +4,3 @@
|
||||||
(module)
|
(module)
|
||||||
(select_expression)
|
(select_expression)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
||||||
; vim: sw=2 foldmethod=marker
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
; Operators {{{
|
|
||||||
(operator) @operator
|
(operator) @operator
|
||||||
|
|
||||||
(integer_literal ("-") @operator)
|
(integer_literal
|
||||||
; }}}
|
"-" @operator)
|
||||||
|
|
||||||
; Punctuation {{{
|
|
||||||
[
|
[
|
||||||
","
|
","
|
||||||
":"
|
":"
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
")"
|
")"
|
||||||
"["
|
"["
|
||||||
"]"
|
"]"
|
||||||
"{"
|
"{"
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
; }}}
|
|
||||||
|
|
||||||
; Literal {{{
|
|
||||||
(boolean_literal) @boolean
|
(boolean_literal) @boolean
|
||||||
|
|
||||||
(integer_literal) @number
|
(integer_literal) @number
|
||||||
|
|
||||||
[
|
[
|
||||||
(raw_string_literal)
|
(raw_string_literal)
|
||||||
(interpreted_string_literal)
|
(interpreted_string_literal)
|
||||||
] @string
|
] @string
|
||||||
|
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
; }}}
|
|
||||||
|
|
||||||
; Declarations {{{
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
(module
|
(module
|
||||||
|
|
@ -44,23 +38,19 @@
|
||||||
(module
|
(module
|
||||||
(property
|
(property
|
||||||
field: (identifier) @variable.parameter))
|
field: (identifier) @variable.parameter))
|
||||||
; }}}
|
|
||||||
|
|
||||||
; Built-ins {{{
|
|
||||||
[
|
[
|
||||||
(unset)
|
(unset)
|
||||||
"default"
|
(default)
|
||||||
|
(any)
|
||||||
] @variable.builtin
|
] @variable.builtin
|
||||||
(selection_type) @function.builtin
|
|
||||||
; }}}
|
|
||||||
|
|
||||||
; Expressions {{{
|
(condition
|
||||||
|
name: (identifier) @function.builtin)
|
||||||
|
|
||||||
(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,27 +1,38 @@
|
||||||
; 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.branch)
|
||||||
|
|
||||||
|
(select_pattern
|
||||||
|
"(" @indent.begin)
|
||||||
|
|
||||||
|
(select_pattern
|
||||||
|
")" @indent.branch)
|
||||||
|
|
||||||
(select_cases) @indent.begin
|
(select_cases) @indent.begin
|
||||||
|
|
||||||
(select_cases
|
(select_cases
|
||||||
"}" @indent.branch)
|
"}" @indent.branch)
|
||||||
; }}}
|
|
||||||
|
|
||||||
; 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,4 +1,2 @@
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
; vim: sw=2 foldmethod=marker
|
|
||||||
|
|
|
||||||
15
queries/locals.scm
Normal file
15
queries/locals.scm
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
(module
|
||||||
|
(property
|
||||||
|
field: (identifier) @local.definition.parameter))
|
||||||
|
|
||||||
|
(map_expression
|
||||||
|
(property
|
||||||
|
field: (identifier) @local.definition.field))
|
||||||
|
|
||||||
|
(assignment
|
||||||
|
left: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(pattern_binding
|
||||||
|
binding: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(identifier) @local.reference
|
||||||
57
setup.py
Normal file
57
setup.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
from os.path import isdir, join
|
||||||
|
from platform import system
|
||||||
|
|
||||||
|
from setuptools import Extension, find_packages, setup
|
||||||
|
from setuptools.command.build import build
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
|
||||||
|
|
||||||
|
class Build(build):
|
||||||
|
def run(self):
|
||||||
|
if isdir("queries"):
|
||||||
|
dest = join(self.build_lib, "tree_sitter_bp", "queries")
|
||||||
|
self.copy_tree("queries", dest)
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
class BdistWheel(bdist_wheel):
|
||||||
|
def get_tag(self):
|
||||||
|
python, abi, platform = super().get_tag()
|
||||||
|
if python.startswith("cp"):
|
||||||
|
python, abi = "cp38", "abi3"
|
||||||
|
return python, abi, platform
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
packages=find_packages("bindings/python"),
|
||||||
|
package_dir={"": "bindings/python"},
|
||||||
|
package_data={
|
||||||
|
"tree_sitter_bp": ["*.pyi", "py.typed"],
|
||||||
|
"tree_sitter_bp.queries": ["*.scm"],
|
||||||
|
},
|
||||||
|
ext_package="tree_sitter_bp",
|
||||||
|
ext_modules=[
|
||||||
|
Extension(
|
||||||
|
name="_binding",
|
||||||
|
sources=[
|
||||||
|
"bindings/python/tree_sitter_bp/binding.c",
|
||||||
|
"src/parser.c",
|
||||||
|
# NOTE: if your language uses an external scanner, add it here.
|
||||||
|
],
|
||||||
|
extra_compile_args=(
|
||||||
|
["-std=c11"] if system() != 'Windows' else []
|
||||||
|
),
|
||||||
|
define_macros=[
|
||||||
|
("Py_LIMITED_API", "0x03080000"),
|
||||||
|
("PY_SSIZE_T_CLEAN", None)
|
||||||
|
],
|
||||||
|
include_dirs=["src"],
|
||||||
|
py_limited_api=True,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
cmdclass={
|
||||||
|
"build": Build,
|
||||||
|
"bdist_wheel": BdistWheel
|
||||||
|
},
|
||||||
|
zip_safe=False
|
||||||
|
)
|
||||||
335
src/grammar.json
generated
335
src/grammar.json
generated
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
|
||||||
"name": "bp",
|
"name": "bp",
|
||||||
"rules": {
|
"rules": {
|
||||||
"source_file": {
|
"source_file": {
|
||||||
|
|
@ -469,17 +470,8 @@
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "SYMBOL",
|
||||||
"members": [
|
"name": "select_value"
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_value"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "soong_config_variable"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
@ -496,66 +488,73 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"select_value": {
|
"select_value": {
|
||||||
"type": "SEQ",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "SYMBOL",
|
||||||
"name": "type",
|
"name": "condition"
|
||||||
"content": {
|
},
|
||||||
"type": "ALIAS",
|
{
|
||||||
"content": {
|
"type": "SEQ",
|
||||||
"type": "CHOICE",
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "("
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "SYMBOL",
|
||||||
"value": "product_variable"
|
"name": "condition"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "REPEAT",
|
||||||
"value": "release_variable"
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "condition"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "CHOICE",
|
||||||
"value": "variant"
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"named": true,
|
{
|
||||||
"value": "selection_type"
|
"type": "STRING",
|
||||||
}
|
"value": ")"
|
||||||
},
|
}
|
||||||
{
|
]
|
||||||
"type": "STRING",
|
|
||||||
"value": "("
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "condition",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_string_literal"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ")"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"soong_config_variable": {
|
"condition": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "type",
|
"name": "name",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "ALIAS",
|
"type": "SYMBOL",
|
||||||
"content": {
|
"name": "identifier"
|
||||||
"type": "STRING",
|
|
||||||
"value": "soong_config_variable"
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "selection_type"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -564,29 +563,37 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "condition",
|
"name": "arguments",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SEQ",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "SEQ",
|
||||||
"name": "namespace",
|
"members": [
|
||||||
"content": {
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "_string_literal"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_string_literal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "BLANK"
|
||||||
"value": ","
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "variable",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_string_literal"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -604,30 +611,6 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "{"
|
"value": "{"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "REPEAT",
|
|
||||||
"content": {
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_case"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ","
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
@ -636,11 +619,35 @@
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "default_case"
|
"name": "select_case"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "REPEAT",
|
||||||
"value": ","
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "select_case"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -663,7 +670,7 @@
|
||||||
"name": "pattern",
|
"name": "pattern",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_string_literal"
|
"name": "select_pattern"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -680,27 +687,139 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default_case": {
|
"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": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "pattern",
|
"name": "value",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "STRING",
|
"type": "ALIAS",
|
||||||
"value": "default"
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "any"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "any"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "FIELD",
|
||||||
"value": ":"
|
"name": "operator",
|
||||||
|
"content": {
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "@"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "operator"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "value",
|
"name": "binding",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_case_value"
|
"name": "identifier"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -968,6 +1087,6 @@
|
||||||
"precedences": [],
|
"precedences": [],
|
||||||
"externals": [],
|
"externals": [],
|
||||||
"inline": [],
|
"inline": [],
|
||||||
"supertypes": []
|
"supertypes": [],
|
||||||
|
"reserved": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
237
src/node-types.json
generated
237
src/node-types.json
generated
|
|
@ -178,61 +178,33 @@
|
||||||
"fields": {}
|
"fields": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "default_case",
|
"type": "condition",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {
|
"fields": {
|
||||||
"pattern": {
|
"arguments": {
|
||||||
"multiple": false,
|
"multiple": true,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": ",",
|
||||||
"named": false
|
"named": false
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"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",
|
"type": "interpreted_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "list_expression",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "map_expression",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "raw_string_literal",
|
"type": "raw_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "select_expression",
|
"type": "identifier",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "unset",
|
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -349,6 +321,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "pattern_binding",
|
||||||
|
"named": true,
|
||||||
|
"fields": {
|
||||||
|
"binding": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "operator",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"multiple": false,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "property",
|
"type": "property",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -416,11 +424,7 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "interpreted_string_literal",
|
"type": "select_pattern",
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "raw_string_literal",
|
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -481,10 +485,6 @@
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": false,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
|
||||||
"type": "default_case",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "select_case",
|
"type": "select_case",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -507,9 +507,44 @@
|
||||||
{
|
{
|
||||||
"type": "select_value",
|
"type": "select_value",
|
||||||
"named": true
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "select_pattern",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "soong_config_variable",
|
"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",
|
||||||
"named": true
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -518,90 +553,22 @@
|
||||||
{
|
{
|
||||||
"type": "select_value",
|
"type": "select_value",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {
|
"fields": {},
|
||||||
"condition": {
|
"children": {
|
||||||
"multiple": false,
|
"multiple": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "interpreted_string_literal",
|
"type": "condition",
|
||||||
"named": true
|
"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",
|
"type": "source_file",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
"root": true,
|
||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
|
|
@ -666,9 +633,13 @@
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "any",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"named": false
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "escape_sequence",
|
"type": "escape_sequence",
|
||||||
|
|
@ -694,10 +665,6 @@
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "selection_type",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "true",
|
"type": "true",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
|
||||||
8452
src/parser.c
generated
8452
src/parser.c
generated
File diff suppressed because it is too large
Load diff
54
src/tree_sitter/alloc.h
generated
Normal file
54
src/tree_sitter/alloc.h
generated
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef TREE_SITTER_ALLOC_H_
|
||||||
|
#define TREE_SITTER_ALLOC_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
#ifndef ts_malloc
|
||||||
|
#define ts_malloc ts_current_malloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_calloc
|
||||||
|
#define ts_calloc ts_current_calloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_realloc
|
||||||
|
#define ts_realloc ts_current_realloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_free
|
||||||
|
#define ts_free ts_current_free
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef ts_malloc
|
||||||
|
#define ts_malloc malloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_calloc
|
||||||
|
#define ts_calloc calloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_realloc
|
||||||
|
#define ts_realloc realloc
|
||||||
|
#endif
|
||||||
|
#ifndef ts_free
|
||||||
|
#define ts_free free
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TREE_SITTER_ALLOC_H_
|
||||||
291
src/tree_sitter/array.h
generated
Normal file
291
src/tree_sitter/array.h
generated
Normal file
|
|
@ -0,0 +1,291 @@
|
||||||
|
#ifndef TREE_SITTER_ARRAY_H_
|
||||||
|
#define TREE_SITTER_ARRAY_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./alloc.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4101)
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Array(T) \
|
||||||
|
struct { \
|
||||||
|
T *contents; \
|
||||||
|
uint32_t size; \
|
||||||
|
uint32_t capacity; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize an array.
|
||||||
|
#define array_init(self) \
|
||||||
|
((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
|
||||||
|
|
||||||
|
/// Create an empty array.
|
||||||
|
#define array_new() \
|
||||||
|
{ NULL, 0, 0 }
|
||||||
|
|
||||||
|
/// Get a pointer to the element at a given `index` in the array.
|
||||||
|
#define array_get(self, _index) \
|
||||||
|
(assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
|
||||||
|
|
||||||
|
/// Get a pointer to the first element in the array.
|
||||||
|
#define array_front(self) array_get(self, 0)
|
||||||
|
|
||||||
|
/// Get a pointer to the last element in the array.
|
||||||
|
#define array_back(self) array_get(self, (self)->size - 1)
|
||||||
|
|
||||||
|
/// Clear the array, setting its size to zero. Note that this does not free any
|
||||||
|
/// memory allocated for the array's contents.
|
||||||
|
#define array_clear(self) ((self)->size = 0)
|
||||||
|
|
||||||
|
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
||||||
|
/// less than the array's current capacity, this function has no effect.
|
||||||
|
#define array_reserve(self, new_capacity) \
|
||||||
|
_array__reserve((Array *)(self), array_elem_size(self), new_capacity)
|
||||||
|
|
||||||
|
/// Free any memory allocated for this array. Note that this does not free any
|
||||||
|
/// memory allocated for the array's contents.
|
||||||
|
#define array_delete(self) _array__delete((Array *)(self))
|
||||||
|
|
||||||
|
/// Push a new `element` onto the end of the array.
|
||||||
|
#define array_push(self, element) \
|
||||||
|
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
||||||
|
(self)->contents[(self)->size++] = (element))
|
||||||
|
|
||||||
|
/// Increase the array's size by `count` elements.
|
||||||
|
/// New elements are zero-initialized.
|
||||||
|
#define array_grow_by(self, count) \
|
||||||
|
do { \
|
||||||
|
if ((count) == 0) break; \
|
||||||
|
_array__grow((Array *)(self), count, array_elem_size(self)); \
|
||||||
|
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
|
||||||
|
(self)->size += (count); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/// Append all elements from one array to the end of another.
|
||||||
|
#define array_push_all(self, other) \
|
||||||
|
array_extend((self), (other)->size, (other)->contents)
|
||||||
|
|
||||||
|
/// Append `count` elements to the end of the array, reading their values from the
|
||||||
|
/// `contents` pointer.
|
||||||
|
#define array_extend(self, count, contents) \
|
||||||
|
_array__splice( \
|
||||||
|
(Array *)(self), array_elem_size(self), (self)->size, \
|
||||||
|
0, count, contents \
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Remove `old_count` elements from the array starting at the given `index`. At
|
||||||
|
/// the same index, insert `new_count` new elements, reading their values from the
|
||||||
|
/// `new_contents` pointer.
|
||||||
|
#define array_splice(self, _index, old_count, new_count, new_contents) \
|
||||||
|
_array__splice( \
|
||||||
|
(Array *)(self), array_elem_size(self), _index, \
|
||||||
|
old_count, new_count, new_contents \
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Insert one `element` into the array at the given `index`.
|
||||||
|
#define array_insert(self, _index, element) \
|
||||||
|
_array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
|
||||||
|
|
||||||
|
/// Remove one element from the array at the given `index`.
|
||||||
|
#define array_erase(self, _index) \
|
||||||
|
_array__erase((Array *)(self), array_elem_size(self), _index)
|
||||||
|
|
||||||
|
/// Pop the last element off the array, returning the element by value.
|
||||||
|
#define array_pop(self) ((self)->contents[--(self)->size])
|
||||||
|
|
||||||
|
/// Assign the contents of one array to another, reallocating if necessary.
|
||||||
|
#define array_assign(self, other) \
|
||||||
|
_array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
|
||||||
|
|
||||||
|
/// Swap one array with another
|
||||||
|
#define array_swap(self, other) \
|
||||||
|
_array__swap((Array *)(self), (Array *)(other))
|
||||||
|
|
||||||
|
/// Get the size of the array contents
|
||||||
|
#define array_elem_size(self) (sizeof *(self)->contents)
|
||||||
|
|
||||||
|
/// Search a sorted array for a given `needle` value, using the given `compare`
|
||||||
|
/// callback to determine the order.
|
||||||
|
///
|
||||||
|
/// If an existing element is found to be equal to `needle`, then the `index`
|
||||||
|
/// out-parameter is set to the existing value's index, and the `exists`
|
||||||
|
/// out-parameter is set to true. Otherwise, `index` is set to an index where
|
||||||
|
/// `needle` should be inserted in order to preserve the sorting, and `exists`
|
||||||
|
/// is set to false.
|
||||||
|
#define array_search_sorted_with(self, compare, needle, _index, _exists) \
|
||||||
|
_array__search_sorted(self, 0, compare, , needle, _index, _exists)
|
||||||
|
|
||||||
|
/// Search a sorted array for a given `needle` value, using integer comparisons
|
||||||
|
/// of a given struct field (specified with a leading dot) to determine the order.
|
||||||
|
///
|
||||||
|
/// See also `array_search_sorted_with`.
|
||||||
|
#define array_search_sorted_by(self, field, needle, _index, _exists) \
|
||||||
|
_array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
|
||||||
|
|
||||||
|
/// Insert a given `value` into a sorted array, using the given `compare`
|
||||||
|
/// callback to determine the order.
|
||||||
|
#define array_insert_sorted_with(self, compare, value) \
|
||||||
|
do { \
|
||||||
|
unsigned _index, _exists; \
|
||||||
|
array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
|
||||||
|
if (!_exists) array_insert(self, _index, value); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/// Insert a given `value` into a sorted array, using integer comparisons of
|
||||||
|
/// a given struct field (specified with a leading dot) to determine the order.
|
||||||
|
///
|
||||||
|
/// See also `array_search_sorted_by`.
|
||||||
|
#define array_insert_sorted_by(self, field, value) \
|
||||||
|
do { \
|
||||||
|
unsigned _index, _exists; \
|
||||||
|
array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
|
||||||
|
if (!_exists) array_insert(self, _index, value); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
// Private
|
||||||
|
|
||||||
|
typedef Array(void) Array;
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_delete`.
|
||||||
|
static inline void _array__delete(Array *self) {
|
||||||
|
if (self->contents) {
|
||||||
|
ts_free(self->contents);
|
||||||
|
self->contents = NULL;
|
||||||
|
self->size = 0;
|
||||||
|
self->capacity = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_erase`.
|
||||||
|
static inline void _array__erase(Array *self, size_t element_size,
|
||||||
|
uint32_t index) {
|
||||||
|
assert(index < self->size);
|
||||||
|
char *contents = (char *)self->contents;
|
||||||
|
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
||||||
|
(self->size - index - 1) * element_size);
|
||||||
|
self->size--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_reserve`.
|
||||||
|
static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
|
||||||
|
if (new_capacity > self->capacity) {
|
||||||
|
if (self->contents) {
|
||||||
|
self->contents = ts_realloc(self->contents, new_capacity * element_size);
|
||||||
|
} else {
|
||||||
|
self->contents = ts_malloc(new_capacity * element_size);
|
||||||
|
}
|
||||||
|
self->capacity = new_capacity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_assign`.
|
||||||
|
static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
|
||||||
|
_array__reserve(self, element_size, other->size);
|
||||||
|
self->size = other->size;
|
||||||
|
memcpy(self->contents, other->contents, self->size * element_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_swap`.
|
||||||
|
static inline void _array__swap(Array *self, Array *other) {
|
||||||
|
Array swap = *other;
|
||||||
|
*other = *self;
|
||||||
|
*self = swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
||||||
|
static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
|
||||||
|
uint32_t new_size = self->size + count;
|
||||||
|
if (new_size > self->capacity) {
|
||||||
|
uint32_t new_capacity = self->capacity * 2;
|
||||||
|
if (new_capacity < 8) new_capacity = 8;
|
||||||
|
if (new_capacity < new_size) new_capacity = new_size;
|
||||||
|
_array__reserve(self, element_size, new_capacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is not what you're looking for, see `array_splice`.
|
||||||
|
static inline void _array__splice(Array *self, size_t element_size,
|
||||||
|
uint32_t index, uint32_t old_count,
|
||||||
|
uint32_t new_count, const void *elements) {
|
||||||
|
uint32_t new_size = self->size + new_count - old_count;
|
||||||
|
uint32_t old_end = index + old_count;
|
||||||
|
uint32_t new_end = index + new_count;
|
||||||
|
assert(old_end <= self->size);
|
||||||
|
|
||||||
|
_array__reserve(self, element_size, new_size);
|
||||||
|
|
||||||
|
char *contents = (char *)self->contents;
|
||||||
|
if (self->size > old_end) {
|
||||||
|
memmove(
|
||||||
|
contents + new_end * element_size,
|
||||||
|
contents + old_end * element_size,
|
||||||
|
(self->size - old_end) * element_size
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (new_count > 0) {
|
||||||
|
if (elements) {
|
||||||
|
memcpy(
|
||||||
|
(contents + index * element_size),
|
||||||
|
elements,
|
||||||
|
new_count * element_size
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
memset(
|
||||||
|
(contents + index * element_size),
|
||||||
|
0,
|
||||||
|
new_count * element_size
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self->size += new_count - old_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
||||||
|
/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
|
||||||
|
#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
|
||||||
|
do { \
|
||||||
|
*(_index) = start; \
|
||||||
|
*(_exists) = false; \
|
||||||
|
uint32_t size = (self)->size - *(_index); \
|
||||||
|
if (size == 0) break; \
|
||||||
|
int comparison; \
|
||||||
|
while (size > 1) { \
|
||||||
|
uint32_t half_size = size / 2; \
|
||||||
|
uint32_t mid_index = *(_index) + half_size; \
|
||||||
|
comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
|
||||||
|
if (comparison <= 0) *(_index) = mid_index; \
|
||||||
|
size -= half_size; \
|
||||||
|
} \
|
||||||
|
comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
|
||||||
|
if (comparison == 0) *(_exists) = true; \
|
||||||
|
else if (comparison < 0) *(_index) += 1; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
|
||||||
|
/// parameter by reference in order to work with the generic sorting function above.
|
||||||
|
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TREE_SITTER_ARRAY_H_
|
||||||
81
src/tree_sitter/parser.h
generated
81
src/tree_sitter/parser.h
generated
|
|
@ -18,6 +18,12 @@ 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 {
|
||||||
|
|
@ -26,10 +32,11 @@ 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;
|
||||||
} TSFieldMapSlice;
|
} TSMapSlice;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool visible;
|
bool visible;
|
||||||
|
|
@ -47,6 +54,7 @@ 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 {
|
||||||
|
|
@ -78,6 +86,12 @@ 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 {
|
||||||
|
|
@ -86,8 +100,13 @@ typedef union {
|
||||||
} entry;
|
} entry;
|
||||||
} TSParseActionEntry;
|
} TSParseActionEntry;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t start;
|
||||||
|
int32_t end;
|
||||||
|
} TSCharacterRange;
|
||||||
|
|
||||||
struct TSLanguage {
|
struct TSLanguage {
|
||||||
uint32_t version;
|
uint32_t abi_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;
|
||||||
|
|
@ -103,13 +122,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 TSFieldMapSlice *field_map_slices;
|
const TSMapSlice *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 TSLexMode *lex_modes;
|
const TSLexerMode *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;
|
||||||
|
|
@ -123,8 +142,34 @@ 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
|
||||||
*/
|
*/
|
||||||
|
|
@ -154,6 +199,17 @@ struct TSLanguage {
|
||||||
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; \
|
||||||
|
|
@ -203,14 +259,15 @@ struct TSLanguage {
|
||||||
} \
|
} \
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
||||||
{{ \
|
{{ \
|
||||||
.reduce = { \
|
.reduce = { \
|
||||||
.type = TSParseActionTypeReduce, \
|
.type = TSParseActionTypeReduce, \
|
||||||
.symbol = symbol_val, \
|
.symbol = symbol_name, \
|
||||||
.child_count = child_count_val, \
|
.child_count = children, \
|
||||||
__VA_ARGS__ \
|
.dynamic_precedence = precedence, \
|
||||||
}, \
|
.production_id = prod_id \
|
||||||
|
}, \
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#define RECOVER() \
|
#define RECOVER() \
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,19 @@ 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,6 +20,35 @@ 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,6 +4,7 @@ Select
|
||||||
|
|
||||||
foo = select(release_variable("RELEASE_TEST"), {
|
foo = select(release_variable("RELEASE_TEST"), {
|
||||||
"d": "d2",
|
"d": "d2",
|
||||||
|
any: unset,
|
||||||
default: unset,
|
default: unset,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -15,22 +16,29 @@ foo = select(release_variable("RELEASE_TEST"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(default_case
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(any))
|
||||||
|
(unset))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
(unset))))))
|
(unset))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select (soong config variable)
|
Select (no trailing comma)
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
foo = select(release_variable("RELEASE_TEST"), {
|
||||||
"foo": unset,
|
default: unset
|
||||||
"default": "bar",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
@ -40,17 +48,54 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
(identifier)
|
(identifier)
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(soong_config_variable
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal)
|
(identifier)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(unset))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (soong config variable)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
|
"foo": unset,
|
||||||
|
"default": "bar",
|
||||||
|
any @ foo: unset,
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier)
|
||||||
(interpreted_string_literal)
|
(interpreted_string_literal)
|
||||||
|
(interpreted_string_literal)))
|
||||||
|
(select_cases
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(unset))
|
(unset))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(pattern_binding
|
||||||
|
(any)
|
||||||
|
(operator)
|
||||||
|
(identifier)))
|
||||||
|
(unset))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select (no default)
|
Select (no default)
|
||||||
|
|
@ -71,20 +116,25 @@ foo = select(variant("arch"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
@ -101,8 +151,9 @@ foo = select(variant("VARIANT"), {})
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases))))
|
(select_cases))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
@ -125,23 +176,29 @@ foo = select(variant("VARIANT"), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(interpreted_string_literal))
|
(identifier)
|
||||||
|
(interpreted_string_literal)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(ERROR
|
|
||||||
(default_case
|
|
||||||
(unset)))
|
|
||||||
(select_case
|
|
||||||
(interpreted_string_literal)
|
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal))
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(unset))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
@ -161,13 +218,16 @@ foo = select(variant(), {
|
||||||
(operator)
|
(operator)
|
||||||
(select_expression
|
(select_expression
|
||||||
(select_value
|
(select_value
|
||||||
(selection_type)
|
(condition
|
||||||
(MISSING raw_string_literal))
|
(identifier)))
|
||||||
(select_cases
|
(select_cases
|
||||||
(select_case
|
(select_case
|
||||||
(interpreted_string_literal)
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
(unset))
|
(unset))
|
||||||
(default_case
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
(interpreted_string_literal))))))
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
@ -185,13 +245,209 @@ foo = select(some_unknown_type("CONDITION"), {
|
||||||
(assignment
|
(assignment
|
||||||
(identifier)
|
(identifier)
|
||||||
(operator)
|
(operator)
|
||||||
(ERROR
|
(select_expression
|
||||||
(identifier)
|
(select_value
|
||||||
(identifier)
|
(condition
|
||||||
(interpreted_string_literal)
|
(identifier)
|
||||||
(interpreted_string_literal))
|
(interpreted_string_literal)))
|
||||||
(interpreted_string_literal))
|
(select_cases
|
||||||
(ERROR))
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(interpreted_string_literal))
|
||||||
|
(select_case
|
||||||
|
(select_pattern
|
||||||
|
(default))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Select (multiple type arguments)
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = select(release_variable("ONE", "TWO"), {
|
||||||
|
"d": "d2",
|
||||||
|
default: "f2",
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(assignment
|
||||||
|
(identifier)
|
||||||
|
(operator)
|
||||||
|
(select_expression
|
||||||
|
(select_value
|
||||||
|
(condition
|
||||||
|
(identifier)
|
||||||
|
(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))
|
||||||
|
(interpreted_string_literal))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Select as an identifier
|
Select as an identifier
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
// ^ function.builtin
|
// ^ function.builtin
|
||||||
"foo": unset,
|
"foo": unset,
|
||||||
// ^ variable.builtin
|
// ^ variable.builtin
|
||||||
|
any: unset,
|
||||||
|
// <- variable.builtin
|
||||||
default: select(variant("VARIANT"), {}),
|
default: select(variant("VARIANT"), {}),
|
||||||
// <- variable.builtin
|
// <- variable.builtin
|
||||||
// ^ function.builtin
|
// ^ function.builtin
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
foo = select(soong_config_variable("my_namespace", "my_var"), {
|
||||||
// ^ keyword.conditional
|
// ^ keyword.conditional
|
||||||
"foo": unset,
|
"foo": unset,
|
||||||
|
any @ foo: unset,
|
||||||
|
// ^ operator
|
||||||
|
// ^ variable
|
||||||
default: "bar",
|
default: "bar",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,35 @@ foo = select(
|
||||||
default: 0,
|
default: 0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
foo = select((
|
||||||
|
arch(),
|
||||||
|
os(),
|
||||||
|
), {
|
||||||
|
(default, default): [],
|
||||||
|
})
|
||||||
|
|
||||||
|
foo = select(
|
||||||
|
(arch(), os()),
|
||||||
|
{
|
||||||
|
(default, default): [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// We're really getting into more and more unlikely choices here...
|
||||||
|
foo = select(
|
||||||
|
(
|
||||||
|
arch(),
|
||||||
|
os(),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
(default, default): [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
foo = select((arch(), os()), {
|
||||||
|
(
|
||||||
|
default,
|
||||||
|
default,
|
||||||
|
): [],
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
|
||||||
|
|
||||||
local Runner = require("tests.indent.common").Runner
|
local Runner = require("tests.indent.common").Runner
|
||||||
|
local XFAIL = require("tests.indent.common").XFAIL
|
||||||
|
|
||||||
-- FIXME: path to root
|
-- FIXME: path to root
|
||||||
local runner = Runner:new(it, ".", {
|
local runner = Runner:new(it, ".", {
|
||||||
|
|
@ -19,7 +20,7 @@ describe("indent Blueprint:", function()
|
||||||
})
|
})
|
||||||
runner:whole_file("test/indent/", {
|
runner:whole_file("test/indent/", {
|
||||||
expected_failures = {
|
expected_failures = {
|
||||||
-- NOTE: none for now
|
"test/indent/select.bp",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
@ -39,9 +40,22 @@ describe("indent Blueprint:", function()
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 1, text = 'default: "value"', indent = 4 }, "default case")
|
runner:new_line("test/indent/select.bp", { on_line = 1, text = 'default: "value"', indent = 4 }, "default case")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 11, text = '"case": "value"', indent = 4 }, "select case, trailing")
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = '"case": "value"', indent = 4 }, "select case, trailing")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 11, text = 'default: "value"', indent = 4 }, "default case, trailing")
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = 'default: "value"', indent = 4 }, "default case, trailing")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 11, text = '}', indent = 0 }, "select cases closing delimiter")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 16, text = '"case": "value"', indent = 8 }, "select case, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 16, text = '"case": "value"', indent = 8 }, "select case, alternate formatting")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 16, text = 'default: "value"', indent = 8 }, "default case, alternate formatting")
|
runner:new_line("test/indent/select.bp", { on_line = 16, text = 'default: "value"', indent = 8 }, "default case, alternate formatting")
|
||||||
runner:new_line("test/indent/select.bp", { on_line = 26, text = '"case": "value"', indent = 8 }, "select case, trailing, alternate formattingg")
|
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 formattingn")
|
runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 26, text = '}', indent = 4 }, "select cases closing delimiter, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 30, text = 'device()', indent = 4 }, "multi-valued select condition, begin")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 31, text = 'device()', indent = 4 }, "multi-valued select condition, middle")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 32, text = 'device()', indent = 4 }, "multi-valued select condition, end")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 46, text = 'device()', indent = 8 }, "multi-valued select condition, begin, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 47, text = 'device()', indent = 8 }, "multi-valued select condition, middle, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 48, text = 'device()', indent = 8 }, "multi-valued select condition, end, alternate formatting")
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 56, text = 'default,', indent = 8 }, "multi-valued select case, begin", XFAIL)
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 57, text = 'default,', indent = 8 }, "multi-valued select case, middle", XFAIL)
|
||||||
|
runner:new_line("test/indent/select.bp", { on_line = 58, text = 'default,', indent = 8 }, "multi-valued select case, end", XFAIL)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
30
tree-sitter.json
Normal file
30
tree-sitter.json
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"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