-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: regenerate parser and bindings with tree-sitter-cli v0.22.2
- Loading branch information
Showing
27 changed files
with
3,299 additions
and
2,761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
VERSION := 0.22.3 | ||
|
||
LANGUAGE_NAME := tree-sitter-cuda | ||
|
||
# repository | ||
SRC_DIR := src | ||
|
||
PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null) | ||
|
||
ifeq ($(PARSER_URL),) | ||
PARSER_URL := $(subst .git,,$(PARSER_REPO_URL)) | ||
ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),) | ||
PARSER_URL := $(subst :,/,$(PARSER_URL)) | ||
PARSER_URL := $(subst git@,https://,$(PARSER_URL)) | ||
endif | ||
endif | ||
|
||
TS ?= tree-sitter | ||
|
||
# ABI versioning | ||
SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION))) | ||
SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION))) | ||
|
||
# install directory layout | ||
PREFIX ?= /usr/local | ||
INCLUDEDIR ?= $(PREFIX)/include | ||
LIBDIR ?= $(PREFIX)/lib | ||
PCLIBDIR ?= $(LIBDIR)/pkgconfig | ||
|
||
# object files | ||
OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c)) | ||
|
||
# flags | ||
ARFLAGS := rcs | ||
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC | ||
|
||
# OS-specific bits | ||
ifeq ($(OS),Windows_NT) | ||
$(error "Windows is not supported") | ||
else ifeq ($(shell uname),Darwin) | ||
SOEXT = dylib | ||
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib | ||
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib | ||
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, | ||
ifneq ($(ADDITIONAL_LIBS),) | ||
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS), | ||
endif | ||
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks | ||
else | ||
SOEXT = so | ||
SOEXTVER_MAJOR = so.$(SONAME_MAJOR) | ||
SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) | ||
LINKSHARED := $(LINKSHARED)-shared -Wl, | ||
ifneq ($(ADDITIONAL_LIBS),) | ||
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS) | ||
endif | ||
LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).so.$(SONAME_MAJOR) | ||
endif | ||
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),) | ||
PCLIBDIR := $(PREFIX)/libdata/pkgconfig | ||
endif | ||
|
||
all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc | ||
|
||
lib$(LANGUAGE_NAME).a: $(OBJS) | ||
$(AR) $(ARFLAGS) $@ $^ | ||
|
||
lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS) | ||
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ | ||
ifneq ($(STRIP),) | ||
$(STRIP) $@ | ||
endif | ||
|
||
$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in | ||
sed -e 's|@URL@|$(PARSER_URL)|' \ | ||
-e 's|@VERSION@|$(VERSION)|' \ | ||
-e 's|@LIBDIR@|$(LIBDIR)|' \ | ||
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ | ||
-e 's|@REQUIRES@|$(REQUIRES)|' \ | ||
-e 's|@ADDITIONAL_LIBS@|$(ADDITIONAL_LIBS)|' \ | ||
-e 's|=$(PREFIX)|=$${prefix}|' \ | ||
-e 's|@PREFIX@|$(PREFIX)|' $< > $@ | ||
|
||
$(SRC_DIR)/parser.c: grammar.js | ||
$(TS) generate --no-bindings | ||
|
||
install: all | ||
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)' | ||
install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h | ||
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc | ||
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a | ||
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) | ||
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) | ||
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) | ||
|
||
uninstall: | ||
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \ | ||
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \ | ||
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \ | ||
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \ | ||
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \ | ||
'$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc | ||
|
||
clean: | ||
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) | ||
|
||
test: | ||
$(TS) test | ||
|
||
.PHONY: all install uninstall clean test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// swift-tools-version:5.3 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TreeSitterCuda", | ||
platforms: [.macOS(.v10_13), .iOS(.v11)], | ||
products: [ | ||
.library(name: "TreeSitterCuda", targets: ["TreeSitterCuda"]), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
.target(name: "TreeSitterCuda", | ||
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", | ||
"src/scanner.c", | ||
], | ||
resources: [ | ||
.copy("queries") | ||
], | ||
publicHeadersPath: "bindings/swift", | ||
cSettings: [.headerSearchPath("src")]) | ||
], | ||
cLanguageStandard: .c11 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef TREE_SITTER_CUDA_H_ | ||
#define TREE_SITTER_CUDA_H_ | ||
|
||
typedef struct TSLanguage TSLanguage; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
const TSLanguage *tree_sitter_cuda(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // TREE_SITTER_CUDA_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix=@PREFIX@ | ||
libdir=@LIBDIR@ | ||
includedir=@INCLUDEDIR@ | ||
|
||
Name: tree-sitter-cuda | ||
Description: Cuda grammar for tree-sitter | ||
URL: @URL@ | ||
Version: @VERSION@ | ||
Requires: @REQUIRES@ | ||
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-cuda | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tree_sitter_cuda | ||
|
||
// #cgo CFLAGS: -std=c11 -fPIC | ||
// #include "../../src/parser.c" | ||
// #include "../../src/scanner.c" | ||
import "C" | ||
|
||
import "unsafe" | ||
|
||
// Get the tree-sitter Language for this grammar. | ||
func Language() unsafe.Pointer { | ||
return unsafe.Pointer(C.tree_sitter_cuda()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tree_sitter_cuda_test | ||
|
||
import ( | ||
"testing" | ||
|
||
tree_sitter "github.com/smacker/go-tree-sitter" | ||
"github.com/tree-sitter/tree-sitter-cuda" | ||
) | ||
|
||
func TestCanLoadGrammar(t *testing.T) { | ||
language := tree_sitter.NewLanguage(tree_sitter_cuda.Language()) | ||
if language == nil { | ||
t.Errorf("Error loading Cuda grammar") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/tree-sitter/tree-sitter-cuda | ||
|
||
go 1.22 | ||
|
||
require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_cuda(); | ||
extern "C" TSLanguage *tree_sitter_cuda(); | ||
|
||
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_cuda()); | ||
|
||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("cuda").ToLocalChecked()); | ||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); | ||
Napi::Object Init(Napi::Env env, Napi::Object exports) { | ||
exports["name"] = Napi::String::New(env, "cuda"); | ||
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_cuda()); | ||
language.TypeTag(&LANGUAGE_TYPE_TAG); | ||
exports["language"] = language; | ||
return exports; | ||
} | ||
|
||
NODE_MODULE(tree_sitter_cuda_binding, Init) | ||
|
||
} // namespace | ||
NODE_API_MODULE(tree_sitter_cuda_binding, Init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"Cuda grammar for tree-sitter" | ||
|
||
from ._binding import language | ||
|
||
__all__ = ["language"] |
Oops, something went wrong.