Finch/editors/vscode/syntaxes/finch.tmLanguage.json
Nexoniarz bb9702aeba Finch 2.5.0: docs (EN, PL), Kate and VS Code for the new features
- cheat sheets, technicians' and engineers' guides: "\(x)", test blocks, finch fmt, finch.toml,
  the build cache, the chain of calls, threads and atomics, C++/Rust/Android, struct #defines,
  passing structs, why there is no warning for big copies
- Kate (version 4) and VS Code: code inside text, test, min/max/abs/clamp/assert/atomic_...
- finch.toml's name is used only for its entry; other files of the project keep their own name

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
2026-10-29 11:34:41 +01:00

314 lines
7.4 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Finch",
"scopeName": "source.finch",
"fileTypes": [
"fch"
],
"patterns": [
{
"include": "#comments"
},
{
"include": "#imports"
},
{
"include": "#struct"
},
{
"include": "#function"
},
{
"include": "#statements"
}
],
"repository": {
"comments": {
"patterns": [
{
"name": "comment.line.double-slash.finch",
"match": "//.*$"
},
{
"name": "comment.block.finch",
"begin": "/\\*",
"end": "\\*/"
}
]
},
"imports": {
"patterns": [
{
"match": "^\\s*(import)\\s+(\"[^\"]*\")",
"captures": {
"1": {
"name": "keyword.control.import.finch"
},
"2": {
"name": "string.quoted.double.include.finch"
}
}
},
{
"match": "^\\s*(import)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "keyword.control.import.finch"
},
"2": {
"name": "entity.name.namespace.finch"
}
}
},
{
"match": "^\\s*(link)\\s+(\"[^\"]*\")",
"captures": {
"1": {
"name": "keyword.control.import.finch"
},
"2": {
"name": "string.quoted.double.finch"
}
}
}
]
},
"struct": {
"match": "\\b(struct|enum)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "storage.type.struct.finch"
},
"2": {
"name": "entity.name.type.struct.finch"
}
}
},
"function": {
"match": "\\b(fn)\\s+(?:([A-Za-z_][A-Za-z0-9_]*)(\\.))?([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "storage.type.function.finch"
},
"2": {
"name": "entity.name.type.finch"
},
"3": {
"name": "punctuation.accessor.finch"
},
"4": {
"name": "entity.name.function.finch"
}
}
},
"statements": {
"patterns": [
{
"name": "keyword.other.test.finch",
"match": "\\btest(?=\\s*\")"
},
{
"include": "#comments"
},
{
"include": "#longstrings"
},
{
"include": "#strings"
},
{
"include": "#chars"
},
{
"include": "#numbers"
},
{
"name": "keyword.control.finch",
"match": "\\b(if|else|while|for|in|break|continue|return|defer|or|try|match)\\b"
},
{
"name": "storage.type.function.finch",
"match": "\\bfn\\b"
},
{
"name": "storage.type.struct.finch",
"match": "\\b(struct|enum|const)\\b"
},
{
"name": "storage.modifier.finch",
"match": "\\bexport\\b"
},
{
"name": "constant.language.finch",
"match": "\\b(true|false|null)\\b"
},
{
"name": "variable.language.self.finch",
"match": "\\bself\\b"
},
{
"name": "storage.type.primitive.finch",
"match": "\\b(int|float|bool|char|str|ptr|map|i8|i16|i32|i64|u8|u16|u32|u64|f32|f64)\\b"
},
{
"match": "\\b(print|input|read_file|write_file|file_exists|delete_file|shell|exit|addr|new|free|error|min|max|abs|clamp|assert|atomic_add|atomic_sub|atomic_load|atomic_store|atomic_swap|atomic_cas)\\s*(?=\\()",
"captures": {
"1": {
"name": "support.function.builtin.finch"
}
}
},
{
"match": "(?<=\\.)(len|ptr|value)\\b(?!\\s*\\()",
"captures": {
"1": {
"name": "variable.other.property.finch"
}
}
},
{
"match": "\\b([A-Z][A-Za-z0-9_]*)\\s*(?=\\()",
"captures": {
"1": {
"name": "entity.name.type.finch"
}
}
},
{
"match": "\\b([a-z_][A-Za-z0-9_]*)\\s*(?=\\()",
"captures": {
"1": {
"name": "entity.name.function.call.finch"
}
}
},
{
"name": "entity.name.type.finch",
"match": "\\b[A-Z][A-Za-z0-9_]*\\b"
},
{
"name": "keyword.operator.assignment.finch",
"match": ":=|\\+=|-=|\\*=|/=|%=|(?<![=!<>])=(?!=)"
},
{
"name": "keyword.operator.comparison.finch",
"match": "==|!=|<=|>=|<|>"
},
{
"name": "keyword.operator.logical.finch",
"match": "&&|\\|\\||!"
},
{
"name": "keyword.operator.arrow.finch",
"match": "->"
},
{
"name": "keyword.operator.range.finch",
"match": "\\.\\."
},
{
"name": "keyword.operator.arithmetic.finch",
"match": "<<|>>|[-+*/%&|^~]"
},
{
"name": "variable.other.finch",
"match": "\\b[a-z_][A-Za-z0-9_]*\\b"
}
]
},
"strings": {
"name": "string.quoted.double.finch",
"begin": "\"",
"end": "\"|$",
"patterns": [
{
"include": "#interpolation"
},
{
"name": "constant.character.escape.finch",
"match": "\\\\[ntr0\\\\\"']"
},
{
"name": "invalid.illegal.escape.finch",
"match": "\\\\."
}
]
},
"chars": {
"name": "string.quoted.single.finch",
"begin": "'",
"end": "'|$",
"patterns": [
{
"name": "constant.character.escape.finch",
"match": "\\\\[ntr0\\\\\"']"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.hex.finch",
"match": "\\b0[xX][0-9A-Fa-f_]+\\b"
},
{
"name": "constant.numeric.float.finch",
"match": "\\b\\d[\\d_]*(\\.\\d[\\d_]*([eE][+-]?\\d+)?|[eE][+-]?\\d+)\\b"
},
{
"name": "constant.numeric.integer.finch",
"match": "\\b\\d[\\d_]*\\b"
}
]
},
"longstrings": {
"name": "string.quoted.triple.finch",
"begin": "\"\"\"",
"end": "\"\"\"",
"patterns": [
{
"include": "#interpolation"
},
{
"name": "constant.character.escape.finch",
"match": "\\\\[ntr0\\\\\"']"
}
]
},
"interpolation": {
"name": "meta.embedded.line.finch",
"begin": "\\\\\\(",
"end": "\\)",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.finch"
}
},
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.finch"
}
},
"patterns": [
{
"include": "#interpolation-parens"
},
{
"include": "$self"
}
]
},
"interpolation-parens": {
"begin": "\\(",
"end": "\\)",
"patterns": [
{
"include": "#interpolation-parens"
},
{
"include": "$self"
}
]
}
}
}