~repos /plum
git clone https://pyrossh.dev/repos/plum.git
A statically typed, imperative programming language inspired by rust, python
src/main.rs
use tree_sitter;use tree_sitter_plum;
fn main() { let code = r#"module std
import std/intimport std/str
PI = 3.14MSG = "Hello World"SUM = 1 + {{2 * 3} / 4}ENABLED = !False
# Animal is a set of behavior of every animal speciestrait Animal = speak() -> Str
# Cat is an animal that meows alwaystype Cat(Animal, IToStr) = name: Str age: Int
withName<Cat>(name: Str) -> Cat = Cat(name: name, age: self.age)
withAge<Cat>(age: Int) -> Cat = Cat(name: self.name, age: age)
speak<Cat>() -> Str = "meow"
toStr<Cat>() -> Str = for i in 0..10 printLn("delta") if dog > 1 printLn("Hellow") else printLn("New") "Cat({self.name}, {self.age})"
main() = printLn("Hello world")
"#; let mut parser = tree_sitter::Parser::new(); let language = tree_sitter_plum::LANGUAGE; parser .set_language(&language.into()) .expect("Error loading plum parser"); let tree = parser.parse(code, None).unwrap(); assert!(!tree.root_node().has_error()); let mut cursor = tree.root_node().walk(); for item in tree.root_node().children(&mut cursor) { println!("kind:{} {}", item.kind(), item.to_sexp()); }}