tree-sitter-sed 0.14.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 +12 -32
- package/README.md +11 -13
- package/bindings/rust/build.rs +26 -45
- package/bindings/rust/lib.rs +0 -993
- package/common/grammar.js +141 -185
- package/common/regex.js +37 -41
- package/common/scanner.h +104 -111
- package/package.json +11 -7
- package/sed_ere/src/grammar.json +384 -634
- package/sed_ere/src/parser.c +36292 -27606
- package/src/grammar.json +384 -634
- package/src/parser.c +38036 -29331
- package/test/bindings.test.rs +917 -0
- package/tree-sitter.json +1 -6
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
|
-
|
|
11
|
-
|
|
12
|
-
repository = "https://github.com/konomanoasa/tree-sitter-sed"
|
|
13
|
-
version = "0.14.0"
|
|
14
|
-
|
|
3
|
+
version = "0.16.0"
|
|
4
|
+
edition = "2024"
|
|
15
5
|
build = "bindings/rust/build.rs"
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
[
|
|
37
|
-
|
|
12
|
+
[[test]]
|
|
13
|
+
name = "bindings"
|
|
14
|
+
path = "test/bindings.test.rs"
|
|
38
15
|
|
|
39
|
-
[
|
|
40
|
-
|
|
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
|
-
[](https://github.com/konomanoasa/tree-sitter-sed/actions/workflows/ci.yaml)
|
|
4
4
|
[](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
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
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
|
|
31
|
-
npm
|
|
28
|
+
npm run build
|
|
29
|
+
npm test
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
## Specifications
|
|
35
33
|
|
|
36
|
-
- [POSIX.1-2024
|
|
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
|
package/bindings/rust/build.rs
CHANGED
|
@@ -1,50 +1,31 @@
|
|
|
1
|
-
use std::path::Path;
|
|
1
|
+
use std::{env, path::Path};
|
|
2
2
|
|
|
3
|
-
fn
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
}
|