plum

#treesitter#compiler#wasm

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

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


e58dc7b — Peter John 2026-11-10T11:41:54+05:30
Grammar checks in test-all; mut highlighted; ... before .. in the tmLanguage
compiler/scripts/test-all.sh CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
- # Runs every test: all Rust test executables, then the Plum sweep in three modes.
2
+ # Runs every test: all Rust test executables, the Plum sweep in three modes, and the
3
+ # tree-sitter corpus when the tree-sitter CLI is installed.
3
4
  # The Rust executables run side by side (TEST_ALL_JOBS at a time, default 4: each one also
4
5
  # runs its own tests on several threads; one that fails is rerun alone), and `plum test` tests its files in parallel
5
6
  # (PLUM_TEST_JOBS, default one per core). Output is printed in a fixed order.
@@ -87,5 +88,20 @@ $(failureLines < "$tmp/sweep$mode.out" | head -80)"
87
88
  fi
88
89
  done
89
90
 
91
+ # The grammar's corpus (test/corpus) and highlight assertions (test/highlight), when the
92
+ # tree-sitter CLI is installed (`brew install tree-sitter-cli` or `npm i -g tree-sitter-cli`).
93
+ if command -v tree-sitter > /dev/null; then
94
+ if ts=$(cd compiler/tooling/tree-sitter-plum && tree-sitter test 2>&1); then
95
+ echo "ok tree-sitter corpus and highlights"
96
+ else
97
+ echo "FAIL tree-sitter corpus and highlights"
98
+ fail=$((fail + 1))
99
+ failed_names="$failed_names
100
+ $(echo "$ts" | grep -E '✗|Failure|failed parses' | head -40)"
101
+ fi
102
+ else
103
+ echo "skip tree-sitter corpus and highlights (no tree-sitter CLI)"
104
+ fi
105
+
90
106
  [ -n "$(echo "$failed_names" | tr -d '[:space:]')" ] && echo "Failing tests:$failed_names"
91
107
  if [ "$fail" -eq 0 ]; then echo "ALL PASSED"; else echo "FAILED: $fail"; exit 1; fi
compiler/tooling/tree-sitter-plum/queries/plum/highlights.scm CHANGED
@@ -104,6 +104,7 @@
104
104
  "export"
105
105
  "fip"
106
106
  "fn"
107
+ "mut"
107
108
  "test"
108
109
  ] @keyword
109
110
 
compiler/tooling/tree-sitter-plum/test/highlight/sample.plum CHANGED
@@ -1,15 +1,28 @@
1
1
  module std
2
+ # <- keyword
2
3
 
3
- struct Cat(name: Str, age: Int) =
4
+ struct Cat(name: Str, mut age: Int) =
5
+ # <- keyword
6
+ # ^ type
7
+ # ^ keyword
8
+ # ^ type
4
9
 
5
10
  fun withName(self, name: Str) -> Cat =
11
+ # <- keyword
12
+ # ^ function
13
+ # ^ variable.builtin
6
14
  Cat(name: name, age: self.age)
7
15
 
8
- fun withAge(self, age: Int) -> Cat =
9
- Cat(name: self.name, age: age)
10
-
11
16
  fun toStr(self) -> Str =
12
17
  "Cat({self.name}, {self.age})"
18
+ # <- string
13
19
 
14
20
  fun main() =
21
+ for i := range 3
22
+ # <- keyword.control.repeat
23
+ # ^ keyword.control.repeat
24
+ if i == 1
25
+ # <- keyword.control.conditional
26
+ crash "one"
27
+ # <- keyword.control.exception
15
- printLn("Hello world")
28
+ printLn("Hello world")
compiler/tooling/vscode-plum/syntaxes/plum.tmLanguage.json CHANGED
@@ -39,21 +39,21 @@
39
39
  "keywords": {
40
40
  "patterns": [
41
41
  {
42
- "match": "\\b(module|struct|enum|trait|primitive|fun|fn|extern|export|fip|self|test)(?![A-Za-z0-9_])",
42
+ "match": "\\b(module|struct|enum|trait|primitive|fun|fn|extern|export|fip|mut|self|test)(?![A-Za-z0-9_])",
43
43
  "name": "keyword.const.plum"
44
44
  },
45
45
  {
46
46
  "name": "keyword.control.plum",
47
47
  "match": "\\b(import|return|continue|break|match|when|if|then|else|while|for|range|assert|todo|crash|is|as)\\b"
48
48
  },
49
- {
50
- "name": "keyword.operator.range.plum",
51
- "match": "\\.\\."
52
- },
53
49
  {
54
50
  "name": "keyword.operator.splat.plum",
55
51
  "match": "\\.\\.\\."
56
52
  },
53
+ {
54
+ "name": "keyword.operator.range.plum",
55
+ "match": "\\.\\."
56
+ },
57
57
  {
58
58
  "name": "keyword.operator.comparison.plum",
59
59
  "match": "(==|!=|<=|>=|<|>)"