cheat/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typescript.xml

263 lines
7.9 KiB
XML

<lexer>
<config>
<name>TypeScript</name>
<alias>ts</alias>
<alias>tsx</alias>
<alias>typescript</alias>
<filename>*.ts</filename>
<filename>*.tsx</filename>
<filename>*.mts</filename>
<filename>*.cts</filename>
<mime_type>text/x-typescript</mime_type>
<dot_all>true</dot_all>
<ensure_nl>true</ensure_nl>
</config>
<rules>
<state name="expression">
<rule pattern="{">
<token type="Punctuation"/>
<push/>
</rule>
<rule pattern="}">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule>
<include state="root"/>
</rule>
</state>
<state name="jsx">
<rule pattern="(&lt;)(/?)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(&lt;)([\w\.]+)">
<bygroups>
<token type="Punctuation"/>
<token type="NameTag"/>
</bygroups>
<push state="tag"/>
</rule>
<rule pattern="(&lt;)(/)([\w\.]*)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation"/>
<token type="NameTag"/>
<token type="Punctuation"/>
</bygroups>
</rule>
</state>
<state name="tag">
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="([\w]+\s*)(=)(\s*)">
<bygroups>
<token type="NameAttribute"/>
<token type="Operator"/>
<token type="Text"/>
</bygroups>
<push state="attr"/>
</rule>
<rule pattern="[{}]+">
<token type="Punctuation"/>
</rule>
<rule pattern="[\w\.]+">
<token type="NameAttribute"/>
</rule>
<rule pattern="(/?)(\s*)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Text"/>
<token type="Punctuation"/>
</bygroups>
<pop depth="1"/>
</rule>
</state>
<state name="commentsandwhitespace">
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="&lt;!--">
<token type="Comment"/>
</rule>
<rule pattern="//.*?\n">
<token type="CommentSingle"/>
</rule>
<rule pattern="/\*.*?\*/">
<token type="CommentMultiline"/>
</rule>
</state>
<state name="badregex">
<rule pattern="\n">
<token type="Text"/>
<pop depth="1"/>
</rule>
</state>
<state name="interp">
<rule pattern="`">
<token type="LiteralStringBacktick"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\">
<token type="LiteralStringBacktick"/>
</rule>
<rule pattern="\\`">
<token type="LiteralStringBacktick"/>
</rule>
<rule pattern="\$\{">
<token type="LiteralStringInterpol"/>
<push state="interp-inside"/>
</rule>
<rule pattern="\$">
<token type="LiteralStringBacktick"/>
</rule>
<rule pattern="[^`\\$]+">
<token type="LiteralStringBacktick"/>
</rule>
</state>
<state name="attr">
<rule pattern="{">
<token type="Punctuation"/>
<push state="expression"/>
</rule>
<rule pattern="&#34;.*?&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule pattern="&#39;.*?&#39;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="interp-inside">
<rule pattern="\}">
<token type="LiteralStringInterpol"/>
<pop depth="1"/>
</rule>
<rule>
<include state="root"/>
</rule>
</state>
<state name="slashstartsregex">
<rule>
<include state="commentsandwhitespace"/>
</rule>
<rule pattern="/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)">
<token type="LiteralStringRegex"/>
<pop depth="1"/>
</rule>
<rule pattern="(?=/)">
<token type="Text"/>
<push state="#pop" state="badregex"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="root">
<rule>
<include state="jsx"/>
</rule>
<rule pattern="^(?=\s|/|&lt;!--)">
<token type="Text"/>
<push state="slashstartsregex"/>
</rule>
<rule>
<include state="commentsandwhitespace"/>
</rule>
<rule pattern="\+\+|--|~|&amp;&amp;|\?|:|\|\||\\(?=\n)|(&lt;&lt;|&gt;&gt;&gt;?|==?|!=?|[-&lt;&gt;+*%&amp;|^/])=?">
<token type="Operator"/>
<push state="slashstartsregex"/>
</rule>
<rule pattern="[{(\[;,]">
<token type="Punctuation"/>
<push state="slashstartsregex"/>
</rule>
<rule pattern="[})\].]">
<token type="Punctuation"/>
</rule>
<rule pattern="(for|in|of|while|do|break|return|yield|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|keyof|asserts|is|infer|await|void|this)\b">
<token type="Keyword"/>
<push state="slashstartsregex"/>
</rule>
<rule pattern="(var|let|with|function)\b">
<token type="KeywordDeclaration"/>
<push state="slashstartsregex"/>
</rule>
<rule pattern="(abstract|async|boolean|class|const|debugger|enum|export|extends|from|get|global|goto|implements|import|interface|namespace|package|private|protected|public|readonly|require|set|static|super|type)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(true|false|null|NaN|Infinity|undefined)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="(Array|Boolean|Date|Error|Function|Math|Number|Object|Packages|RegExp|String|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\b">
<token type="NameBuiltin"/>
</rule>
<rule pattern="\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="NameOther"/>
<token type="Text"/>
</bygroups>
<push state="slashstartsregex"/>
</rule>
<rule pattern="\b(string|bool|number|any|never|object|symbol|unique|unknown|bigint)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="\b(constructor|declare|interface|as)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(super)(\s*)(\([\w,?.$\s]+\s*\))">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
</bygroups>
<push state="slashstartsregex"/>
</rule>
<rule pattern="([a-zA-Z_?.$][\w?.$]*)\(\) \{">
<token type="NameOther"/>
<push state="slashstartsregex"/>
</rule>
<rule pattern="([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)">
<bygroups>
<token type="NameOther"/>
<token type="Text"/>
<token type="KeywordType"/>
</bygroups>
</rule>
<rule pattern="[$a-zA-Z_]\w*">
<token type="NameOther"/>
</rule>
<rule pattern="[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="0x[0-9a-fA-F]+">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="[0-9]+">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="&#39;(\\\\|\\&#39;|[^&#39;])*&#39;">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="`">
<token type="LiteralStringBacktick"/>
<push state="interp"/>
</rule>
<rule pattern="@\w+">
<token type="KeywordDeclaration"/>
</rule>
</state>
</rules>
</lexer>