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
213 lines
8.9 KiB
XML
213 lines
8.9 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE language>
|
|
<!--
|
|
Finch syntax highlighting for Kate, KWrite and KDevelop (KSyntaxHighlighting).
|
|
Install: copy to ~/.local/share/org.kde.syntax-highlighting/syntax/finch.xml
|
|
(or run editors/kate/install.sh), then restart Kate.
|
|
-->
|
|
<language name="Finch" version="5" kateversion="5.0" section="Sources" extensions="*.fch"
|
|
mimetype="text/x-finch" indenter="cstyle" author="The Finch authors" license="Apache-2.0">
|
|
<highlighting>
|
|
<list name="keywords">
|
|
<item>fn</item>
|
|
<item>struct</item>
|
|
<item>enum</item>
|
|
<item>export</item>
|
|
<item>const</item>
|
|
</list>
|
|
<list name="control">
|
|
<item>if</item>
|
|
<item>else</item>
|
|
<item>while</item>
|
|
<item>for</item>
|
|
<item>in</item>
|
|
<item>break</item>
|
|
<item>continue</item>
|
|
<item>return</item>
|
|
<item>defer</item>
|
|
<item>or</item>
|
|
<item>try</item>
|
|
<item>match</item>
|
|
</list>
|
|
<list name="imports">
|
|
<item>import</item>
|
|
<item>link</item>
|
|
</list>
|
|
<list name="constants">
|
|
<item>true</item>
|
|
<item>false</item>
|
|
<item>null</item>
|
|
<item>self</item>
|
|
</list>
|
|
<list name="types">
|
|
<item>int</item>
|
|
<item>float</item>
|
|
<item>bool</item>
|
|
<item>char</item>
|
|
<item>str</item>
|
|
<item>ptr</item>
|
|
<item>map</item>
|
|
<item>i8</item>
|
|
<item>i16</item>
|
|
<item>i32</item>
|
|
<item>i64</item>
|
|
<item>u8</item>
|
|
<item>u16</item>
|
|
<item>u32</item>
|
|
<item>u64</item>
|
|
<item>f32</item>
|
|
<item>f64</item>
|
|
</list>
|
|
<list name="builtins">
|
|
<item>print</item>
|
|
<item>input</item>
|
|
<item>read_file</item>
|
|
<item>write_file</item>
|
|
<item>file_exists</item>
|
|
<item>delete_file</item>
|
|
<item>shell</item>
|
|
<item>exit</item>
|
|
<item>addr</item>
|
|
<item>new</item>
|
|
<item>free</item>
|
|
<item>error</item>
|
|
<item>min</item>
|
|
<item>max</item>
|
|
<item>abs</item>
|
|
<item>clamp</item>
|
|
<item>assert</item>
|
|
<item>atomic_add</item>
|
|
<item>atomic_sub</item>
|
|
<item>atomic_load</item>
|
|
<item>atomic_store</item>
|
|
<item>atomic_swap</item>
|
|
<item>atomic_cas</item>
|
|
</list>
|
|
|
|
<contexts>
|
|
<context name="Normal" attribute="Normal Text" lineEndContext="#stay">
|
|
<DetectSpaces/>
|
|
<Detect2Chars char="/" char1="/" attribute="Comment" context="LineComment"/>
|
|
<Detect2Chars char="/" char1="*" attribute="Comment" context="BlockComment" beginRegion="Comment"/>
|
|
<DetectChar char="{" attribute="Symbol" beginRegion="Brace"/>
|
|
<DetectChar char="}" attribute="Symbol" endRegion="Brace"/>
|
|
<StringDetect String=""""" attribute="String" context="LongString" beginRegion="LongString"/>
|
|
<DetectChar char=""" attribute="String" context="String"/>
|
|
<DetectChar char="'" attribute="Char" context="Char"/>
|
|
|
|
<WordDetect String="fn" attribute="Keyword" context="FunctionName"/>
|
|
<RegExpr String="\btest(?=\s*")" attribute="Keyword"/>
|
|
<RegExpr String="(?<=\s)as(?=\s+[A-Za-z_])" attribute="Import"/>
|
|
<WordDetect String="struct" attribute="Keyword" context="StructName"/>
|
|
<keyword String="control" attribute="Control Flow"/>
|
|
<keyword String="imports" attribute="Import"/>
|
|
<keyword String="constants" attribute="Constant"/>
|
|
<keyword String="types" attribute="Data Type"/>
|
|
<!-- vectors: f32x8, i8x32, u16x16, f64x4 ... -->
|
|
<RegExpr String="\b[iuf](8|16|32|64)x(2|4|8|16|32|64)\b" attribute="Data Type"/>
|
|
<keyword String="builtins" attribute="Built-in"/>
|
|
|
|
<RegExpr String="\b0[xX][0-9a-fA-F_]+\b" attribute="Hex"/>
|
|
<RegExpr String="\b[0-9][0-9_]*(\.[0-9][0-9_]*)?[eE][+-]?[0-9]+\b" attribute="Float"/>
|
|
<RegExpr String="\b[0-9][0-9_]*\.[0-9][0-9_]*\b" attribute="Float"/>
|
|
<RegExpr String="\b[0-9][0-9_]*\b" attribute="Decimal"/>
|
|
|
|
<!-- a call: name( ; method or field after a dot -->
|
|
<RegExpr String="\b[A-Za-z_][A-Za-z0-9_]*(?=\s*\()" attribute="Function"/>
|
|
<!-- struct names are written with a capital letter by convention -->
|
|
<RegExpr String="\b[A-Z][A-Za-z0-9_]*\b" attribute="Data Type"/>
|
|
<DetectIdentifier/>
|
|
|
|
<Detect2Chars char=":" char1="=" attribute="Operator"/>
|
|
<Detect2Chars char="-" char1=">" attribute="Operator"/>
|
|
<Detect2Chars char="." char1="." attribute="Operator"/>
|
|
<AnyChar String="+-*/%=<>!&|^~" attribute="Operator"/>
|
|
<AnyChar String="()[],.:" attribute="Symbol"/>
|
|
</context>
|
|
|
|
<!-- fn name( or fn Type.method( -->
|
|
<context name="FunctionName" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
|
|
<DetectSpaces/>
|
|
<RegExpr String="[A-Za-z_][A-Za-z0-9_]*(?=\.)" attribute="Data Type"/>
|
|
<DetectChar char="." attribute="Symbol"/>
|
|
<RegExpr String="[A-Za-z_][A-Za-z0-9_]*" attribute="Function Definition" context="#pop"/>
|
|
</context>
|
|
|
|
<context name="StructName" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
|
|
<DetectSpaces/>
|
|
<RegExpr String="[A-Za-z_][A-Za-z0-9_]*" attribute="Data Type" context="#pop"/>
|
|
</context>
|
|
|
|
<context name="LineComment" attribute="Comment" lineEndContext="#pop">
|
|
<DetectSpaces/>
|
|
<IncludeRules context="##Comments"/>
|
|
</context>
|
|
|
|
<context name="BlockComment" attribute="Comment" lineEndContext="#stay">
|
|
<Detect2Chars char="*" char1="/" attribute="Comment" context="#pop" endRegion="Comment"/>
|
|
<IncludeRules context="##Comments"/>
|
|
</context>
|
|
|
|
<context name="String" attribute="String" lineEndContext="#pop">
|
|
<RegExpr String="\\\(" attribute="Escape" context="Interpolation"/>
|
|
<RegExpr String="\\[ntr0\\"']" attribute="Escape"/>
|
|
<RegExpr String="\\." attribute="Error"/>
|
|
<DetectChar char=""" attribute="String" context="#pop"/>
|
|
</context>
|
|
|
|
<context name="LongString" attribute="String" lineEndContext="#stay">
|
|
<RegExpr String="\\\(" attribute="Escape" context="Interpolation"/>
|
|
<RegExpr String="\\[ntr0\\"']" attribute="Escape"/>
|
|
<StringDetect String=""""" attribute="String" context="#pop" endRegion="LongString"/>
|
|
</context>
|
|
|
|
<!-- "hp \(hp + 1)": code inside text, up to the ) that closes \( -->
|
|
<context name="Interpolation" attribute="Normal Text" lineEndContext="#stay">
|
|
<DetectChar char=")" attribute="Escape" context="#pop"/>
|
|
<DetectChar char="(" attribute="Symbol" context="InterpolationParen"/>
|
|
<IncludeRules context="Normal"/>
|
|
</context>
|
|
<context name="InterpolationParen" attribute="Normal Text" lineEndContext="#stay">
|
|
<DetectChar char=")" attribute="Symbol" context="#pop"/>
|
|
<DetectChar char="(" attribute="Symbol" context="InterpolationParen"/>
|
|
<IncludeRules context="Normal"/>
|
|
</context>
|
|
|
|
<context name="Char" attribute="Char" lineEndContext="#pop">
|
|
<RegExpr String="\\[ntr0\\"']" attribute="Escape"/>
|
|
<DetectChar char="'" attribute="Char" context="#pop"/>
|
|
</context>
|
|
</contexts>
|
|
|
|
<itemDatas>
|
|
<itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/>
|
|
<itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
|
|
<itemData name="Control Flow" defStyleNum="dsControlFlow" spellChecking="false"/>
|
|
<itemData name="Import" defStyleNum="dsImport" spellChecking="false"/>
|
|
<itemData name="Constant" defStyleNum="dsConstant" spellChecking="false"/>
|
|
<itemData name="Data Type" defStyleNum="dsDataType" spellChecking="false"/>
|
|
<itemData name="Built-in" defStyleNum="dsBuiltIn" spellChecking="false"/>
|
|
<itemData name="Function" defStyleNum="dsFunction" spellChecking="false"/>
|
|
<itemData name="Function Definition" defStyleNum="dsFunction" bold="true" spellChecking="false"/>
|
|
<itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false"/>
|
|
<itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/>
|
|
<itemData name="Float" defStyleNum="dsFloat" spellChecking="false"/>
|
|
<itemData name="String" defStyleNum="dsString"/>
|
|
<itemData name="Char" defStyleNum="dsChar" spellChecking="false"/>
|
|
<itemData name="Escape" defStyleNum="dsSpecialChar" spellChecking="false"/>
|
|
<itemData name="Operator" defStyleNum="dsOperator" spellChecking="false"/>
|
|
<itemData name="Symbol" defStyleNum="dsNormal" spellChecking="false"/>
|
|
<itemData name="Comment" defStyleNum="dsComment"/>
|
|
<itemData name="Error" defStyleNum="dsError" spellChecking="false"/>
|
|
</itemDatas>
|
|
</highlighting>
|
|
|
|
<general>
|
|
<comments>
|
|
<comment name="singleLine" start="//"/>
|
|
<comment name="multiLine" start="/*" end="*/" region="Comment"/>
|
|
</comments>
|
|
<keywords casesensitive="1"/>
|
|
<folding indentationsensitive="0"/>
|
|
</general>
|
|
</language>
|