diff --git a/Package.swift b/Package.swift deleted file mode 100644 index b4d403c..0000000 --- a/Package.swift +++ /dev/null @@ -1,41 +0,0 @@ -// swift-tools-version:5.3 - -import Foundation -import PackageDescription - -var sources = ["src/parser.c"] -if FileManager.default.fileExists(atPath: "src/scanner.c") { - sources.append("src/scanner.c") -} - -let package = Package( - name: "TreeSitterNoil", - products: [ - .library(name: "TreeSitterNoil", targets: ["TreeSitterNoil"]), - ], - dependencies: [ - .package(name: "SwiftTreeSitter", url: "https://github.com/tree-sitter/swift-tree-sitter", from: "0.9.0"), - ], - targets: [ - .target( - name: "TreeSitterNoil", - dependencies: [], - path: ".", - sources: sources, - resources: [ - .copy("queries") - ], - publicHeadersPath: "bindings/swift", - cSettings: [.headerSearchPath("src")] - ), - .testTarget( - name: "TreeSitterNoilTests", - dependencies: [ - "SwiftTreeSitter", - "TreeSitterNoil", - ], - path: "bindings/swift/TreeSitterNoilTests" - ) - ], - cLanguageStandard: .c11 -) diff --git a/bindings/go/binding.go b/bindings/go/binding.go deleted file mode 100644 index 186aaf1..0000000 --- a/bindings/go/binding.go +++ /dev/null @@ -1,15 +0,0 @@ -package tree_sitter_noil - -// #cgo CFLAGS: -std=c11 -fPIC -// #include "../../src/parser.c" -// #if __has_include("../../src/scanner.c") -// #include "../../src/scanner.c" -// #endif -import "C" - -import "unsafe" - -// Get the tree-sitter Language for this grammar. -func Language() unsafe.Pointer { - return unsafe.Pointer(C.tree_sitter_noil()) -} diff --git a/bindings/go/binding_test.go b/bindings/go/binding_test.go deleted file mode 100644 index d88dea3..0000000 --- a/bindings/go/binding_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package tree_sitter_noil_test - -import ( - "testing" - - tree_sitter "github.com/tree-sitter/go-tree-sitter" - tree_sitter_noil "git.front.kjuulh.io/kjuulh/tree-sitter-noil/bindings/go" -) - -func TestCanLoadGrammar(t *testing.T) { - language := tree_sitter.NewLanguage(tree_sitter_noil.Language()) - if language == nil { - t.Errorf("Error loading Noil grammar") - } -} diff --git a/bindings/python/tests/test_binding.py b/bindings/python/tests/test_binding.py deleted file mode 100644 index 38de90b..0000000 --- a/bindings/python/tests/test_binding.py +++ /dev/null @@ -1,12 +0,0 @@ -from unittest import TestCase - -import tree_sitter -import tree_sitter_noil - - -class TestLanguage(TestCase): - def test_can_load_grammar(self): - try: - tree_sitter.Language(tree_sitter_noil.language()) - except Exception: - self.fail("Error loading Noil grammar") diff --git a/bindings/python/tree_sitter_noil/__init__.py b/bindings/python/tree_sitter_noil/__init__.py deleted file mode 100644 index 42d0adc..0000000 --- a/bindings/python/tree_sitter_noil/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Noil treats your file like any buffer""" - -from importlib.resources import files as _files - -from ._binding import language - - -def _get_query(name, file): - query = _files(f"{__package__}.queries") / file - globals()[name] = query.read_text() - return globals()[name] - - -def __getattr__(name): - # NOTE: uncomment these to include any queries that this grammar contains: - - # if name == "HIGHLIGHTS_QUERY": - # return _get_query("HIGHLIGHTS_QUERY", "highlights.scm") - # if name == "INJECTIONS_QUERY": - # return _get_query("INJECTIONS_QUERY", "injections.scm") - # if name == "LOCALS_QUERY": - # return _get_query("LOCALS_QUERY", "locals.scm") - # if name == "TAGS_QUERY": - # return _get_query("TAGS_QUERY", "tags.scm") - - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") - - -__all__ = [ - "language", - # "HIGHLIGHTS_QUERY", - # "INJECTIONS_QUERY", - # "LOCALS_QUERY", - # "TAGS_QUERY", -] - - -def __dir__(): - return sorted(__all__ + [ - "__all__", "__builtins__", "__cached__", "__doc__", "__file__", - "__loader__", "__name__", "__package__", "__path__", "__spec__", - ]) diff --git a/bindings/python/tree_sitter_noil/__init__.pyi b/bindings/python/tree_sitter_noil/__init__.pyi deleted file mode 100644 index abf6633..0000000 --- a/bindings/python/tree_sitter_noil/__init__.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Final - -# NOTE: uncomment these to include any queries that this grammar contains: - -# HIGHLIGHTS_QUERY: Final[str] -# INJECTIONS_QUERY: Final[str] -# LOCALS_QUERY: Final[str] -# TAGS_QUERY: Final[str] - -def language() -> object: ... diff --git a/bindings/python/tree_sitter_noil/binding.c b/bindings/python/tree_sitter_noil/binding.c deleted file mode 100644 index 67891b5..0000000 --- a/bindings/python/tree_sitter_noil/binding.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -typedef struct TSLanguage TSLanguage; - -TSLanguage *tree_sitter_noil(void); - -static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { - return PyCapsule_New(tree_sitter_noil(), "tree_sitter.Language", NULL); -} - -static struct PyModuleDef_Slot slots[] = { -#ifdef Py_GIL_DISABLED - {Py_mod_gil, Py_MOD_GIL_NOT_USED}, -#endif - {0, NULL} -}; - -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 = 0, - .m_methods = methods, - .m_slots = slots, -}; - -PyMODINIT_FUNC PyInit__binding(void) { - return PyModuleDef_Init(&module); -} diff --git a/bindings/python/tree_sitter_noil/py.typed b/bindings/python/tree_sitter_noil/py.typed deleted file mode 100644 index e69de29..0000000 diff --git a/bindings/swift/TreeSitterNoil/noil.h b/bindings/swift/TreeSitterNoil/noil.h deleted file mode 100644 index 79365f0..0000000 --- a/bindings/swift/TreeSitterNoil/noil.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef TREE_SITTER_NOIL_H_ -#define TREE_SITTER_NOIL_H_ - -typedef struct TSLanguage TSLanguage; - -#ifdef __cplusplus -extern "C" { -#endif - -const TSLanguage *tree_sitter_noil(void); - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_NOIL_H_ diff --git a/bindings/swift/TreeSitterNoilTests/TreeSitterNoilTests.swift b/bindings/swift/TreeSitterNoilTests/TreeSitterNoilTests.swift deleted file mode 100644 index e5029ae..0000000 --- a/bindings/swift/TreeSitterNoilTests/TreeSitterNoilTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import XCTest -import SwiftTreeSitter -import TreeSitterNoil - -final class TreeSitterNoilTests: XCTestCase { - func testCanLoadGrammar() throws { - let parser = Parser() - let language = Language(language: tree_sitter_noil()) - XCTAssertNoThrow(try parser.setLanguage(language), - "Error loading Noil grammar") - } -} diff --git a/go.mod b/go.mod deleted file mode 100644 index 2342a1e..0000000 --- a/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module git.front.kjuulh.io/kjuulh/tree-sitter-noil - -go 1.22 - -require github.com/tree-sitter/go-tree-sitter v0.24.0 diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 585278f..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,29 +0,0 @@ -[build-system] -requires = ["setuptools>=62.4.0", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "tree-sitter-noil" -description = "Noil treats your file like any buffer" -version = "0.1.0" -keywords = ["incremental", "parsing", "tree-sitter", "noil"] -classifiers = [ - "Intended Audience :: Developers", - "Topic :: Software Development :: Compilers", - "Topic :: Text Processing :: Linguistic", - "Typing :: Typed", -] -authors = [{ name = "kjuulh", email = "contact@kasperhermansen.com" }] -requires-python = ">=3.10" -license.text = "MIT" -readme = "README.md" - -[project.urls] -Homepage = "https://git.front.kjuulh.io/kjuulh/tree-sitter-noil" - -[project.optional-dependencies] -core = ["tree-sitter~=0.24"] - -[tool.cibuildwheel] -build = "cp310-*" -build-frontend = "build" diff --git a/setup.py b/setup.py deleted file mode 100644 index 2eb64b7..0000000 --- a/setup.py +++ /dev/null @@ -1,77 +0,0 @@ -from os import path -from platform import system -from sysconfig import get_config_var - -from setuptools import Extension, find_packages, setup -from setuptools.command.build import build -from setuptools.command.egg_info import egg_info -from wheel.bdist_wheel import bdist_wheel - -sources = [ - "bindings/python/tree_sitter_noil/binding.c", - "src/parser.c", -] -if path.exists("src/scanner.c"): - sources.append("src/scanner.c") - -macros: list[tuple[str, str | None]] = [ - ("PY_SSIZE_T_CLEAN", None), - ("TREE_SITTER_HIDE_SYMBOLS", None), -] -if limited_api := not get_config_var("Py_GIL_DISABLED"): - macros.append(("Py_LIMITED_API", "0x030A0000")) - -if system() != "Windows": - cflags = ["-std=c11", "-fvisibility=hidden"] -else: - cflags = ["/std:c11", "/utf-8"] - - -class Build(build): - def run(self): - if path.isdir("queries"): - dest = path.join(self.build_lib, "tree_sitter_noil", "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 = "cp310", "abi3" - return python, abi, platform - - -class EggInfo(egg_info): - def find_sources(self): - super().find_sources() - self.filelist.recursive_include("queries", "*.scm") - self.filelist.include("src/tree_sitter/*.h") - - -setup( - packages=find_packages("bindings/python"), - package_dir={"": "bindings/python"}, - package_data={ - "tree_sitter_noil": ["*.pyi", "py.typed"], - "tree_sitter_noil.queries": ["*.scm"], - }, - ext_package="tree_sitter_noil", - ext_modules=[ - Extension( - name="_binding", - sources=sources, - extra_compile_args=cflags, - define_macros=macros, - include_dirs=["src"], - py_limited_api=limited_api, - ) - ], - cmdclass={ - "build": Build, - "bdist_wheel": BdistWheel, - "egg_info": EggInfo, - }, - zip_safe=False -)