From 1aafaff4d26dac5a36dd3495be33e1c20161d761 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 7 Apr 2024 02:22:00 -0400 Subject: [PATCH] build: update bindings --- .eslintrc.js | 20 -------- .npmignore | 5 -- Cargo.toml | 6 +-- Makefile | 3 +- Package.swift | 3 +- bindings/python/tree_sitter_c/__init__.py | 2 + bindings/rust/build.rs | 2 +- bindings/rust/lib.rs | 14 +++--- bindings/swift/TreeSitterC/c.h | 4 +- grammar.js | 6 +-- package-lock.json | 44 ++++++++--------- package.json | 60 ++++++++++++++++++++--- pyproject.toml | 2 +- 13 files changed, 94 insertions(+), 77 deletions(-) delete mode 100644 .eslintrc.js delete mode 100644 .npmignore diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b2e707a9..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - 'env': { - 'commonjs': true, - 'es2021': true, - }, - 'extends': 'google', - 'overrides': [ - ], - 'parserOptions': { - 'ecmaVersion': 'latest', - 'sourceType': 'module', - }, - 'rules': { - 'indent': ['error', 2, {'SwitchCase': 1}], - 'max-len': [ - 'error', - {'code': 120, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true}, - ], - }, -}; diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 194ff845..00000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -/test -/examples -/build -/script -/target diff --git a/Cargo.toml b/Cargo.toml index 8c995770..6edec5c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "tree-sitter-c" description = "C grammar for tree-sitter" -version = "0.21.0" +version = "0.21.1" authors = [ "Max Brunsfeld ", - "Amaan Qureshi ", ] license = "MIT" keywords = ["incremental", "parsing", "tree-sitter", "c"] @@ -23,4 +23,4 @@ path = "bindings/rust/lib.rs" tree-sitter = ">=0.21.0" [build-dependencies] -cc = "^1.0.89" +cc = "1.0.90" diff --git a/Makefile b/Makefile index 4f0a9600..abba2ece 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.0.1 +VERSION := 0.21.1 LANGUAGE_NAME := tree-sitter-c @@ -106,5 +106,6 @@ clean: test: $(TS) test + $(TS) parse examples/* --quiet --time .PHONY: all install uninstall clean test diff --git a/Package.swift b/Package.swift index 27bcdb44..e409f263 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,6 @@ import PackageDescription let package = Package( name: "TreeSitterC", - platforms: [.macOS(.v10_13), .iOS(.v11)], products: [ .library(name: "TreeSitterC", targets: ["TreeSitterC"]), ], @@ -27,12 +26,12 @@ let package = Package( "pyproject.toml", "setup.py", "test", - "types", "examples", ".editorconfig", ".github", ".gitignore", ".gitattributes", + ".gitmodules", ], sources: [ "src/parser.c", diff --git a/bindings/python/tree_sitter_c/__init__.py b/bindings/python/tree_sitter_c/__init__.py index bbb6614a..714cba64 100644 --- a/bindings/python/tree_sitter_c/__init__.py +++ b/bindings/python/tree_sitter_c/__init__.py @@ -1,3 +1,5 @@ "C grammar for tree-sitter" from ._binding import language + +__all__ = ["language"] diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 27193eaa..e545800a 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -2,7 +2,7 @@ fn main() { let src_dir = std::path::Path::new("src"); let mut c_config = cc::Build::new(); - c_config.include(src_dir); + c_config.std("c11").include(src_dir); let parser_path = src_dir.join("parser.c"); c_config.file(&parser_path); diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index bd410444..7351f38c 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,6 +1,6 @@ -//! This crate provides a C grammar for the [tree-sitter][] parsing library. +//! This crate provides C language support for the [tree-sitter][] parsing library. //! -//! Typically, you will use the [language][language func] function to add this grammar to a +//! 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: //! //! ``` @@ -13,10 +13,8 @@ //! "#; //! let mut parser = Parser::new(); //! parser.set_language(&tree_sitter_c::language()).expect("Error loading C grammar"); -//! let parsed = parser.parse(code, None); -//! # let parsed = parsed.unwrap(); -//! # let root = parsed.root_node(); -//! # assert!(!root.has_error()); +//! let tree = parser.parse(code, None).unwrap(); +//! assert!(!tree.root_node().has_error()); //! ``` //! //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html @@ -30,7 +28,7 @@ extern "C" { fn tree_sitter_c() -> Language; } -/// Returns the tree-sitter [Language][] for this grammar. +/// Get the tree-sitter [Language][] for this grammar. /// /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html pub fn language() -> Language { @@ -51,7 +49,7 @@ pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm"); #[cfg(test)] mod tests { #[test] - fn can_load_grammar() { + fn test_can_load_grammar() { let mut parser = tree_sitter::Parser::new(); parser .set_language(&super::language()) diff --git a/bindings/swift/TreeSitterC/c.h b/bindings/swift/TreeSitterC/c.h index ae1557a4..e725f1e2 100644 --- a/bindings/swift/TreeSitterC/c.h +++ b/bindings/swift/TreeSitterC/c.h @@ -7,10 +7,10 @@ typedef struct TSLanguage TSLanguage; extern "C" { #endif -extern TSLanguage *tree_sitter_c(); +const TSLanguage *tree_sitter_c(void); #ifdef __cplusplus } #endif -#endif // TREE_SITTER_C_H_ \ No newline at end of file +#endif // TREE_SITTER_C_H_ diff --git a/grammar.js b/grammar.js index cfe6724f..8c127897 100644 --- a/grammar.js +++ b/grammar.js @@ -1,12 +1,10 @@ /** * @file C grammar for tree-sitter - * @author Max Brunsfeld + * @author Max Brunsfeld + * @author Amaan Qureshi * @license MIT */ -/* eslint-disable arrow-parens */ -/* eslint-disable camelcase */ -/* eslint-disable-next-line spaced-comment */ /// // @ts-check diff --git a/package-lock.json b/package-lock.json index b863cb4c..bce76afd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,23 @@ { "name": "tree-sitter-c", - "version": "0.21.0", + "version": "0.21.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tree-sitter-c", - "version": "0.21.0", + "version": "0.21.1", "hasInstallScript": true, "license": "MIT", "dependencies": { - "node-addon-api": "^7.1.0", + "node-addon-api": "^8.0.0", "node-gyp-build": "^4.8.0" }, "devDependencies": { - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-config-google": "^0.14.0", "prebuildify": "^6.0.0", - "tree-sitter-cli": "^0.21.0" + "tree-sitter-cli": "^0.22.2" }, "peerDependencies": { "tree-sitter": "^0.21.0" @@ -121,9 +121,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "node_modules/@nodelib/fs.scandir": { @@ -973,9 +973,9 @@ "dev": true }, "node_modules/node-abi": { - "version": "3.56.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", - "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", + "version": "3.57.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.57.0.tgz", + "integrity": "sha512-Dp+A9JWxRaKuHP35H77I4kCKesDy5HUDEmScia2FyncMTOXASMyg251F5PhFoDA5uqBrDDffiLpbqnrZmNXW+g==", "dev": true, "dependencies": { "semver": "^7.3.5" @@ -985,11 +985,11 @@ } }, "node_modules/node-addon-api": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.0.tgz", - "integrity": "sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==", + "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==", "engines": { - "node": "^16 || ^18 || >= 20" + "node": "^18 || ^20 || >= 21" } }, "node_modules/node-gyp-build": { @@ -1382,20 +1382,20 @@ "dev": true }, "node_modules/tree-sitter": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.21.0.tgz", - "integrity": "sha512-WDhpLxQdW7wsmmnBsf4NGqnEKs+Kxljk/CfbJJxgzZiinfA1gAWnhi/GirQjClw+woXhYsNq930BlskFulMMBQ==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.21.1.tgz", + "integrity": "sha512-7dxoA6kYvtgWw80265MyqJlkRl4yawIjO7S5MigytjELkX43fV2WsAXzsNfO7sBpPPCF5Gp0+XzHk0DwLCq3xQ==", "hasInstallScript": true, "peer": true, "dependencies": { - "node-addon-api": "^7.1.0", + "node-addon-api": "^8.0.0", "node-gyp-build": "^4.8.0" } }, "node_modules/tree-sitter-cli": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.21.0.tgz", - "integrity": "sha512-wA7wT5724fNQW82XDH6zT6ZcYonjrAKLCHHuhLsPcAKULrhp3rNuMvlgBdB5FUBvmjHNhtTZF/qpHenMoRJPBw==", + "version": "0.22.2", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.22.2.tgz", + "integrity": "sha512-ecqccEp27XMFXgjLMEEU71vK9JCWAC7fqSTTxcs5P1tnEnaaf4GkHz/wfo4lJ9l3rfxcTDPxN84tHAoitIQqdA==", "dev": true, "hasInstallScript": true, "bin": { diff --git a/package.json b/package.json index bfd4e4cb..d2c62034 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tree-sitter-c", - "version": "0.21.0", + "version": "0.21.1", "description": "C grammar for tree-sitter", "repository": "github:tree-sitter/tree-sitter-c", "license": "MIT", @@ -25,7 +25,7 @@ "src/**" ], "dependencies": { - "node-addon-api": "^7.1.0", + "node-addon-api": "^8.0.0", "node-gyp-build": "^4.8.0" }, "peerDependencies": { @@ -37,17 +37,19 @@ } }, "devDependencies": { - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-config-google": "^0.14.0", - "tree-sitter-cli": "^0.21.0", + "tree-sitter-cli": "^0.22.2", "prebuildify": "^6.0.0" }, "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", - "test": "tree-sitter test", - "install": "node-gyp-build", - "prebuildify": "prebuildify --napi --strip" + "parse": "tree-sitter parse", + "test": "tree-sitter test" }, "tree-sitter": [ { @@ -60,5 +62,47 @@ "highlights": "queries/highlights.scm", "tags": "queries/tags.scm" } - ] + ], + "eslintConfig": { + "env": { + "commonjs": true, + "es2021": true + }, + "extends": "google", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "arrow-parens": "off", + "camel-case": "off", + "indent": [ + "error", + 2, + { + "SwitchCase": 1 + } + ], + "max-len": [ + "error", + { + "code": 160, + "ignoreComments": true, + "ignoreUrls": true, + "ignoreStrings": true + } + ], + "spaced-comment": [ + "warn", + "always", + { + "line": { + "markers": [ + "/" + ] + } + } + ] + } + } } diff --git a/pyproject.toml b/pyproject.toml index 9e29481b..b2c89048 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "tree-sitter-c" description = "C grammar for tree-sitter" -version = "0.21.0" +version = "0.21.1" keywords = ["incremental", "parsing", "tree-sitter", "c"] classifiers = [ "Intended Audience :: Developers",