tree-sitter-sed 0.15.0 → 0.17.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 CHANGED
@@ -1,43 +1,41 @@
1
1
  [package]
2
- authors = ["konomanoasa"]
3
- autoexamples = false
4
- categories = ["parser-implementations", "parsing", "text-editors"]
5
- description = "Tree-sitter grammars for POSIX sed."
6
- edition = "2024"
7
- keywords = ["incremental", "parsing", "tree-sitter", "sed"]
8
- license = "MIT"
9
2
  name = "tree-sitter-sed"
10
- publish = false
3
+ version = "0.17.0"
4
+ edition = "2024"
5
+ description = "Tree-sitter grammars for POSIX sed."
11
6
  readme = "README.md"
12
7
  repository = "https://github.com/konomanoasa/tree-sitter-sed"
13
- version = "0.15.0"
14
-
8
+ license = "MIT"
15
9
  build = "bindings/rust/build.rs"
10
+ links = "tree-sitter-sed"
16
11
  include = [
17
12
  "/LICENSE",
18
13
  "/README.md",
19
14
  "/bindings/rust/*.rs",
20
- "/common/scanner.h",
15
+ "/common/**/*.h",
21
16
  "/queries/*.scm",
22
17
  "/sed_ere/queries/*.scm",
18
+ "/sed_ere/src/*.c",
23
19
  "/sed_ere/src/node-types.json",
24
- "/sed_ere/src/parser.c",
25
- "/sed_ere/src/scanner.c",
26
20
  "/sed_ere/src/tree_sitter/*.h",
21
+ "/src/*.c",
27
22
  "/src/node-types.json",
28
- "/src/parser.c",
29
- "/src/scanner.c",
30
23
  "/src/tree_sitter/*.h",
24
+ "/test/bindings.test.rs",
31
25
  ]
32
26
 
33
27
  [lib]
34
28
  path = "bindings/rust/lib.rs"
35
29
 
36
- [dependencies]
37
- tree-sitter-language = "0.1"
30
+ [[test]]
31
+ name = "bindings"
32
+ path = "test/bindings.test.rs"
38
33
 
39
- [build-dependencies]
40
- cc = "1.2"
34
+ [dependencies]
35
+ tree-sitter-language = "0.1.8"
41
36
 
42
37
  [dev-dependencies]
43
38
  tree-sitter = "0.27.0"
39
+
40
+ [build-dependencies]
41
+ cc = "1.4"
package/README.md CHANGED
@@ -1,39 +1,38 @@
1
1
  # tree-sitter-sed
2
2
 
3
- [![CI](https://github.com/konomanoasa/tree-sitter-sed/actions/workflows/ci.yml/badge.svg)](https://github.com/konomanoasa/tree-sitter-sed/actions/workflows/ci.yml)
3
+ [![CI](https://github.com/konomanoasa/tree-sitter-sed/actions/workflows/ci.yaml/badge.svg)](https://github.com/konomanoasa/tree-sitter-sed/actions/workflows/ci.yaml)
4
+ [![crates.io](https://img.shields.io/crates/v/tree-sitter-sed)](https://crates.io/crates/tree-sitter-sed)
4
5
  [![npm](https://img.shields.io/npm/v/tree-sitter-sed)](https://www.npmjs.com/package/tree-sitter-sed)
5
6
 
6
7
  [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammars for
7
- POSIX.1-2024 `sed`.
8
+ POSIX.1-2024 sed.
8
9
 
9
10
  ## Installation
10
11
 
11
- ### npm
12
-
13
12
  ```sh
14
13
  npm install tree-sitter-sed
15
14
  ```
16
15
 
17
16
  ## Grammars
18
17
 
19
- This repository contains the following two grammars.
20
-
21
- | Grammar | Regexp | Rust constant |
22
- | --------- | ------ | -------------- |
23
- | `sed` | BRE | `LANGUAGE` |
24
- | `sed_ere` | ERE | `LANGUAGE_ERE` |
18
+ | Grammar | Description |
19
+ | --------- | ------------------------- |
20
+ | `sed` | POSIX.1-2024 sed with BRE |
21
+ | `sed_ere` | POSIX.1-2024 sed with ERE |
25
22
 
26
23
  ## Development
27
24
 
25
+ Development uses Node.js 24 or later.
26
+
28
27
  ```sh
29
28
  npm install
30
- npm run parse -- script.sed
31
- npm run parse:ere -- script.sed
29
+ npm run build
30
+ npm test
32
31
  ```
33
32
 
34
33
  ## Specifications
35
34
 
36
- - [POSIX.1-2024 `sed`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/sed.html)
35
+ - [POSIX.1-2024 sed](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/sed.html)
37
36
  - [POSIX.1-2024 regular expressions](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/V1_chap09.html)
38
37
 
39
38
  ## License
@@ -1,50 +1,31 @@
1
- use std::path::Path;
1
+ use std::{env, path::Path};
2
2
 
3
- fn compile_parser(
4
- source_dir: &Path,
5
- library_name: &str,
6
- wasm_headers: Option<&Path>,
7
- ) {
8
- let parser_path = source_dir.join("parser.c");
9
- let scanner_path = source_dir.join("scanner.c");
10
- let mut c_config = cc::Build::new();
11
- c_config.std("c17").include(source_dir);
12
-
13
- if c_config.get_compiler().is_like_msvc() {
14
- c_config.flag("-utf-8");
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");
15
8
  }
16
-
17
- if let Some(headers) = wasm_headers {
18
- c_config.include(headers);
19
- println!("cargo:rerun-if-changed={}", headers.display());
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());
20
16
  }
21
17
 
22
- c_config.file(&parser_path).file(&scanner_path);
23
- c_config.compile(library_name);
24
-
25
- println!("cargo:rerun-if-changed={}", parser_path.display());
26
- println!("cargo:rerun-if-changed={}", scanner_path.display());
27
- println!(
28
- "cargo:rerun-if-changed={}",
29
- source_dir.join("tree_sitter").display()
30
- );
31
- }
32
-
33
- fn main() {
34
- let target = std::env::var("TARGET").expect("Cargo must provide TARGET");
35
- let wasm_headers = (target == "wasm32-unknown-unknown").then(|| {
36
- std::env::var_os("DEP_TREE_SITTER_LANGUAGE_WASM_HEADERS")
37
- .map(std::path::PathBuf::from)
38
- .expect(
39
- "tree-sitter-language must provide headers for wasm32-unknown-unknown",
40
- )
41
- });
42
-
43
- compile_parser(Path::new("src"), "tree-sitter-sed", wasm_headers.as_deref());
44
- compile_parser(
45
- Path::new("sed_ere/src"),
46
- "tree-sitter-sed-ere",
47
- wasm_headers.as_deref(),
48
- );
49
- println!("cargo:rerun-if-changed=common/scanner.h");
18
+ for (directory, library) in [
19
+ ("src", "tree-sitter-sed"),
20
+ ("sed_ere/src", "tree-sitter-sed-ere"),
21
+ ] {
22
+ println!("cargo::rerun-if-changed={directory}");
23
+ let directory = Path::new(directory);
24
+ build
25
+ .clone()
26
+ .include(directory)
27
+ .files([directory.join("parser.c"), directory.join("scanner.c")])
28
+ .compile(library);
29
+ }
30
+ println!("cargo::rerun-if-changed=common/scanner.h");
50
31
  }