~repos /plum
git clone https://pyrossh.dev/repos/plum.git
A statically typed, imperative programming language inspired by rust, python
08530fac
—
pyrossh 11 months ago
improve
- tooling/tree-sitter-plum/aa.plum +17 -0
- tooling/tree-sitter-plum/bindings/c/tree-sitter-plum.h +0 -16
- tooling/tree-sitter-plum/bindings/c/tree-sitter-plum.pc.in +0 -11
- tooling/tree-sitter-plum/bindings/go/binding.go +0 -13
- tooling/tree-sitter-plum/bindings/go/binding_test.go +0 -15
- tooling/tree-sitter-plum/bindings/go/go.mod +0 -5
- tooling/tree-sitter-plum/bindings/node/binding.cc +0 -20
- tooling/tree-sitter-plum/bindings/node/index.d.ts +0 -28
- tooling/tree-sitter-plum/bindings/node/index.js +0 -7
- tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/__init__.py +0 -5
- tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/__init__.pyi +0 -1
- tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/binding.c +0 -27
- tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/py.typed +0 -0
- tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/__init__.py +0 -5
- tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/__init__.pyi +0 -1
- tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/binding.c +0 -27
- tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/py.typed +0 -0
- tooling/tree-sitter-plum/bindings/rust/build.rs +0 -20
- tooling/tree-sitter-plum/bindings/rust/lib.rs +0 -54
- tooling/tree-sitter-plum/bindings/swift/TreeSitterKestrel/kestrel.h +0 -16
- tooling/tree-sitter-plum/bindings/swift/TreeSitterPlum/plum.h +0 -16
- tooling/tree-sitter-plum/queries/highlights.scm +5 -12
- tooling/tree-sitter-plum/tree-sitter.json +11 -5
tooling/tree-sitter-plum/aa.plum
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module std
|
|
2
|
+
|
|
3
|
+
type Cat(ToStr) =
|
|
4
|
+
name: Str
|
|
5
|
+
age: Int
|
|
6
|
+
|
|
7
|
+
withName<Cat>(name: Str) -> Cat =
|
|
8
|
+
Cat(name: name, age: self.age)
|
|
9
|
+
|
|
10
|
+
withAge<Cat>(age: Int) -> Cat =
|
|
11
|
+
Cat(name: self.name, age: age)
|
|
12
|
+
|
|
13
|
+
toStr<Cat>() -> Str =
|
|
14
|
+
"Cat({self.name}, {self.age})"
|
|
15
|
+
|
|
16
|
+
main() =
|
|
17
|
+
printLn("Hello world")
|
tooling/tree-sitter-plum/bindings/c/tree-sitter-plum.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef TREE_SITTER_PLUM_H_
|
|
2
|
-
#define TREE_SITTER_PLUM_H_
|
|
3
|
-
|
|
4
|
-
typedef struct TSLanguage TSLanguage;
|
|
5
|
-
|
|
6
|
-
#ifdef __cplusplus
|
|
7
|
-
extern "C" {
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
const TSLanguage *tree_sitter_plum(void);
|
|
11
|
-
|
|
12
|
-
#ifdef __cplusplus
|
|
13
|
-
}
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#endif // TREE_SITTER_PLUM_H_
|
tooling/tree-sitter-plum/bindings/c/tree-sitter-plum.pc.in
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
prefix=@PREFIX@
|
|
2
|
-
libdir=@LIBDIR@
|
|
3
|
-
includedir=@INCLUDEDIR@
|
|
4
|
-
|
|
5
|
-
Name: tree-sitter-plum
|
|
6
|
-
Description: Plum grammar for tree-sitter
|
|
7
|
-
URL: @URL@
|
|
8
|
-
Version: @VERSION@
|
|
9
|
-
Requires: @REQUIRES@
|
|
10
|
-
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-plum
|
|
11
|
-
Cflags: -I${includedir}
|
tooling/tree-sitter-plum/bindings/go/binding.go
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
package tree_sitter_plum
|
|
2
|
-
|
|
3
|
-
// #cgo CFLAGS: -std=c11 -fPIC
|
|
4
|
-
// #include "../../src/parser.c"
|
|
5
|
-
// // NOTE: if your language has an external scanner, add it here.
|
|
6
|
-
import "C"
|
|
7
|
-
|
|
8
|
-
import "unsafe"
|
|
9
|
-
|
|
10
|
-
// Get the tree-sitter Language for this grammar.
|
|
11
|
-
func Language() unsafe.Pointer {
|
|
12
|
-
return unsafe.Pointer(C.tree_sitter_plum())
|
|
13
|
-
}
|
tooling/tree-sitter-plum/bindings/go/binding_test.go
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
package tree_sitter_plum_test
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"testing"
|
|
5
|
-
|
|
6
|
-
tree_sitter "github.com/smacker/go-tree-sitter"
|
|
7
|
-
"github.com/tree-sitter/tree-sitter-plum"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
func TestCanLoadGrammar(t *testing.T) {
|
|
11
|
-
language := tree_sitter.NewLanguage(tree_sitter_plum.Language())
|
|
12
|
-
if language == nil {
|
|
13
|
-
t.Errorf("Error loading plum grammar")
|
|
14
|
-
}
|
|
15
|
-
}
|
tooling/tree-sitter-plum/bindings/go/go.mod
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
module github.com/tree-sitter/tree-sitter-plum
|
|
2
|
-
|
|
3
|
-
go 1.22
|
|
4
|
-
|
|
5
|
-
require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8
|
tooling/tree-sitter-plum/bindings/node/binding.cc
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#include <napi.h>
|
|
2
|
-
|
|
3
|
-
typedef struct TSLanguage TSLanguage;
|
|
4
|
-
|
|
5
|
-
extern "C" TSLanguage *tree_sitter_plum();
|
|
6
|
-
|
|
7
|
-
// "tree-sitter", "language" hashed with BLAKE2
|
|
8
|
-
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
|
9
|
-
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
13
|
-
exports["name"] = Napi::String::New(env, "plum");
|
|
14
|
-
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_plum());
|
|
15
|
-
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
|
16
|
-
exports["language"] = language;
|
|
17
|
-
return exports;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
NODE_API_MODULE(tree_sitter_plum_binding, Init)
|
tooling/tree-sitter-plum/bindings/node/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type BaseNode = {
|
|
2
|
-
type: string;
|
|
3
|
-
named: boolean;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
type ChildNode = {
|
|
7
|
-
multiple: boolean;
|
|
8
|
-
required: boolean;
|
|
9
|
-
types: BaseNode[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type NodeInfo =
|
|
13
|
-
| (BaseNode & {
|
|
14
|
-
subtypes: BaseNode[];
|
|
15
|
-
})
|
|
16
|
-
| (BaseNode & {
|
|
17
|
-
fields: { [name: string]: ChildNode };
|
|
18
|
-
children: ChildNode[];
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type Language = {
|
|
22
|
-
name: string;
|
|
23
|
-
language: unknown;
|
|
24
|
-
nodeTypeInfo: NodeInfo[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare const language: Language;
|
|
28
|
-
export = language;
|
tooling/tree-sitter-plum/bindings/node/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const root = require("path").join(__dirname, "..", "..");
|
|
2
|
-
|
|
3
|
-
module.exports = require("node-gyp-build")(root);
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
7
|
-
} catch (_) {}
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/__init__.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"plum grammar for tree-sitter"
|
|
2
|
-
|
|
3
|
-
from ._binding import language
|
|
4
|
-
|
|
5
|
-
__all__ = ["language"]
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/__init__.pyi
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
def language() -> int: ...
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/binding.c
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#include <Python.h>
|
|
2
|
-
|
|
3
|
-
typedef struct TSLanguage TSLanguage;
|
|
4
|
-
|
|
5
|
-
TSLanguage *tree_sitter_plum(void);
|
|
6
|
-
|
|
7
|
-
static PyObject* _binding_language(PyObject *self, PyObject *args) {
|
|
8
|
-
return PyLong_FromVoidPtr(tree_sitter_plum());
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static PyMethodDef methods[] = {
|
|
12
|
-
{"language", _binding_language, METH_NOARGS,
|
|
13
|
-
"Get the tree-sitter language for this grammar."},
|
|
14
|
-
{NULL, NULL, 0, NULL}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
static struct PyModuleDef module = {
|
|
18
|
-
.m_base = PyModuleDef_HEAD_INIT,
|
|
19
|
-
.m_name = "_binding",
|
|
20
|
-
.m_doc = NULL,
|
|
21
|
-
.m_size = -1,
|
|
22
|
-
.m_methods = methods
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
PyMODINIT_FUNC PyInit__binding(void) {
|
|
26
|
-
return PyModule_Create(&module);
|
|
27
|
-
}
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_kestrel/py.typed
DELETED
|
File without changes
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/__init__.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"Plum grammar for tree-sitter"
|
|
2
|
-
|
|
3
|
-
from ._binding import language
|
|
4
|
-
|
|
5
|
-
__all__ = ["language"]
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/__init__.pyi
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
def language() -> int: ...
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/binding.c
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#include <Python.h>
|
|
2
|
-
|
|
3
|
-
typedef struct TSLanguage TSLanguage;
|
|
4
|
-
|
|
5
|
-
TSLanguage *tree_sitter_plum(void);
|
|
6
|
-
|
|
7
|
-
static PyObject* _binding_language(PyObject *self, PyObject *args) {
|
|
8
|
-
return PyLong_FromVoidPtr(tree_sitter_plum());
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static PyMethodDef methods[] = {
|
|
12
|
-
{"language", _binding_language, METH_NOARGS,
|
|
13
|
-
"Get the tree-sitter language for this grammar."},
|
|
14
|
-
{NULL, NULL, 0, NULL}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
static struct PyModuleDef module = {
|
|
18
|
-
.m_base = PyModuleDef_HEAD_INIT,
|
|
19
|
-
.m_name = "_binding",
|
|
20
|
-
.m_doc = NULL,
|
|
21
|
-
.m_size = -1,
|
|
22
|
-
.m_methods = methods
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
PyMODINIT_FUNC PyInit__binding(void) {
|
|
26
|
-
return PyModule_Create(&module);
|
|
27
|
-
}
|
tooling/tree-sitter-plum/bindings/python/tree_sitter_plum/py.typed
DELETED
|
File without changes
|
tooling/tree-sitter-plum/bindings/rust/build.rs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
// NOTE: if your language uses an external scanner, uncomment this block:
|
|
15
|
-
let scanner_path = src_dir.join("scanner.c");
|
|
16
|
-
c_config.file(&scanner_path);
|
|
17
|
-
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
18
|
-
|
|
19
|
-
c_config.compile("tree-sitter-plum");
|
|
20
|
-
}
|
tooling/tree-sitter-plum/bindings/rust/lib.rs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//! This crate provides plum language support for the [tree-sitter][] parsing library.
|
|
2
|
-
//!
|
|
3
|
-
//! Typically, you will use the [language][language func] function 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
|
-
//! parser.set_language(&tree_sitter_plum::language()).expect("Error loading plum grammar");
|
|
11
|
-
//! let tree = parser.parse(code, None).unwrap();
|
|
12
|
-
//! assert!(!tree.root_node().has_error());
|
|
13
|
-
//! ```
|
|
14
|
-
//!
|
|
15
|
-
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
16
|
-
//! [language func]: fn.language.html
|
|
17
|
-
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
|
18
|
-
//! [tree-sitter]: https://tree-sitter.github.io/
|
|
19
|
-
|
|
20
|
-
use tree_sitter::Language;
|
|
21
|
-
|
|
22
|
-
extern "C" {
|
|
23
|
-
fn tree_sitter_plum() -> Language;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/// Get the tree-sitter [Language][] for this grammar.
|
|
27
|
-
///
|
|
28
|
-
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
29
|
-
pub fn language() -> Language {
|
|
30
|
-
unsafe { tree_sitter_plum() }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/// The content of the [`node-types.json`][] file for this grammar.
|
|
34
|
-
///
|
|
35
|
-
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
|
36
|
-
pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
|
|
37
|
-
|
|
38
|
-
// Uncomment these to include any queries that this grammar contains
|
|
39
|
-
|
|
40
|
-
pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");
|
|
41
|
-
// pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm");
|
|
42
|
-
// pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm");
|
|
43
|
-
pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm");
|
|
44
|
-
|
|
45
|
-
#[cfg(test)]
|
|
46
|
-
mod tests {
|
|
47
|
-
#[test]
|
|
48
|
-
fn test_can_load_grammar() {
|
|
49
|
-
let mut parser = tree_sitter::Parser::new();
|
|
50
|
-
parser
|
|
51
|
-
.set_language(super::language())
|
|
52
|
-
.expect("Error loading plum grammar");
|
|
53
|
-
}
|
|
54
|
-
}
|
tooling/tree-sitter-plum/bindings/swift/TreeSitterKestrel/kestrel.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef TREE_SITTER_plum_H_
|
|
2
|
-
#define TREE_SITTER_plum_H_
|
|
3
|
-
|
|
4
|
-
typedef struct TSLanguage TSLanguage;
|
|
5
|
-
|
|
6
|
-
#ifdef __cplusplus
|
|
7
|
-
extern "C" {
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
const TSLanguage *tree_sitter_plum(void);
|
|
11
|
-
|
|
12
|
-
#ifdef __cplusplus
|
|
13
|
-
}
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#endif // TREE_SITTER_plum_H_
|
tooling/tree-sitter-plum/bindings/swift/TreeSitterPlum/plum.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef TREE_SITTER_PLUM_H_
|
|
2
|
-
#define TREE_SITTER_PLUM_H_
|
|
3
|
-
|
|
4
|
-
typedef struct TSLanguage TSLanguage;
|
|
5
|
-
|
|
6
|
-
#ifdef __cplusplus
|
|
7
|
-
extern "C" {
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
const TSLanguage *tree_sitter_plum(void);
|
|
11
|
-
|
|
12
|
-
#ifdef __cplusplus
|
|
13
|
-
}
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#endif // TREE_SITTER_PLUM_H_
|
tooling/tree-sitter-plum/queries/highlights.scm
CHANGED
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
; Assume all-caps names are constants
|
|
4
4
|
((identifier) @constant
|
|
5
5
|
(#match? @constant "^[A-Z][A-Z_]*$"))
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
8
|
-
(identifier)
|
|
9
|
-
] @variable
|
|
10
|
-
|
|
11
|
-
(class
|
|
12
|
-
|
|
7
|
+
(type_identifier) @constant
|
|
8
|
+
(identifier) @variable
|
|
13
9
|
|
|
14
10
|
(trait
|
|
15
11
|
name: (type_identifier) @type)
|
|
@@ -20,11 +16,8 @@
|
|
|
20
16
|
(fn
|
|
21
17
|
name: (identifier) @function)
|
|
22
18
|
|
|
23
|
-
[
|
|
24
|
-
|
|
19
|
+
(integer) @number
|
|
25
|
-
(float)
|
|
26
|
-
|
|
20
|
+
(float) @number
|
|
27
|
-
|
|
28
21
|
(comment) @comment
|
|
29
22
|
(string) @string
|
|
30
23
|
(escape_sequence) @escape
|
tooling/tree-sitter-plum/tree-sitter.json
CHANGED
|
@@ -32,10 +32,16 @@
|
|
|
32
32
|
},
|
|
33
33
|
"bindings": {
|
|
34
34
|
"c": true,
|
|
35
|
-
"go":
|
|
35
|
+
"go": false,
|
|
36
|
-
"node":
|
|
36
|
+
"node": false,
|
|
37
|
-
"python":
|
|
37
|
+
"python": false,
|
|
38
38
|
"rust": true,
|
|
39
|
-
"swift":
|
|
39
|
+
"swift": false
|
|
40
|
+
},
|
|
41
|
+
"theme": {
|
|
42
|
+
"keyword": "purple",
|
|
43
|
+
"function": "blue",
|
|
44
|
+
"type": "green",
|
|
45
|
+
"number": "brown"
|
|
40
46
|
}
|
|
41
|
-
}
|
|
47
|
+
}
|