From 6c83daa6e689baed8755f724bcfed27dc98be152 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 9 May 2024 21:53:32 -0400 Subject: [PATCH] build: update bindings --- Cargo.toml | 22 ++-- Makefile | 113 ++++++++++++++++++ bindings/c/tree-sitter-scala.h | 16 +++ bindings/c/tree-sitter-scala.pc.in | 11 ++ bindings/go/binding.go | 13 ++ bindings/go/binding_test.go | 15 +++ bindings/go/go.mod | 5 + bindings/python/tree_sitter_scala/__init__.py | 5 + .../python/tree_sitter_scala/__init__.pyi | 1 + bindings/python/tree_sitter_scala/binding.c | 27 +++++ bindings/python/tree_sitter_scala/py.typed | 0 bindings/rust/build.rs | 20 ++-- bindings/rust/lib.rs | 26 ++-- grammar.js | 4 +- package.json | 41 ++++--- pyproject.toml | 37 ++++++ queries/{scala => }/highlights.scm | 0 queries/{scala => }/locals.scm | 0 setup.py | 60 ++++++++++ {corpus => test/corpus}/annotations.txt | 0 {corpus => test/corpus}/comments.txt | 0 {corpus => test/corpus}/definitions.txt | 0 {corpus => test/corpus}/expressions.txt | 0 {corpus => test/corpus}/literals.txt | 0 {corpus => test/corpus}/patterns.txt | 0 {corpus => test/corpus}/types.txt | 0 26 files changed, 370 insertions(+), 46 deletions(-) create mode 100644 Makefile create mode 100644 bindings/c/tree-sitter-scala.h create mode 100644 bindings/c/tree-sitter-scala.pc.in create mode 100644 bindings/go/binding.go create mode 100644 bindings/go/binding_test.go create mode 100644 bindings/go/go.mod create mode 100644 bindings/python/tree_sitter_scala/__init__.py create mode 100644 bindings/python/tree_sitter_scala/__init__.pyi create mode 100644 bindings/python/tree_sitter_scala/binding.c create mode 100644 bindings/python/tree_sitter_scala/py.typed create mode 100644 pyproject.toml rename queries/{scala => }/highlights.scm (100%) rename queries/{scala => }/locals.scm (100%) create mode 100644 setup.py rename {corpus => test/corpus}/annotations.txt (100%) rename {corpus => test/corpus}/comments.txt (100%) rename {corpus => test/corpus}/definitions.txt (100%) rename {corpus => test/corpus}/expressions.txt (100%) rename {corpus => test/corpus}/literals.txt (100%) rename {corpus => test/corpus}/patterns.txt (100%) rename {corpus => test/corpus}/types.txt (100%) diff --git a/Cargo.toml b/Cargo.toml index 818c2de..b72f5b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,26 @@ [package] name = "tree-sitter-scala" -description = "scala grammar for the tree-sitter parsing library" +description = "Scala grammar for tree-sitter" version = "0.21.0" -keywords = ["incremental", "parsing", "scala"] +authors = [ + "Max Brunsfeld ", + "Amaan Qureshi ", +] +license = "MIT" +keywords = ["incremental", "parsing", "tree-sitter", "scala"] categories = ["parsing", "text-editors"] repository = "https://github.com/tree-sitter/tree-sitter-scala" edition = "2021" -license = "MIT" +autoexamples = false build = "bindings/rust/build.rs" -include = [ - "bindings/rust/*", - "grammar.js", - "queries/*", - "src/*", -] +include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] [lib] path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "0.21.0" +tree-sitter = ">=0.21.0" [build-dependencies] -cc = "1.0" +cc = "1.0.97" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4314545 --- /dev/null +++ b/Makefile @@ -0,0 +1,113 @@ +VERSION := 0.21.0 + +LANGUAGE_NAME := tree-sitter-scala + +# 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 + +# source/object files +PARSER := $(SRC_DIR)/parser.c +EXTRAS := $(filter-out $(PARSER),$(wildcard $(SRC_DIR)/*.c)) +OBJS := $(patsubst %.c,%.o,$(PARSER) $(EXTRAS)) + +# 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)|' $< > $@ + +$(PARSER): $(SRC_DIR)/grammar.json + $(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 + $(TS) parse examples/* --quiet --time + +.PHONY: all install uninstall clean test diff --git a/bindings/c/tree-sitter-scala.h b/bindings/c/tree-sitter-scala.h new file mode 100644 index 0000000..e55a209 --- /dev/null +++ b/bindings/c/tree-sitter-scala.h @@ -0,0 +1,16 @@ +#ifndef TREE_SITTER_SCALA_H_ +#define TREE_SITTER_SCALA_H_ + +typedef struct TSLanguage TSLanguage; + +#ifdef __cplusplus +extern "C" { +#endif + +const TSLanguage *tree_sitter_scala(void); + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_SCALA_H_ diff --git a/bindings/c/tree-sitter-scala.pc.in b/bindings/c/tree-sitter-scala.pc.in new file mode 100644 index 0000000..96ff5e8 --- /dev/null +++ b/bindings/c/tree-sitter-scala.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: tree-sitter-scala +Description: Scala grammar for tree-sitter +URL: @URL@ +Version: @VERSION@ +Requires: @REQUIRES@ +Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-scala +Cflags: -I${includedir} diff --git a/bindings/go/binding.go b/bindings/go/binding.go new file mode 100644 index 0000000..7ec0d7a --- /dev/null +++ b/bindings/go/binding.go @@ -0,0 +1,13 @@ +package tree_sitter_scala + +// #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_scala()) +} diff --git a/bindings/go/binding_test.go b/bindings/go/binding_test.go new file mode 100644 index 0000000..c69c111 --- /dev/null +++ b/bindings/go/binding_test.go @@ -0,0 +1,15 @@ +package tree_sitter_scala_test + +import ( + "testing" + + tree_sitter "github.com/smacker/go-tree-sitter" + "github.com/tree-sitter/tree-sitter-scala" +) + +func TestCanLoadGrammar(t *testing.T) { + language := tree_sitter.NewLanguage(tree_sitter_scala.Language()) + if language == nil { + t.Errorf("Error loading Scala grammar") + } +} diff --git a/bindings/go/go.mod b/bindings/go/go.mod new file mode 100644 index 0000000..473779d --- /dev/null +++ b/bindings/go/go.mod @@ -0,0 +1,5 @@ +module github.com/tree-sitter/tree-sitter-scala + +go 1.22 + +require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8 diff --git a/bindings/python/tree_sitter_scala/__init__.py b/bindings/python/tree_sitter_scala/__init__.py new file mode 100644 index 0000000..d4e83e5 --- /dev/null +++ b/bindings/python/tree_sitter_scala/__init__.py @@ -0,0 +1,5 @@ +"Scala grammar for tree-sitter" + +from ._binding import language + +__all__ = ["language"] diff --git a/bindings/python/tree_sitter_scala/__init__.pyi b/bindings/python/tree_sitter_scala/__init__.pyi new file mode 100644 index 0000000..5416666 --- /dev/null +++ b/bindings/python/tree_sitter_scala/__init__.pyi @@ -0,0 +1 @@ +def language() -> int: ... diff --git a/bindings/python/tree_sitter_scala/binding.c b/bindings/python/tree_sitter_scala/binding.c new file mode 100644 index 0000000..24fa05d --- /dev/null +++ b/bindings/python/tree_sitter_scala/binding.c @@ -0,0 +1,27 @@ +#include + +typedef struct TSLanguage TSLanguage; + +TSLanguage *tree_sitter_scala(void); + +static PyObject* _binding_language(PyObject *self, PyObject *args) { + return PyLong_FromVoidPtr(tree_sitter_scala()); +} + +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_scala/py.typed b/bindings/python/tree_sitter_scala/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 9bddcd7..bd48e8e 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -1,16 +1,22 @@ fn main() { let src_dir = std::path::Path::new("src"); + let mut c_config = cc::Build::new(); - c_config.include(&src_dir); c_config - .flag_if_supported("-Wno-unused-parameter") - .flag_if_supported("-Wno-unused-but-set-variable") - .flag_if_supported("-Wno-trigraphs"); + .std("c11") + .include(src_dir) + .flag_if_supported("-Wno-unused-value"); + + #[cfg(target_env = "msvc")] + c_config.flag("-utf-8"); + let parser_path = src_dir.join("parser.c"); - let scanner_path = src_dir.join("scanner.c"); c_config.file(&parser_path); - c_config.file(&scanner_path); - c_config.compile("parser"); println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); + + let scanner_path = src_dir.join("scanner.c"); + c_config.file(&scanner_path); println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); + + c_config.compile("tree-sitter-scala"); } diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index 01175cb..4d58c39 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,13 +1,20 @@ -//! This crate provides scala language support for the [tree-sitter][] parsing library. +//! This crate provides Scala language support for the [tree-sitter][] parsing library. //! //! Typically, you will use the [language][language func] function to add this language to a //! tree-sitter [Parser][], and then use the parser to parse some code: //! //! ``` -//! let code = ""; +//! let code = r#" +//! object Main { +//! def main(args: Array[String]): Unit = { +//! println("Hello, world!") +//! } +//! } +//! "#; //! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(&tree_sitter_scala::language()).expect("Error loading scala grammar"); +//! parser.set_language(&tree_sitter_scala::language()).expect("Error loading Scala grammar"); //! let tree = parser.parse(code, None).unwrap(); +//! assert!(!tree.root_node().has_error()); //! ``` //! //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html @@ -31,14 +38,13 @@ pub fn language() -> Language { /// The content of the [`node-types.json`][] file for this grammar. /// /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types -pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); +pub const NODE_TYPES: &str = include_str!("../../src/node-types.json"); -// Uncomment these to include any queries that this grammar contains +/// The syntax highlighting query for this grammar. +pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm"); -pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/scala/highlights.scm"); -// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); -pub const LOCALS_QUERY: &'static str = include_str!("../../queries/scala/locals.scm"); -// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); +/// The local-variable query for this grammar. +pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm"); #[cfg(test)] mod tests { @@ -47,6 +53,6 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser .set_language(&super::language()) - .expect("Error loading scala language"); + .expect("Error loading Scala grammar"); } } diff --git a/grammar.js b/grammar.js index 6b83e8b..7eb410e 100644 --- a/grammar.js +++ b/grammar.js @@ -57,7 +57,7 @@ module.exports = grammar({ // Doc: https://tree-sitter.github.io/tree-sitter/creating-parsers, search "precedences" // These names can be used in the prec functions to define precedence relative only to other names in the array, rather than globally. - precedences: $ => [ + precedences: _ => [ ["mod", "soft_id"], ["end", "soft_id"], ["new", "structural_type"], @@ -70,7 +70,6 @@ module.exports = grammar({ [$.while_expression, $._simple_expression], [$.if_expression], [$.match_expression], - [$._function_constructor, $._type_identifier], [$._given_constructor, $._type_identifier], [$.instance_expression], // In case of: 'extension' _indent '{' 'case' operator_identifier 'if' operator_identifier • '=>' … @@ -92,7 +91,6 @@ module.exports = grammar({ [$.class_parameters], // 'for' operator_identifier ':' _annotated_type • ':' … [$._type, $.compound_type], - [$.lambda_expression, $.modifiers], // 'if' parenthesized_expression • '{' … [$._if_condition, $._simple_expression], // _postfix_expression_choice ':' '(' wildcard • ':' … diff --git a/package.json b/package.json index 5d11720..8db56ab 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,23 @@ { "name": "tree-sitter-scala", - "version": "0.20.0", + "version": "0.21.0", "description": "Scala grammar for tree-sitter", + "repository": "github:tree-sitter/tree-sitter-css", + "license": "MIT", + "author": "Max Brunsfeld ", + "contributors": [ + "Eugene Yokota ", + "Chris Kipp " + ], + "maintainers": [ + "Amaan Qureshi " + ], "main": "bindings/node", "types": "bindings/node", "keywords": [ - "parser", + "incremental", + "parsing", + "tree-sitter", "scala" ], "files": [ @@ -16,11 +28,9 @@ "queries/*", "src/**" ], - "author": "Max Brunsfeld", - "license": "MIT", "dependencies": { - "node-addon-api": "^7.1.0", - "node-gyp-build": "^4.8.0" + "node-addon-api": "^8.0.0", + "node-gyp-build": "^4.8.1" }, "peerDependencies": { "tree-sitter": "0.21.0" @@ -31,16 +41,17 @@ } }, "devDependencies": { - "tree-sitter-cli": "0.21.0", - "prettier": "3.0.0-alpha.6", - "prebuildify": "^6.0.0" + "tree-sitter-cli": "0.22.6", + "prebuildify": "^6.0.1" }, "scripts": { - "build": "tree-sitter generate && node-gyp build", - "test": "tree-sitter test && tree-sitter parse examples/*.scala --quiet --time", - "format": "prettier --write --ignore-unknown grammar.js", "install": "node-gyp-build", - "prebuildify": "prebuildify --napi --strip" + "prebuildify": "prebuildify --napi --strip", + "build": "tree-sitter generate --no-bindings", + "build-wasm": "tree-sitter build --wasm", + "format": "prettier --write --ignore-unknown grammar.js", + "parse": "tree-sitter parse", + "test": "tree-sitter test && tree-sitter parse examples/* --quiet --time" }, "tree-sitter": [ { @@ -49,8 +60,8 @@ "scala", "sbt" ], - "highlights": "queries/scala/highlights.scm", - "locals": "queries/scala/locals.scm" + "highlights": "queries/highlights.scm", + "locals": "queries/locals.scm" } ] } diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c8a89a7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "tree-sitter-scala" +description = "Scala grammar for tree-sitter" +version = "0.21.0" +keywords = ["incremental", "parsing", "tree-sitter", "scala"] +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Topic :: Software Development :: Compilers", + "Topic :: Text Processing :: Linguistic", + "Typing :: Typed", +] +requires-python = ">=3.8" +license.text = "MIT" +readme = "README.md" + +[[project.authors]] +name = "Max Brunsfeld" +email = "maxbrunsfeld@gmail.com" + +[[project.maintainers]] +name = "Amaan Qureshi" +email = "amaanq12@gmail.com" + +[project.urls] +Homepage = "https://github.com/tree-sitter/tree-sitter-scala" + +[project.optional-dependencies] +core = ["tree-sitter~=0.21"] + +[tool.cibuildwheel] +build = "cp38-*" +build-frontend = "build" diff --git a/queries/scala/highlights.scm b/queries/highlights.scm similarity index 100% rename from queries/scala/highlights.scm rename to queries/highlights.scm diff --git a/queries/scala/locals.scm b/queries/locals.scm similarity index 100% rename from queries/scala/locals.scm rename to queries/locals.scm diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..690c8f1 --- /dev/null +++ b/setup.py @@ -0,0 +1,60 @@ +from os.path import isdir, join +from platform import system + +from setuptools import Extension, find_packages, setup +from setuptools.command.build import build +from wheel.bdist_wheel import bdist_wheel + + +class Build(build): + def run(self): + if isdir("queries"): + dest = join(self.build_lib, "tree_sitter_scala", "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 = "cp38", "abi3" + return python, abi, platform + + +setup( + packages=find_packages("bindings/python"), + package_dir={"": "bindings/python"}, + package_data={ + "tree_sitter_scala": ["*.pyi", "py.typed"], + "tree_sitter_scala.queries": ["*.scm"], + }, + ext_package="tree_sitter_scala", + ext_modules=[ + Extension( + name="_binding", + sources=[ + "bindings/python/tree_sitter_scala/binding.c", + "src/parser.c", + "src/scanner.c", + ], + extra_compile_args=[ + "-std=c11", + ] if system() != "Windows" else [ + "/std:c11", + "/utf-8", + ], + define_macros=[ + ("Py_LIMITED_API", "0x03080000"), + ("PY_SSIZE_T_CLEAN", None) + ], + include_dirs=["src"], + py_limited_api=True, + ) + ], + cmdclass={ + "build": Build, + "bdist_wheel": BdistWheel + }, + zip_safe=False +) diff --git a/corpus/annotations.txt b/test/corpus/annotations.txt similarity index 100% rename from corpus/annotations.txt rename to test/corpus/annotations.txt diff --git a/corpus/comments.txt b/test/corpus/comments.txt similarity index 100% rename from corpus/comments.txt rename to test/corpus/comments.txt diff --git a/corpus/definitions.txt b/test/corpus/definitions.txt similarity index 100% rename from corpus/definitions.txt rename to test/corpus/definitions.txt diff --git a/corpus/expressions.txt b/test/corpus/expressions.txt similarity index 100% rename from corpus/expressions.txt rename to test/corpus/expressions.txt diff --git a/corpus/literals.txt b/test/corpus/literals.txt similarity index 100% rename from corpus/literals.txt rename to test/corpus/literals.txt diff --git a/corpus/patterns.txt b/test/corpus/patterns.txt similarity index 100% rename from corpus/patterns.txt rename to test/corpus/patterns.txt diff --git a/corpus/types.txt b/test/corpus/types.txt similarity index 100% rename from corpus/types.txt rename to test/corpus/types.txt