- Bit operators & | ^ ~ << >> and their op= forms (Go precedence),
plus hex, binary and octal literals (0xff, 0b1010, 0o755)
- defer stmt / defer { ... }: runs when the block ends, last first,
also on return, ?, break and continue
- List methods insert, remove, clear, contains, index_of, reverse,
sort and sort_by (stable merge sort)
- rand module: int(a, b), float(), seed(n)
- assert(cond[, msg]) and `rex test`, which runs each test_ function
in its own process
- rex.toml marks a project's top folder: imports count from there
- Docs, formatter, LSP completions and editor grammars updated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
3.5 KiB
JSON
104 lines
3.5 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "Rex",
|
|
"scopeName": "source.rex",
|
|
"patterns": [
|
|
{ "include": "#comments" },
|
|
{ "include": "#strings" },
|
|
{ "include": "#chars" },
|
|
{ "include": "#declarations" },
|
|
{ "include": "#keywords" },
|
|
{ "include": "#constants" },
|
|
{ "include": "#numbers" },
|
|
{ "include": "#types" },
|
|
{ "include": "#calls" },
|
|
{ "include": "#operators" }
|
|
],
|
|
"repository": {
|
|
"comments": {
|
|
"patterns": [
|
|
{ "name": "comment.line.double-slash.rex", "match": "//.*$" },
|
|
{ "name": "comment.block.rex", "begin": "/\\*", "end": "\\*/" }
|
|
]
|
|
},
|
|
"strings": {
|
|
"name": "string.quoted.double.rex",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"patterns": [
|
|
{ "name": "constant.character.escape.rex", "match": "\\\\." },
|
|
{
|
|
"name": "meta.interpolation.rex",
|
|
"begin": "\\{",
|
|
"end": "\\}",
|
|
"beginCaptures": { "0": { "name": "punctuation.section.interpolation.begin.rex" } },
|
|
"endCaptures": { "0": { "name": "punctuation.section.interpolation.end.rex" } },
|
|
"patterns": [{ "include": "$self" }]
|
|
}
|
|
]
|
|
},
|
|
"chars": {
|
|
"name": "string.quoted.single.rex",
|
|
"match": "'(?:\\\\.|[^'\\\\])'",
|
|
"captures": {}
|
|
},
|
|
"declarations": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(func)\\s+([A-Za-z_][A-Za-z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.declaration.function.rex" },
|
|
"2": { "name": "entity.name.function.rex" }
|
|
}
|
|
},
|
|
{
|
|
"match": "\\b(struct|enum|interface)\\s+([A-Za-z_][A-Za-z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.declaration.type.rex" },
|
|
"2": { "name": "entity.name.type.rex" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{ "name": "keyword.control.rex", "match": "\\b(if|else|for|in|step|match|return|break|continue|defer)\\b" },
|
|
{ "name": "keyword.declaration.rex", "match": "\\b(func|var|const|import|struct|enum|interface|pub)\\b" },
|
|
{ "name": "storage.modifier.rex", "match": "\\b(shared|weak)\\b" }
|
|
]
|
|
},
|
|
"constants": {
|
|
"name": "constant.language.rex",
|
|
"match": "\\b(true|false|nil)\\b"
|
|
},
|
|
"numbers": {
|
|
"name": "constant.numeric.rex",
|
|
"match": "\\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|[0-9][0-9_]*(?:\\.[0-9][0-9_]*)?)\\b"
|
|
},
|
|
"types": {
|
|
"patterns": [
|
|
{
|
|
"name": "support.type.builtin.rex",
|
|
"match": "\\b(int|float|bool|char|string|error|map|i8|i16|i32|i64|u8|u16|u32|u64|f32|f64)\\b"
|
|
},
|
|
{ "name": "entity.name.type.rex", "match": "\\b[A-Z][A-Za-z0-9_]*\\b" }
|
|
]
|
|
},
|
|
"calls": {
|
|
"name": "entity.name.function.call.rex",
|
|
"match": "\\b[a-z_][A-Za-z0-9_]*(?=\\s*\\()"
|
|
},
|
|
"operators": {
|
|
"patterns": [
|
|
{ "name": "keyword.operator.arrow.rex", "match": "=>" },
|
|
{ "name": "keyword.operator.range.rex", "match": "\\.\\." },
|
|
{ "name": "keyword.operator.comparison.rex", "match": "==|!=|<=|>=|<|>" },
|
|
{ "name": "keyword.operator.logical.rex", "match": "&&|\\|\\||!" },
|
|
{ "name": "keyword.operator.assignment.rex", "match": "[-+*/%]?=" },
|
|
{ "name": "keyword.operator.arithmetic.rex", "match": "[-+*/%]" },
|
|
{ "name": "keyword.operator.optional.rex", "match": "\\?" }
|
|
]
|
|
}
|
|
}
|
|
}
|