From 4b160d1b2119cd2007ea7a76d4baba56ad66b825 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 18 Apr 2024 11:07:53 +0200 Subject: Support comments… sorta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bindings/python/tree_sitter_gsp/__init__.py | 5 +++++ bindings/python/tree_sitter_gsp/__init__.pyi | 1 + bindings/python/tree_sitter_gsp/binding.c | 27 +++++++++++++++++++++++++++ bindings/python/tree_sitter_gsp/py.typed | 0 4 files changed, 33 insertions(+) create mode 100644 bindings/python/tree_sitter_gsp/__init__.py create mode 100644 bindings/python/tree_sitter_gsp/__init__.pyi create mode 100644 bindings/python/tree_sitter_gsp/binding.c create mode 100644 bindings/python/tree_sitter_gsp/py.typed (limited to 'bindings/python') diff --git a/bindings/python/tree_sitter_gsp/__init__.py b/bindings/python/tree_sitter_gsp/__init__.py new file mode 100644 index 0000000..a844d6d --- /dev/null +++ b/bindings/python/tree_sitter_gsp/__init__.py @@ -0,0 +1,5 @@ +"Gsp grammar for tree-sitter" + +from ._binding import language + +__all__ = ["language"] diff --git a/bindings/python/tree_sitter_gsp/__init__.pyi b/bindings/python/tree_sitter_gsp/__init__.pyi new file mode 100644 index 0000000..5416666 --- /dev/null +++ b/bindings/python/tree_sitter_gsp/__init__.pyi @@ -0,0 +1 @@ +def language() -> int: ... diff --git a/bindings/python/tree_sitter_gsp/binding.c b/bindings/python/tree_sitter_gsp/binding.c new file mode 100644 index 0000000..569c1dc --- /dev/null +++ b/bindings/python/tree_sitter_gsp/binding.c @@ -0,0 +1,27 @@ +#include + +typedef struct TSLanguage TSLanguage; + +TSLanguage *tree_sitter_gsp(void); + +static PyObject* _binding_language(PyObject *self, PyObject *args) { + return PyLong_FromVoidPtr(tree_sitter_gsp()); +} + +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); +} diff --git a/bindings/python/tree_sitter_gsp/py.typed b/bindings/python/tree_sitter_gsp/py.typed new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3