mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 00:44:27 +00:00
- fNxM / iNxM / uNxM up to 512 bits, as LLVM vectors (<8 x float>): LLVM picks SSE, AVX2, AVX-512 or NEON for them - f32x8(x) in every lane, f32x8(a, ..., h), f32x8(list, i) loads, f32x8(i32x8 v) converts - + - * / and the bit operators lane by lane, with a plain number on either side counting for every lane; v[i], v[i] = x, v.len, == / != (every lane), print and str - methods: sum min max dot abs sqrt floor ceil round fma store; min/max/abs/clamp lane by lane - wide vectors (and structs holding them) are loaded and stored with align 16, what malloc and the stack give - --cpu <name> (and cpu = "..." in finch.toml): native, x86-64-v3, apple-m1, ... - debug info shows vectors; the language server completes their methods; Kate and VS Code highlight them - f32 x = -1.5 works: a minus in front of a float written in the code keeps it such a number Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Psc42moPLwP43Cmb9oZqSR
314 lines
7.4 KiB
JSON
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|[iuf](?:8|16|32|64)x(?:2|4|8|16|32|64))\\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"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|