roulette/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/python.xml

594 lines
20 KiB
XML

<lexer>
<config>
<name>Python</name>
<alias>python</alias>
<alias>py</alias>
<alias>sage</alias>
<alias>python3</alias>
<alias>py3</alias>
<filename>*.py</filename>
<filename>*.pyi</filename>
<filename>*.pyw</filename>
<filename>*.jy</filename>
<filename>*.sage</filename>
<filename>*.sc</filename>
<filename>SConstruct</filename>
<filename>SConscript</filename>
<filename>*.bzl</filename>
<filename>BUCK</filename>
<filename>BUILD</filename>
<filename>BUILD.bazel</filename>
<filename>WORKSPACE</filename>
<filename>WORKSPACE.bzlmod</filename>
<filename>WORKSPACE.bazel</filename>
<filename>MODULE.bazel</filename>
<filename>REPO.bazel</filename>
<filename>*.tac</filename>
<mime_type>text/x-python</mime_type>
<mime_type>application/x-python</mime_type>
<mime_type>text/x-python3</mime_type>
<mime_type>application/x-python3</mime_type>
</config>
<rules>
<state name="numbers">
<rule pattern="(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)([eE][+-]?\d(?:_?\d)*)?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="0[oO](?:_?[0-7])+">
<token type="LiteralNumberOct"/>
</rule>
<rule pattern="0[bB](?:_?[01])+">
<token type="LiteralNumberBin"/>
</rule>
<rule pattern="0[xX](?:_?[a-fA-F0-9])+">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="\d(?:_?\d)*">
<token type="LiteralNumberInteger"/>
</rule>
</state>
<state name="expr">
<rule pattern="(?i)(rf|fr)(&#34;&#34;&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="rfstringescape" state="tdqf"/>
</rule>
<rule pattern="(?i)(rf|fr)(&#39;&#39;&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="rfstringescape" state="tsqf"/>
</rule>
<rule pattern="(?i)(rf|fr)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="rfstringescape" state="dqf"/>
</rule>
<rule pattern="(?i)(rf|fr)(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="rfstringescape" state="sqf"/>
</rule>
<rule pattern="([fF])(&#34;&#34;&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="fstringescape" state="tdqf"/>
</rule>
<rule pattern="([fF])(&#39;&#39;&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="fstringescape" state="tsqf"/>
</rule>
<rule pattern="([fF])(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="fstringescape" state="dqf"/>
</rule>
<rule pattern="([fF])(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="fstringescape" state="sqf"/>
</rule>
<rule pattern="(?i)(rb|br|r)(&#34;&#34;&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<push state="tdqs"/>
</rule>
<rule pattern="(?i)(rb|br|r)(&#39;&#39;&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<push state="tsqs"/>
</rule>
<rule pattern="(?i)(rb|br|r)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<push state="dqs"/>
</rule>
<rule pattern="(?i)(rb|br|r)(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<push state="sqs"/>
</rule>
<rule pattern="([uUbB]?)(&#34;&#34;&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="stringescape" state="tdqs"/>
</rule>
<rule pattern="([uUbB]?)(&#39;&#39;&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="stringescape" state="tsqs"/>
</rule>
<rule pattern="([uUbB]?)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDouble"/>
</bygroups>
<combined state="stringescape" state="dqs"/>
</rule>
<rule pattern="([uUbB]?)(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringSingle"/>
</bygroups>
<combined state="stringescape" state="sqs"/>
</rule>
<rule pattern="[^\S\n]+">
<token type="Text"/>
</rule>
<rule>
<include state="numbers"/>
</rule>
<rule pattern="!=|==|&lt;&lt;|&gt;&gt;|:=|[-~+/*%=&lt;&gt;&amp;^|.]">
<token type="Operator"/>
</rule>
<rule pattern="[]{}:(),;[]">
<token type="Punctuation"/>
</rule>
<rule pattern="(in|is|and|or|not)\b">
<token type="OperatorWord"/>
</rule>
<rule>
<include state="expr-keywords"/>
</rule>
<rule>
<include state="builtins"/>
</rule>
<rule>
<include state="magicfuncs"/>
</rule>
<rule>
<include state="magicvars"/>
</rule>
<rule>
<include state="name"/>
</rule>
</state>
<state name="fstrings-double">
<rule pattern="\}">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="\{">
<token type="LiteralStringInterpol"/>
<push state="expr-inside-fstring"/>
</rule>
<rule pattern="[^\\\&#39;&#34;{}\n]+">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="[\&#39;&#34;\\]">
<token type="LiteralStringDouble"/>
</rule>
</state>
<state name="keywords">
<rule pattern="(yield from|nonlocal|continue|finally|except|lambda|assert|global|return|raise|yield|while|break|await|async|pass|else|elif|with|try|for|del|as|if|match|case)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(False|True|None)\b">
<token type="KeywordConstant"/>
</rule>
</state>
<state name="dqs">
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#34;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="strings-double"/>
</rule>
</state>
<state name="fromimport">
<rule pattern="(\s+)(import)\b">
<bygroups>
<token type="Text"/>
<token type="KeywordNamespace"/>
</bygroups>
<pop depth="1"/>
</rule>
<rule pattern="\.">
<token type="NameNamespace"/>
</rule>
<rule pattern="None\b">
<token type="NameBuiltinPseudo"/>
<pop depth="1"/>
</rule>
<rule pattern="[_\p{L}][_\p{L}\p{N}]*">
<token type="NameNamespace"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="builtins">
<rule pattern="(?&lt;!\.)(staticmethod|classmethod|memoryview|__import__|issubclass|isinstance|frozenset|bytearray|enumerate|reversed|property|compile|complex|delattr|hasattr|setattr|globals|getattr|divmod|filter|locals|format|object|sorted|slice|print|bytes|range|input|tuple|round|super|float|eval|list|dict|repr|type|vars|hash|next|bool|open|iter|oct|pow|min|zip|max|map|bin|len|set|any|dir|all|abs|str|sum|chr|int|hex|ord|id)\b">
<token type="NameBuiltin"/>
</rule>
<rule pattern="(?&lt;!\.)(self|Ellipsis|NotImplemented|cls)\b">
<token type="NameBuiltinPseudo"/>
</rule>
<rule pattern="(?&lt;!\.)(PendingDeprecationWarning|ConnectionAbortedError|ConnectionRefusedError|UnicodeTranslateError|ConnectionResetError|ModuleNotFoundError|NotImplementedError|FloatingPointError|StopAsyncIteration|UnicodeDecodeError|DeprecationWarning|UnicodeEncodeError|NotADirectoryError|ProcessLookupError|ZeroDivisionError|IsADirectoryError|FileNotFoundError|UnboundLocalError|KeyboardInterrupt|ChildProcessError|EnvironmentError|IndentationError|InterruptedError|BlockingIOError|ArithmeticError|ConnectionError|BrokenPipeError|FileExistsError|ResourceWarning|PermissionError|RuntimeWarning|ReferenceError|AttributeError|AssertionError|UnicodeWarning|RecursionError|StopIteration|BaseException|OverflowError|SyntaxWarning|FutureWarning|GeneratorExit|ImportWarning|UnicodeError|TimeoutError|WindowsError|RuntimeError|BytesWarning|SystemError|UserWarning|MemoryError|ImportError|LookupError|BufferError|SyntaxError|SystemExit|ValueError|IndexError|NameError|Exception|TypeError|TabError|EOFError|KeyError|VMSError|Warning|OSError|IOError)\b">
<token type="NameException"/>
</rule>
</state>
<state name="classname">
<rule pattern="[_\p{L}][_\p{L}\p{N}]*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
</state>
<state name="import">
<rule pattern="(\s+)(as)(\s+)">
<bygroups>
<token type="Text"/>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
</rule>
<rule pattern="\.">
<token type="NameNamespace"/>
</rule>
<rule pattern="[_\p{L}][_\p{L}\p{N}]*">
<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="tsqs">
<rule pattern="&#39;&#39;&#39;">
<token type="LiteralStringSingle"/>
<pop depth="1"/>
</rule>
<rule>
<include state="strings-single"/>
</rule>
<rule pattern="\n">
<token type="LiteralStringSingle"/>
</rule>
</state>
<state name="strings-double">
<rule pattern="%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsaux%]">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="\{((\w+)((\.\w+)|(\[[^\]]+\]))*)?(\![sra])?(\:(.?[&lt;&gt;=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="[^\\\&#39;&#34;%{\n]+">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="[\&#39;&#34;\\]">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="%|(\{{1,2})">
<token type="LiteralStringDouble"/>
</rule>
</state>
<state name="tdqf">
<rule pattern="&#34;&#34;&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
<rule>
<include state="fstrings-double"/>
</rule>
<rule pattern="\n">
<token type="LiteralStringDouble"/>
</rule>
</state>
<state name="expr-inside-fstring-inner">
<rule pattern="[{([]">
<token type="Punctuation"/>
<push state="expr-inside-fstring-inner"/>
</rule>
<rule pattern="[])}]">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule>
<include state="expr"/>
</rule>
</state>
<state name="sqs">
<rule pattern="&#39;">
<token type="LiteralStringSingle"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#39;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="strings-single"/>
</rule>
</state>
<state name="funcname">
<rule>
<include state="magicfuncs"/>
</rule>
<rule pattern="[_\p{L}][_\p{L}\p{N}]*">
<token type="NameFunction"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="expr-keywords">
<rule pattern="(yield from|async for|lambda|yield|await|else|for|if)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(False|True|None)\b">
<token type="KeywordConstant"/>
</rule>
</state>
<state name="name">
<rule pattern="@[_\p{L}][_\p{L}\p{N}]*(\s*\.\s*[_\p{L}][_\p{L}\p{N}]*)*">
<token type="NameDecorator"/>
</rule>
<rule pattern="@">
<token type="Operator"/>
</rule>
<rule pattern="[_\p{L}][_\p{L}\p{N}]*">
<token type="Name"/>
</rule>
</state>
<state name="magicfuncs">
<rule pattern="(__instancecheck__|__subclasscheck__|__getattribute__|__length_hint__|__rfloordiv__|__ifloordiv__|__itruediv__|__contains__|__floordiv__|__rtruediv__|__reversed__|__setitem__|__complex__|__rdivmod__|__delattr__|__rmatmul__|__ilshift__|__prepare__|__delitem__|__rrshift__|__imatmul__|__rlshift__|__setattr__|__truediv__|__getitem__|__missing__|__getattr__|__irshift__|__rshift__|__format__|__invert__|__matmul__|__divmod__|__delete__|__aenter__|__lshift__|__await__|__bytes__|__anext__|__aiter__|__aexit__|__round__|__float__|__enter__|__index__|__iadd__|__ipow__|__rpow__|__iter__|__init__|__ixor__|__rmul__|__rmod__|__imul__|__imod__|__iand__|__hash__|__rsub__|__exit__|__rxor__|__bool__|__call__|__rand__|__next__|__radd__|__isub__|__repr__|__set__|__add__|__new__|__neg__|__xor__|__and__|__mul__|__mod__|__sub__|__len__|__str__|__ror__|__ior__|__pos__|__del__|__get__|__dir__|__abs__|__int__|__pow__|__eq__|__gt__|__le__|__lt__|__ne__|__or__|__ge__)\b">
<token type="NameFunctionMagic"/>
</rule>
</state>
<state name="root">
<rule pattern="\n">
<token type="Text"/>
</rule>
<rule pattern="^(\s*)([rRuUbB]{,2})(&#34;&#34;&#34;(?:.|\n)*?&#34;&#34;&#34;)">
<bygroups>
<token type="Text"/>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDoc"/>
</bygroups>
</rule>
<rule pattern="^(\s*)([rRuUbB]{,2})(&#39;&#39;&#39;(?:.|\n)*?&#39;&#39;&#39;)">
<bygroups>
<token type="Text"/>
<token type="LiteralStringAffix"/>
<token type="LiteralStringDoc"/>
</bygroups>
</rule>
<rule pattern="\A#!.+$">
<token type="CommentHashbang"/>
</rule>
<rule pattern="#.*$">
<token type="CommentSingle"/>
</rule>
<rule pattern="\\\n">
<token type="Text"/>
</rule>
<rule pattern="\\">
<token type="Text"/>
</rule>
<rule>
<include state="keywords"/>
</rule>
<rule pattern="(def)((?:\s|\\\s)+)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
<push state="funcname"/>
</rule>
<rule pattern="(class)((?:\s|\\\s)+)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
<push state="classname"/>
</rule>
<rule pattern="(from)((?:\s|\\\s)+)">
<bygroups>
<token type="KeywordNamespace"/>
<token type="Text"/>
</bygroups>
<push state="fromimport"/>
</rule>
<rule pattern="(import)((?:\s|\\\s)+)">
<bygroups>
<token type="KeywordNamespace"/>
<token type="Text"/>
</bygroups>
<push state="import"/>
</rule>
<rule>
<include state="expr"/>
</rule>
</state>
<state name="fstrings-single">
<rule pattern="\}">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="\{">
<token type="LiteralStringInterpol"/>
<push state="expr-inside-fstring"/>
</rule>
<rule pattern="[^\\\&#39;&#34;{}\n]+">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="[\&#39;&#34;\\]">
<token type="LiteralStringSingle"/>
</rule>
</state>
<state name="magicvars">
<rule pattern="(__annotations__|__kwdefaults__|__qualname__|__objclass__|__defaults__|__closure__|__globals__|__weakref__|__module__|__class__|__bases__|__slots__|__file__|__code__|__name__|__func__|__dict__|__self__|__mro__|__doc__)\b">
<token type="NameVariableMagic"/>
</rule>
</state>
<state name="tsqf">
<rule pattern="&#39;&#39;&#39;">
<token type="LiteralStringSingle"/>
<pop depth="1"/>
</rule>
<rule>
<include state="fstrings-single"/>
</rule>
<rule pattern="\n">
<token type="LiteralStringSingle"/>
</rule>
</state>
<state name="strings-single">
<rule pattern="%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsaux%]">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="\{((\w+)((\.\w+)|(\[[^\]]+\]))*)?(\![sra])?(\:(.?[&lt;&gt;=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="[^\\\&#39;&#34;%{\n]+">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="[\&#39;&#34;\\]">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="%|(\{{1,2})">
<token type="LiteralStringSingle"/>
</rule>
</state>
<state name="rfstringescape">
<rule pattern="\{\{">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\}\}">
<token type="LiteralStringEscape"/>
</rule>
</state>
<state name="sqf">
<rule pattern="&#39;">
<token type="LiteralStringSingle"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#39;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="fstrings-single"/>
</rule>
</state>
<state name="dqf">
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
<rule pattern="\\\\|\\&#34;|\\\n">
<token type="LiteralStringEscape"/>
</rule>
<rule>
<include state="fstrings-double"/>
</rule>
</state>
<state name="expr-inside-fstring">
<rule pattern="[{([]">
<token type="Punctuation"/>
<push state="expr-inside-fstring-inner"/>
</rule>
<rule pattern="(=\s*)?(\![sraf])?\}">
<token type="LiteralStringInterpol"/>
<pop depth="1"/>
</rule>
<rule pattern="(=\s*)?(\![sraf])?:">
<token type="LiteralStringInterpol"/>
<pop depth="1"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule>
<include state="expr"/>
</rule>
</state>
<state name="tdqs">
<rule pattern="&#34;&#34;&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
<rule>
<include state="strings-double"/>
</rule>
<rule pattern="\n">
<token type="LiteralStringDouble"/>
</rule>
</state>
<state name="fstringescape">
<rule>
<include state="rfstringescape"/>
</rule>
<rule>
<include state="stringescape"/>
</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>
</rules>
</lexer>