This means regenerating all the tree-sitter files, and adding newly generated outputs (mostly new bindings). The `--apply-all-captures` flag has been removed, it is now the default (and only) matching behaviour.
This commit is contained in:
parent
b04cd92189
commit
bc4db561ca
26 changed files with 718 additions and 59 deletions
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 <node.h>
|
||||
#include "nan.h"
|
||||
#include <napi.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) {}
|
||||
|
||||
void Init(Local<Object> exports, Local<Object> module) {
|
||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
||||
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
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);
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
exports["name"] = Napi::String::New(env, "bp");
|
||||
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_bp());
|
||||
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
||||
exports["language"] = language;
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_MODULE(tree_sitter_bp_binding, Init)
|
||||
|
||||
} // namespace
|
||||
NODE_API_MODULE(tree_sitter_bp_binding, Init)
|
||||
|
|
|
|||
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 {
|
||||
module.exports = require("../../build/Release/tree_sitter_bp_binding");
|
||||
} catch (error1) {
|
||||
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
|
||||
}
|
||||
}
|
||||
const root = require("path").join(__dirname, "..", "..");
|
||||
|
||||
module.exports = require("node-gyp-build")(root);
|
||||
|
||||
try {
|
||||
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
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_
|
||||
Loading…
Add table
Add a link
Reference in a new issue