Files
carbon-lang/utils/textmate/Samples/functions_variables.svg
T
Chandler Carruth 25b77cd3d4 Revert "Improve the TextMate grammar scopes and precision (#7888)" (#7909)
This reverts commit 65a3c2b36a.

It was merged by accident with a dependent change. Will re-land
independently.
2026-10-06 20:17:51 +00:00

57 lines
14 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" width="721" height="1012" viewBox="0 0 721 1012">
<rect width="100%" height="100%" fill="#1f1f1f"/>
<g xml:space="preserve" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="14">
<text style="white-space:pre" x="12" y="26"><tspan fill="#6e7681"> 1 </tspan><tspan fill="#6a9955">// Part of the Carbon Language project, under the Apache License v2.0 with LLVM</tspan></text>
<text style="white-space:pre" x="12" y="45"><tspan fill="#6e7681"> 2 </tspan><tspan fill="#6a9955">// Exceptions. See /LICENSE for license information.</tspan></text>
<text style="white-space:pre" x="12" y="64"><tspan fill="#6e7681"> 3 </tspan><tspan fill="#6a9955">// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception</tspan></text>
<text style="white-space:pre" x="12" y="83"><tspan fill="#6e7681"> 4 </tspan></text>
<text style="white-space:pre" x="12" y="102"><tspan fill="#6e7681"> 5 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="121"><tspan fill="#6e7681"> 6 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F1</tspan><tspan fill="#d4d4d4">();</tspan></text>
<text style="white-space:pre" x="12" y="140"><tspan fill="#6e7681"> 7 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">Func</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">);</tspan></text>
<text style="white-space:pre" x="12" y="159"><tspan fill="#6e7681"> 8 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">Generic</tspan><tspan fill="#d4d4d4">[</tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">type</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#4ec9b0">U</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">I</tspan><tspan fill="#d4d4d4">](</tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">U</tspan><tspan fill="#d4d4d4">) -&gt; </tspan><tspan fill="#4ec9b0">U</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="178"><tspan fill="#6e7681"> 9 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">Lambda</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">) -&gt; </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4"> =&gt; </tspan><tspan fill="#c586c0">return</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4"> + </tspan><tspan fill="#b5cea8">5</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="197"><tspan fill="#6e7681">10 </tspan><tspan fill="#569cd6">fn</tspan></text>
<text style="white-space:pre" x="12" y="216"><tspan fill="#6e7681">11 </tspan></text>
<text style="white-space:pre" x="12" y="235"><tspan fill="#6e7681">12 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#4ec9b0">MultiLine</tspan><tspan fill="#d4d4d4">[</tspan></text>
<text style="white-space:pre" x="12" y="254"><tspan fill="#6e7681">13 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">type</tspan><tspan fill="#d4d4d4">,</tspan></text>
<text style="white-space:pre" x="12" y="273"><tspan fill="#6e7681">14 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#4ec9b0">B</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">C1</tspan><tspan fill="#d4d4d4">,</tspan></text>
<text style="white-space:pre" x="12" y="292"><tspan fill="#6e7681">15 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#4ec9b0">C</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">C2</tspan></text>
<text style="white-space:pre" x="12" y="311"><tspan fill="#6e7681">16 </tspan><tspan fill="#d4d4d4"> ](</tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#dcdcaa">A</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#4ec9b0">B</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#4ec9b0">C</tspan><tspan fill="#d4d4d4">),</tspan></text>
<text style="white-space:pre" x="12" y="330"><tspan fill="#6e7681">17 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">B</tspan><tspan fill="#d4d4d4">,</tspan></text>
<text style="white-space:pre" x="12" y="349"><tspan fill="#6e7681">18 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">c</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">);</tspan></text>
<text style="white-space:pre" x="12" y="368"><tspan fill="#6e7681">19 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">Invalid</tspan><tspan fill="#d4d4d4">#+?</tspan><tspan fill="#dcdcaa">Name</tspan><tspan fill="#d4d4d4">();</tspan></text>
<text style="white-space:pre" x="12" y="387"><tspan fill="#6e7681">20 </tspan><tspan fill="#9cdcfe">x</tspan><tspan fill="#d4d4d4">.(</tspan><tspan fill="#4ec9b0">I</tspan><tspan fill="#d4d4d4">.</tspan><tspan fill="#4ec9b0">F</tspan><tspan fill="#d4d4d4">)();</tspan></text>
<text style="white-space:pre" x="12" y="406"><tspan fill="#6e7681">21 </tspan></text>
<text style="white-space:pre" x="12" y="425"><tspan fill="#6e7681">22 </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="444"><tspan fill="#6e7681">23 </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4"> = (</tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#c586c0">as</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">);</tspan></text>
<text style="white-space:pre" x="12" y="463"><tspan fill="#6e7681">24 </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="482"><tspan fill="#6e7681">25 </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">array</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#b5cea8">5</tspan><tspan fill="#d4d4d4">);</tspan></text>
<text style="white-space:pre" x="12" y="501"><tspan fill="#6e7681">26 </tspan><tspan fill="#569cd6">generic</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">type</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="520"><tspan fill="#6e7681">27 </tspan><tspan fill="#569cd6">generic</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4"> = </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="539"><tspan fill="#6e7681">28 </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#c586c0">in</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">some_list</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="558"><tspan fill="#6e7681">29 </tspan><tspan fill="#569cd6">var</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="577"><tspan fill="#6e7681">30 </tspan><tspan fill="#569cd6">let</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="596"><tspan fill="#6e7681">31 </tspan><tspan fill="#9cdcfe">binding</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="615"><tspan fill="#6e7681">32 </tspan><tspan fill="#569cd6">generic</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">binding</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="634"><tspan fill="#6e7681">33 </tspan><tspan fill="#569cd6">var</tspan></text>
<text style="white-space:pre" x="12" y="653"><tspan fill="#6e7681">34 </tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">multiline</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="672"><tspan fill="#6e7681">35 </tspan></text>
<text style="white-space:pre" x="12" y="691"><tspan fill="#6e7681">36 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#569cd6">ref</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">a</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">A</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#569cd6">const</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#569cd6">ref</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">b</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">B</tspan><tspan fill="#d4d4d4">);</tspan></text>
<text style="white-space:pre" x="12" y="710"><tspan fill="#6e7681">37 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F</tspan><tspan fill="#d4d4d4">() -&gt; </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="729"><tspan fill="#6e7681">38 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F</tspan><tspan fill="#d4d4d4">() -&gt; </tspan><tspan fill="#4ec9b0">T</tspan><tspan fill="#d4d4d4">.</tspan><tspan fill="#4ec9b0">U</tspan><tspan fill="#d4d4d4"> { </tspan><tspan fill="#c586c0">return</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#569cd6">val</tspan><tspan fill="#d4d4d4">; }</tspan></text>
<text style="white-space:pre" x="12" y="748"><tspan fill="#6e7681">39 </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#dcdcaa">F</tspan><tspan fill="#d4d4d4">() -&gt; </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4"> =&gt; </tspan><tspan fill="#c586c0">return</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#569cd6">val</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="767"><tspan fill="#6e7681">40 </tspan></text>
<text style="white-space:pre" x="12" y="786"><tspan fill="#6e7681">41 </tspan><tspan fill="#6a9955">// --- lambdas and positional parameters</tspan></text>
<text style="white-space:pre" x="12" y="805"><tspan fill="#6e7681">42 </tspan></text>
<text style="white-space:pre" x="12" y="824"><tspan fill="#6e7681">43 </tspan><tspan fill="#569cd6">var</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">explicit</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">auto</tspan><tspan fill="#d4d4d4"> = </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> (</tspan><tspan fill="#9cdcfe">x</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">) -&gt; </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4"> { </tspan><tspan fill="#c586c0">return</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">x</tspan><tspan fill="#d4d4d4"> + </tspan><tspan fill="#b5cea8">1</tspan><tspan fill="#d4d4d4">; };</tspan></text>
<text style="white-space:pre" x="12" y="843"><tspan fill="#6e7681">44 </tspan><tspan fill="#569cd6">var</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">expression</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">auto</tspan><tspan fill="#d4d4d4"> = </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> (</tspan><tspan fill="#9cdcfe">x</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4">) =&gt; </tspan><tspan fill="#9cdcfe">x</tspan><tspan fill="#d4d4d4"> + </tspan><tspan fill="#b5cea8">1</tspan><tspan fill="#d4d4d4">;</tspan></text>
<text style="white-space:pre" x="12" y="862"><tspan fill="#6e7681">45 </tspan><tspan fill="#569cd6">var</tspan><tspan fill="#d4d4d4"> </tspan><tspan fill="#9cdcfe">positional</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">auto</tspan><tspan fill="#d4d4d4"> = </tspan><tspan fill="#569cd6">fn</tspan><tspan fill="#d4d4d4"> { </tspan><tspan fill="#dcdcaa">Print</tspan><tspan fill="#d4d4d4">(</tspan><tspan fill="#9cdcfe">$0</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#9cdcfe">$1</tspan><tspan fill="#d4d4d4">, </tspan><tspan fill="#9cdcfe">$42</tspan><tspan fill="#d4d4d4">); };</tspan></text>
<text style="white-space:pre" x="12" y="881"><tspan fill="#6e7681">46 </tspan></text>
<text style="white-space:pre" x="12" y="900"><tspan fill="#6e7681">47 </tspan><tspan fill="#6a9955">// --- raw identifiers</tspan></text>
<text style="white-space:pre" x="12" y="919"><tspan fill="#6e7681">48 </tspan></text>
<text style="white-space:pre" x="12" y="938"><tspan fill="#6e7681">49 </tspan><tspan fill="#d4d4d4">r#</tspan><tspan fill="#9cdcfe">class</tspan></text>
<text style="white-space:pre" x="12" y="957"><tspan fill="#6e7681">50 </tspan><tspan fill="#d4d4d4">r#</tspan><tspan fill="#9cdcfe">if</tspan></text>
<text style="white-space:pre" x="12" y="976"><tspan fill="#6e7681">51 </tspan><tspan fill="#d4d4d4">r#</tspan><tspan fill="#9cdcfe">i32</tspan></text>
<text style="white-space:pre" x="12" y="995"><tspan fill="#6e7681">52 </tspan><tspan fill="#569cd6">var</tspan><tspan fill="#d4d4d4"> r#</tspan><tspan fill="#9cdcfe">var</tspan><tspan fill="#d4d4d4">: </tspan><tspan fill="#4ec9b0">i32</tspan><tspan fill="#d4d4d4"> = r#</tspan><tspan fill="#9cdcfe">class</tspan><tspan fill="#d4d4d4">;</tspan></text>
</g></svg>