mirror of
https://github.com/cheat/cheat.git
synced 2024-11-23 22:41:35 +01:00
1790aec85d
Bump `alecthomas/chroma` to `v2`: https://github.com/cheat/cheat/issues/735
270 lines
8.1 KiB
XML
270 lines
8.1 KiB
XML
<lexer>
|
|
<config>
|
|
<name>Metal</name>
|
|
<alias>metal</alias>
|
|
<filename>*.metal</filename>
|
|
<mime_type>text/x-metal</mime_type>
|
|
<ensure_nl>true</ensure_nl>
|
|
</config>
|
|
<rules>
|
|
<state name="function">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="statements"/>
|
|
</rule>
|
|
<rule pattern=";">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
<push/>
|
|
</rule>
|
|
<rule pattern="\}">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="macro">
|
|
<rule pattern="(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)">
|
|
<bygroups>
|
|
<token type="CommentPreproc"/>
|
|
<token type="Text"/>
|
|
<token type="CommentPreprocFile"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="[^/\n]+">
|
|
<token type="CommentPreproc"/>
|
|
</rule>
|
|
<rule pattern="/[*](.|\n)*?[*]/">
|
|
<token type="CommentMultiline"/>
|
|
</rule>
|
|
<rule pattern="//.*?\n">
|
|
<token type="CommentSingle"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="/">
|
|
<token type="CommentPreproc"/>
|
|
</rule>
|
|
<rule pattern="(?<=\\)\n">
|
|
<token type="CommentPreproc"/>
|
|
</rule>
|
|
<rule pattern="\n">
|
|
<token type="CommentPreproc"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="if0">
|
|
<rule pattern="^\s*#if.*?(?<!\\)\n">
|
|
<token type="CommentPreproc"/>
|
|
<push/>
|
|
</rule>
|
|
<rule pattern="^\s*#el(?:se|if).*\n">
|
|
<token type="CommentPreproc"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="^\s*#endif.*?(?<!\\)\n">
|
|
<token type="CommentPreproc"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern=".*?\n">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
</state>
|
|
<state name="statements">
|
|
<rule pattern="(namespace|constexpr|operator|template|using|this)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="(enum)\b(\s+)(class)\b(\s*)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="classname"/>
|
|
</rule>
|
|
<rule pattern="(class|struct|enum|union)\b(\s*)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="classname"/>
|
|
</rule>
|
|
<rule pattern="\[\[.+\]\]">
|
|
<token type="NameAttribute"/>
|
|
</rule>
|
|
<rule pattern="(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*">
|
|
<token type="LiteralNumberFloat"/>
|
|
</rule>
|
|
<rule pattern="(\d+\.\d*|\.\d+|\d+[fF])[fF]?">
|
|
<token type="LiteralNumberFloat"/>
|
|
</rule>
|
|
<rule pattern="0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*">
|
|
<token type="LiteralNumberHex"/>
|
|
</rule>
|
|
<rule pattern="0('?[0-7]+)+[LlUu]*">
|
|
<token type="LiteralNumberOct"/>
|
|
</rule>
|
|
<rule pattern="0[Bb][01]('?[01]+)*[LlUu]*">
|
|
<token type="LiteralNumberBin"/>
|
|
</rule>
|
|
<rule pattern="[0-9]('?[0-9]+)*[LlUu]*">
|
|
<token type="LiteralNumberInteger"/>
|
|
</rule>
|
|
<rule pattern="\*/">
|
|
<token type="Error"/>
|
|
</rule>
|
|
<rule pattern="[~!%^&*+=|?:<>/-]">
|
|
<token type="Operator"/>
|
|
</rule>
|
|
<rule pattern="[()\[\],.]">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="(continue|typedef|sizeof|extern|static|switch|struct|return|union|const|break|while|enum|else|case|for|do|if)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="(bool|float|half|long|ptrdiff_t|size_t|unsigned|u?char|u?int((8|16|32|64)_t)?|u?short)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="(bool|float|half|u?(char|int|long|short))(2|3|4)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="packed_(float|half|long|u?(char|int|short))(2|3|4)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="(float|half)(2|3|4)x(2|3|4)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="atomic_u?int\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="(rg?(8|16)(u|s)norm|rgba(8|16)(u|s)norm|srgba8unorm|rgb10a2|rg11b10f|rgb9e5)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="(array|depth(2d|cube)(_array)?|depth2d_ms(_array)?|sampler|texture_buffer|texture(1|2)d(_array)?|texture2d_ms(_array)?|texture3d|texturecube(_array)?|uniform|visible_function_table)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="(true|false|NULL)\b">
|
|
<token type="NameBuiltin"/>
|
|
</rule>
|
|
<rule pattern="(threadgroup_imageblock|threadgroup|constant|ray_data|device|thread)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="([a-zA-Z_]\w*)(\s*)(:)(?!:)">
|
|
<bygroups>
|
|
<token type="NameLabel"/>
|
|
<token type="Text"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="Name"/>
|
|
</rule>
|
|
</state>
|
|
<state name="root">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule pattern="(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<usingself state="root"/>
|
|
<token type="NameFunction"/>
|
|
<usingself state="root"/>
|
|
<usingself state="root"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="function"/>
|
|
</rule>
|
|
<rule pattern="(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<usingself state="root"/>
|
|
<token type="NameFunction"/>
|
|
<usingself state="root"/>
|
|
<usingself state="root"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule>
|
|
<push state="statement"/>
|
|
</rule>
|
|
</state>
|
|
<state name="classname">
|
|
<rule pattern="(\[\[.+\]\])(\s*)">
|
|
<bygroups>
|
|
<token type="NameAttribute"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="NameClass"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="\s*(?=[>{])">
|
|
<token type="Text"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="whitespace">
|
|
<rule pattern="^#if\s+0">
|
|
<token type="CommentPreproc"/>
|
|
<push state="if0"/>
|
|
</rule>
|
|
<rule pattern="^#">
|
|
<token type="CommentPreproc"/>
|
|
<push state="macro"/>
|
|
</rule>
|
|
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)">
|
|
<bygroups>
|
|
<usingself state="root"/>
|
|
<token type="CommentPreproc"/>
|
|
</bygroups>
|
|
<push state="if0"/>
|
|
</rule>
|
|
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#)">
|
|
<bygroups>
|
|
<usingself state="root"/>
|
|
<token type="CommentPreproc"/>
|
|
</bygroups>
|
|
<push state="macro"/>
|
|
</rule>
|
|
<rule pattern="\n">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="\s+">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="\\\n">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="//(\n|[\w\W]*?[^\\]\n)">
|
|
<token type="CommentSingle"/>
|
|
</rule>
|
|
<rule pattern="/(\\\n)?[*][\w\W]*?[*](\\\n)?/">
|
|
<token type="CommentMultiline"/>
|
|
</rule>
|
|
<rule pattern="/(\\\n)?[*][\w\W]*">
|
|
<token type="CommentMultiline"/>
|
|
</rule>
|
|
</state>
|
|
<state name="statement">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="statements"/>
|
|
</rule>
|
|
<rule pattern="[{]">
|
|
<token type="Punctuation"/>
|
|
<push state="root"/>
|
|
</rule>
|
|
<rule pattern="[;}]">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
</rules>
|
|
</lexer> |