diff --git a/.editorconfig b/.editorconfig index d3a8b5b..f363cc5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,9 +2,6 @@ root = true [*] charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true [*.{json,toml,yml,gyp}] indent_style = space @@ -14,11 +11,11 @@ indent_size = 2 indent_style = space indent_size = 2 -[*.rs] +[*.{c,cc,h}] indent_style = space indent_size = 4 -[*.{c,cc,h}] +[*.rs] indent_style = space indent_size = 4 @@ -37,3 +34,6 @@ indent_size = 8 [Makefile] indent_style = tab indent_size = 8 + +[parser.c] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index ffb52ab..4cb1058 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -* text eol=lf +* text=auto eol=lf src/*.json linguist-generated src/parser.c linguist-generated diff --git a/.gitignore b/.gitignore index 27fc43f..2fd9dac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Rust artifacts -Cargo.lock target/ # Node artifacts @@ -10,9 +9,9 @@ node_modules/ # Swift artifacts .build/ +Package.resolved # Go artifacts -go.sum _obj/ # Python artifacts diff --git a/Cargo.lock b/Cargo.lock index 89dc93c..4ce5714 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,21 +13,24 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +dependencies = [ + "shlex", +] [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "regex" -version = "1.10.4" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -37,9 +40,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -48,24 +51,39 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "tree-sitter" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df7cc499ceadd4dcdf7ec6d4cbc34ece92c3fa07821e287aedecd4416c516dca" +checksum = "20f4cd3642c47a85052a887d86704f4eac272969f61b686bdd3f772122aabaff" dependencies = [ "cc", "regex", + "regex-syntax", + "tree-sitter-language", ] [[package]] name = "tree-sitter-embedded-template" -version = "0.20.0" +version = "0.21.0" dependencies = [ "cc", "tree-sitter", + "tree-sitter-language", ] + +[[package]] +name = "tree-sitter-language" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2545046bd1473dac6c626659cc2567c6c0ff302fc8b84a56c4243378276f7f57" diff --git a/Cargo.toml b/Cargo.toml index b303f67..f77d26f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,10 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = ">=0.21.0" +tree-sitter-language = "0.1.0" [build-dependencies] cc = "1.0.96" + +[dev-dependencies] +tree-sitter = "0.23" diff --git a/Makefile b/Makefile index f7bd504..b935fdf 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,8 @@ -VERSION := 0.21.0 +ifeq ($(OS),Windows_NT) +$(error Windows is not supported) +endif + +VERSION := 0.0.1 LANGUAGE_NAME := tree-sitter-embedded_template @@ -17,44 +21,44 @@ 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)) +# 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 +ARFLAGS ?= rcs override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC +# ABI versioning +SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION))) +SONAME_MINOR := $(shell sed -n 's/#define LANGUAGE_VERSION //p' $(PARSER)) + # OS-specific bits -ifeq ($(OS),Windows_NT) - $(error "Windows is not supported") -else ifeq ($(shell uname),Darwin) +ifeq ($(shell uname),Darwin) SOEXT = dylib - SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib - SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib + SOEXTVER_MAJOR = $(SONAME_MAJOR).$(SOEXT) + SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).$(SOEXT) 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 + LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER),-rpath,@executable_path/../Frameworks else SOEXT = so - SOEXTVER_MAJOR = so.$(SONAME_MAJOR) - SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) + SOEXTVER_MAJOR = $(SOEXT).$(SONAME_MAJOR) + SOEXTVER = $(SOEXT).$(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) + LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).$(SOEXTVER) endif ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),) PCLIBDIR := $(PREFIX)/libdata/pkgconfig @@ -81,13 +85,14 @@ $(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in -e 's|=$(PREFIX)|=$${prefix}|' \ -e 's|@PREFIX@|$(PREFIX)|' $< > $@ -$(SRC_DIR)/parser.c: grammar.js - $(TS) generate --no-bindings +$(PARSER): $(SRC_DIR)/grammar.json + $(TS) generate --no-bindings $^ install: all - install -Dm644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h - install -Dm644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc - install -Dm755 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a + 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) diff --git a/Package.swift b/Package.swift index 87aa6a6..25585aa 100644 --- a/Package.swift +++ b/Package.swift @@ -3,45 +3,57 @@ import PackageDescription let package = Package( name: "TreeSitterEmbeddedTemplate", - platforms: [.macOS(.v10_13), .iOS(.v11)], products: [ .library(name: "TreeSitterEmbeddedTemplate", targets: ["TreeSitterEmbeddedTemplate"]), ], - dependencies: [], + dependencies: [ + .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.8.0"), + ], targets: [ - .target(name: "TreeSitterEmbeddedTemplate", - path: ".", - exclude: [ - "Cargo.toml", - "Makefile", - "binding.gyp", - "bindings/c", - "bindings/go", - "bindings/node", - "bindings/python", - "bindings/rust", - "examples", - "grammar.js", - "package.json", - "package-lock.json", - "pyproject.toml", - "setup.py", - "test", - "types", - ".editorconfig", - ".github", - ".gitignore", - ".gitattributes", - ".gitmodules", - ], - sources: [ - "src/parser.c", - ], - resources: [ - .copy("queries") - ], - publicHeadersPath: "bindings/swift", - cSettings: [.headerSearchPath("src")]) + .target( + name: "TreeSitterEmbeddedTemplate", + dependencies: [], + 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", + ], + resources: [ + .copy("queries") + ], + publicHeadersPath: "bindings/swift", + cSettings: [.headerSearchPath("src")] + ), + .testTarget( + name: "TreeSitterEmbeddedTemplateTests", + dependencies: [ + "SwiftTreeSitter", + "TreeSitterEmbeddedTemplate", + ], + path: "bindings/swift/TreeSitterEmbeddedTemplateTests" + ) ], cLanguageStandard: .c11 ) diff --git a/bindings/go/binding_test.go b/bindings/go/binding_test.go index 3ae6034..4551ade 100644 --- a/bindings/go/binding_test.go +++ b/bindings/go/binding_test.go @@ -3,13 +3,13 @@ package tree_sitter_embedded_template_test import ( "testing" - tree_sitter "github.com/smacker/go-tree-sitter" + tree_sitter "github.com/tree-sitter/go-tree-sitter" tree_sitter_embedded_template "github.com/tree-sitter/tree-sitter-embedded-template/bindings/go" ) func TestCanLoadGrammar(t *testing.T) { language := tree_sitter.NewLanguage(tree_sitter_embedded_template.Language()) if language == nil { - t.Errorf("Error loading Embedded Template grammar") + t.Errorf("Error loading EmbeddedTemplate grammar") } } diff --git a/bindings/node/binding_test.js b/bindings/node/binding_test.js new file mode 100644 index 0000000..afede30 --- /dev/null +++ b/bindings/node/binding_test.js @@ -0,0 +1,9 @@ +/// + +const assert = require("node:assert"); +const { test } = require("node:test"); + +test("can load grammar", () => { + const parser = new (require("tree-sitter"))(); + assert.doesNotThrow(() => parser.setLanguage(require("."))); +}); diff --git a/bindings/python/tests/test_binding.py b/bindings/python/tests/test_binding.py new file mode 100644 index 0000000..18c18f6 --- /dev/null +++ b/bindings/python/tests/test_binding.py @@ -0,0 +1,11 @@ +from unittest import TestCase + +import tree_sitter, tree_sitter_embedded_template + + +class TestLanguage(TestCase): + def test_can_load_grammar(self): + try: + tree_sitter.Language(tree_sitter_embedded_template.language()) + except Exception: + self.fail("Error loading EmbeddedTemplate grammar") diff --git a/bindings/python/tree_sitter_embedded_template/binding.c b/bindings/python/tree_sitter_embedded_template/binding.c index c712ca8..e0cc8b6 100644 --- a/bindings/python/tree_sitter_embedded_template/binding.c +++ b/bindings/python/tree_sitter_embedded_template/binding.c @@ -4,8 +4,8 @@ typedef struct TSLanguage TSLanguage; TSLanguage *tree_sitter_embedded_template(void); -static PyObject* _binding_language(PyObject *self, PyObject *args) { - return PyLong_FromVoidPtr(tree_sitter_embedded_template()); +static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { + return PyCapsule_New(tree_sitter_embedded_template(), "tree_sitter.Language", NULL); } static PyMethodDef methods[] = { diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index ffcf762..20599e0 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,9 +1,11 @@ -//! This crate provides Embedded Template language support for the [tree-sitter][] parsing library. +//! This crate provides EmbeddedTemplate 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: //! //! ``` +//! use tree_sitter::Parser; +//! //! let code = r#" //! //! @@ -13,8 +15,11 @@ //! //! //! "#; -//! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(&tree_sitter_embedded_template::language()).expect("Error loading Embedded Template grammar"); +//! let mut parser = Parser::new(); +//! let language = tree_sitter_embedded_template::LANGUAGE; +//! parser +//! .set_language(&language.into()) +//! .expect("Error loading EmbeddedTemplate parser"); //! let tree = parser.parse(code, None).unwrap(); //! assert!(!tree.root_node().has_error()); //! ``` @@ -24,18 +29,14 @@ //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html //! [tree-sitter]: https://tree-sitter.github.io/ -use tree_sitter::Language; +use tree_sitter_language::LanguageFn; extern "C" { - fn tree_sitter_embedded_template() -> Language; + fn tree_sitter_embedded_template() -> *const (); } -/// Get the tree-sitter [Language][] for this grammar. -/// -/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html -pub fn language() -> Language { - unsafe { tree_sitter_embedded_template() } -} +/// The tree-sitter [`LanguageFn`] for this grammar. +pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_embedded_template) }; /// The content of the [`node-types.json`][] file for this grammar. /// @@ -57,7 +58,7 @@ mod tests { fn test_can_load_grammar() { let mut parser = tree_sitter::Parser::new(); parser - .set_language(&super::language()) - .expect("Error loading Embedded Template grammar"); + .set_language(&super::LANGUAGE.into()) + .expect("Error loading EmbeddedTemplate parser"); } } diff --git a/bindings/swift/TreeSitterEmbeddedTemplateTests/TreeSitterEmbeddedTemplateTests.swift b/bindings/swift/TreeSitterEmbeddedTemplateTests/TreeSitterEmbeddedTemplateTests.swift new file mode 100644 index 0000000..5c2d42e --- /dev/null +++ b/bindings/swift/TreeSitterEmbeddedTemplateTests/TreeSitterEmbeddedTemplateTests.swift @@ -0,0 +1,12 @@ +import XCTest +import SwiftTreeSitter +import TreeSitterEmbeddedTemplate + +final class TreeSitterEmbeddedTemplateTests: XCTestCase { + func testCanLoadGrammar() throws { + let parser = Parser() + let language = Language(language: tree_sitter_embedded_template()) + XCTAssertNoThrow(try parser.setLanguage(language), + "Error loading EmbeddedTemplate grammar") + } +} diff --git a/go.mod b/go.mod index 7cc4d27..c6b6391 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,9 @@ module github.com/tree-sitter/tree-sitter-embedded-template -go 1.22 +go 1.23 -require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8 +toolchain go1.23.0 + +require github.com/tree-sitter/go-tree-sitter v0.23.1 + +require github.com/mattn/go-pointer v0.0.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2a16b2b --- /dev/null +++ b/go.sum @@ -0,0 +1,34 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= +github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tree-sitter/go-tree-sitter v0.23.1 h1:HCfaE19sKfG7q190xfM1loUZf6wEHa4TDqDEW46s9Lg= +github.com/tree-sitter/go-tree-sitter v0.23.1/go.mod h1:EvIVhMvvPNvhu9x+ddSPxSnUEU5AnsSwi1LMqXIVE3A= +github.com/tree-sitter/tree-sitter-c v0.21.5-0.20240818205408-927da1f210eb h1:A8425heRM8mylnv4H58FPUiH+aYivyitre0PzxrfmWs= +github.com/tree-sitter/tree-sitter-c v0.21.5-0.20240818205408-927da1f210eb/go.mod h1:dOF6gtQiF9UwNh995T5OphYmtIypkjsp3ap7r9AN/iA= +github.com/tree-sitter/tree-sitter-cpp v0.22.4-0.20240818224355-b1a4e2b25148 h1:AfFPZwtwGN01BW1jDdqBVqscTwetvMpydqYZz57RSlc= +github.com/tree-sitter/tree-sitter-cpp v0.22.4-0.20240818224355-b1a4e2b25148/go.mod h1:Bh6U3viD57rFXRYIQ+kmiYtr+1Bx0AceypDLJJSyi9s= +github.com/tree-sitter/tree-sitter-go v0.21.3-0.20240818010209-8c0f0e7a6012 h1:Xvxck3tE5FW7F7bTS97iNM2ADMyCMJztVqn5HYKdJGo= +github.com/tree-sitter/tree-sitter-go v0.21.3-0.20240818010209-8c0f0e7a6012/go.mod h1:T40D0O1cPvUU/+AmiXVXy1cncYQT6wem4Z0g4SfAYvY= +github.com/tree-sitter/tree-sitter-html v0.20.5-0.20240818004741-d11201a263d0 h1:c46K6uh5Dz00zJeU9BfjXdb8I+E4RkUdfnWJpQADXFo= +github.com/tree-sitter/tree-sitter-html v0.20.5-0.20240818004741-d11201a263d0/go.mod h1:hcNt/kOJHcIcuMvouE7LJcYdeFUFbVpBJ6d4wmOA+tU= +github.com/tree-sitter/tree-sitter-java v0.21.1-0.20240824015150-576d8097e495 h1:jrt4qbJVEFs4H93/ITxygHc6u0TGqAkkate7TQ4wFSA= +github.com/tree-sitter/tree-sitter-java v0.21.1-0.20240824015150-576d8097e495/go.mod h1:oyaR7fLnRV0hT9z6qwE9GkaeTom/hTDwK3H2idcOJFc= +github.com/tree-sitter/tree-sitter-javascript v0.21.5-0.20240818005344-15887341e5b5 h1:om4X9AVg3asL8gxNJDcz4e/Wp+VpQj1PY3uJXKr6EOg= +github.com/tree-sitter/tree-sitter-javascript v0.21.5-0.20240818005344-15887341e5b5/go.mod h1:nNqgPoV/h9uYWk6kYEFdEAhNVOacpfpRW5SFmdaP4tU= +github.com/tree-sitter/tree-sitter-json v0.21.1-0.20240818005659-bdd69eb8c8a5 h1:pfV3G3k7NCKqKk8THBmyuh2zA33lgYHS3GVrzRR8ry4= +github.com/tree-sitter/tree-sitter-json v0.21.1-0.20240818005659-bdd69eb8c8a5/go.mod h1:GbMKRjLfk0H+PI7nLi1Sx5lHf5wCpLz9al8tQYSxpEk= +github.com/tree-sitter/tree-sitter-php v0.22.9-0.20240819002312-a552625b56c1 h1:ZXZMDwE+IhUtGug4Brv6NjJWUU3rfkZBKpemf6RY8/g= +github.com/tree-sitter/tree-sitter-php v0.22.9-0.20240819002312-a552625b56c1/go.mod h1:UKCLuYnJ312Mei+3cyTmGOHzn0YAnaPRECgJmHtzrqs= +github.com/tree-sitter/tree-sitter-python v0.21.1-0.20240818005537-55a9b8a4fbfb h1:EXEM82lFM7JjJb6qiKZXkpIDaCcbV2obNn82ghwj9lw= +github.com/tree-sitter/tree-sitter-python v0.21.1-0.20240818005537-55a9b8a4fbfb/go.mod h1:lXCF1nGG5Dr4J3BTS0ObN4xJCCICiSu/b+Xe/VqMV7g= +github.com/tree-sitter/tree-sitter-ruby v0.21.1-0.20240818211811-7dbc1e2d0e2d h1:fcYCvoXdcP1uRQYXqJHRy6Hec+uKScQdKVtMwK9JeCI= +github.com/tree-sitter/tree-sitter-ruby v0.21.1-0.20240818211811-7dbc1e2d0e2d/go.mod h1:T1nShQ4v5AJtozZ8YyAS4uzUtDAJj/iv4YfwXSbUHzg= +github.com/tree-sitter/tree-sitter-rust v0.21.3-0.20240818005432-2b43eafe6447 h1:o9alBu1J/WjrcTKEthYtXmdkDc5OVXD+PqlvnEZ0Lzc= +github.com/tree-sitter/tree-sitter-rust v0.21.3-0.20240818005432-2b43eafe6447/go.mod h1:1Oh95COkkTn6Ezp0vcMbvfhRP5gLeqqljR0BYnBzWvc= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/package-lock.json b/package-lock.json index 754e10e..21b09f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,20 +10,20 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.1" + "node-addon-api": "^8.1.0", + "node-gyp-build": "^4.8.2" }, "devDependencies": { "eslint": ">=8.57.0", "eslint-config-google": "^0.14.0", "prebuildify": "^6.0.1", - "tree-sitter-cli": "^0.22.6" + "tree-sitter-cli": "^0.23.0" }, "peerDependencies": { "tree-sitter": "^0.21.0" }, "peerDependenciesMeta": { - "tree_sitter": { + "tree-sitter": { "optional": true } } @@ -967,17 +967,17 @@ } }, "node_modules/node-addon-api": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.0.0.tgz", - "integrity": "sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.1.0.tgz", + "integrity": "sha512-yBY+qqWSv3dWKGODD6OGE6GnTX7Q2r+4+DfpqxHSHh8x0B4EKP9+wVGLS6U/AM1vxSNNmUEuIV5EGhYwPpfOwQ==", "engines": { "node": "^18 || ^20 || >= 21" } }, "node_modules/node-gyp-build": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.1.tgz", - "integrity": "sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==", + "version": "4.8.2", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.2.tgz", + "integrity": "sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==", "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -1367,6 +1367,7 @@ "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.21.1.tgz", "integrity": "sha512-7dxoA6kYvtgWw80265MyqJlkRl4yawIjO7S5MigytjELkX43fV2WsAXzsNfO7sBpPPCF5Gp0+XzHk0DwLCq3xQ==", "hasInstallScript": true, + "optional": true, "peer": true, "dependencies": { "node-addon-api": "^8.0.0", @@ -1374,13 +1375,16 @@ } }, "node_modules/tree-sitter-cli": { - "version": "0.22.6", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.22.6.tgz", - "integrity": "sha512-s7mYOJXi8sIFkt/nLJSqlYZP96VmKTc3BAwIX0rrrlRxWjWuCwixFqwzxWZBQz4R8Hx01iP7z3cT3ih58BUmZQ==", + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.23.0.tgz", + "integrity": "sha512-/DdQaPCCOrOYGp9FxGdhFUnHIrjhfbYatQXgNIcmaAOpPunpnDj2vsO/H+svsfQLaFsQ1C+BjgPhpbV28zka1w==", "dev": true, "hasInstallScript": true, "bin": { "tree-sitter": "cli.js" + }, + "engines": { + "node": ">=12.0.0" } }, "node_modules/type-check": { diff --git a/package.json b/package.json index a5257de..4441342 100644 --- a/package.json +++ b/package.json @@ -25,31 +25,29 @@ "src/**" ], "dependencies": { - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.1" + "node-addon-api": "^8.1.0", + "node-gyp-build": "^4.8.2" }, "peerDependencies": { "tree-sitter": "^0.21.0" }, "peerDependenciesMeta": { - "tree_sitter": { + "tree-sitter": { "optional": true } }, "devDependencies": { "eslint": ">=8.57.0", "eslint-config-google": "^0.14.0", - "tree-sitter-cli": "^0.22.6", + "tree-sitter-cli": "^0.23.0", "prebuildify": "^6.0.1" }, "scripts": { "install": "node-gyp-build", - "prebuildify": "prebuildify --napi --strip", - "build": "tree-sitter generate --no-bindings", - "build-wasm": "tree-sitter build --wasm", "lint": "eslint grammar.js", - "parse": "tree-sitter parse", - "test": "tree-sitter test" + "prestart": "tree-sitter build --wasm", + "start": "tree-sitter playground", + "test": "node --test bindings/node/*_test.js" }, "tree-sitter": [ { diff --git a/pyproject.toml b/pyproject.toml index fe11e10..75736d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ authors = [ { name = "Max Brunsfeld", email = "maxbrunsfeld@gmail.com" }, { name = "Amaan Qureshi", email = "amaanq12@gmail.com" }, ] -requires-python = ">=3.8" +requires-python = ">=3.9" license.text = "MIT" readme = "README.md" @@ -29,5 +29,5 @@ Homepage = "https://github.com/tree-sitter/tree-sitter-embedded-template" core = ["tree-sitter~=0.21"] [tool.cibuildwheel] -build = "cp38-*" +build = "cp39-*" build-frontend = "build" diff --git a/setup.py b/setup.py index fe6be5d..ebd1cea 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ class BdistWheel(bdist_wheel): def get_tag(self): python, abi, platform = super().get_tag() if python.startswith("cp"): - python, abi = "cp38", "abi3" + python, abi = "cp39", "abi3" return python, abi, platform @@ -37,12 +37,17 @@ def get_tag(self): "bindings/python/tree_sitter_embedded_template/binding.c", "src/parser.c", ], - extra_compile_args=( - ["-std=c11"] if system() != 'Windows' else [] - ), + extra_compile_args=[ + "-std=c11", + "-fvisibility=hidden", + ] if system() != "Windows" else [ + "/std:c11", + "/utf-8", + ], define_macros=[ - ("Py_LIMITED_API", "0x03080000"), - ("PY_SSIZE_T_CLEAN", None) + ("Py_LIMITED_API", "0x03090000"), + ("PY_SSIZE_T_CLEAN", None), + ("TREE_SITTER_HIDE_SYMBOLS", None), ], include_dirs=["src"], py_limited_api=True, diff --git a/src/parser.c b/src/parser.c index 785399d..5425e59 100644 --- a/src/parser.c +++ b/src/parser.c @@ -269,8 +269,8 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = { [15] = 15, [16] = 16, [17] = 17, - [18] = 16, - [19] = 17, + [18] = 17, + [19] = 16, [20] = 20, [21] = 21, [22] = 16, @@ -468,8 +468,8 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [11] = {.lex_state = 14}, [12] = {.lex_state = 14}, [13] = {.lex_state = 14}, - [14] = {.lex_state = 1}, - [15] = {.lex_state = 2}, + [14] = {.lex_state = 2}, + [15] = {.lex_state = 1}, [16] = {.lex_state = 1}, [17] = {.lex_state = 1}, [18] = {.lex_state = 2}, @@ -496,13 +496,13 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_EQ_PERCENT_GT] = ACTIONS(1), }, [1] = { - [sym_template] = STATE(28), - [sym_content] = STATE(3), - [sym_directive] = STATE(3), - [sym_output_directive] = STATE(3), - [sym_comment_directive] = STATE(3), - [sym_graphql_directive] = STATE(3), - [aux_sym_template_repeat1] = STATE(3), + [sym_template] = STATE(26), + [sym_content] = STATE(2), + [sym_directive] = STATE(2), + [sym_output_directive] = STATE(2), + [sym_comment_directive] = STATE(2), + [sym_graphql_directive] = STATE(2), + [aux_sym_template_repeat1] = STATE(2), [aux_sym_content_repeat1] = STATE(4), [ts_builtin_sym_end] = ACTIONS(3), [aux_sym_content_token1] = ACTIONS(5), @@ -519,36 +519,14 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_LT_PERCENTgraphql] = ACTIONS(19), }, [2] = { - [sym_content] = STATE(2), - [sym_directive] = STATE(2), - [sym_output_directive] = STATE(2), - [sym_comment_directive] = STATE(2), - [sym_graphql_directive] = STATE(2), - [aux_sym_template_repeat1] = STATE(2), + [sym_content] = STATE(3), + [sym_directive] = STATE(3), + [sym_output_directive] = STATE(3), + [sym_comment_directive] = STATE(3), + [sym_graphql_directive] = STATE(3), + [aux_sym_template_repeat1] = STATE(3), [aux_sym_content_repeat1] = STATE(4), [ts_builtin_sym_end] = ACTIONS(21), - [aux_sym_content_token1] = ACTIONS(23), - [anon_sym_LT_PERCENT_PERCENT] = ACTIONS(26), - [anon_sym_LT_PERCENT] = ACTIONS(29), - [anon_sym_LT_PERCENT_] = ACTIONS(32), - [anon_sym_LT_PERCENT_PIPE] = ACTIONS(29), - [anon_sym_LT_PERCENT_EQ] = ACTIONS(35), - [anon_sym_LT_PERCENT_EQ_EQ] = ACTIONS(38), - [anon_sym_LT_PERCENT_PIPE_EQ] = ACTIONS(35), - [anon_sym_LT_PERCENT_PIPE_EQ_EQ] = ACTIONS(38), - [anon_sym_LT_PERCENT_DASH] = ACTIONS(38), - [anon_sym_LT_PERCENT_POUND] = ACTIONS(41), - [anon_sym_LT_PERCENTgraphql] = ACTIONS(44), - }, - [3] = { - [sym_content] = STATE(2), - [sym_directive] = STATE(2), - [sym_output_directive] = STATE(2), - [sym_comment_directive] = STATE(2), - [sym_graphql_directive] = STATE(2), - [aux_sym_template_repeat1] = STATE(2), - [aux_sym_content_repeat1] = STATE(4), - [ts_builtin_sym_end] = ACTIONS(47), [aux_sym_content_token1] = ACTIONS(5), [anon_sym_LT_PERCENT_PERCENT] = ACTIONS(7), [anon_sym_LT_PERCENT] = ACTIONS(9), @@ -562,6 +540,28 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_LT_PERCENT_POUND] = ACTIONS(17), [anon_sym_LT_PERCENTgraphql] = ACTIONS(19), }, + [3] = { + [sym_content] = STATE(3), + [sym_directive] = STATE(3), + [sym_output_directive] = STATE(3), + [sym_comment_directive] = STATE(3), + [sym_graphql_directive] = STATE(3), + [aux_sym_template_repeat1] = STATE(3), + [aux_sym_content_repeat1] = STATE(4), + [ts_builtin_sym_end] = ACTIONS(23), + [aux_sym_content_token1] = ACTIONS(25), + [anon_sym_LT_PERCENT_PERCENT] = ACTIONS(28), + [anon_sym_LT_PERCENT] = ACTIONS(31), + [anon_sym_LT_PERCENT_] = ACTIONS(34), + [anon_sym_LT_PERCENT_PIPE] = ACTIONS(31), + [anon_sym_LT_PERCENT_EQ] = ACTIONS(37), + [anon_sym_LT_PERCENT_EQ_EQ] = ACTIONS(40), + [anon_sym_LT_PERCENT_PIPE_EQ] = ACTIONS(37), + [anon_sym_LT_PERCENT_PIPE_EQ_EQ] = ACTIONS(40), + [anon_sym_LT_PERCENT_DASH] = ACTIONS(40), + [anon_sym_LT_PERCENT_POUND] = ACTIONS(43), + [anon_sym_LT_PERCENTgraphql] = ACTIONS(46), + }, }; static const uint16_t ts_small_parse_table[] = { @@ -738,27 +738,27 @@ static const uint16_t ts_small_parse_table[] = { aux_sym_code_token1, ACTIONS(101), 1, anon_sym_PERCENT_PERCENT_GT, - STATE(16), 1, + STATE(19), 1, aux_sym_code_repeat1, STATE(25), 1, sym_code, ACTIONS(103), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, - anon_sym__PERCENT_GT, + anon_sym_EQ_PERCENT_GT, [212] = 5, ACTIONS(105), 1, aux_sym_code_token1, ACTIONS(107), 1, anon_sym_PERCENT_PERCENT_GT, - STATE(18), 1, + STATE(16), 1, aux_sym_code_repeat1, STATE(24), 1, sym_code, ACTIONS(109), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, - anon_sym_EQ_PERCENT_GT, + anon_sym__PERCENT_GT, [230] = 4, ACTIONS(111), 1, aux_sym_code_token1, @@ -784,22 +784,22 @@ static const uint16_t ts_small_parse_table[] = { [260] = 4, ACTIONS(125), 1, aux_sym_code_token1, - ACTIONS(127), 1, + ACTIONS(128), 1, anon_sym_PERCENT_PERCENT_GT, - STATE(19), 1, + STATE(18), 1, aux_sym_code_repeat1, - ACTIONS(115), 3, + ACTIONS(123), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, anon_sym_EQ_PERCENT_GT, [275] = 4, - ACTIONS(129), 1, + ACTIONS(131), 1, aux_sym_code_token1, - ACTIONS(132), 1, + ACTIONS(133), 1, anon_sym_PERCENT_PERCENT_GT, - STATE(19), 1, + STATE(18), 1, aux_sym_code_repeat1, - ACTIONS(123), 3, + ACTIONS(115), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, anon_sym_EQ_PERCENT_GT, @@ -812,7 +812,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_PERCENT_GT, STATE(22), 1, aux_sym_code_repeat1, - STATE(26), 1, + STATE(28), 1, sym_code, [306] = 5, ACTIONS(135), 1, @@ -847,21 +847,21 @@ static const uint16_t ts_small_parse_table[] = { ACTIONS(153), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, - anon_sym_EQ_PERCENT_GT, + anon_sym__PERCENT_GT, [354] = 1, ACTIONS(155), 3, anon_sym_PERCENT_GT, anon_sym_DASH_PERCENT_GT, - anon_sym__PERCENT_GT, + anon_sym_EQ_PERCENT_GT, [360] = 1, ACTIONS(157), 1, - anon_sym_PERCENT_GT, + ts_builtin_sym_end, [364] = 1, ACTIONS(159), 1, anon_sym_PERCENT_GT, [368] = 1, ACTIONS(161), 1, - ts_builtin_sym_end, + anon_sym_PERCENT_GT, }; static const uint32_t ts_small_parse_table_map[] = { @@ -898,22 +898,22 @@ static const TSParseActionEntry ts_parse_actions[] = { [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_template, 0, 0, 0), [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4), [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), - [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), - [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), - [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), - [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), + [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), - [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), - [23] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(4), - [26] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(4), - [29] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(14), - [32] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(14), - [35] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(15), - [38] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(15), - [41] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(20), - [44] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(21), - [47] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_template, 1, 0, 0), + [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_template, 1, 0, 0), + [23] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), + [25] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(4), + [28] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(4), + [31] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(15), + [34] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(15), + [37] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(14), + [40] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(14), + [43] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(20), + [46] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_template_repeat1, 2, 0, 0), SHIFT_REPEAT(21), [49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_content, 1, 0, 0), [51] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5), [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), @@ -922,51 +922,51 @@ static const TSParseActionEntry ts_parse_actions[] = { [59] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_content_repeat1, 2, 0, 0), SHIFT_REPEAT(5), [62] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_content_repeat1, 2, 0, 0), SHIFT_REPEAT(5), [65] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_content_repeat1, 2, 0, 0), - [67] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment_directive, 2, 0, 0), - [69] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment_directive, 2, 0, 0), - [71] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_output_directive, 3, 0, 0), - [73] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_output_directive, 3, 0, 0), + [67] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_directive, 2, 0, 0), + [69] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_directive, 2, 0, 0), + [71] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_output_directive, 2, 0, 0), + [73] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_output_directive, 2, 0, 0), [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_graphql_directive, 3, 0, 0), [77] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_graphql_directive, 3, 0, 0), - [79] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_directive, 2, 0, 0), - [81] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_directive, 2, 0, 0), - [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment_directive, 3, 0, 1), - [85] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment_directive, 3, 0, 1), - [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_directive, 3, 0, 0), - [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_directive, 3, 0, 0), - [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_output_directive, 2, 0, 0), - [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_output_directive, 2, 0, 0), - [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_graphql_directive, 2, 0, 0), - [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_graphql_directive, 2, 0, 0), - [99] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), - [101] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [103] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), - [105] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), - [107] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), - [109] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [79] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_directive, 3, 0, 0), + [81] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_directive, 3, 0, 0), + [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment_directive, 2, 0, 0), + [85] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment_directive, 2, 0, 0), + [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_graphql_directive, 2, 0, 0), + [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_graphql_directive, 2, 0, 0), + [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_output_directive, 3, 0, 0), + [93] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_output_directive, 3, 0, 0), + [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment_directive, 3, 0, 1), + [97] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment_directive, 3, 0, 1), + [99] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19), + [101] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [103] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [105] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), + [107] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), + [109] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), [111] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), [113] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_code, 1, 0, 0), [117] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(17), [120] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(17), [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), - [125] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19), - [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [129] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(19), - [132] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(19), + [125] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(18), + [128] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(18), + [131] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), + [133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), [135] = {.entry = {.count = 1, .reusable = false}}, SHIFT(22), [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), - [139] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), - [141] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [139] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [141] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), [143] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23), [145] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), [147] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(23), [150] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_code_repeat1, 2, 0, 0), SHIFT_REPEAT(23), - [153] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), - [155] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), - [157] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [153] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [155] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [157] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), [159] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), - [161] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [161] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), }; #ifdef __cplusplus diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index 17f0e94..799f599 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -47,6 +47,7 @@ struct TSLexer { uint32_t (*get_column)(TSLexer *); bool (*is_at_included_range_start)(const TSLexer *); bool (*eof)(const TSLexer *); + void (*log)(const TSLexer *, const char *, ...); }; typedef enum {