tartrazine/lexers/cython.xml

373 lines
12 KiB
XML
Raw Normal View History

2024-08-02 20:03:49 +00:00
<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*)(&#34;&#34;&#34;(?:.|\n)*?&#34;&#34;&#34;)">
<bygroups>
<token type="Text"/>
<token type="LiteralStringDoc"/>
</bygroups>
</rule>
<rule pattern="^(\s*)(&#39;&#39;&#39;(?:.|\n)*?&#39;&#39;&#39;)">
<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="(&lt;)([a-zA-Z0-9.?]+)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="KeywordType"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="!=|==|&lt;&lt;|&gt;&gt;|[-~+/*%=&lt;&gt;&amp;^|.?]">
<token type="Operator"/>
</rule>
<rule pattern="(from)(\d+)(&lt;=)(\s+)(&lt;)(\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])&#34;&#34;&#34;">
<token type="LiteralString"/>
<push state="tdqs"/>
</rule>
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])&#39;&#39;&#39;">
<token type="LiteralString"/>
<push state="tsqs"/>
</rule>
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])&#34;">
<token type="LiteralString"/>
<push state="dqs"/>
</rule>
<rule pattern="(?:[rR]|[uU][rR]|[rR][uU])&#39;">
<token type="LiteralString"/>
<push state="sqs"/>
</rule>
<rule pattern="[uU]?&#34;&#34;&#34;">
<token type="LiteralString"/>
<combined state="stringescape" state="tdqs"/>
</rule>
<rule pattern="[uU]?&#39;&#39;&#39;">
<token type="LiteralString"/>
<combined state="stringescape" state="tsqs"/>
</rule>
<rule pattern="[uU]?&#34;">
<token type="LiteralString"/>
<combined state="stringescape" state="dqs"/>
</rule>
<rule pattern="[uU]?&#39;">
<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&#34;\&#39;]|\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="[^\\\&#39;&#34;%\n]+">
<token type="LiteralString"/>
</rule>
<rule pattern="[\&#39;&#34;\\]">
<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="&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#34;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="strings"/>
</rule>
</state>
<state name="tsqs">
<rule pattern="&#39;&#39;&#39;">
<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="(?=[&#34;\&#39;])">
<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="&#39;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#39;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="strings"/>
</rule>
</state>
<state name="tdqs">
<rule pattern="&#34;&#34;&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule>
<include state="strings"/>
</rule>
<rule>
<include state="nl"/>
</rule>
</state>
<state name="builtins">
<rule pattern="(?&lt;!\.)(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="(?&lt;!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL)\b">
<token type="NameBuiltinPseudo"/>
</rule>
<rule pattern="(?&lt;!\.)(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>
2024-08-26 23:18:28 +00:00
</lexer>