plum

#treesitter#compiler#wasm

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

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


plum-tooling/vscode-plum/syntaxes/plum.tmLanguage.json
5f5d99d 1
{
5f5d99d 2
  "name": "plum",
c05610c 3
  "scopeName": "source.plum",
5f5d99d 4
  "patterns": [
5f5d99d 5
    {
5f5d99d 6
      "include": "#comments"
5f5d99d 7
    },
5f5d99d 8
    {
5f5d99d 9
      "include": "#keywords"
5f5d99d 10
    },
5f5d99d 11
    {
d322d05 12
      "include": "#constant"
5f5d99d 13
    },
5f5d99d 14
    {
d322d05 15
      "include": "#string"
5f5d99d 16
    },
c05610c 17
    {
141de54 18
      "include": "#raw_quoted_string"
c05610c 19
    },
267c262 20
    {
267c262 21
      "include": "#number"
267c262 22
    },
5f5d99d 23
    {
5f5d99d 24
      "include": "#entity"
5f5d99d 25
    },
5f5d99d 26
    {
5f5d99d 27
      "include": "#discards"
5f5d99d 28
    }
5f5d99d 29
  ],
5f5d99d 30
  "repository": {
d322d05 31
    "comments": {
d322d05 32
      "patterns": [
d322d05 33
        {
d322d05 34
          "name": "comment.line.plum",
d322d05 35
          "match": "#.*"
d322d05 36
        }
d322d05 37
      ]
d322d05 38
    },
5f5d99d 39
    "keywords": {
5f5d99d 40
      "patterns": [
d322d05 41
        {
900c685 42
          "match": "\\b(module|enum|trait|fun|self|test)\\b",
d322d05 43
          "name": "keyword.const.plum"
d322d05 44
        },
5f5d99d 45
        {
5f5d99d 46
          "name": "keyword.control.plum",
a9a0147 47
          "match": "\\b(import|in|return|continue|break|match|when|if|else|while|for|assert|todo)\\b"
c05610c 48
        },
c05610c 49
        {
c05610c 50
          "name": "keyword.operator.range.plum",
c05610c 51
          "match": "\\.\\."
5f5d99d 52
        },
5f5d99d 53
        {
d322d05 54
          "name": "keyword.operator.splat.plum",
d322d05 55
          "match": "\\.\\.\\."
5f5d99d 56
        },
5f5d99d 57
        {
d322d05 58
          "name": "keyword.operator.comparison.plum",
d322d05 59
          "match": "(==|!=|<=|>=|<|>)"
5f5d99d 60
        },
900c685 61
        {
900c685 62
          "comment": "elvis (Result/Option unwrap-or-fallback) — checked before the bare `?` try-operator below, since `?:` must win the longer match",
900c685 63
          "name": "keyword.operator.elvis.plum",
900c685 64
          "match": "\\?:"
900c685 65
        },
43e5250 66
        {
43e5250 67
          "comment": "safe navigation (Result/Option `.map` sugar) — checked before the bare `?` try-operator below, since `?.` must win the longer match",
43e5250 68
          "name": "keyword.operator.safenav.plum",
43e5250 69
          "match": "\\?\\."
43e5250 70
        },
900c685 71
        {
900c685 72
          "comment": "postfix try-operator (Result/Option unwrap-or-early-return) — matched only when `?` glues directly to the preceding token with no space, `plum format`'s own convention for this postfix operator (unlike ternary's `?`, always spaced); ternary's own `?`/`:` are deliberately left unstyled here too, matching the tree-sitter highlights.scm, since a regex can't reliably tell them apart",
900c685 73
          "name": "keyword.operator.try.plum",
43e5250 74
          "match": "(?<=[A-Za-z0-9_\\)\\]])\\?(?!:)(?!\\.)"
900c685 75
        },
5f5d99d 76
        {
d322d05 77
          "name": "keyword.operator.logical.plum",
d322d05 78
          "match": "(&&|\\|\\|)"
5f5d99d 79
        },
5f5d99d 80
        {
d322d05 81
          "name": "keyword.operator.arithmetic.plum",
d322d05 82
          "match": "(\\+|\\-|/|\\*|%)"
5f5d99d 83
        },
5f5d99d 84
        {
d322d05 85
          "name": "keyword.operator.assignment.plum",
d322d05 86
          "match": "="
d322d05 87
        }
d322d05 88
      ]
d322d05 89
    },
d322d05 90
    "constant": {
d322d05 91
      "patterns": [
5f5d99d 92
        {
d322d05 93
          "comment": "ALL CAPS constants",
d322d05 94
          "name": "constant.other.caps.plum",
d322d05 95
          "match": "\\b[A-Z]{2}[A-Z0-9_]*\\b"
5f5d99d 96
        },
5f5d99d 97
        {
d322d05 98
          "comment": "constant declarations",
d322d05 99
          "match": "\\b\\s+([A-Z_]*)\\b",
d322d05 100
          "captures": {
d322d05 101
            "1": {
d322d05 102
              "name": "storage.type.plum"
d322d05 103
            },
d322d05 104
            "2": {
d322d05 105
              "name": "constant.other.caps.plum"
d322d05 106
            }
d322d05 107
          }
d322d05 108
        }
d322d05 109
      ]
d322d05 110
    },
d322d05 111
    "number": {
d322d05 112
      "name": "constant.numeric.plum",
d322d05 113
      "patterns": [
d322d05 114
        {
d322d05 115
          "include": "#number-float"
d322d05 116
        },
d322d05 117
        {
d322d05 118
          "include": "#number-dec"
d322d05 119
        },
d322d05 120
        {
d322d05 121
          "include": "#number-hex"
d322d05 122
        },
d322d05 123
        {
d322d05 124
          "include": "#number-bin"
d322d05 125
        },
d322d05 126
        {
d322d05 127
          "name": "invalid.illegal.name.plum",
d322d05 128
          "match": "\\b[0-9]+\\w+"
5f5d99d 129
        }
5f5d99d 130
      ]
5f5d99d 131
    },
d322d05 132
    "number-float": {
d322d05 133
      "name": "constant.numeric.float.plum",
2ec05c8 134
      "match": "(?x)\n  (?<! \\w)(?:\n    (?:\n      (?:[0-9]+(?:_+[0-9]+)*)? \\. [0-9]+(?:_+[0-9]+)* (?: [eE][+-]?[0-9]+(?:_+[0-9]+)* )?\n      |\n      [0-9]+(?:_+[0-9]+)* [eE][+-]?[0-9]+(?:_+[0-9]+)*\n    ) ([fF])?\n    |\n    [0-9]+(?:_+[0-9]+)* ([fF])\n  )\\b\n",
d322d05 135
      "captures": {
d322d05 136
        "1": {
2ec05c8 137
          "name": "storage.type.number.plum"
2ec05c8 138
        },
2ec05c8 139
        "2": {
2ec05c8 140
          "name": "storage.type.number.plum"
d322d05 141
        }
d322d05 142
      }
5f5d99d 143
    },
d322d05 144
    "number-dec": {
d322d05 145
      "name": "constant.numeric.dec.plum",
d322d05 146
      "match": "(?x)\n  (?<![\\w\\.])(?:\n      [1-9](?: _?[0-9] )*\n      |\n      0+\n      |\n      [0-9](?: _?[0-9] )* ([jJ])\n      |\n      0 ([0-9]+)(?![eE\\.])\n  )\\b\n",
d322d05 147
      "captures": {
d322d05 148
        "1": {
d322d05 149
          "name": "storage.type.imaginary.number.plum"
d322d05 150
        },
d322d05 151
        "2": {
d322d05 152
          "name": "invalid.illegal.dec.plum"
d322d05 153
        }
d322d05 154
      }
5f5d99d 155
    },
d322d05 156
    "number-hex": {
d322d05 157
      "name": "constant.numeric.hex.plum",
d322d05 158
      "match": "(?x)\n  (?<![\\w\\.])\n    (0[xX]) (_?[0-9a-fA-F])+\n  \\b\n",
d322d05 159
      "captures": {
d322d05 160
        "1": {
d322d05 161
          "name": "storage.type.number.plum"
d322d05 162
        }
d322d05 163
      }
d322d05 164
    },
d322d05 165
    "number-bin": {
d322d05 166
      "name": "constant.numeric.bin.plum",
d322d05 167
      "match": "(?x)\n  (?<![\\w\\.])\n    (0[bB]) (_?[01])+\n  \\b\n",
d322d05 168
      "captures": {
d322d05 169
        "1": {
d322d05 170
          "name": "storage.type.number.plum"
d322d05 171
        }
d322d05 172
      }
5f5d99d 173
    },
5f5d99d 174
    "entity": {
5f5d99d 175
      "patterns": [
c05610c 176
        {
c05610c 177
          "name": "entity.name.type.plum",
c05610c 178
          "match": "[[:upper:]][[:alnum:]]*"
c05610c 179
        },
5f5d99d 180
        {
d322d05 181
          "begin": "\\b([[:lower:]][[:word:]]*)\\b\\(",
5f5d99d 182
          "end": "\\)",
5f5d99d 183
          "patterns": [
5f5d99d 184
            {
5f5d99d 185
              "include": "$self"
5f5d99d 186
            }
5f5d99d 187
          ],
5f5d99d 188
          "captures": {
5f5d99d 189
            "1": {
5f5d99d 190
              "name": "entity.name.function.plum"
5f5d99d 191
            }
5f5d99d 192
          }
5f5d99d 193
        },
5f5d99d 194
        {
5f5d99d 195
          "name": "variable.parameter.plum",
5f5d99d 196
          "match": "\\b([[:lower:]][[:word:]]*):\\s"
5f5d99d 197
        },
5f5d99d 198
        {
5f5d99d 199
          "name": "entity.name.namespace.plum",
5f5d99d 200
          "match": "\\b([[:lower:]][[:word:]]*):"
5f5d99d 201
        }
5f5d99d 202
      ]
5f5d99d 203
    },
c05610c 204
    "string": {
c05610c 205
      "patterns": [
c05610c 206
        {
c05610c 207
          "name": "string.quoted.double.plum",
c05610c 208
          "begin": "\"",
c05610c 209
          "beginCaptures": {
c05610c 210
            "0": {
c05610c 211
              "name": "punctuation.definition.string.begin.plum"
c05610c 212
            }
c05610c 213
          },
c05610c 214
          "end": "\"",
c05610c 215
          "endCaptures": {
c05610c 216
            "0": {
c05610c 217
              "name": "punctuation.definition.string.end.plum"
c05610c 218
            }
c05610c 219
          },
c05610c 220
          "patterns": [
c05610c 221
            {
c05610c 222
              "include": "#template-substitution-element"
c05610c 223
            },
c05610c 224
            {
c05610c 225
              "include": "#string-character-escape"
c05610c 226
            }
c05610c 227
          ]
c05610c 228
        }
c05610c 229
      ]
c05610c 230
    },
c05610c 231
    "string-character-escape": {
c05610c 232
      "name": "constant.character.escape.plum",
c05610c 233
      "match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)"
c05610c 234
    },
c05610c 235
    "template-substitution-element": {
c05610c 236
      "name": "meta.template.expression.plum",
c05610c 237
      "begin": "\\{",
c05610c 238
      "beginCaptures": {
c05610c 239
        "0": {
c05610c 240
          "name": "punctuation.definition.template-expression.begin.plum"
c05610c 241
        }
c05610c 242
      },
c05610c 243
      "end": "\\}",
c05610c 244
      "endCaptures": {
c05610c 245
        "0": {
c05610c 246
          "name": "punctuation.definition.template-expression.end.plum"
c05610c 247
        }
c05610c 248
      },
c05610c 249
      "patterns": [
c05610c 250
        {
c05610c 251
          "include": "#expression"
c05610c 252
        }
c05610c 253
      ],
c05610c 254
      "contentName": "meta.embedded.line.plum"
c05610c 255
    },
c05610c 256
    "expression": {
c05610c 257
      "patterns": [
c05610c 258
        {
c05610c 259
          "match": "\\b(self)\\b",
c05610c 260
          "name": "keyword.const.plum"
c05610c 261
        },
c05610c 262
        {
c05610c 263
          "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\\#?[[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])",
c05610c 264
          "captures": {
c05610c 265
            "1": {
c05610c 266
              "name": "punctuation.accessor.plum"
c05610c 267
            },
c05610c 268
            "2": {
c05610c 269
              "name": "punctuation.accessor.optional.plum"
c05610c 270
            },
c05610c 271
            "3": {
c05610c 272
              "name": "variable.other.constant.property.plum"
c05610c 273
            }
c05610c 274
          }
c05610c 275
        },
c05610c 276
        {
c05610c 277
          "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*)",
c05610c 278
          "captures": {
c05610c 279
            "1": {
c05610c 280
              "name": "punctuation.accessor.plum"
c05610c 281
            },
c05610c 282
            "2": {
c05610c 283
              "name": "punctuation.accessor.optional.plum"
c05610c 284
            },
c05610c 285
            "3": {
c05610c 286
              "name": "variable.other.property.plum"
c05610c 287
            }
c05610c 288
          }
c05610c 289
        },
c05610c 290
        {
c05610c 291
          "name": "variable.other.constant.plum",
c05610c 292
          "match": "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])"
c05610c 293
        },
c05610c 294
        {
c05610c 295
          "name": "variable.other.readwrite.plum",
c05610c 296
          "match": "[_$[:alpha:]][_$[:alnum:]]*"
c05610c 297
        }
c05610c 298
      ]
c05610c 299
    },
c05610c 300
    "raw_quoted_string": {
c05610c 301
      "comment": "Raw string literals",
c05610c 302
      "begin": "`",
c05610c 303
      "beginCaptures": {
c05610c 304
        "0": {
c05610c 305
          "name": "punctuation.definition.string.begin.go.mod"
c05610c 306
        }
c05610c 307
      },
c05610c 308
      "end": "`",
c05610c 309
      "endCaptures": {
c05610c 310
        "0": {
c05610c 311
          "name": "punctuation.definition.string.end.go.mod"
c05610c 312
        }
c05610c 313
      },
c05610c 314
      "name": "string.quoted.raw",
c05610c 315
      "patterns": [
c05610c 316
        {
c05610c 317
          "include": "#string_placeholder"
c05610c 318
        }
c05610c 319
      ]
c05610c 320
    },
c05610c 321
    "string_placeholder": {
c05610c 322
      "patterns": [
c05610c 323
        {
c05610c 324
          "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]",
c05610c 325
          "name": "constant.other.placeholder.go.mod"
c05610c 326
        }
c05610c 327
      ]
c05610c 328
    },
5f5d99d 329
    "discards": {
5f5d99d 330
      "name": "comment.unused.plum",
5f5d99d 331
      "match": "\\b_(?:[[:word:]]+)?\\b"
5f5d99d 332
    }
c05610c 333
  }
5f5d99d 334
}