mirror of
https://github.com/cheat/cheat.git
synced 2024-12-25 14:09:44 +01:00
1790aec85d
Bump `alecthomas/chroma` to `v2`: https://github.com/cheat/cheat/issues/735
154 lines
5.1 KiB
XML
154 lines
5.1 KiB
XML
<lexer>
|
|
<config>
|
|
<name>Thrift</name>
|
|
<alias>thrift</alias>
|
|
<filename>*.thrift</filename>
|
|
<mime_type>application/x-thrift</mime_type>
|
|
</config>
|
|
<rules>
|
|
<state name="class">
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="NameClass"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="keywords">
|
|
<rule pattern="(async|oneway|extends|throws|required|optional)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="(true|false)\b">
|
|
<token type="KeywordConstant"/>
|
|
</rule>
|
|
<rule pattern="(const|typedef)\b">
|
|
<token type="KeywordDeclaration"/>
|
|
</rule>
|
|
<rule pattern="(smalltalk_category|smalltalk_prefix|delphi_namespace|csharp_namespace|ruby_namespace|xsd_namespace|cpp_namespace|php_namespace|xsd_nillable|xsd_optional|java_package|cocoa_prefix|perl_package|cpp_include|py_module|xsd_attrs|cpp_type|xsd_all|include)\b">
|
|
<token type="KeywordNamespace"/>
|
|
</rule>
|
|
<rule pattern="(double|binary|string|slist|senum|bool|void|byte|list|i64|map|set|i32|i16)\b">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern="\b(__NAMESPACE__|synchronized|__FUNCTION__|__METHOD__|endforeach|implements|enddeclare|instanceof|transient|endswitch|protected|interface|__CLASS__|continue|__FILE__|abstract|function|endwhile|unsigned|register|volatile|__LINE__|declare|foreach|default|__DIR__|private|finally|dynamic|virtual|lambda|elseif|inline|switch|unless|endfor|delete|import|return|module|ensure|native|rescue|assert|sizeof|static|global|except|public|float|BEGIN|super|endif|yield|elsif|throw|clone|class|catch|until|break|retry|begin|raise|alias|while|print|undef|exec|with|when|case|redo|args|elif|this|then|self|goto|else|pass|next|var|for|xor|END|not|try|del|and|def|new|use|nil|end|if|do|is|or|in|as)\b">
|
|
<token type="KeywordReserved"/>
|
|
</rule>
|
|
</state>
|
|
<state name="numbers">
|
|
<rule pattern="[+-]?(\d+\.\d+([eE][+-]?\d+)?|\.?\d+[eE][+-]?\d+)">
|
|
<token type="LiteralNumberFloat"/>
|
|
</rule>
|
|
<rule pattern="[+-]?0x[0-9A-Fa-f]+">
|
|
<token type="LiteralNumberHex"/>
|
|
</rule>
|
|
<rule pattern="[+-]?[0-9]+">
|
|
<token type="LiteralNumberInteger"/>
|
|
</rule>
|
|
</state>
|
|
<state name="root">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern=""">
|
|
<token type="LiteralStringDouble"/>
|
|
<combined state="stringescape" state="dqs"/>
|
|
</rule>
|
|
<rule pattern="\'">
|
|
<token type="LiteralStringSingle"/>
|
|
<combined state="stringescape" state="sqs"/>
|
|
</rule>
|
|
<rule pattern="(namespace)(\s+)">
|
|
<bygroups>
|
|
<token type="KeywordNamespace"/>
|
|
<token type="TextWhitespace"/>
|
|
</bygroups>
|
|
<push state="namespace"/>
|
|
</rule>
|
|
<rule pattern="(enum|union|struct|service|exception)(\s+)">
|
|
<bygroups>
|
|
<token type="KeywordDeclaration"/>
|
|
<token type="TextWhitespace"/>
|
|
</bygroups>
|
|
<push state="class"/>
|
|
</rule>
|
|
<rule pattern="((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()">
|
|
<bygroups>
|
|
<usingself state="root"/>
|
|
<token type="NameFunction"/>
|
|
<token type="Text"/>
|
|
<token type="Operator"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule>
|
|
<include state="keywords"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="numbers"/>
|
|
</rule>
|
|
<rule pattern="[&=]">
|
|
<token type="Operator"/>
|
|
</rule>
|
|
<rule pattern="[:;,{}()<>\[\]]">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_](\.\w|\w)*">
|
|
<token type="Name"/>
|
|
</rule>
|
|
</state>
|
|
<state name="dqs">
|
|
<rule pattern=""">
|
|
<token type="LiteralStringDouble"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="[^\\"\n]+">
|
|
<token type="LiteralStringDouble"/>
|
|
</rule>
|
|
</state>
|
|
<state name="namespace">
|
|
<rule pattern="[a-z*](\.\w|\w)*">
|
|
<token type="NameNamespace"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="whitespace">
|
|
<rule pattern="\n">
|
|
<token type="TextWhitespace"/>
|
|
</rule>
|
|
<rule pattern="\s+">
|
|
<token type="TextWhitespace"/>
|
|
</rule>
|
|
</state>
|
|
<state name="comments">
|
|
<rule pattern="#.*$">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
<rule pattern="//.*?\n">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
<rule pattern="/\*[\w\W]*?\*/">
|
|
<token type="CommentMultiline"/>
|
|
</rule>
|
|
</state>
|
|
<state name="stringescape">
|
|
<rule pattern="\\([\\nrt"\'])">
|
|
<token type="LiteralStringEscape"/>
|
|
</rule>
|
|
</state>
|
|
<state name="sqs">
|
|
<rule pattern="'">
|
|
<token type="LiteralStringSingle"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="[^\\\'\n]+">
|
|
<token type="LiteralStringSingle"/>
|
|
</rule>
|
|
</state>
|
|
</rules>
|
|
</lexer> |