plum

#treesitter#compiler#wasm

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

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


examples/control_flow.plum
0fe3528 1
fun loopSum(limit: Int) -> Int =
0000000 2
  total := 0
0000000 3
  for i := range limit
0e1801a 4
    if i == 3
0e1801a 5
      continue
0e1801a 6
    if i == 8
0e1801a 7
      break
0e1801a 8
    total = total + i
0e1801a 9
  return total
0e1801a 10
0fe3528 11
fun classify(n: Int) -> Str =
0e1801a 12
  if n < 0
0e1801a 13
    return "negative"
0e1801a 14
  else if n == 0
0e1801a 15
    return "zero"
0e1801a 16
  else
0e1801a 17
    return "positive"
0e1801a 18
0fe3528 19
fun countdown(start: Int) -> Int =
0000000 20
  i := start
0e1801a 21
  while i > 0
0e1801a 22
    i = i - 1
0e1801a 23
  return i
0e1801a 24
0fe3528 25
fun placeholder() =
0e1801a 26
  todo
0e1801a 27
0fe3528 28
fun checkPositive(n: Int) =
0e1801a 29
  assert n > 0