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
372 lines
12 KiB
XML
372 lines
12 KiB
XML
<lexer>
|
|
<config>
|
|
<name>Cython</name>
|
|
<alias>cython</alias>
|
|
<alias>pyx</alias>
|
|
<alias>pyrex</alias>
|
|
<filename>*.pyx</filename>
|
|
<filename>*.pxd</filename>
|
|
<filename>*.pxi</filename>
|
|
<mime_type>text/x-cython</mime_type>
|
|
<mime_type>application/x-cython</mime_type>
|
|
</config>
|
|
<rules>
|
|
<state name="funcname">
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="NameFunction"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="root">
|
|
<rule pattern="\n">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="^(\s*)("""(?:.|\n)*?""")">
|
|
<bygroups>
|
|
<token type="Text"/>
|
|
<token type="LiteralStringDoc"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="^(\s*)('''(?:.|\n)*?''')">
|
|
<bygroups>
|
|
<token type="Text"/>
|
|
<token type="LiteralStringDoc"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="[^\S\n]+">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="#.*$">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
<rule pattern="[]{}:(),;[]">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="\\\n">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="\\">
|
|
<token type="Text"/>
|
|
</rule>
|
|
<rule pattern="(in|is|and|or|not)\b">
|
|
<token type="OperatorWord"/>
|
|
</rule>
|
|
<rule pattern="(<)([a-zA-Z0-9.?]+)(>)">
|
|
<bygroups>
|
|
<token type="Punctuation"/>
|
|
<token type="KeywordType"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="!=|==|<<|>>|[-~+/*%=<>&^|.?]">
|
|
<token type="Operator"/>
|
|
</rule>
|
|
<rule pattern="(from)(\d+)(<=)(\s+)(<)(\d+)(:)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="LiteralNumberInteger"/>
|
|
<token type="Operator"/>
|
|
<token type="Name"/>
|
|
<token type="Operator"/>
|
|
<token type="Name"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule>
|
|
<include state="keywords"/>
|
|
</rule>
|
|
<rule pattern="(def|property)(\s+)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="funcname"/>
|
|
</rule>
|
|
<rule pattern="(cp?def)(\s+)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="cdef"/>
|
|
</rule>
|
|
<rule pattern="(cdef)(:)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="(class|struct)(\s+)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="classname"/>
|
|
</rule>
|
|
<rule pattern="(from)(\s+)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="fromimport"/>
|
|
</rule>
|
|
<rule pattern="(c?import)(\s+)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<push state="import"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="builtins"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="backtick"/>
|
|
</rule>
|
|
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])"""">
|
|
<token type="LiteralString"/>
|
|
<push state="tdqs"/>
|
|
</rule>
|
|
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])'''">
|
|
<token type="LiteralString"/>
|
|
<push state="tsqs"/>
|
|
</rule>
|
|
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])"">
|
|
<token type="LiteralString"/>
|
|
<push state="dqs"/>
|
|
</rule>
|
|
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])'">
|
|
<token type="LiteralString"/>
|
|
<push state="sqs"/>
|
|
</rule>
|
|
<rule pattern="[uU]?"""">
|
|
<token type="LiteralString"/>
|
|
<combined state="stringescape" state="tdqs"/>
|
|
</rule>
|
|
<rule pattern="[uU]?'''">
|
|
<token type="LiteralString"/>
|
|
<combined state="stringescape" state="tsqs"/>
|
|
</rule>
|
|
<rule pattern="[uU]?"">
|
|
<token type="LiteralString"/>
|
|
<combined state="stringescape" state="dqs"/>
|
|
</rule>
|
|
<rule pattern="[uU]?'">
|
|
<token type="LiteralString"/>
|
|
<combined state="stringescape" state="sqs"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="name"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="numbers"/>
|
|
</rule>
|
|
</state>
|
|
<state name="stringescape">
|
|
<rule pattern="\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})">
|
|
<token type="LiteralStringEscape"/>
|
|
</rule>
|
|
</state>
|
|
<state name="strings">
|
|
<rule pattern="%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]">
|
|
<token type="LiteralStringInterpol"/>
|
|
</rule>
|
|
<rule pattern="[^\\\'"%\n]+">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
<rule pattern="[\'"\\]">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
<rule pattern="%">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
</state>
|
|
<state name="backtick">
|
|
<rule pattern="`.*?`">
|
|
<token type="LiteralStringBacktick"/>
|
|
</rule>
|
|
</state>
|
|
<state name="numbers">
|
|
<rule pattern="(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?">
|
|
<token type="LiteralNumberFloat"/>
|
|
</rule>
|
|
<rule pattern="0\d+">
|
|
<token type="LiteralNumberOct"/>
|
|
</rule>
|
|
<rule pattern="0[xX][a-fA-F0-9]+">
|
|
<token type="LiteralNumberHex"/>
|
|
</rule>
|
|
<rule pattern="\d+L">
|
|
<token type="LiteralNumberIntegerLong"/>
|
|
</rule>
|
|
<rule pattern="\d+">
|
|
<token type="LiteralNumberInteger"/>
|
|
</rule>
|
|
</state>
|
|
<state name="keywords">
|
|
<rule pattern="(continue|ctypedef|except\?|include|finally|global|return|lambda|assert|except|print|nogil|while|fused|yield|break|raise|exec|else|elif|pass|with|gil|for|try|del|by|as|if)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="(DEF|IF|ELIF|ELSE)\b">
|
|
<token type="CommentPreproc"/>
|
|
</rule>
|
|
</state>
|
|
<state name="fromimport">
|
|
<rule pattern="(\s+)(c?import)\b">
|
|
<bygroups>
|
|
<token type="Text"/>
|
|
<token type="Keyword"/>
|
|
</bygroups>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_.][\w.]*">
|
|
<token type="NameNamespace"/>
|
|
</rule>
|
|
<rule>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="nl">
|
|
<rule pattern="\n">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
</state>
|
|
<state name="dqs">
|
|
<rule pattern=""">
|
|
<token type="LiteralString"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="\\\\|\\"|\\\n">
|
|
<token type="LiteralStringEscape"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="strings"/>
|
|
</rule>
|
|
</state>
|
|
<state name="tsqs">
|
|
<rule pattern="'''">
|
|
<token type="LiteralString"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="strings"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="nl"/>
|
|
</rule>
|
|
</state>
|
|
<state name="import">
|
|
<rule pattern="(\s+)(as)(\s+)">
|
|
<bygroups>
|
|
<token type="Text"/>
|
|
<token type="Keyword"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_][\w.]*">
|
|
<token type="NameNamespace"/>
|
|
</rule>
|
|
<rule pattern="(\s*)(,)(\s*)">
|
|
<bygroups>
|
|
<token type="Text"/>
|
|
<token type="Operator"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="name">
|
|
<rule pattern="@\w+">
|
|
<token type="NameDecorator"/>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="Name"/>
|
|
</rule>
|
|
</state>
|
|
<state name="cdef">
|
|
<rule pattern="(public|readonly|extern|api|inline)\b">
|
|
<token type="KeywordReserved"/>
|
|
</rule>
|
|
<rule pattern="(struct|enum|union|class)\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)">
|
|
<bygroups>
|
|
<token type="NameFunction"/>
|
|
<token type="Text"/>
|
|
</bygroups>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="([a-zA-Z_]\w*)(\s*)(,)">
|
|
<bygroups>
|
|
<token type="NameFunction"/>
|
|
<token type="Text"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="from\b">
|
|
<token type="Keyword"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="as\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern=":">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="(?=["\'])">
|
|
<token type="Text"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="KeywordType"/>
|
|
</rule>
|
|
<rule pattern=".">
|
|
<token type="Text"/>
|
|
</rule>
|
|
</state>
|
|
<state name="classname">
|
|
<rule pattern="[a-zA-Z_]\w*">
|
|
<token type="NameClass"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="sqs">
|
|
<rule pattern="'">
|
|
<token type="LiteralString"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="\\\\|\\'|\\\n">
|
|
<token type="LiteralStringEscape"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="strings"/>
|
|
</rule>
|
|
</state>
|
|
<state name="tdqs">
|
|
<rule pattern=""""">
|
|
<token type="LiteralString"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="strings"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="nl"/>
|
|
</rule>
|
|
</state>
|
|
<state name="builtins">
|
|
<rule pattern="(?<!\.)(staticmethod|classmethod|__import__|issubclass|isinstance|basestring|bytearray|raw_input|frozenset|enumerate|property|unsigned|reversed|callable|execfile|hasattr|compile|complex|delattr|setattr|unicode|globals|getattr|reload|divmod|xrange|unichr|filter|reduce|buffer|intern|coerce|sorted|locals|object|round|input|range|super|tuple|bytes|float|slice|apply|bool|long|exit|vars|file|next|type|iter|open|dict|repr|hash|list|eval|oct|map|zip|int|hex|set|sum|chr|cmp|any|str|pow|ord|dir|len|min|all|abs|max|bin|id)\b">
|
|
<token type="NameBuiltin"/>
|
|
</rule>
|
|
<rule pattern="(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL)\b">
|
|
<token type="NameBuiltinPseudo"/>
|
|
</rule>
|
|
<rule pattern="(?<!\.)(PendingDeprecationWarning|UnicodeTranslateError|NotImplementedError|FloatingPointError|DeprecationWarning|UnicodeDecodeError|UnicodeEncodeError|UnboundLocalError|KeyboardInterrupt|ZeroDivisionError|IndentationError|EnvironmentError|OverflowWarning|ArithmeticError|RuntimeWarning|UnicodeWarning|AttributeError|AssertionError|NotImplemented|ReferenceError|StopIteration|SyntaxWarning|OverflowError|GeneratorExit|FutureWarning|BaseException|ImportWarning|StandardError|RuntimeError|UnicodeError|LookupError|ImportError|SyntaxError|MemoryError|SystemError|UserWarning|SystemExit|ValueError|IndexError|NameError|TypeError|Exception|KeyError|EOFError|TabError|OSError|Warning|IOError)\b">
|
|
<token type="NameException"/>
|
|
</rule>
|
|
</state>
|
|
</rules>
|
|
</lexer> |