tree-sitter-sed 0.15.0 → 0.16.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,23 @@
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
11
- readme = "README.md"
12
- repository = "https://github.com/konomanoasa/tree-sitter-sed"
13
- version = "0.15.0"
14
-
3
+ version = "0.16.0"
4
+ edition = "2024"
15
5
  build = "bindings/rust/build.rs"
16
- include = [
17
- "/LICENSE",
18
- "/README.md",
19
- "/bindings/rust/*.rs",
20
- "/common/scanner.h",
21
- "/queries/*.scm",
22
- "/sed_ere/queries/*.scm",
23
- "/sed_ere/src/node-types.json",
24
- "/sed_ere/src/parser.c",
25
- "/sed_ere/src/scanner.c",
26
- "/sed_ere/src/tree_sitter/*.h",
27
- "/src/node-types.json",
28
- "/src/parser.c",
29
- "/src/scanner.c",
30
- "/src/tree_sitter/*.h",
31
- ]
6
+ links = "tree-sitter-sed"
7
+ publish = false
32
8
 
33
9
  [lib]
34
10
  path = "bindings/rust/lib.rs"
35
11
 
36
- [dependencies]
37
- tree-sitter-language = "0.1"
12
+ [[test]]
13
+ name = "bindings"
14
+ path = "test/bindings.test.rs"
38
15
 
39
- [build-dependencies]
40
- cc = "1.2"
16
+ [dependencies]
17
+ tree-sitter-language = "0.1.8"
41
18
 
42
19
  [dev-dependencies]
43
20
  tree-sitter = "0.27.0"
21
+
22
+ [build-dependencies]
23
+ cc = "1.4"
package/README.md CHANGED
@@ -1,39 +1,37 @@
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
4
  [![npm](https://img.shields.io/npm/v/tree-sitter-sed)](https://www.npmjs.com/package/tree-sitter-sed)
5
5
 
6
6
  [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammars for
7
- POSIX.1-2024 `sed`.
7
+ POSIX.1-2024 sed.
8
8
 
9
9
  ## Installation
10
10
 
11
- ### npm
12
-
13
11
  ```sh
14
12
  npm install tree-sitter-sed
15
13
  ```
16
14
 
17
15
  ## Grammars
18
16
 
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` |
17
+ | Grammar | Description | Rust constant |
18
+ | --- | --- | --- |
19
+ | `sed` | POSIX.1-2024 sed with BRE | `LANGUAGE` |
20
+ | `sed_ere` | POSIX.1-2024 sed with ERE | `LANGUAGE_ERE` |
25
21
 
26
22
  ## Development
27
23
 
24
+ Development requires Node.js 24.2.0 or later.
25
+
28
26
  ```sh
29
27
  npm install
30
- npm run parse -- script.sed
31
- npm run parse:ere -- script.sed
28
+ npm run build
29
+ npm test
32
30
  ```
33
31
 
34
32
  ## Specifications
35
33
 
36
- - [POSIX.1-2024 `sed`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/sed.html)
34
+ - [POSIX.1-2024 sed](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/sed.html)
37
35
  - [POSIX.1-2024 regular expressions](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/V1_chap09.html)
38
36
 
39
37
  ## 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
  }