@konomanoasa/tree-sitter-gyp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml ADDED
@@ -0,0 +1,36 @@
1
+ [package]
2
+ name = "konomanoasa-tree-sitter-gyp"
3
+ version = "0.1.0"
4
+ description = "Tree-sitter grammar for GYP."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ repository = "https://github.com/konomanoasa/tree-sitter-gyp"
8
+ edition = "2024"
9
+ build = "bindings/rust/build.rs"
10
+ links = "tree-sitter-gyp"
11
+ include = [
12
+ "/LICENSE",
13
+ "/README.md",
14
+ "/bindings/rust/*.rs",
15
+ "/queries/*.scm",
16
+ "/src/*.c",
17
+ "/src/node-types.json",
18
+ "/src/tree_sitter/*.h",
19
+ "/test/bindings.test.rs",
20
+ ]
21
+
22
+ [lib]
23
+ path = "bindings/rust/lib.rs"
24
+
25
+ [[test]]
26
+ name = "bindings"
27
+ path = "test/bindings.test.rs"
28
+
29
+ [dependencies]
30
+ tree-sitter-language = "=0.1.9"
31
+
32
+ [dev-dependencies]
33
+ tree-sitter = "=0.27.1"
34
+
35
+ [build-dependencies]
36
+ cc = "=1.10.0"
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 konomanoasa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # tree-sitter-gyp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/konomanoasa/tree-sitter-gyp/actions/workflows/ci.yaml/badge.svg)](https://github.com/konomanoasa/tree-sitter-gyp/actions/workflows/ci.yaml)
4
+ [![crates.io](https://img.shields.io/crates/v/konomanoasa-tree-sitter-gyp)](https://crates.io/crates/konomanoasa-tree-sitter-gyp)
5
+ [![npm](https://img.shields.io/npm/v/@konomanoasa/tree-sitter-gyp)](https://www.npmjs.com/package/@konomanoasa/tree-sitter-gyp)
6
+ [![PyPI](https://img.shields.io/pypi/v/konomanoasa-tree-sitter-gyp)](https://pypi.org/project/konomanoasa-tree-sitter-gyp/)
7
+
8
+ [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
9
+ Generate Your Projects.
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ npm install @konomanoasa/tree-sitter-gyp
15
+ ```
16
+
17
+ ## Development
18
+
19
+ ```sh
20
+ npm install
21
+ npm run build
22
+ npm test
23
+ ```
24
+
25
+ ## Specifications
26
+
27
+ - [GYP Input Format Reference](https://chromium.googlesource.com/external/gyp/+/refs/heads/md-pages/docs/InputFormatReference.md)
28
+ - [GYP Language Specification](https://chromium.googlesource.com/external/gyp/+/refs/heads/md-pages/docs/LanguageSpecification.md)
29
+
30
+ ## License
31
+
32
+ [MIT](LICENSE)
package/binding.gyp ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_gyp_binding",
5
+ "sources": [
6
+ "bindings/node/binding.cc",
7
+ "src/parser.c",
8
+ "src/scanner.c"
9
+ ],
10
+ "include_dirs": ["src"],
11
+ "dependencies": [
12
+ "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except"
13
+ ],
14
+ "cflags_c": ["-std=c17"],
15
+ "cflags_cc": ["-std=c++17"],
16
+ "msvs_settings": {
17
+ "VCCLCompilerTool": {
18
+ "AdditionalOptions": ["/utf-8"],
19
+ "AdditionalOptions!": ["-std:c++20"],
20
+ "LanguageStandard": "stdcpp17",
21
+ "LanguageStandard_C": "stdc17"
22
+ }
23
+ },
24
+ "target_conditions": [
25
+ [
26
+ "OS==\"mac\"",
27
+ {
28
+ "xcode_settings": {
29
+ "CLANG_CXX_LANGUAGE_STANDARD": "c++17",
30
+ "GCC_C_LANGUAGE_STANDARD": "c17",
31
+ "MACOSX_DEPLOYMENT_TARGET": "14.0"
32
+ }
33
+ }
34
+ ]
35
+ ]
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,25 @@
1
+ #include <napi.h>
2
+
3
+ struct TSLanguage;
4
+ extern "C" const TSLanguage *tree_sitter_gyp();
5
+
6
+ namespace {
7
+
8
+ constexpr napi_type_tag language_type_tag = {
9
+ 0x8AF2E5212AD58ABF,
10
+ 0xD5006CAD83ABBA16
11
+ };
12
+
13
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
14
+ auto language = Napi::External<TSLanguage>::New(
15
+ env,
16
+ const_cast<TSLanguage *>(tree_sitter_gyp())
17
+ );
18
+ language.TypeTag(&language_type_tag);
19
+ exports["language"] = language;
20
+ return exports;
21
+ }
22
+
23
+ }
24
+
25
+ NODE_API_MODULE(tree_sitter_gyp_binding, Init)
@@ -0,0 +1,7 @@
1
+ import type { Language } from "tree-sitter";
2
+
3
+ declare const binding: Language & {
4
+ HIGHLIGHTS_QUERY: string;
5
+ };
6
+
7
+ export default binding;
@@ -0,0 +1,14 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import load from "node-gyp-build";
4
+
5
+ const binding = load(fileURLToPath(new URL("../..", import.meta.url)));
6
+ binding.nodeTypeInfo = JSON.parse(
7
+ readFileSync(new URL("../../src/node-types.json", import.meta.url), "utf8"),
8
+ );
9
+ binding.HIGHLIGHTS_QUERY = readFileSync(
10
+ new URL("../../queries/highlights.scm", import.meta.url),
11
+ "utf8",
12
+ );
13
+
14
+ export default binding;
@@ -0,0 +1,9 @@
1
+ from importlib.resources import files
2
+
3
+ from .binding import language
4
+
5
+ HIGHLIGHTS_QUERY: str = (
6
+ files(__package__).joinpath("queries/highlights.scm").read_text("utf-8")
7
+ )
8
+
9
+ __all__ = ["HIGHLIGHTS_QUERY", "language"]
@@ -0,0 +1,27 @@
1
+ #include <Python.h>
2
+
3
+ #include "../../src/tree_sitter/parser.h"
4
+
5
+ const TSLanguage *tree_sitter_gyp(void);
6
+
7
+ static PyObject *language(PyObject *self, PyObject *args) {
8
+ (void)self;
9
+ (void)args;
10
+ return PyCapsule_New((void *)tree_sitter_gyp(), "tree_sitter.Language", NULL);
11
+ }
12
+
13
+ static PyMethodDef methods[] = {
14
+ {"language", language, METH_NOARGS, "Return the GYP language capsule."},
15
+ {NULL, NULL, 0, NULL},
16
+ };
17
+
18
+ static struct PyModuleDef module = {
19
+ PyModuleDef_HEAD_INIT,
20
+ .m_name = "binding",
21
+ .m_size = -1,
22
+ .m_methods = methods,
23
+ };
24
+
25
+ PyMODINIT_FUNC PyInit_binding(void) {
26
+ return PyModule_Create(&module);
27
+ }
@@ -0,0 +1,3 @@
1
+ from types import CapsuleType
2
+
3
+ def language() -> CapsuleType: ...
File without changes
@@ -0,0 +1,23 @@
1
+ use std::{env, path::Path};
2
+
3
+ fn main() {
4
+ let mut build = cc::Build::new();
5
+ build.std("c17");
6
+ if build.get_compiler().is_like_msvc() {
7
+ build.flag("-utf-8");
8
+ }
9
+ if env::var("TARGET").expect("Cargo must provide TARGET")
10
+ == "wasm32-unknown-unknown"
11
+ {
12
+ let headers = env::var_os("DEP_TREE_SITTER_LANGUAGE_WASM_HEADERS")
13
+ .expect("tree-sitter-language must provide WebAssembly headers");
14
+ build.include(&headers);
15
+ println!("cargo::rerun-if-changed={}", Path::new(&headers).display());
16
+ }
17
+
18
+ println!("cargo::rerun-if-changed=src");
19
+ build
20
+ .include("src")
21
+ .files(["src/parser.c", "src/scanner.c"])
22
+ .compile("tree-sitter-gyp");
23
+ }
@@ -0,0 +1,10 @@
1
+ use tree_sitter_language::LanguageFn;
2
+
3
+ unsafe extern "C" {
4
+ fn tree_sitter_gyp() -> *const ();
5
+ }
6
+
7
+ pub const LANGUAGE: LanguageFn =
8
+ unsafe { LanguageFn::from_raw(tree_sitter_gyp) };
9
+ pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
10
+ pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");