~repos /plum
git clone
https://pyrossh.dev/repos/plum.git
Discussions:
https://groups.google.com/g/rust-embed-devs
A statically typed, imperative programming language inspired by rust, python
0d8e2ab8
—
pyrossh 1 year ago
add cargo pkg
- tooling/tree-sitter-plum/.gitignore +4 -1
- tooling/tree-sitter-plum/Cargo.lock +96 -0
- tooling/tree-sitter-plum/Cargo.toml +32 -0
- tooling/tree-sitter-plum/bindings/rust/build.rs +19 -0
- tooling/tree-sitter-plum/bindings/rust/lib.rs +53 -0
- tooling/tree-sitter-plum/src/grammar.json +0 -0
- tooling/tree-sitter-plum/src/node-types.json +0 -0
- tooling/tree-sitter-plum/src/parser.c +0 -0
tooling/tree-sitter-plum/.gitignore
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
plum.dylib
|
|
2
|
-
plum.so
|
|
2
|
+
plum.so
|
|
3
|
+
|
|
4
|
+
# Rust artifacts
|
|
5
|
+
target/
|
tooling/tree-sitter-plum/Cargo.lock
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.3"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "cc"
|
|
16
|
+
version = "1.2.4"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"shlex",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "memchr"
|
|
25
|
+
version = "2.7.4"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "regex"
|
|
31
|
+
version = "1.11.1"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"aho-corasick",
|
|
36
|
+
"memchr",
|
|
37
|
+
"regex-automata",
|
|
38
|
+
"regex-syntax",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "regex-automata"
|
|
43
|
+
version = "0.4.9"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"aho-corasick",
|
|
48
|
+
"memchr",
|
|
49
|
+
"regex-syntax",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "regex-syntax"
|
|
54
|
+
version = "0.8.5"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
57
|
+
|
|
58
|
+
[[package]]
|
|
59
|
+
name = "shlex"
|
|
60
|
+
version = "1.3.0"
|
|
61
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
62
|
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
63
|
+
|
|
64
|
+
[[package]]
|
|
65
|
+
name = "streaming-iterator"
|
|
66
|
+
version = "0.1.9"
|
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
+
checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520"
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "tree-sitter"
|
|
72
|
+
version = "0.24.5"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "8ac95b18f0f727aaaa012bd5179a1916706ee3ed071920fdbda738750b0c0bf5"
|
|
75
|
+
dependencies = [
|
|
76
|
+
"cc",
|
|
77
|
+
"regex",
|
|
78
|
+
"regex-syntax",
|
|
79
|
+
"streaming-iterator",
|
|
80
|
+
"tree-sitter-language",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "tree-sitter-language"
|
|
85
|
+
version = "0.1.3"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "c199356c799a8945965bb5f2c55b2ad9d9aa7c4b4f6e587fe9dea0bc715e5f9c"
|
|
88
|
+
|
|
89
|
+
[[package]]
|
|
90
|
+
name = "tree-sitter-plum"
|
|
91
|
+
version = "0.1.0"
|
|
92
|
+
dependencies = [
|
|
93
|
+
"cc",
|
|
94
|
+
"tree-sitter",
|
|
95
|
+
"tree-sitter-language",
|
|
96
|
+
]
|
tooling/tree-sitter-plum/Cargo.toml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "tree-sitter-plum"
|
|
3
|
+
description = "plum"
|
|
4
|
+
version = "0.1.0"
|
|
5
|
+
authors = ["pyrossh <pyros2097@gmail.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
keywords = ["incremental", "parsing", "tree-sitter", "plum"]
|
|
8
|
+
categories = ["parsing", "text-editors"]
|
|
9
|
+
repository = "https://git.sr.ht/~pyrossh/plum"
|
|
10
|
+
edition = "2021"
|
|
11
|
+
autoexamples = false
|
|
12
|
+
|
|
13
|
+
build = "bindings/rust/build.rs"
|
|
14
|
+
include = [
|
|
15
|
+
"bindings/rust/*",
|
|
16
|
+
"grammar.js",
|
|
17
|
+
"queries/*",
|
|
18
|
+
"src/*",
|
|
19
|
+
"tree-sitter.json",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[lib]
|
|
23
|
+
path = "bindings/rust/lib.rs"
|
|
24
|
+
|
|
25
|
+
[dependencies]
|
|
26
|
+
tree-sitter-language = "0.1"
|
|
27
|
+
|
|
28
|
+
[build-dependencies]
|
|
29
|
+
cc = "1.1.22"
|
|
30
|
+
|
|
31
|
+
[dev-dependencies]
|
|
32
|
+
tree-sitter = "0.24.5"
|
tooling/tree-sitter-plum/bindings/rust/build.rs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
fn main() {
|
|
2
|
+
let src_dir = std::path::Path::new("src");
|
|
3
|
+
|
|
4
|
+
let mut c_config = cc::Build::new();
|
|
5
|
+
c_config.std("c11").include(src_dir);
|
|
6
|
+
|
|
7
|
+
#[cfg(target_env = "msvc")]
|
|
8
|
+
c_config.flag("-utf-8");
|
|
9
|
+
|
|
10
|
+
let parser_path = src_dir.join("parser.c");
|
|
11
|
+
c_config.file(&parser_path);
|
|
12
|
+
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
|
13
|
+
|
|
14
|
+
let scanner_path = src_dir.join("scanner.c");
|
|
15
|
+
c_config.file(&scanner_path);
|
|
16
|
+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
17
|
+
|
|
18
|
+
c_config.compile("tree-sitter-plum");
|
|
19
|
+
}
|
tooling/tree-sitter-plum/bindings/rust/lib.rs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//! This crate provides plum language support for the [tree-sitter][] parsing library.
|
|
2
|
+
//!
|
|
3
|
+
//! Typically, you will use the [LANGUAGE][] constant to add this language to a
|
|
4
|
+
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
|
5
|
+
//!
|
|
6
|
+
//! ```
|
|
7
|
+
//! let code = r#"
|
|
8
|
+
//! "#;
|
|
9
|
+
//! let mut parser = tree_sitter::Parser::new();
|
|
10
|
+
//! let language = tree_sitter_plum::LANGUAGE;
|
|
11
|
+
//! parser
|
|
12
|
+
//! .set_language(&language.into())
|
|
13
|
+
//! .expect("Error loading plum parser");
|
|
14
|
+
//! let tree = parser.parse(code, None).unwrap();
|
|
15
|
+
//! assert!(!tree.root_node().has_error());
|
|
16
|
+
//! ```
|
|
17
|
+
//!
|
|
18
|
+
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
|
19
|
+
//! [tree-sitter]: https://tree-sitter.github.io/
|
|
20
|
+
|
|
21
|
+
use tree_sitter_language::LanguageFn;
|
|
22
|
+
|
|
23
|
+
extern "C" {
|
|
24
|
+
fn tree_sitter_plum() -> *const ();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// The tree-sitter [`LanguageFn`][LanguageFn] for this grammar.
|
|
28
|
+
///
|
|
29
|
+
/// [LanguageFn]: https://docs.rs/tree-sitter-language/*/tree_sitter_language/struct.LanguageFn.html
|
|
30
|
+
pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_plum) };
|
|
31
|
+
|
|
32
|
+
/// The content of the [`node-types.json`][] file for this grammar.
|
|
33
|
+
///
|
|
34
|
+
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
|
35
|
+
pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
|
|
36
|
+
|
|
37
|
+
// NOTE: uncomment these to include any queries that this grammar contains:
|
|
38
|
+
|
|
39
|
+
// pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");
|
|
40
|
+
// pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm");
|
|
41
|
+
// pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm");
|
|
42
|
+
// pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm");
|
|
43
|
+
|
|
44
|
+
#[cfg(test)]
|
|
45
|
+
mod tests {
|
|
46
|
+
#[test]
|
|
47
|
+
fn test_can_load_grammar() {
|
|
48
|
+
let mut parser = tree_sitter::Parser::new();
|
|
49
|
+
parser
|
|
50
|
+
.set_language(&super::LANGUAGE.into())
|
|
51
|
+
.expect("Error loading plum parser");
|
|
52
|
+
}
|
|
53
|
+
}
|
tooling/tree-sitter-plum/src/grammar.json
CHANGED
|
Binary file
|
tooling/tree-sitter-plum/src/node-types.json
CHANGED
|
Binary file
|
tooling/tree-sitter-plum/src/parser.c
CHANGED
|
Binary file
|