Skip to content

Commit 4ab983d

Browse files
committed
chore: regenerate parser and bindings with tree-sitter-cli v0.22.2
1 parent 3b5e926 commit 4ab983d

File tree

24 files changed

+871
-50
lines changed

24 files changed

+871
-50
lines changed

.editorconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{json,toml,yml,gyp}]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.js]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.rs]
18+
indent_style = space
19+
indent_size = 4
20+
21+
[*.{c,cc,h}]
22+
indent_style = space
23+
indent_size = 4
24+
25+
[*.{py,pyi}]
26+
indent_style = space
27+
indent_size = 4
28+
29+
[*.swift]
30+
indent_style = space
31+
indent_size = 4
32+
33+
[*.go]
34+
indent_style = tab
35+
indent_size = 8
36+
37+
[Makefile]
38+
indent_style = tab
39+
indent_size = 8

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ jobs:
1313
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
1414
secrets:
1515
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}
16+
pypi:
17+
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
18+
secrets:
19+
PYPI_API_TOKEN: ${{secrets.PYPI_TOKEN}}

Makefile

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
VERSION := 0.22.3
2+
3+
LANGUAGE_NAME := tree-sitter-cuda
4+
5+
# repository
6+
SRC_DIR := src
7+
8+
PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null)
9+
10+
ifeq ($(PARSER_URL),)
11+
PARSER_URL := $(subst .git,,$(PARSER_REPO_URL))
12+
ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),)
13+
PARSER_URL := $(subst :,/,$(PARSER_URL))
14+
PARSER_URL := $(subst git@,https://,$(PARSER_URL))
15+
endif
16+
endif
17+
18+
TS ?= tree-sitter
19+
20+
# ABI versioning
21+
SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION)))
22+
SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION)))
23+
24+
# install directory layout
25+
PREFIX ?= /usr/local
26+
INCLUDEDIR ?= $(PREFIX)/include
27+
LIBDIR ?= $(PREFIX)/lib
28+
PCLIBDIR ?= $(LIBDIR)/pkgconfig
29+
30+
# object files
31+
OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c))
32+
33+
# flags
34+
ARFLAGS := rcs
35+
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC
36+
37+
# OS-specific bits
38+
ifeq ($(OS),Windows_NT)
39+
$(error "Windows is not supported")
40+
else ifeq ($(shell uname),Darwin)
41+
SOEXT = dylib
42+
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
43+
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
44+
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl,
45+
ifneq ($(ADDITIONAL_LIBS),)
46+
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS),
47+
endif
48+
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks
49+
else
50+
SOEXT = so
51+
SOEXTVER_MAJOR = so.$(SONAME_MAJOR)
52+
SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR)
53+
LINKSHARED := $(LINKSHARED)-shared -Wl,
54+
ifneq ($(ADDITIONAL_LIBS),)
55+
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS)
56+
endif
57+
LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).so.$(SONAME_MAJOR)
58+
endif
59+
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),)
60+
PCLIBDIR := $(PREFIX)/libdata/pkgconfig
61+
endif
62+
63+
all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc
64+
65+
lib$(LANGUAGE_NAME).a: $(OBJS)
66+
$(AR) $(ARFLAGS) $@ $^
67+
68+
lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS)
69+
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
70+
ifneq ($(STRIP),)
71+
$(STRIP) $@
72+
endif
73+
74+
$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in
75+
sed -e 's|@URL@|$(PARSER_URL)|' \
76+
-e 's|@VERSION@|$(VERSION)|' \
77+
-e 's|@LIBDIR@|$(LIBDIR)|' \
78+
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
79+
-e 's|@REQUIRES@|$(REQUIRES)|' \
80+
-e 's|@ADDITIONAL_LIBS@|$(ADDITIONAL_LIBS)|' \
81+
-e 's|=$(PREFIX)|=$${prefix}|' \
82+
-e 's|@PREFIX@|$(PREFIX)|' $< > $@
83+
84+
$(SRC_DIR)/parser.c: grammar.js
85+
$(TS) generate --no-bindings
86+
87+
install: all
88+
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
89+
install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
90+
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
91+
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
92+
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)
93+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)
94+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT)
95+
96+
uninstall:
97+
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \
98+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \
99+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \
100+
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \
101+
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \
102+
'$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
103+
104+
clean:
105+
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT)
106+
107+
test:
108+
$(TS) test
109+
110+
.PHONY: all install uninstall clean test

Package.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.3
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "TreeSitterCuda",
6+
platforms: [.macOS(.v10_13), .iOS(.v11)],
7+
products: [
8+
.library(name: "TreeSitterCuda", targets: ["TreeSitterCuda"]),
9+
],
10+
dependencies: [],
11+
targets: [
12+
.target(name: "TreeSitterCuda",
13+
path: ".",
14+
exclude: [
15+
"Cargo.toml",
16+
"Makefile",
17+
"binding.gyp",
18+
"bindings/c",
19+
"bindings/go",
20+
"bindings/node",
21+
"bindings/python",
22+
"bindings/rust",
23+
"prebuilds",
24+
"grammar.js",
25+
"package.json",
26+
"package-lock.json",
27+
"pyproject.toml",
28+
"setup.py",
29+
"test",
30+
"examples",
31+
".editorconfig",
32+
".github",
33+
".gitignore",
34+
".gitattributes",
35+
".gitmodules",
36+
],
37+
sources: [
38+
"src/parser.c",
39+
"src/scanner.c",
40+
],
41+
resources: [
42+
.copy("queries")
43+
],
44+
publicHeadersPath: "bindings/swift",
45+
cSettings: [.headerSearchPath("src")])
46+
],
47+
cLanguageStandard: .c11
48+
)

binding.gyp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
"targets": [
33
{
44
"target_name": "tree_sitter_cuda_binding",
5+
"dependencies": [
6+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
7+
],
58
"include_dirs": [
6-
"<!(node -e \"require('nan')\")",
7-
"src"
9+
"src",
810
],
911
"sources": [
1012
"bindings/node/binding.cc",
11-
"src/parser.c",
12-
"src/scanner.c"
13+
"src/parser.c",
14+
"src/scanner.c",
1315
],
1416
"cflags_c": [
15-
"-std=c99",
16-
]
17+
"-std=c11",
18+
],
1719
}
1820
]
1921
}

bindings/c/tree-sitter-cuda.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef TREE_SITTER_CUDA_H_
2+
#define TREE_SITTER_CUDA_H_
3+
4+
typedef struct TSLanguage TSLanguage;
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
const TSLanguage *tree_sitter_cuda(void);
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif
15+
16+
#endif // TREE_SITTER_CUDA_H_

bindings/c/tree-sitter-cuda.pc.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@PREFIX@
2+
libdir=@LIBDIR@
3+
includedir=@INCLUDEDIR@
4+
5+
Name: tree-sitter-cuda
6+
Description: Cuda grammar for tree-sitter
7+
URL: @URL@
8+
Version: @VERSION@
9+
Requires: @REQUIRES@
10+
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-cuda
11+
Cflags: -I${includedir}

bindings/go/binding.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package tree_sitter_cuda
2+
3+
// #cgo CFLAGS: -std=c11 -fPIC
4+
// #include "../../src/parser.c"
5+
// #include "../../src/scanner.c"
6+
import "C"
7+
8+
import "unsafe"
9+
10+
// Get the tree-sitter Language for this grammar.
11+
func Language() unsafe.Pointer {
12+
return unsafe.Pointer(C.tree_sitter_cuda())
13+
}

bindings/go/binding_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package tree_sitter_cuda_test
2+
3+
import (
4+
"testing"
5+
6+
tree_sitter "github.com/smacker/go-tree-sitter"
7+
"github.com/tree-sitter/tree-sitter-cuda"
8+
)
9+
10+
func TestCanLoadGrammar(t *testing.T) {
11+
language := tree_sitter.NewLanguage(tree_sitter_cuda.Language())
12+
if language == nil {
13+
t.Errorf("Error loading Cuda grammar")
14+
}
15+
}

bindings/go/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/tree-sitter/tree-sitter-cuda
2+
3+
go 1.22
4+
5+
require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8

0 commit comments

Comments
 (0)