plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


plum-tooling/tree-sitter-plum/test/aa.plum
08530fa 1
module std
08530fa 2
59e3de6 3
import std/int
59e3de6 4
import std/str
59e3de6 5
58cc293 6
PI = 3.14
58cc293 7
MSG = "Hello World"
58cc293 8
SUM = 1 + {{2 * 3} / 4}
58cc293 9
ENABLED = !False
58cc293 10
58cc293 11
# Animal is a set of behavior of every animal species
e9b4405 12
trait IAnimal =
59e3de6 13
  speak() -> Str
59e3de6 14
4aca0b2 15
# Cat is an animal that meows always
e9b4405 16
type Cat(IAnimal, IToStr) =
08530fa 17
  name: Str
08530fa 18
  age: Int
08530fa 19
6b5d9db 20
  fun withName(name: Str) -> Cat =
6b5d9db 21
    Cat(name: name, age: self.age)
6b5d9db 22
6b5d9db 23
  fun withAge(age: Int) -> Cat =
6b5d9db 24
    Cat(name: self.name, age: age)
6b5d9db 25
6b5d9db 26
  fun speak() -> Str =
6b5d9db 27
    "meow"
6b5d9db 28
6b5d9db 29
  fun toStr() -> Str =
6b5d9db 30
    for i in 0..10
6b5d9db 31
      printLn("delta")
6b5d9db 32
    if dog > 1
6b5d9db 33
      printLn("Hellow")
6b5d9db 34
    else
6b5d9db 35
      printLn("New")
6b5d9db 36
    "Cat({self.name}, {self.age})"
08530fa 37
c06ddba 38
fun main() =
d357000 39
  printLn("Hello world")