Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .cache/pip/http-v2/f/c/6/8/7/fc687abc6120c7bc7cfd867fe3788604e9f8e9dcf17e51396d803e25.body +3 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/rtf.py +349 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/svg.py +185 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/terminal.py +127 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/terminal256.py +338 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/arrow.py +116 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/arturo.py +249 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/asc.py +55 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/asn1.py +178 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bare.py +101 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/basic.py +656 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bibtex.py +159 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/blueprint.py +173 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/boa.py +97 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bqn.py +112 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/business.py +625 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/c_cpp.py +415 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/c_like.py +738 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/capnproto.py +74 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/carbon.py +95 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/cddl.py +172 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/chapel.py +139 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/clean.py +180 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/codeql.py +80 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/comal.py +81 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/compiled.py +35 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/configs.py +1433 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/console.py +114 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/cplint.py +43 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/crystal.py +364 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/csound.py +466 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/css.py +632 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/d.py +259 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dalvik.py +126 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/data.py +763 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dax.py +135 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/devicetree.py +120 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/diff.py +169 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dns.py +109 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dotnet.py +873 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dsls.py +970 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dylan.py +279 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/ecl.py +144 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/eiffel.py +68 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/elm.py +123 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/elpi.py +201 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/email.py +132 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/erlang.py +526 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/esoteric.py +300 -0
- .cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/ezhil.py +76 -0
.cache/pip/http-v2/f/c/6/8/7/fc687abc6120c7bc7cfd867fe3788604e9f8e9dcf17e51396d803e25.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d00e655fcef08aba35ec9610536bfe90267d7ab5ba944f7032549c55a146da1
|
| 3 |
+
size 362601
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/rtf.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
A formatter that generates RTF files.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from collections import OrderedDict
|
| 12 |
+
from pygments.formatter import Formatter
|
| 13 |
+
from pygments.style import _ansimap
|
| 14 |
+
from pygments.util import get_bool_opt, get_int_opt, get_list_opt, surrogatepair
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['RtfFormatter']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class RtfFormatter(Formatter):
|
| 21 |
+
"""
|
| 22 |
+
Format tokens as RTF markup. This formatter automatically outputs full RTF
|
| 23 |
+
documents with color information and other useful stuff. Perfect for Copy and
|
| 24 |
+
Paste into Microsoft(R) Word(R) documents.
|
| 25 |
+
|
| 26 |
+
Please note that ``encoding`` and ``outencoding`` options are ignored.
|
| 27 |
+
The RTF format is ASCII natively, but handles unicode characters correctly
|
| 28 |
+
thanks to escape sequences.
|
| 29 |
+
|
| 30 |
+
.. versionadded:: 0.6
|
| 31 |
+
|
| 32 |
+
Additional options accepted:
|
| 33 |
+
|
| 34 |
+
`style`
|
| 35 |
+
The style to use, can be a string or a Style subclass (default:
|
| 36 |
+
``'default'``).
|
| 37 |
+
|
| 38 |
+
`fontface`
|
| 39 |
+
The used font family, for example ``Bitstream Vera Sans``. Defaults to
|
| 40 |
+
some generic font which is supposed to have fixed width.
|
| 41 |
+
|
| 42 |
+
`fontsize`
|
| 43 |
+
Size of the font used. Size is specified in half points. The
|
| 44 |
+
default is 24 half-points, giving a size 12 font.
|
| 45 |
+
|
| 46 |
+
.. versionadded:: 2.0
|
| 47 |
+
|
| 48 |
+
`linenos`
|
| 49 |
+
Turn on line numbering (default: ``False``).
|
| 50 |
+
|
| 51 |
+
.. versionadded:: 2.18
|
| 52 |
+
|
| 53 |
+
`lineno_fontsize`
|
| 54 |
+
Font size for line numbers. Size is specified in half points
|
| 55 |
+
(default: `fontsize`).
|
| 56 |
+
|
| 57 |
+
.. versionadded:: 2.18
|
| 58 |
+
|
| 59 |
+
`lineno_padding`
|
| 60 |
+
Number of spaces between the (inline) line numbers and the
|
| 61 |
+
source code (default: ``2``).
|
| 62 |
+
|
| 63 |
+
.. versionadded:: 2.18
|
| 64 |
+
|
| 65 |
+
`linenostart`
|
| 66 |
+
The line number for the first line (default: ``1``).
|
| 67 |
+
|
| 68 |
+
.. versionadded:: 2.18
|
| 69 |
+
|
| 70 |
+
`linenostep`
|
| 71 |
+
If set to a number n > 1, only every nth line number is printed.
|
| 72 |
+
|
| 73 |
+
.. versionadded:: 2.18
|
| 74 |
+
|
| 75 |
+
`lineno_color`
|
| 76 |
+
Color for line numbers specified as a hex triplet, e.g. ``'5e5e5e'``.
|
| 77 |
+
Defaults to the style's line number color if it is a hex triplet,
|
| 78 |
+
otherwise ansi bright black.
|
| 79 |
+
|
| 80 |
+
.. versionadded:: 2.18
|
| 81 |
+
|
| 82 |
+
`hl_lines`
|
| 83 |
+
Specify a list of lines to be highlighted, as line numbers separated by
|
| 84 |
+
spaces, e.g. ``'3 7 8'``. The line numbers are relative to the input
|
| 85 |
+
(i.e. the first line is line 1) unless `hl_linenostart` is set.
|
| 86 |
+
|
| 87 |
+
.. versionadded:: 2.18
|
| 88 |
+
|
| 89 |
+
`hl_color`
|
| 90 |
+
Color for highlighting the lines specified in `hl_lines`, specified as
|
| 91 |
+
a hex triplet (default: style's `highlight_color`).
|
| 92 |
+
|
| 93 |
+
.. versionadded:: 2.18
|
| 94 |
+
|
| 95 |
+
`hl_linenostart`
|
| 96 |
+
If set to ``True`` line numbers in `hl_lines` are specified
|
| 97 |
+
relative to `linenostart` (default ``False``).
|
| 98 |
+
|
| 99 |
+
.. versionadded:: 2.18
|
| 100 |
+
"""
|
| 101 |
+
name = 'RTF'
|
| 102 |
+
aliases = ['rtf']
|
| 103 |
+
filenames = ['*.rtf']
|
| 104 |
+
|
| 105 |
+
def __init__(self, **options):
|
| 106 |
+
r"""
|
| 107 |
+
Additional options accepted:
|
| 108 |
+
|
| 109 |
+
``fontface``
|
| 110 |
+
Name of the font used. Could for example be ``'Courier New'``
|
| 111 |
+
to further specify the default which is ``'\fmodern'``. The RTF
|
| 112 |
+
specification claims that ``\fmodern`` are "Fixed-pitch serif
|
| 113 |
+
and sans serif fonts". Hope every RTF implementation thinks
|
| 114 |
+
the same about modern...
|
| 115 |
+
|
| 116 |
+
"""
|
| 117 |
+
Formatter.__init__(self, **options)
|
| 118 |
+
self.fontface = options.get('fontface') or ''
|
| 119 |
+
self.fontsize = get_int_opt(options, 'fontsize', 0)
|
| 120 |
+
self.linenos = get_bool_opt(options, 'linenos', False)
|
| 121 |
+
self.lineno_fontsize = get_int_opt(options, 'lineno_fontsize',
|
| 122 |
+
self.fontsize)
|
| 123 |
+
self.lineno_padding = get_int_opt(options, 'lineno_padding', 2)
|
| 124 |
+
self.linenostart = abs(get_int_opt(options, 'linenostart', 1))
|
| 125 |
+
self.linenostep = abs(get_int_opt(options, 'linenostep', 1))
|
| 126 |
+
self.hl_linenostart = get_bool_opt(options, 'hl_linenostart', False)
|
| 127 |
+
|
| 128 |
+
self.hl_color = options.get('hl_color', '')
|
| 129 |
+
if not self.hl_color:
|
| 130 |
+
self.hl_color = self.style.highlight_color
|
| 131 |
+
|
| 132 |
+
self.hl_lines = []
|
| 133 |
+
for lineno in get_list_opt(options, 'hl_lines', []):
|
| 134 |
+
try:
|
| 135 |
+
lineno = int(lineno)
|
| 136 |
+
if self.hl_linenostart:
|
| 137 |
+
lineno = lineno - self.linenostart + 1
|
| 138 |
+
self.hl_lines.append(lineno)
|
| 139 |
+
except ValueError:
|
| 140 |
+
pass
|
| 141 |
+
|
| 142 |
+
self.lineno_color = options.get('lineno_color', '')
|
| 143 |
+
if not self.lineno_color:
|
| 144 |
+
if self.style.line_number_color == 'inherit':
|
| 145 |
+
# style color is the css value 'inherit'
|
| 146 |
+
# default to ansi bright-black
|
| 147 |
+
self.lineno_color = _ansimap['ansibrightblack']
|
| 148 |
+
else:
|
| 149 |
+
# style color is assumed to be a hex triplet as other
|
| 150 |
+
# colors in pygments/style.py
|
| 151 |
+
self.lineno_color = self.style.line_number_color
|
| 152 |
+
|
| 153 |
+
self.color_mapping = self._create_color_mapping()
|
| 154 |
+
|
| 155 |
+
def _escape(self, text):
|
| 156 |
+
return text.replace('\\', '\\\\') \
|
| 157 |
+
.replace('{', '\\{') \
|
| 158 |
+
.replace('}', '\\}')
|
| 159 |
+
|
| 160 |
+
def _escape_text(self, text):
|
| 161 |
+
# empty strings, should give a small performance improvement
|
| 162 |
+
if not text:
|
| 163 |
+
return ''
|
| 164 |
+
|
| 165 |
+
# escape text
|
| 166 |
+
text = self._escape(text)
|
| 167 |
+
|
| 168 |
+
buf = []
|
| 169 |
+
for c in text:
|
| 170 |
+
cn = ord(c)
|
| 171 |
+
if cn < (2**7):
|
| 172 |
+
# ASCII character
|
| 173 |
+
buf.append(str(c))
|
| 174 |
+
elif (2**7) <= cn < (2**16):
|
| 175 |
+
# single unicode escape sequence
|
| 176 |
+
buf.append('{\\u%d}' % cn)
|
| 177 |
+
elif (2**16) <= cn:
|
| 178 |
+
# RTF limits unicode to 16 bits.
|
| 179 |
+
# Force surrogate pairs
|
| 180 |
+
buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
|
| 181 |
+
|
| 182 |
+
return ''.join(buf).replace('\n', '\\par')
|
| 183 |
+
|
| 184 |
+
@staticmethod
|
| 185 |
+
def hex_to_rtf_color(hex_color):
|
| 186 |
+
if hex_color[0] == "#":
|
| 187 |
+
hex_color = hex_color[1:]
|
| 188 |
+
|
| 189 |
+
return '\\red%d\\green%d\\blue%d;' % (
|
| 190 |
+
int(hex_color[0:2], 16),
|
| 191 |
+
int(hex_color[2:4], 16),
|
| 192 |
+
int(hex_color[4:6], 16)
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
def _split_tokens_on_newlines(self, tokensource):
|
| 196 |
+
"""
|
| 197 |
+
Split tokens containing newline characters into multiple token
|
| 198 |
+
each representing a line of the input file. Needed for numbering
|
| 199 |
+
lines of e.g. multiline comments.
|
| 200 |
+
"""
|
| 201 |
+
for ttype, value in tokensource:
|
| 202 |
+
if value == '\n':
|
| 203 |
+
yield (ttype, value)
|
| 204 |
+
elif "\n" in value:
|
| 205 |
+
lines = value.split("\n")
|
| 206 |
+
for line in lines[:-1]:
|
| 207 |
+
yield (ttype, line+"\n")
|
| 208 |
+
if lines[-1]:
|
| 209 |
+
yield (ttype, lines[-1])
|
| 210 |
+
else:
|
| 211 |
+
yield (ttype, value)
|
| 212 |
+
|
| 213 |
+
def _create_color_mapping(self):
|
| 214 |
+
"""
|
| 215 |
+
Create a mapping of style hex colors to index/offset in
|
| 216 |
+
the RTF color table.
|
| 217 |
+
"""
|
| 218 |
+
color_mapping = OrderedDict()
|
| 219 |
+
offset = 1
|
| 220 |
+
|
| 221 |
+
if self.linenos:
|
| 222 |
+
color_mapping[self.lineno_color] = offset
|
| 223 |
+
offset += 1
|
| 224 |
+
|
| 225 |
+
if self.hl_lines:
|
| 226 |
+
color_mapping[self.hl_color] = offset
|
| 227 |
+
offset += 1
|
| 228 |
+
|
| 229 |
+
for _, style in self.style:
|
| 230 |
+
for color in style['color'], style['bgcolor'], style['border']:
|
| 231 |
+
if color and color not in color_mapping:
|
| 232 |
+
color_mapping[color] = offset
|
| 233 |
+
offset += 1
|
| 234 |
+
|
| 235 |
+
return color_mapping
|
| 236 |
+
|
| 237 |
+
@property
|
| 238 |
+
def _lineno_template(self):
|
| 239 |
+
if self.lineno_fontsize != self.fontsize:
|
| 240 |
+
return '{{\\fs{} \\cf{} %s{}}}'.format(self.lineno_fontsize,
|
| 241 |
+
self.color_mapping[self.lineno_color],
|
| 242 |
+
" " * self.lineno_padding)
|
| 243 |
+
|
| 244 |
+
return '{{\\cf{} %s{}}}'.format(self.color_mapping[self.lineno_color],
|
| 245 |
+
" " * self.lineno_padding)
|
| 246 |
+
|
| 247 |
+
@property
|
| 248 |
+
def _hl_open_str(self):
|
| 249 |
+
return rf'{{\highlight{self.color_mapping[self.hl_color]} '
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def _rtf_header(self):
|
| 253 |
+
lines = []
|
| 254 |
+
# rtf 1.8 header
|
| 255 |
+
lines.append('{\\rtf1\\ansi\\uc0\\deff0'
|
| 256 |
+
'{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
|
| 257 |
+
% (self.fontface and ' '
|
| 258 |
+
+ self._escape(self.fontface) or ''))
|
| 259 |
+
|
| 260 |
+
# color table
|
| 261 |
+
lines.append('{\\colortbl;')
|
| 262 |
+
for color, _ in self.color_mapping.items():
|
| 263 |
+
lines.append(self.hex_to_rtf_color(color))
|
| 264 |
+
lines.append('}')
|
| 265 |
+
|
| 266 |
+
# font and fontsize
|
| 267 |
+
lines.append('\\f0\\sa0')
|
| 268 |
+
if self.fontsize:
|
| 269 |
+
lines.append('\\fs%d' % self.fontsize)
|
| 270 |
+
|
| 271 |
+
# ensure Libre Office Writer imports and renders consecutive
|
| 272 |
+
# space characters the same width, needed for line numbering.
|
| 273 |
+
# https://bugs.documentfoundation.org/show_bug.cgi?id=144050
|
| 274 |
+
lines.append('\\dntblnsbdb')
|
| 275 |
+
|
| 276 |
+
return lines
|
| 277 |
+
|
| 278 |
+
def format_unencoded(self, tokensource, outfile):
|
| 279 |
+
for line in self._rtf_header:
|
| 280 |
+
outfile.write(line + "\n")
|
| 281 |
+
|
| 282 |
+
tokensource = self._split_tokens_on_newlines(tokensource)
|
| 283 |
+
|
| 284 |
+
# first pass of tokens to count lines, needed for line numbering
|
| 285 |
+
if self.linenos:
|
| 286 |
+
line_count = 0
|
| 287 |
+
tokens = [] # for copying the token source generator
|
| 288 |
+
for ttype, value in tokensource:
|
| 289 |
+
tokens.append((ttype, value))
|
| 290 |
+
if value.endswith("\n"):
|
| 291 |
+
line_count += 1
|
| 292 |
+
|
| 293 |
+
# width of line number strings (for padding with spaces)
|
| 294 |
+
linenos_width = len(str(line_count+self.linenostart-1))
|
| 295 |
+
|
| 296 |
+
tokensource = tokens
|
| 297 |
+
|
| 298 |
+
# highlight stream
|
| 299 |
+
lineno = 1
|
| 300 |
+
start_new_line = True
|
| 301 |
+
for ttype, value in tokensource:
|
| 302 |
+
if start_new_line and lineno in self.hl_lines:
|
| 303 |
+
outfile.write(self._hl_open_str)
|
| 304 |
+
|
| 305 |
+
if start_new_line and self.linenos:
|
| 306 |
+
if (lineno-self.linenostart+1)%self.linenostep == 0:
|
| 307 |
+
current_lineno = lineno + self.linenostart - 1
|
| 308 |
+
lineno_str = str(current_lineno).rjust(linenos_width)
|
| 309 |
+
else:
|
| 310 |
+
lineno_str = "".rjust(linenos_width)
|
| 311 |
+
outfile.write(self._lineno_template % lineno_str)
|
| 312 |
+
|
| 313 |
+
while not self.style.styles_token(ttype) and ttype.parent:
|
| 314 |
+
ttype = ttype.parent
|
| 315 |
+
style = self.style.style_for_token(ttype)
|
| 316 |
+
buf = []
|
| 317 |
+
if style['bgcolor']:
|
| 318 |
+
buf.append('\\cb%d' % self.color_mapping[style['bgcolor']])
|
| 319 |
+
if style['color']:
|
| 320 |
+
buf.append('\\cf%d' % self.color_mapping[style['color']])
|
| 321 |
+
if style['bold']:
|
| 322 |
+
buf.append('\\b')
|
| 323 |
+
if style['italic']:
|
| 324 |
+
buf.append('\\i')
|
| 325 |
+
if style['underline']:
|
| 326 |
+
buf.append('\\ul')
|
| 327 |
+
if style['border']:
|
| 328 |
+
buf.append('\\chbrdr\\chcfpat%d' %
|
| 329 |
+
self.color_mapping[style['border']])
|
| 330 |
+
start = ''.join(buf)
|
| 331 |
+
if start:
|
| 332 |
+
outfile.write(f'{{{start} ')
|
| 333 |
+
outfile.write(self._escape_text(value))
|
| 334 |
+
if start:
|
| 335 |
+
outfile.write('}')
|
| 336 |
+
start_new_line = False
|
| 337 |
+
|
| 338 |
+
# complete line of input
|
| 339 |
+
if value.endswith("\n"):
|
| 340 |
+
# close line highlighting
|
| 341 |
+
if lineno in self.hl_lines:
|
| 342 |
+
outfile.write('}')
|
| 343 |
+
# newline in RTF file after closing }
|
| 344 |
+
outfile.write("\n")
|
| 345 |
+
|
| 346 |
+
start_new_line = True
|
| 347 |
+
lineno += 1
|
| 348 |
+
|
| 349 |
+
outfile.write('}\n')
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/svg.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.formatters.svg
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Formatter for SVG output.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.formatter import Formatter
|
| 12 |
+
from pygments.token import Comment
|
| 13 |
+
from pygments.util import get_bool_opt, get_int_opt
|
| 14 |
+
|
| 15 |
+
__all__ = ['SvgFormatter']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def escape_html(text):
|
| 19 |
+
"""Escape &, <, > as well as single and double quotes for HTML."""
|
| 20 |
+
return text.replace('&', '&'). \
|
| 21 |
+
replace('<', '<'). \
|
| 22 |
+
replace('>', '>'). \
|
| 23 |
+
replace('"', '"'). \
|
| 24 |
+
replace("'", ''')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class2style = {}
|
| 28 |
+
|
| 29 |
+
class SvgFormatter(Formatter):
|
| 30 |
+
"""
|
| 31 |
+
Format tokens as an SVG graphics file. This formatter is still experimental.
|
| 32 |
+
Each line of code is a ``<text>`` element with explicit ``x`` and ``y``
|
| 33 |
+
coordinates containing ``<tspan>`` elements with the individual token styles.
|
| 34 |
+
|
| 35 |
+
By default, this formatter outputs a full SVG document including doctype
|
| 36 |
+
declaration and the ``<svg>`` root element.
|
| 37 |
+
|
| 38 |
+
.. versionadded:: 0.9
|
| 39 |
+
|
| 40 |
+
Additional options accepted:
|
| 41 |
+
|
| 42 |
+
`nowrap`
|
| 43 |
+
Don't wrap the SVG ``<text>`` elements in ``<svg><g>`` elements and
|
| 44 |
+
don't add a XML declaration and a doctype. If true, the `fontfamily`
|
| 45 |
+
and `fontsize` options are ignored. Defaults to ``False``.
|
| 46 |
+
|
| 47 |
+
`fontfamily`
|
| 48 |
+
The value to give the wrapping ``<g>`` element's ``font-family``
|
| 49 |
+
attribute, defaults to ``"monospace"``.
|
| 50 |
+
|
| 51 |
+
`fontsize`
|
| 52 |
+
The value to give the wrapping ``<g>`` element's ``font-size``
|
| 53 |
+
attribute, defaults to ``"14px"``.
|
| 54 |
+
|
| 55 |
+
`linenos`
|
| 56 |
+
If ``True``, add line numbers (default: ``False``).
|
| 57 |
+
|
| 58 |
+
`linenostart`
|
| 59 |
+
The line number for the first line (default: ``1``).
|
| 60 |
+
|
| 61 |
+
`linenostep`
|
| 62 |
+
If set to a number n > 1, only every nth line number is printed.
|
| 63 |
+
|
| 64 |
+
`linenowidth`
|
| 65 |
+
Maximum width devoted to line numbers (default: ``3*ystep``, sufficient
|
| 66 |
+
for up to 4-digit line numbers. Increase width for longer code blocks).
|
| 67 |
+
|
| 68 |
+
`xoffset`
|
| 69 |
+
Starting offset in X direction, defaults to ``0``.
|
| 70 |
+
|
| 71 |
+
`yoffset`
|
| 72 |
+
Starting offset in Y direction, defaults to the font size if it is given
|
| 73 |
+
in pixels, or ``20`` else. (This is necessary since text coordinates
|
| 74 |
+
refer to the text baseline, not the top edge.)
|
| 75 |
+
|
| 76 |
+
`ystep`
|
| 77 |
+
Offset to add to the Y coordinate for each subsequent line. This should
|
| 78 |
+
roughly be the text size plus 5. It defaults to that value if the text
|
| 79 |
+
size is given in pixels, or ``25`` else.
|
| 80 |
+
|
| 81 |
+
`spacehack`
|
| 82 |
+
Convert spaces in the source to `` ``, which are non-breaking
|
| 83 |
+
spaces. SVG provides the ``xml:space`` attribute to control how
|
| 84 |
+
whitespace inside tags is handled, in theory, the ``preserve`` value
|
| 85 |
+
could be used to keep all whitespace as-is. However, many current SVG
|
| 86 |
+
viewers don't obey that rule, so this option is provided as a workaround
|
| 87 |
+
and defaults to ``True``.
|
| 88 |
+
"""
|
| 89 |
+
name = 'SVG'
|
| 90 |
+
aliases = ['svg']
|
| 91 |
+
filenames = ['*.svg']
|
| 92 |
+
|
| 93 |
+
def __init__(self, **options):
|
| 94 |
+
Formatter.__init__(self, **options)
|
| 95 |
+
self.nowrap = get_bool_opt(options, 'nowrap', False)
|
| 96 |
+
self.fontfamily = options.get('fontfamily', 'monospace')
|
| 97 |
+
self.fontsize = options.get('fontsize', '14px')
|
| 98 |
+
self.xoffset = get_int_opt(options, 'xoffset', 0)
|
| 99 |
+
fs = self.fontsize.strip()
|
| 100 |
+
if fs.endswith('px'):
|
| 101 |
+
fs = fs[:-2].strip()
|
| 102 |
+
try:
|
| 103 |
+
int_fs = int(fs)
|
| 104 |
+
except ValueError:
|
| 105 |
+
int_fs = 20
|
| 106 |
+
self.yoffset = get_int_opt(options, 'yoffset', int_fs)
|
| 107 |
+
self.ystep = get_int_opt(options, 'ystep', int_fs + 5)
|
| 108 |
+
self.spacehack = get_bool_opt(options, 'spacehack', True)
|
| 109 |
+
self.linenos = get_bool_opt(options,'linenos',False)
|
| 110 |
+
self.linenostart = get_int_opt(options,'linenostart',1)
|
| 111 |
+
self.linenostep = get_int_opt(options,'linenostep',1)
|
| 112 |
+
self.linenowidth = get_int_opt(options,'linenowidth', 3*self.ystep)
|
| 113 |
+
self._stylecache = {}
|
| 114 |
+
|
| 115 |
+
def format_unencoded(self, tokensource, outfile):
|
| 116 |
+
"""
|
| 117 |
+
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
|
| 118 |
+
tuples and write it into ``outfile``.
|
| 119 |
+
|
| 120 |
+
For our implementation we put all lines in their own 'line group'.
|
| 121 |
+
"""
|
| 122 |
+
x = self.xoffset
|
| 123 |
+
y = self.yoffset
|
| 124 |
+
if not self.nowrap:
|
| 125 |
+
if self.encoding:
|
| 126 |
+
outfile.write(f'<?xml version="1.0" encoding="{self.encoding}"?>\n')
|
| 127 |
+
else:
|
| 128 |
+
outfile.write('<?xml version="1.0"?>\n')
|
| 129 |
+
outfile.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" '
|
| 130 |
+
'"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/'
|
| 131 |
+
'svg10.dtd">\n')
|
| 132 |
+
outfile.write('<svg xmlns="http://www.w3.org/2000/svg">\n')
|
| 133 |
+
outfile.write(f'<g font-family="{self.fontfamily}" font-size="{self.fontsize}">\n')
|
| 134 |
+
|
| 135 |
+
counter = self.linenostart
|
| 136 |
+
counter_step = self.linenostep
|
| 137 |
+
counter_style = self._get_style(Comment)
|
| 138 |
+
line_x = x
|
| 139 |
+
|
| 140 |
+
if self.linenos:
|
| 141 |
+
if counter % counter_step == 0:
|
| 142 |
+
outfile.write(f'<text x="{x+self.linenowidth}" y="{y}" {counter_style} text-anchor="end">{counter}</text>')
|
| 143 |
+
line_x += self.linenowidth + self.ystep
|
| 144 |
+
counter += 1
|
| 145 |
+
|
| 146 |
+
outfile.write(f'<text x="{line_x}" y="{y}" xml:space="preserve">')
|
| 147 |
+
for ttype, value in tokensource:
|
| 148 |
+
style = self._get_style(ttype)
|
| 149 |
+
tspan = style and '<tspan' + style + '>' or ''
|
| 150 |
+
tspanend = tspan and '</tspan>' or ''
|
| 151 |
+
value = escape_html(value)
|
| 152 |
+
if self.spacehack:
|
| 153 |
+
value = value.expandtabs().replace(' ', ' ')
|
| 154 |
+
parts = value.split('\n')
|
| 155 |
+
for part in parts[:-1]:
|
| 156 |
+
outfile.write(tspan + part + tspanend)
|
| 157 |
+
y += self.ystep
|
| 158 |
+
outfile.write('</text>\n')
|
| 159 |
+
if self.linenos and counter % counter_step == 0:
|
| 160 |
+
outfile.write(f'<text x="{x+self.linenowidth}" y="{y}" text-anchor="end" {counter_style}>{counter}</text>')
|
| 161 |
+
|
| 162 |
+
counter += 1
|
| 163 |
+
outfile.write(f'<text x="{line_x}" y="{y}" ' 'xml:space="preserve">')
|
| 164 |
+
outfile.write(tspan + parts[-1] + tspanend)
|
| 165 |
+
outfile.write('</text>')
|
| 166 |
+
|
| 167 |
+
if not self.nowrap:
|
| 168 |
+
outfile.write('</g></svg>\n')
|
| 169 |
+
|
| 170 |
+
def _get_style(self, tokentype):
|
| 171 |
+
if tokentype in self._stylecache:
|
| 172 |
+
return self._stylecache[tokentype]
|
| 173 |
+
otokentype = tokentype
|
| 174 |
+
while not self.style.styles_token(tokentype):
|
| 175 |
+
tokentype = tokentype.parent
|
| 176 |
+
value = self.style.style_for_token(tokentype)
|
| 177 |
+
result = ''
|
| 178 |
+
if value['color']:
|
| 179 |
+
result = ' fill="#' + value['color'] + '"'
|
| 180 |
+
if value['bold']:
|
| 181 |
+
result += ' font-weight="bold"'
|
| 182 |
+
if value['italic']:
|
| 183 |
+
result += ' font-style="italic"'
|
| 184 |
+
self._stylecache[otokentype] = result
|
| 185 |
+
return result
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/terminal.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.formatters.terminal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Formatter for terminal output with ANSI sequences.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.formatter import Formatter
|
| 12 |
+
from pygments.token import Keyword, Name, Comment, String, Error, \
|
| 13 |
+
Number, Operator, Generic, Token, Whitespace
|
| 14 |
+
from pygments.console import ansiformat
|
| 15 |
+
from pygments.util import get_choice_opt
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
__all__ = ['TerminalFormatter']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
#: Map token types to a tuple of color values for light and dark
|
| 22 |
+
#: backgrounds.
|
| 23 |
+
TERMINAL_COLORS = {
|
| 24 |
+
Token: ('', ''),
|
| 25 |
+
|
| 26 |
+
Whitespace: ('gray', 'brightblack'),
|
| 27 |
+
Comment: ('gray', 'brightblack'),
|
| 28 |
+
Comment.Preproc: ('cyan', 'brightcyan'),
|
| 29 |
+
Keyword: ('blue', 'brightblue'),
|
| 30 |
+
Keyword.Type: ('cyan', 'brightcyan'),
|
| 31 |
+
Operator.Word: ('magenta', 'brightmagenta'),
|
| 32 |
+
Name.Builtin: ('cyan', 'brightcyan'),
|
| 33 |
+
Name.Function: ('green', 'brightgreen'),
|
| 34 |
+
Name.Namespace: ('_cyan_', '_brightcyan_'),
|
| 35 |
+
Name.Class: ('_green_', '_brightgreen_'),
|
| 36 |
+
Name.Exception: ('cyan', 'brightcyan'),
|
| 37 |
+
Name.Decorator: ('brightblack', 'gray'),
|
| 38 |
+
Name.Variable: ('red', 'brightred'),
|
| 39 |
+
Name.Constant: ('red', 'brightred'),
|
| 40 |
+
Name.Attribute: ('cyan', 'brightcyan'),
|
| 41 |
+
Name.Tag: ('brightblue', 'brightblue'),
|
| 42 |
+
String: ('yellow', 'yellow'),
|
| 43 |
+
Number: ('blue', 'brightblue'),
|
| 44 |
+
|
| 45 |
+
Generic.Deleted: ('brightred', 'brightred'),
|
| 46 |
+
Generic.Inserted: ('green', 'brightgreen'),
|
| 47 |
+
Generic.Heading: ('**', '**'),
|
| 48 |
+
Generic.Subheading: ('*magenta*', '*brightmagenta*'),
|
| 49 |
+
Generic.Prompt: ('**', '**'),
|
| 50 |
+
Generic.Error: ('brightred', 'brightred'),
|
| 51 |
+
|
| 52 |
+
Error: ('_brightred_', '_brightred_'),
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class TerminalFormatter(Formatter):
|
| 57 |
+
r"""
|
| 58 |
+
Format tokens with ANSI color sequences, for output in a text console.
|
| 59 |
+
Color sequences are terminated at newlines, so that paging the output
|
| 60 |
+
works correctly.
|
| 61 |
+
|
| 62 |
+
The `get_style_defs()` method doesn't do anything special since there is
|
| 63 |
+
no support for common styles.
|
| 64 |
+
|
| 65 |
+
Options accepted:
|
| 66 |
+
|
| 67 |
+
`bg`
|
| 68 |
+
Set to ``"light"`` or ``"dark"`` depending on the terminal's background
|
| 69 |
+
(default: ``"light"``).
|
| 70 |
+
|
| 71 |
+
`colorscheme`
|
| 72 |
+
A dictionary mapping token types to (lightbg, darkbg) color names or
|
| 73 |
+
``None`` (default: ``None`` = use builtin colorscheme).
|
| 74 |
+
|
| 75 |
+
`linenos`
|
| 76 |
+
Set to ``True`` to have line numbers on the terminal output as well
|
| 77 |
+
(default: ``False`` = no line numbers).
|
| 78 |
+
"""
|
| 79 |
+
name = 'Terminal'
|
| 80 |
+
aliases = ['terminal', 'console']
|
| 81 |
+
filenames = []
|
| 82 |
+
|
| 83 |
+
def __init__(self, **options):
|
| 84 |
+
Formatter.__init__(self, **options)
|
| 85 |
+
self.darkbg = get_choice_opt(options, 'bg',
|
| 86 |
+
['light', 'dark'], 'light') == 'dark'
|
| 87 |
+
self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS
|
| 88 |
+
self.linenos = options.get('linenos', False)
|
| 89 |
+
self._lineno = 0
|
| 90 |
+
|
| 91 |
+
def format(self, tokensource, outfile):
|
| 92 |
+
return Formatter.format(self, tokensource, outfile)
|
| 93 |
+
|
| 94 |
+
def _write_lineno(self, outfile):
|
| 95 |
+
self._lineno += 1
|
| 96 |
+
outfile.write("%s%04d: " % (self._lineno != 1 and '\n' or '', self._lineno))
|
| 97 |
+
|
| 98 |
+
def _get_color(self, ttype):
|
| 99 |
+
# self.colorscheme is a dict containing usually generic types, so we
|
| 100 |
+
# have to walk the tree of dots. The base Token type must be a key,
|
| 101 |
+
# even if it's empty string, as in the default above.
|
| 102 |
+
colors = self.colorscheme.get(ttype)
|
| 103 |
+
while colors is None:
|
| 104 |
+
ttype = ttype.parent
|
| 105 |
+
colors = self.colorscheme.get(ttype)
|
| 106 |
+
return colors[self.darkbg]
|
| 107 |
+
|
| 108 |
+
def format_unencoded(self, tokensource, outfile):
|
| 109 |
+
if self.linenos:
|
| 110 |
+
self._write_lineno(outfile)
|
| 111 |
+
|
| 112 |
+
for ttype, value in tokensource:
|
| 113 |
+
color = self._get_color(ttype)
|
| 114 |
+
|
| 115 |
+
for line in value.splitlines(True):
|
| 116 |
+
if color:
|
| 117 |
+
outfile.write(ansiformat(color, line.rstrip('\n')))
|
| 118 |
+
else:
|
| 119 |
+
outfile.write(line.rstrip('\n'))
|
| 120 |
+
if line.endswith('\n'):
|
| 121 |
+
if self.linenos:
|
| 122 |
+
self._write_lineno(outfile)
|
| 123 |
+
else:
|
| 124 |
+
outfile.write('\n')
|
| 125 |
+
|
| 126 |
+
if self.linenos:
|
| 127 |
+
outfile.write("\n")
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/formatters/terminal256.py
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.formatters.terminal256
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Formatter for 256-color terminal output with ANSI sequences.
|
| 6 |
+
|
| 7 |
+
RGB-to-XTERM color conversion routines adapted from xterm256-conv
|
| 8 |
+
tool (http://frexx.de/xterm-256-notes/data/xterm256-conv2.tar.bz2)
|
| 9 |
+
by Wolfgang Frisch.
|
| 10 |
+
|
| 11 |
+
Formatter version 1.
|
| 12 |
+
|
| 13 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 14 |
+
:license: BSD, see LICENSE for details.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
# TODO:
|
| 18 |
+
# - Options to map style's bold/underline/italic/border attributes
|
| 19 |
+
# to some ANSI attrbutes (something like 'italic=underline')
|
| 20 |
+
# - An option to output "style RGB to xterm RGB/index" conversion table
|
| 21 |
+
# - An option to indicate that we are running in "reverse background"
|
| 22 |
+
# xterm. This means that default colors are white-on-black, not
|
| 23 |
+
# black-on-while, so colors like "white background" need to be converted
|
| 24 |
+
# to "white background, black foreground", etc...
|
| 25 |
+
|
| 26 |
+
from pygments.formatter import Formatter
|
| 27 |
+
from pygments.console import codes
|
| 28 |
+
from pygments.style import ansicolors
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
__all__ = ['Terminal256Formatter', 'TerminalTrueColorFormatter']
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class EscapeSequence:
|
| 35 |
+
def __init__(self, fg=None, bg=None, bold=False, underline=False, italic=False):
|
| 36 |
+
self.fg = fg
|
| 37 |
+
self.bg = bg
|
| 38 |
+
self.bold = bold
|
| 39 |
+
self.underline = underline
|
| 40 |
+
self.italic = italic
|
| 41 |
+
|
| 42 |
+
def escape(self, attrs):
|
| 43 |
+
if len(attrs):
|
| 44 |
+
return "\x1b[" + ";".join(attrs) + "m"
|
| 45 |
+
return ""
|
| 46 |
+
|
| 47 |
+
def color_string(self):
|
| 48 |
+
attrs = []
|
| 49 |
+
if self.fg is not None:
|
| 50 |
+
if self.fg in ansicolors:
|
| 51 |
+
esc = codes[self.fg.replace('ansi','')]
|
| 52 |
+
if ';01m' in esc:
|
| 53 |
+
self.bold = True
|
| 54 |
+
# extract fg color code.
|
| 55 |
+
attrs.append(esc[2:4])
|
| 56 |
+
else:
|
| 57 |
+
attrs.extend(("38", "5", "%i" % self.fg))
|
| 58 |
+
if self.bg is not None:
|
| 59 |
+
if self.bg in ansicolors:
|
| 60 |
+
esc = codes[self.bg.replace('ansi','')]
|
| 61 |
+
# extract fg color code, add 10 for bg.
|
| 62 |
+
attrs.append(str(int(esc[2:4])+10))
|
| 63 |
+
else:
|
| 64 |
+
attrs.extend(("48", "5", "%i" % self.bg))
|
| 65 |
+
if self.bold:
|
| 66 |
+
attrs.append("01")
|
| 67 |
+
if self.underline:
|
| 68 |
+
attrs.append("04")
|
| 69 |
+
if self.italic:
|
| 70 |
+
attrs.append("03")
|
| 71 |
+
return self.escape(attrs)
|
| 72 |
+
|
| 73 |
+
def true_color_string(self):
|
| 74 |
+
attrs = []
|
| 75 |
+
if self.fg:
|
| 76 |
+
attrs.extend(("38", "2", str(self.fg[0]), str(self.fg[1]), str(self.fg[2])))
|
| 77 |
+
if self.bg:
|
| 78 |
+
attrs.extend(("48", "2", str(self.bg[0]), str(self.bg[1]), str(self.bg[2])))
|
| 79 |
+
if self.bold:
|
| 80 |
+
attrs.append("01")
|
| 81 |
+
if self.underline:
|
| 82 |
+
attrs.append("04")
|
| 83 |
+
if self.italic:
|
| 84 |
+
attrs.append("03")
|
| 85 |
+
return self.escape(attrs)
|
| 86 |
+
|
| 87 |
+
def reset_string(self):
|
| 88 |
+
attrs = []
|
| 89 |
+
if self.fg is not None:
|
| 90 |
+
attrs.append("39")
|
| 91 |
+
if self.bg is not None:
|
| 92 |
+
attrs.append("49")
|
| 93 |
+
if self.bold or self.underline or self.italic:
|
| 94 |
+
attrs.append("00")
|
| 95 |
+
return self.escape(attrs)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class Terminal256Formatter(Formatter):
|
| 99 |
+
"""
|
| 100 |
+
Format tokens with ANSI color sequences, for output in a 256-color
|
| 101 |
+
terminal or console. Like in `TerminalFormatter` color sequences
|
| 102 |
+
are terminated at newlines, so that paging the output works correctly.
|
| 103 |
+
|
| 104 |
+
The formatter takes colors from a style defined by the `style` option
|
| 105 |
+
and converts them to nearest ANSI 256-color escape sequences. Bold and
|
| 106 |
+
underline attributes from the style are preserved (and displayed).
|
| 107 |
+
|
| 108 |
+
.. versionadded:: 0.9
|
| 109 |
+
|
| 110 |
+
.. versionchanged:: 2.2
|
| 111 |
+
If the used style defines foreground colors in the form ``#ansi*``, then
|
| 112 |
+
`Terminal256Formatter` will map these to non extended foreground color.
|
| 113 |
+
See :ref:`AnsiTerminalStyle` for more information.
|
| 114 |
+
|
| 115 |
+
.. versionchanged:: 2.4
|
| 116 |
+
The ANSI color names have been updated with names that are easier to
|
| 117 |
+
understand and align with colornames of other projects and terminals.
|
| 118 |
+
See :ref:`this table <new-ansi-color-names>` for more information.
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
Options accepted:
|
| 122 |
+
|
| 123 |
+
`style`
|
| 124 |
+
The style to use, can be a string or a Style subclass (default:
|
| 125 |
+
``'default'``).
|
| 126 |
+
|
| 127 |
+
`linenos`
|
| 128 |
+
Set to ``True`` to have line numbers on the terminal output as well
|
| 129 |
+
(default: ``False`` = no line numbers).
|
| 130 |
+
"""
|
| 131 |
+
name = 'Terminal256'
|
| 132 |
+
aliases = ['terminal256', 'console256', '256']
|
| 133 |
+
filenames = []
|
| 134 |
+
|
| 135 |
+
def __init__(self, **options):
|
| 136 |
+
Formatter.__init__(self, **options)
|
| 137 |
+
|
| 138 |
+
self.xterm_colors = []
|
| 139 |
+
self.best_match = {}
|
| 140 |
+
self.style_string = {}
|
| 141 |
+
|
| 142 |
+
self.usebold = 'nobold' not in options
|
| 143 |
+
self.useunderline = 'nounderline' not in options
|
| 144 |
+
self.useitalic = 'noitalic' not in options
|
| 145 |
+
|
| 146 |
+
self._build_color_table() # build an RGB-to-256 color conversion table
|
| 147 |
+
self._setup_styles() # convert selected style's colors to term. colors
|
| 148 |
+
|
| 149 |
+
self.linenos = options.get('linenos', False)
|
| 150 |
+
self._lineno = 0
|
| 151 |
+
|
| 152 |
+
def _build_color_table(self):
|
| 153 |
+
# colors 0..15: 16 basic colors
|
| 154 |
+
|
| 155 |
+
self.xterm_colors.append((0x00, 0x00, 0x00)) # 0
|
| 156 |
+
self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1
|
| 157 |
+
self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2
|
| 158 |
+
self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3
|
| 159 |
+
self.xterm_colors.append((0x00, 0x00, 0xee)) # 4
|
| 160 |
+
self.xterm_colors.append((0xcd, 0x00, 0xcd)) # 5
|
| 161 |
+
self.xterm_colors.append((0x00, 0xcd, 0xcd)) # 6
|
| 162 |
+
self.xterm_colors.append((0xe5, 0xe5, 0xe5)) # 7
|
| 163 |
+
self.xterm_colors.append((0x7f, 0x7f, 0x7f)) # 8
|
| 164 |
+
self.xterm_colors.append((0xff, 0x00, 0x00)) # 9
|
| 165 |
+
self.xterm_colors.append((0x00, 0xff, 0x00)) # 10
|
| 166 |
+
self.xterm_colors.append((0xff, 0xff, 0x00)) # 11
|
| 167 |
+
self.xterm_colors.append((0x5c, 0x5c, 0xff)) # 12
|
| 168 |
+
self.xterm_colors.append((0xff, 0x00, 0xff)) # 13
|
| 169 |
+
self.xterm_colors.append((0x00, 0xff, 0xff)) # 14
|
| 170 |
+
self.xterm_colors.append((0xff, 0xff, 0xff)) # 15
|
| 171 |
+
|
| 172 |
+
# colors 16..231: the 6x6x6 color cube
|
| 173 |
+
|
| 174 |
+
valuerange = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff)
|
| 175 |
+
|
| 176 |
+
for i in range(216):
|
| 177 |
+
r = valuerange[(i // 36) % 6]
|
| 178 |
+
g = valuerange[(i // 6) % 6]
|
| 179 |
+
b = valuerange[i % 6]
|
| 180 |
+
self.xterm_colors.append((r, g, b))
|
| 181 |
+
|
| 182 |
+
# colors 232..255: grayscale
|
| 183 |
+
|
| 184 |
+
for i in range(24):
|
| 185 |
+
v = 8 + i * 10
|
| 186 |
+
self.xterm_colors.append((v, v, v))
|
| 187 |
+
|
| 188 |
+
def _closest_color(self, r, g, b):
|
| 189 |
+
distance = 257*257*3 # "infinity" (>distance from #000000 to #ffffff)
|
| 190 |
+
match = 0
|
| 191 |
+
|
| 192 |
+
for i in range(0, 256):
|
| 193 |
+
values = self.xterm_colors[i]
|
| 194 |
+
|
| 195 |
+
rd = r - values[0]
|
| 196 |
+
gd = g - values[1]
|
| 197 |
+
bd = b - values[2]
|
| 198 |
+
d = rd*rd + gd*gd + bd*bd
|
| 199 |
+
|
| 200 |
+
if d < distance:
|
| 201 |
+
match = i
|
| 202 |
+
distance = d
|
| 203 |
+
return match
|
| 204 |
+
|
| 205 |
+
def _color_index(self, color):
|
| 206 |
+
index = self.best_match.get(color, None)
|
| 207 |
+
if color in ansicolors:
|
| 208 |
+
# strip the `ansi/#ansi` part and look up code
|
| 209 |
+
index = color
|
| 210 |
+
self.best_match[color] = index
|
| 211 |
+
if index is None:
|
| 212 |
+
try:
|
| 213 |
+
rgb = int(str(color), 16)
|
| 214 |
+
except ValueError:
|
| 215 |
+
rgb = 0
|
| 216 |
+
|
| 217 |
+
r = (rgb >> 16) & 0xff
|
| 218 |
+
g = (rgb >> 8) & 0xff
|
| 219 |
+
b = rgb & 0xff
|
| 220 |
+
index = self._closest_color(r, g, b)
|
| 221 |
+
self.best_match[color] = index
|
| 222 |
+
return index
|
| 223 |
+
|
| 224 |
+
def _setup_styles(self):
|
| 225 |
+
for ttype, ndef in self.style:
|
| 226 |
+
escape = EscapeSequence()
|
| 227 |
+
# get foreground from ansicolor if set
|
| 228 |
+
if ndef['ansicolor']:
|
| 229 |
+
escape.fg = self._color_index(ndef['ansicolor'])
|
| 230 |
+
elif ndef['color']:
|
| 231 |
+
escape.fg = self._color_index(ndef['color'])
|
| 232 |
+
if ndef['bgansicolor']:
|
| 233 |
+
escape.bg = self._color_index(ndef['bgansicolor'])
|
| 234 |
+
elif ndef['bgcolor']:
|
| 235 |
+
escape.bg = self._color_index(ndef['bgcolor'])
|
| 236 |
+
if self.usebold and ndef['bold']:
|
| 237 |
+
escape.bold = True
|
| 238 |
+
if self.useunderline and ndef['underline']:
|
| 239 |
+
escape.underline = True
|
| 240 |
+
if self.useitalic and ndef['italic']:
|
| 241 |
+
escape.italic = True
|
| 242 |
+
self.style_string[str(ttype)] = (escape.color_string(),
|
| 243 |
+
escape.reset_string())
|
| 244 |
+
|
| 245 |
+
def _write_lineno(self, outfile):
|
| 246 |
+
self._lineno += 1
|
| 247 |
+
outfile.write("%s%04d: " % (self._lineno != 1 and '\n' or '', self._lineno))
|
| 248 |
+
|
| 249 |
+
def format(self, tokensource, outfile):
|
| 250 |
+
return Formatter.format(self, tokensource, outfile)
|
| 251 |
+
|
| 252 |
+
def format_unencoded(self, tokensource, outfile):
|
| 253 |
+
if self.linenos:
|
| 254 |
+
self._write_lineno(outfile)
|
| 255 |
+
|
| 256 |
+
for ttype, value in tokensource:
|
| 257 |
+
not_found = True
|
| 258 |
+
while ttype and not_found:
|
| 259 |
+
try:
|
| 260 |
+
# outfile.write( "<" + str(ttype) + ">" )
|
| 261 |
+
on, off = self.style_string[str(ttype)]
|
| 262 |
+
|
| 263 |
+
# Like TerminalFormatter, add "reset colors" escape sequence
|
| 264 |
+
# on newline.
|
| 265 |
+
spl = value.split('\n')
|
| 266 |
+
for line in spl[:-1]:
|
| 267 |
+
if line:
|
| 268 |
+
outfile.write(on + line + off)
|
| 269 |
+
if self.linenos:
|
| 270 |
+
self._write_lineno(outfile)
|
| 271 |
+
else:
|
| 272 |
+
outfile.write('\n')
|
| 273 |
+
|
| 274 |
+
if spl[-1]:
|
| 275 |
+
outfile.write(on + spl[-1] + off)
|
| 276 |
+
|
| 277 |
+
not_found = False
|
| 278 |
+
# outfile.write( '#' + str(ttype) + '#' )
|
| 279 |
+
|
| 280 |
+
except KeyError:
|
| 281 |
+
# ottype = ttype
|
| 282 |
+
ttype = ttype.parent
|
| 283 |
+
# outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' )
|
| 284 |
+
|
| 285 |
+
if not_found:
|
| 286 |
+
outfile.write(value)
|
| 287 |
+
|
| 288 |
+
if self.linenos:
|
| 289 |
+
outfile.write("\n")
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
class TerminalTrueColorFormatter(Terminal256Formatter):
|
| 294 |
+
r"""
|
| 295 |
+
Format tokens with ANSI color sequences, for output in a true-color
|
| 296 |
+
terminal or console. Like in `TerminalFormatter` color sequences
|
| 297 |
+
are terminated at newlines, so that paging the output works correctly.
|
| 298 |
+
|
| 299 |
+
.. versionadded:: 2.1
|
| 300 |
+
|
| 301 |
+
Options accepted:
|
| 302 |
+
|
| 303 |
+
`style`
|
| 304 |
+
The style to use, can be a string or a Style subclass (default:
|
| 305 |
+
``'default'``).
|
| 306 |
+
"""
|
| 307 |
+
name = 'TerminalTrueColor'
|
| 308 |
+
aliases = ['terminal16m', 'console16m', '16m']
|
| 309 |
+
filenames = []
|
| 310 |
+
|
| 311 |
+
def _build_color_table(self):
|
| 312 |
+
pass
|
| 313 |
+
|
| 314 |
+
def _color_tuple(self, color):
|
| 315 |
+
try:
|
| 316 |
+
rgb = int(str(color), 16)
|
| 317 |
+
except ValueError:
|
| 318 |
+
return None
|
| 319 |
+
r = (rgb >> 16) & 0xff
|
| 320 |
+
g = (rgb >> 8) & 0xff
|
| 321 |
+
b = rgb & 0xff
|
| 322 |
+
return (r, g, b)
|
| 323 |
+
|
| 324 |
+
def _setup_styles(self):
|
| 325 |
+
for ttype, ndef in self.style:
|
| 326 |
+
escape = EscapeSequence()
|
| 327 |
+
if ndef['color']:
|
| 328 |
+
escape.fg = self._color_tuple(ndef['color'])
|
| 329 |
+
if ndef['bgcolor']:
|
| 330 |
+
escape.bg = self._color_tuple(ndef['bgcolor'])
|
| 331 |
+
if self.usebold and ndef['bold']:
|
| 332 |
+
escape.bold = True
|
| 333 |
+
if self.useunderline and ndef['underline']:
|
| 334 |
+
escape.underline = True
|
| 335 |
+
if self.useitalic and ndef['italic']:
|
| 336 |
+
escape.italic = True
|
| 337 |
+
self.style_string[str(ttype)] = (escape.true_color_string(),
|
| 338 |
+
escape.reset_string())
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/arrow.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.arrow
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Arrow.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, default, include
|
| 12 |
+
from pygments.token import Text, Operator, Keyword, Punctuation, Name, \
|
| 13 |
+
String, Number, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['ArrowLexer']
|
| 16 |
+
|
| 17 |
+
TYPES = r'\b(int|bool|char)((?:\[\])*)(?=\s+)'
|
| 18 |
+
IDENT = r'([a-zA-Z_][a-zA-Z0-9_]*)'
|
| 19 |
+
DECL = TYPES + r'(\s+)' + IDENT
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class ArrowLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
Lexer for Arrow
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Arrow'
|
| 28 |
+
url = 'https://pypi.org/project/py-arrow-lang/'
|
| 29 |
+
aliases = ['arrow']
|
| 30 |
+
filenames = ['*.arw']
|
| 31 |
+
version_added = '2.7'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
(r'\s+', Whitespace),
|
| 36 |
+
(r'^[|\s]+', Punctuation),
|
| 37 |
+
include('blocks'),
|
| 38 |
+
include('statements'),
|
| 39 |
+
include('expressions'),
|
| 40 |
+
],
|
| 41 |
+
'blocks': [
|
| 42 |
+
(r'(function)(\n+)(/-->)(\s*)' +
|
| 43 |
+
DECL + # 4 groups
|
| 44 |
+
r'(\()', bygroups(
|
| 45 |
+
Keyword.Reserved, Whitespace, Punctuation,
|
| 46 |
+
Whitespace, Keyword.Type, Punctuation, Whitespace,
|
| 47 |
+
Name.Function, Punctuation
|
| 48 |
+
), 'fparams'),
|
| 49 |
+
(r'/-->$|\\-->$|/--<|\\--<|\^', Punctuation),
|
| 50 |
+
],
|
| 51 |
+
'statements': [
|
| 52 |
+
(DECL, bygroups(Keyword.Type, Punctuation, Text, Name.Variable)),
|
| 53 |
+
(r'\[', Punctuation, 'index'),
|
| 54 |
+
(r'=', Operator),
|
| 55 |
+
(r'require|main', Keyword.Reserved),
|
| 56 |
+
(r'print', Keyword.Reserved, 'print'),
|
| 57 |
+
],
|
| 58 |
+
'expressions': [
|
| 59 |
+
(r'\s+', Whitespace),
|
| 60 |
+
(r'[0-9]+', Number.Integer),
|
| 61 |
+
(r'true|false', Keyword.Constant),
|
| 62 |
+
(r"'", String.Char, 'char'),
|
| 63 |
+
(r'"', String.Double, 'string'),
|
| 64 |
+
(r'\{', Punctuation, 'array'),
|
| 65 |
+
(r'==|!=|<|>|\+|-|\*|/|%', Operator),
|
| 66 |
+
(r'and|or|not|length', Operator.Word),
|
| 67 |
+
(r'(input)(\s+)(int|char\[\])', bygroups(
|
| 68 |
+
Keyword.Reserved, Whitespace, Keyword.Type
|
| 69 |
+
)),
|
| 70 |
+
(IDENT + r'(\()', bygroups(
|
| 71 |
+
Name.Function, Punctuation
|
| 72 |
+
), 'fargs'),
|
| 73 |
+
(IDENT, Name.Variable),
|
| 74 |
+
(r'\[', Punctuation, 'index'),
|
| 75 |
+
(r'\(', Punctuation, 'expressions'),
|
| 76 |
+
(r'\)', Punctuation, '#pop'),
|
| 77 |
+
],
|
| 78 |
+
'print': [
|
| 79 |
+
include('expressions'),
|
| 80 |
+
(r',', Punctuation),
|
| 81 |
+
default('#pop'),
|
| 82 |
+
],
|
| 83 |
+
'fparams': [
|
| 84 |
+
(DECL, bygroups(Keyword.Type, Punctuation, Whitespace, Name.Variable)),
|
| 85 |
+
(r',', Punctuation),
|
| 86 |
+
(r'\)', Punctuation, '#pop'),
|
| 87 |
+
],
|
| 88 |
+
'escape': [
|
| 89 |
+
(r'\\(["\\/abfnrtv]|[0-9]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})',
|
| 90 |
+
String.Escape),
|
| 91 |
+
],
|
| 92 |
+
'char': [
|
| 93 |
+
(r"'", String.Char, '#pop'),
|
| 94 |
+
include('escape'),
|
| 95 |
+
(r"[^'\\]", String.Char),
|
| 96 |
+
],
|
| 97 |
+
'string': [
|
| 98 |
+
(r'"', String.Double, '#pop'),
|
| 99 |
+
include('escape'),
|
| 100 |
+
(r'[^"\\]+', String.Double),
|
| 101 |
+
],
|
| 102 |
+
'array': [
|
| 103 |
+
include('expressions'),
|
| 104 |
+
(r'\}', Punctuation, '#pop'),
|
| 105 |
+
(r',', Punctuation),
|
| 106 |
+
],
|
| 107 |
+
'fargs': [
|
| 108 |
+
include('expressions'),
|
| 109 |
+
(r'\)', Punctuation, '#pop'),
|
| 110 |
+
(r',', Punctuation),
|
| 111 |
+
],
|
| 112 |
+
'index': [
|
| 113 |
+
include('expressions'),
|
| 114 |
+
(r'\]', Punctuation, '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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.arturo
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Arturo language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, do_insertions, include, \
|
| 12 |
+
this, using, words
|
| 13 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \
|
| 14 |
+
Punctuation, String, Text
|
| 15 |
+
|
| 16 |
+
from pygments.util import ClassNotFound, get_bool_opt
|
| 17 |
+
|
| 18 |
+
__all__ = ['ArturoLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class ArturoLexer(RegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
For Arturo source code.
|
| 24 |
+
|
| 25 |
+
See `Arturo's Github <https://github.com/arturo-lang/arturo>`_
|
| 26 |
+
and `Arturo's Website <https://arturo-lang.io/>`_.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
name = 'Arturo'
|
| 30 |
+
aliases = ['arturo', 'art']
|
| 31 |
+
filenames = ['*.art']
|
| 32 |
+
url = 'https://arturo-lang.io/'
|
| 33 |
+
version_added = '2.14'
|
| 34 |
+
|
| 35 |
+
def __init__(self, **options):
|
| 36 |
+
self.handle_annotateds = get_bool_opt(options, 'handle_annotateds',
|
| 37 |
+
True)
|
| 38 |
+
RegexLexer.__init__(self, **options)
|
| 39 |
+
|
| 40 |
+
def handle_annotated_strings(self, match):
|
| 41 |
+
"""Adds syntax from another languages inside annotated strings
|
| 42 |
+
|
| 43 |
+
match args:
|
| 44 |
+
1:open_string,
|
| 45 |
+
2:exclamation_mark,
|
| 46 |
+
3:lang_name,
|
| 47 |
+
4:space_or_newline,
|
| 48 |
+
5:code,
|
| 49 |
+
6:close_string
|
| 50 |
+
"""
|
| 51 |
+
from pygments.lexers import get_lexer_by_name
|
| 52 |
+
|
| 53 |
+
# Header's section
|
| 54 |
+
yield match.start(1), String.Double, match.group(1)
|
| 55 |
+
yield match.start(2), String.Interpol, match.group(2)
|
| 56 |
+
yield match.start(3), String.Interpol, match.group(3)
|
| 57 |
+
yield match.start(4), Text.Whitespace, match.group(4)
|
| 58 |
+
|
| 59 |
+
lexer = None
|
| 60 |
+
if self.handle_annotateds:
|
| 61 |
+
try:
|
| 62 |
+
lexer = get_lexer_by_name(match.group(3).strip())
|
| 63 |
+
except ClassNotFound:
|
| 64 |
+
pass
|
| 65 |
+
code = match.group(5)
|
| 66 |
+
|
| 67 |
+
if lexer is None:
|
| 68 |
+
yield match.group(5), String, code
|
| 69 |
+
else:
|
| 70 |
+
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
|
| 71 |
+
|
| 72 |
+
yield match.start(6), String.Double, match.group(6)
|
| 73 |
+
|
| 74 |
+
tokens = {
|
| 75 |
+
'root': [
|
| 76 |
+
(r';.*?$', Comment.Single),
|
| 77 |
+
(r'^((\s#!)|(#!)).*?$', Comment.Hashbang),
|
| 78 |
+
|
| 79 |
+
# Constants
|
| 80 |
+
(words(('false', 'true', 'maybe'), # boolean
|
| 81 |
+
suffix=r'\b'), Name.Constant),
|
| 82 |
+
(words(('this', 'init'), # class related keywords
|
| 83 |
+
prefix=r'\b', suffix=r'\b\??:?'), Name.Builtin.Pseudo),
|
| 84 |
+
(r'`.`', String.Char), # character
|
| 85 |
+
(r'\\\w+\b\??:?', Name.Property), # array index
|
| 86 |
+
(r'#\w+', Name.Constant), # color
|
| 87 |
+
(r'\b[0-9]+\.[0-9]+', Number.Float), # float
|
| 88 |
+
(r'\b[0-9]+', Number.Integer), # integer
|
| 89 |
+
(r'\w+\b\??:', Name.Label), # label
|
| 90 |
+
# Note: Literals can be labeled too
|
| 91 |
+
(r'\'(?:\w+\b\??:?)', Keyword.Declaration), # literal
|
| 92 |
+
(r'\:\w+', Keyword.Type), # type
|
| 93 |
+
# Note: Attributes can be labeled too
|
| 94 |
+
(r'\.\w+\??:?', Name.Attribute), # attributes
|
| 95 |
+
|
| 96 |
+
# Switch structure
|
| 97 |
+
(r'(\()(.*?)(\)\?)',
|
| 98 |
+
bygroups(Punctuation, using(this), Punctuation)),
|
| 99 |
+
|
| 100 |
+
# Single Line Strings
|
| 101 |
+
(r'"', String.Double, 'inside-simple-string'),
|
| 102 |
+
(r'»', String.Single, 'inside-smart-string'),
|
| 103 |
+
(r'«««', String.Double, 'inside-safe-string'),
|
| 104 |
+
(r'\{\/', String.Single, 'inside-regex-string'),
|
| 105 |
+
|
| 106 |
+
# Multi Line Strings
|
| 107 |
+
(r'\{\:', String.Double, 'inside-curly-verb-string'),
|
| 108 |
+
(r'(\{)(\!)(\w+)(\s|\n)([\w\W]*?)(^\})', handle_annotated_strings),
|
| 109 |
+
(r'\{', String.Single, 'inside-curly-string'),
|
| 110 |
+
(r'\-{3,}', String.Single, 'inside-eof-string'),
|
| 111 |
+
|
| 112 |
+
include('builtin-functions'),
|
| 113 |
+
|
| 114 |
+
# Operators
|
| 115 |
+
(r'[()[\],]', Punctuation),
|
| 116 |
+
(words(('->', '==>', '|', '::', '@', '#', # sugar syntax
|
| 117 |
+
'$', '&', '!', '!!', './')), Name.Decorator),
|
| 118 |
+
(words(('<:', ':>', ':<', '>:', '<\\', '<>', '<', '>',
|
| 119 |
+
'ø', '∞',
|
| 120 |
+
'+', '-', '*', '~', '=', '^', '%', '/', '//',
|
| 121 |
+
'==>', '<=>', '<==>',
|
| 122 |
+
'=>>', '<<=>>', '<<==>>',
|
| 123 |
+
'-->', '<->', '<-->',
|
| 124 |
+
'=|', '|=', '-:', ':-',
|
| 125 |
+
'_', '.', '..', '\\')), Operator),
|
| 126 |
+
|
| 127 |
+
(r'\b\w+', Name),
|
| 128 |
+
(r'\s+', Text.Whitespace),
|
| 129 |
+
(r'.+$', Error),
|
| 130 |
+
],
|
| 131 |
+
|
| 132 |
+
'inside-interpol': [
|
| 133 |
+
(r'\|', String.Interpol, '#pop'),
|
| 134 |
+
(r'[^|]+', using(this)),
|
| 135 |
+
],
|
| 136 |
+
'inside-template': [
|
| 137 |
+
(r'\|\|\>', String.Interpol, '#pop'),
|
| 138 |
+
(r'[^|]+', using(this)),
|
| 139 |
+
],
|
| 140 |
+
'string-escape': [
|
| 141 |
+
(words(('\\\\', '\\n', '\\t', '\\"')), String.Escape),
|
| 142 |
+
],
|
| 143 |
+
|
| 144 |
+
'inside-simple-string': [
|
| 145 |
+
include('string-escape'),
|
| 146 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 147 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 148 |
+
(r'"', String.Double, '#pop'), # Closing Quote
|
| 149 |
+
(r'[^|"]+', String) # String Content
|
| 150 |
+
],
|
| 151 |
+
'inside-smart-string': [
|
| 152 |
+
include('string-escape'),
|
| 153 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 154 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 155 |
+
(r'\n', String.Single, '#pop'), # Closing Quote
|
| 156 |
+
(r'[^|\n]+', String) # String Content
|
| 157 |
+
],
|
| 158 |
+
'inside-safe-string': [
|
| 159 |
+
include('string-escape'),
|
| 160 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 161 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 162 |
+
(r'»»»', String.Double, '#pop'), # Closing Quote
|
| 163 |
+
(r'[^|»]+', String) # String Content
|
| 164 |
+
],
|
| 165 |
+
'inside-regex-string': [
|
| 166 |
+
(r'\\[sSwWdDbBZApPxucItnvfr0]+', String.Escape),
|
| 167 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 168 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 169 |
+
(r'\/\}', String.Single, '#pop'), # Closing Quote
|
| 170 |
+
(r'[^|\/]+', String.Regex), # String Content
|
| 171 |
+
],
|
| 172 |
+
'inside-curly-verb-string': [
|
| 173 |
+
include('string-escape'),
|
| 174 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 175 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 176 |
+
(r'\:\}', String.Double, '#pop'), # Closing Quote
|
| 177 |
+
(r'[^|<:]+', String), # String Content
|
| 178 |
+
],
|
| 179 |
+
'inside-curly-string': [
|
| 180 |
+
include('string-escape'),
|
| 181 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 182 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 183 |
+
(r'\}', String.Single, '#pop'), # Closing Quote
|
| 184 |
+
(r'[^|<}]+', String), # String Content
|
| 185 |
+
],
|
| 186 |
+
'inside-eof-string': [
|
| 187 |
+
include('string-escape'),
|
| 188 |
+
(r'\|', String.Interpol, 'inside-interpol'), # Interpolation
|
| 189 |
+
(r'\<\|\|', String.Interpol, 'inside-template'), # Templates
|
| 190 |
+
(r'\Z', String.Single, '#pop'), # Closing Quote
|
| 191 |
+
(r'[^|<]+', String), # String Content
|
| 192 |
+
],
|
| 193 |
+
|
| 194 |
+
'builtin-functions': [
|
| 195 |
+
(words((
|
| 196 |
+
'all', 'and', 'any', 'ascii', 'attr', 'attribute',
|
| 197 |
+
'attributeLabel', 'binary', 'block' 'char', 'contains',
|
| 198 |
+
'database', 'date', 'dictionary', 'empty', 'equal', 'even',
|
| 199 |
+
'every', 'exists', 'false', 'floatin', 'function', 'greater',
|
| 200 |
+
'greaterOrEqual', 'if', 'in', 'inline', 'integer', 'is',
|
| 201 |
+
'key', 'label', 'leap', 'less', 'lessOrEqual', 'literal',
|
| 202 |
+
'logical', 'lower', 'nand', 'negative', 'nor', 'not',
|
| 203 |
+
'notEqual', 'null', 'numeric', 'odd', 'or', 'path',
|
| 204 |
+
'pathLabel', 'positive', 'prefix', 'prime', 'set', 'some',
|
| 205 |
+
'sorted', 'standalone', 'string', 'subset', 'suffix',
|
| 206 |
+
'superset', 'ymbol', 'true', 'try', 'type', 'unless', 'upper',
|
| 207 |
+
'when', 'whitespace', 'word', 'xnor', 'xor', 'zero',
|
| 208 |
+
), prefix=r'\b', suffix=r'\b\?'), Name.Builtin),
|
| 209 |
+
(words((
|
| 210 |
+
'abs', 'acos', 'acosh', 'acsec', 'acsech', 'actan', 'actanh',
|
| 211 |
+
'add', 'after', 'alphabet', 'and', 'angle', 'append', 'arg',
|
| 212 |
+
'args', 'arity', 'array', 'as', 'asec', 'asech', 'asin',
|
| 213 |
+
'asinh', 'atan', 'atan2', 'atanh', 'attr', 'attrs', 'average',
|
| 214 |
+
'before', 'benchmark', 'blend', 'break', 'builtins1',
|
| 215 |
+
'builtins2', 'call', 'capitalize', 'case', 'ceil', 'chop',
|
| 216 |
+
'chunk', 'clear', 'close', 'cluster', 'color', 'combine',
|
| 217 |
+
'conj', 'continue', 'copy', 'cos', 'cosh', 'couple', 'csec',
|
| 218 |
+
'csech', 'ctan', 'ctanh', 'cursor', 'darken', 'dec', 'decode',
|
| 219 |
+
'decouple', 'define', 'delete', 'desaturate', 'deviation',
|
| 220 |
+
'dictionary', 'difference', 'digest', 'digits', 'div', 'do',
|
| 221 |
+
'download', 'drop', 'dup', 'e', 'else', 'empty', 'encode',
|
| 222 |
+
'ensure', 'env', 'epsilon', 'escape', 'execute', 'exit', 'exp',
|
| 223 |
+
'extend', 'extract', 'factors', 'false', 'fdiv', 'filter',
|
| 224 |
+
'first', 'flatten', 'floor', 'fold', 'from', 'function',
|
| 225 |
+
'gamma', 'gcd', 'get', 'goto', 'hash', 'help', 'hypot', 'if',
|
| 226 |
+
'in', 'inc', 'indent', 'index', 'infinity', 'info', 'input',
|
| 227 |
+
'insert', 'inspect', 'intersection', 'invert', 'join', 'keys',
|
| 228 |
+
'kurtosis', 'last', 'let', 'levenshtein', 'lighten', 'list',
|
| 229 |
+
'ln', 'log', 'loop', 'lower', 'mail', 'map', 'match', 'max',
|
| 230 |
+
'maybe', 'median', 'min', 'mod', 'module', 'mul', 'nand',
|
| 231 |
+
'neg', 'new', 'nor', 'normalize', 'not', 'now', 'null', 'open',
|
| 232 |
+
'or', 'outdent', 'pad', 'panic', 'path', 'pause',
|
| 233 |
+
'permissions', 'permutate', 'pi', 'pop', 'pow', 'powerset',
|
| 234 |
+
'powmod', 'prefix', 'print', 'prints', 'process', 'product',
|
| 235 |
+
'query', 'random', 'range', 'read', 'relative', 'remove',
|
| 236 |
+
'rename', 'render', 'repeat', 'replace', 'request', 'return',
|
| 237 |
+
'reverse', 'round', 'sample', 'saturate', 'script', 'sec',
|
| 238 |
+
'sech', 'select', 'serve', 'set', 'shl', 'shr', 'shuffle',
|
| 239 |
+
'sin', 'sinh', 'size', 'skewness', 'slice', 'sort', 'split',
|
| 240 |
+
'sqrt', 'squeeze', 'stack', 'strip', 'sub', 'suffix', 'sum',
|
| 241 |
+
'switch', 'symbols', 'symlink', 'sys', 'take', 'tan', 'tanh',
|
| 242 |
+
'terminal', 'to', 'true', 'truncate', 'try', 'type', 'union',
|
| 243 |
+
'unique', 'unless', 'until', 'unzip', 'upper', 'values', 'var',
|
| 244 |
+
'variance', 'volume', 'webview', 'while', 'with', 'wordwrap',
|
| 245 |
+
'write', 'xnor', 'xor', 'zip'
|
| 246 |
+
), prefix=r'\b', suffix=r'\b'), Name.Builtin)
|
| 247 |
+
],
|
| 248 |
+
|
| 249 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/asc.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.asc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for various ASCII armored files.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
import re
|
| 11 |
+
|
| 12 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 13 |
+
from pygments.token import Comment, Generic, Name, Operator, String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['AscLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class AscLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for ASCII armored files, containing `-----BEGIN/END ...-----` wrapped
|
| 21 |
+
base64 data.
|
| 22 |
+
"""
|
| 23 |
+
name = 'ASCII armored'
|
| 24 |
+
aliases = ['asc', 'pem']
|
| 25 |
+
filenames = [
|
| 26 |
+
'*.asc', # PGP; *.gpg, *.pgp, and *.sig too, but those can be binary
|
| 27 |
+
'*.pem', # X.509; *.cer, *.crt, *.csr, and key etc too, but those can be binary
|
| 28 |
+
'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk',
|
| 29 |
+
'id_rsa', # SSH private keys
|
| 30 |
+
]
|
| 31 |
+
mimetypes = ['application/pgp-keys', 'application/pgp-encrypted',
|
| 32 |
+
'application/pgp-signature', 'application/pem-certificate-chain']
|
| 33 |
+
url = 'https://www.openpgp.org'
|
| 34 |
+
version_added = '2.10'
|
| 35 |
+
|
| 36 |
+
flags = re.MULTILINE
|
| 37 |
+
|
| 38 |
+
tokens = {
|
| 39 |
+
'root': [
|
| 40 |
+
(r'\s+', Whitespace),
|
| 41 |
+
(r'^-----BEGIN [^\n]+-----$', Generic.Heading, 'data'),
|
| 42 |
+
(r'\S+', Comment),
|
| 43 |
+
],
|
| 44 |
+
'data': [
|
| 45 |
+
(r'\s+', Whitespace),
|
| 46 |
+
(r'^([^:]+)(:)([ \t]+)(.*)',
|
| 47 |
+
bygroups(Name.Attribute, Operator, Whitespace, String)),
|
| 48 |
+
(r'^-----END [^\n]+-----$', Generic.Heading, 'root'),
|
| 49 |
+
(r'\S+', String),
|
| 50 |
+
],
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
def analyse_text(text):
|
| 54 |
+
if re.search(r'^-----BEGIN [^\n]+-----\r?\n', text):
|
| 55 |
+
return True
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.asn1
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments lexers for ASN.1.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation, Whitespace
|
| 15 |
+
from pygments.lexer import RegexLexer, words, bygroups
|
| 16 |
+
|
| 17 |
+
__all__ = ['Asn1Lexer']
|
| 18 |
+
|
| 19 |
+
SINGLE_WORD_KEYWORDS = [
|
| 20 |
+
"ENCODED",
|
| 21 |
+
"ABSTRACT-SYNTAX",
|
| 22 |
+
"END",
|
| 23 |
+
"APPLICATION",
|
| 24 |
+
"EXPLICIT",
|
| 25 |
+
"IMPLICIT",
|
| 26 |
+
"AUTOMATIC",
|
| 27 |
+
"TAGS",
|
| 28 |
+
"BEGIN",
|
| 29 |
+
"EXTENSIBILITY",
|
| 30 |
+
"BY",
|
| 31 |
+
"FROM",
|
| 32 |
+
"COMPONENT",
|
| 33 |
+
"UNIVERSAL",
|
| 34 |
+
"COMPONENTS",
|
| 35 |
+
"CONSTRAINED",
|
| 36 |
+
"IMPLIED",
|
| 37 |
+
"DEFINITIONS",
|
| 38 |
+
"INCLUDES",
|
| 39 |
+
"PRIVATE",
|
| 40 |
+
"WITH",
|
| 41 |
+
"OF",
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
OPERATOR_WORDS = [
|
| 45 |
+
"EXCEPT",
|
| 46 |
+
"UNION",
|
| 47 |
+
"INTERSECTION",
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
SINGLE_WORD_NAMESPACE_KEYWORDS = [
|
| 51 |
+
"EXPORTS",
|
| 52 |
+
"IMPORTS",
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
+
MULTI_WORDS_DECLARATIONS = [
|
| 56 |
+
"SEQUENCE OF",
|
| 57 |
+
"SET OF",
|
| 58 |
+
"INSTANCE OF",
|
| 59 |
+
"WITH SYNTAX",
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
SINGLE_WORDS_DECLARATIONS = [
|
| 63 |
+
"SIZE",
|
| 64 |
+
"SEQUENCE",
|
| 65 |
+
"SET",
|
| 66 |
+
"CLASS",
|
| 67 |
+
"UNIQUE",
|
| 68 |
+
"DEFAULT",
|
| 69 |
+
"CHOICE",
|
| 70 |
+
"PATTERN",
|
| 71 |
+
"OPTIONAL",
|
| 72 |
+
"PRESENT",
|
| 73 |
+
"ABSENT",
|
| 74 |
+
"CONTAINING",
|
| 75 |
+
"ENUMERATED",
|
| 76 |
+
"ALL",
|
| 77 |
+
]
|
| 78 |
+
|
| 79 |
+
TWO_WORDS_TYPES = [
|
| 80 |
+
"OBJECT IDENTIFIER",
|
| 81 |
+
"BIT STRING",
|
| 82 |
+
"OCTET STRING",
|
| 83 |
+
"CHARACTER STRING",
|
| 84 |
+
"EMBEDDED PDV",
|
| 85 |
+
]
|
| 86 |
+
|
| 87 |
+
SINGLE_WORD_TYPES = [
|
| 88 |
+
"RELATIVE-OID",
|
| 89 |
+
"TYPE-IDENTIFIER",
|
| 90 |
+
"ObjectDescriptor",
|
| 91 |
+
"IA5String",
|
| 92 |
+
"INTEGER",
|
| 93 |
+
"ISO646String",
|
| 94 |
+
"T61String",
|
| 95 |
+
"BMPString",
|
| 96 |
+
"NumericString",
|
| 97 |
+
"TeletexString",
|
| 98 |
+
"GeneralizedTime",
|
| 99 |
+
"REAL",
|
| 100 |
+
"BOOLEAN",
|
| 101 |
+
"GeneralString",
|
| 102 |
+
"GraphicString",
|
| 103 |
+
"UniversalString",
|
| 104 |
+
"UTCTime",
|
| 105 |
+
"VisibleString",
|
| 106 |
+
"UTF8String",
|
| 107 |
+
"PrintableString",
|
| 108 |
+
"VideotexString",
|
| 109 |
+
"EXTERNAL",
|
| 110 |
+
]
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def word_sequences(tokens):
|
| 114 |
+
return "(" + '|'.join(token.replace(' ', r'\s+') for token in tokens) + r')\b'
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class Asn1Lexer(RegexLexer):
|
| 118 |
+
|
| 119 |
+
"""
|
| 120 |
+
Lexer for ASN.1 module definition
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
flags = re.MULTILINE
|
| 124 |
+
|
| 125 |
+
name = 'ASN.1'
|
| 126 |
+
aliases = ['asn1']
|
| 127 |
+
filenames = ["*.asn1"]
|
| 128 |
+
url = "https://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf"
|
| 129 |
+
version_added = '2.16'
|
| 130 |
+
|
| 131 |
+
tokens = {
|
| 132 |
+
'root': [
|
| 133 |
+
# Whitespace:
|
| 134 |
+
(r'\s+', Whitespace),
|
| 135 |
+
# Comments:
|
| 136 |
+
(r'--.*$', Comment.Single),
|
| 137 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 138 |
+
# Numbers:
|
| 139 |
+
(r'\d+\.\d+([eE][-+]?\d+)?', Number.Float),
|
| 140 |
+
(r'\d+', Number.Integer),
|
| 141 |
+
# Identifier:
|
| 142 |
+
(r"&?[a-z][-a-zA-Z0-9]*[a-zA-Z0-9]\b", Name.Variable),
|
| 143 |
+
# Constants:
|
| 144 |
+
(words(("TRUE", "FALSE", "NULL", "MINUS-INFINITY", "PLUS-INFINITY", "MIN", "MAX"), suffix=r'\b'), Keyword.Constant),
|
| 145 |
+
# Builtin types:
|
| 146 |
+
(word_sequences(TWO_WORDS_TYPES), Keyword.Type),
|
| 147 |
+
(words(SINGLE_WORD_TYPES, suffix=r'\b'), Keyword.Type),
|
| 148 |
+
# Other keywords:
|
| 149 |
+
(r"EXPORTS\s+ALL\b", Keyword.Namespace),
|
| 150 |
+
(words(SINGLE_WORD_NAMESPACE_KEYWORDS, suffix=r'\b'), Operator.Namespace),
|
| 151 |
+
(word_sequences(MULTI_WORDS_DECLARATIONS), Keyword.Declaration),
|
| 152 |
+
(words(SINGLE_WORDS_DECLARATIONS, suffix=r'\b'), Keyword.Declaration),
|
| 153 |
+
(words(OPERATOR_WORDS, suffix=r'\b'), Operator.Word),
|
| 154 |
+
(words(SINGLE_WORD_KEYWORDS), Keyword),
|
| 155 |
+
# Type identifier:
|
| 156 |
+
(r"&?[A-Z][-a-zA-Z0-9]*[a-zA-Z0-9]\b", Name.Type),
|
| 157 |
+
# Operators:
|
| 158 |
+
(r"(::=|\.\.\.|\.\.|\[\[|\]\]|\||\^|-)", Operator),
|
| 159 |
+
# Punctuation:
|
| 160 |
+
(r"(\.|,|\{|\}|\(|\)|\[|\])", Punctuation),
|
| 161 |
+
# String:
|
| 162 |
+
(r'"', String, 'string'),
|
| 163 |
+
# Binary string:
|
| 164 |
+
(r"('[01 ]*')(B)\b", bygroups(String, String.Affix)),
|
| 165 |
+
(r"('[0-9A-F ]*')(H)\b",bygroups(String, String.Affix)),
|
| 166 |
+
],
|
| 167 |
+
'comment': [
|
| 168 |
+
(r'[^*/]+', Comment.Multiline),
|
| 169 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 170 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 171 |
+
(r'[*/]', Comment.Multiline)
|
| 172 |
+
],
|
| 173 |
+
'string': [
|
| 174 |
+
(r'""', String),
|
| 175 |
+
(r'"', String, "#pop"),
|
| 176 |
+
(r'[^"]', String),
|
| 177 |
+
]
|
| 178 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bare.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.bare
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the BARE schema.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, bygroups
|
| 12 |
+
from pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace
|
| 13 |
+
|
| 14 |
+
__all__ = ['BareLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class BareLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For BARE schema source.
|
| 20 |
+
"""
|
| 21 |
+
name = 'BARE'
|
| 22 |
+
url = 'https://baremessages.org'
|
| 23 |
+
filenames = ['*.bare']
|
| 24 |
+
aliases = ['bare']
|
| 25 |
+
version_added = '2.7'
|
| 26 |
+
|
| 27 |
+
keywords = [
|
| 28 |
+
'type',
|
| 29 |
+
'enum',
|
| 30 |
+
'u8',
|
| 31 |
+
'u16',
|
| 32 |
+
'u32',
|
| 33 |
+
'u64',
|
| 34 |
+
'uint',
|
| 35 |
+
'i8',
|
| 36 |
+
'i16',
|
| 37 |
+
'i32',
|
| 38 |
+
'i64',
|
| 39 |
+
'int',
|
| 40 |
+
'f32',
|
| 41 |
+
'f64',
|
| 42 |
+
'bool',
|
| 43 |
+
'void',
|
| 44 |
+
'data',
|
| 45 |
+
'string',
|
| 46 |
+
'optional',
|
| 47 |
+
'map',
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
tokens = {
|
| 51 |
+
'root': [
|
| 52 |
+
(r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\{)',
|
| 53 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'struct'),
|
| 54 |
+
(r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\()',
|
| 55 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'union'),
|
| 56 |
+
(r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)',
|
| 57 |
+
bygroups(Keyword, Whitespace, Name, Whitespace), 'typedef'),
|
| 58 |
+
(r'(enum)(\s+)([A-Z][a-zA-Z0-9]+)(\s+\{)',
|
| 59 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'enum'),
|
| 60 |
+
(r'#.*?$', Comment),
|
| 61 |
+
(r'\s+', Whitespace),
|
| 62 |
+
],
|
| 63 |
+
'struct': [
|
| 64 |
+
(r'\{', Text, '#push'),
|
| 65 |
+
(r'\}', Text, '#pop'),
|
| 66 |
+
(r'([a-zA-Z0-9]+)(:)(\s*)',
|
| 67 |
+
bygroups(Name.Attribute, Text, Whitespace), 'typedef'),
|
| 68 |
+
(r'\s+', Whitespace),
|
| 69 |
+
],
|
| 70 |
+
'union': [
|
| 71 |
+
(r'\)', Text, '#pop'),
|
| 72 |
+
(r'(\s*)(\|)(\s*)', bygroups(Whitespace, Text, Whitespace)),
|
| 73 |
+
(r'[A-Z][a-zA-Z0-9]+', Name.Class),
|
| 74 |
+
(words(keywords), Keyword),
|
| 75 |
+
(r'\s+', Whitespace),
|
| 76 |
+
],
|
| 77 |
+
'typedef': [
|
| 78 |
+
(r'\[\]', Text),
|
| 79 |
+
(r'#.*?$', Comment, '#pop'),
|
| 80 |
+
(r'(\[)(\d+)(\])', bygroups(Text, Literal, Text)),
|
| 81 |
+
(r'<|>', Text),
|
| 82 |
+
(r'\(', Text, 'union'),
|
| 83 |
+
(r'(\[)([a-z][a-z-A-Z0-9]+)(\])', bygroups(Text, Keyword, Text)),
|
| 84 |
+
(r'(\[)([A-Z][a-z-A-Z0-9]+)(\])', bygroups(Text, Name.Class, Text)),
|
| 85 |
+
(r'([A-Z][a-z-A-Z0-9]+)', Name.Class),
|
| 86 |
+
(words(keywords), Keyword),
|
| 87 |
+
(r'\n', Text, '#pop'),
|
| 88 |
+
(r'\{', Text, 'struct'),
|
| 89 |
+
(r'\s+', Whitespace),
|
| 90 |
+
(r'\d+', Literal),
|
| 91 |
+
],
|
| 92 |
+
'enum': [
|
| 93 |
+
(r'\{', Text, '#push'),
|
| 94 |
+
(r'\}', Text, '#pop'),
|
| 95 |
+
(r'([A-Z][A-Z0-9_]*)(\s*=\s*)(\d+)',
|
| 96 |
+
bygroups(Name.Attribute, Text, Literal)),
|
| 97 |
+
(r'([A-Z][A-Z0-9_]*)', bygroups(Name.Attribute)),
|
| 98 |
+
(r'#.*?$', Comment),
|
| 99 |
+
(r'\s+', Whitespace),
|
| 100 |
+
],
|
| 101 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/basic.py
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.basic
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for BASIC like languages (other than VB.net).
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, default, words, include
|
| 14 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, \
|
| 15 |
+
Punctuation, Operator, String, Text, Whitespace
|
| 16 |
+
from pygments.lexers import _vbscript_builtins
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
__all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer',
|
| 20 |
+
'QBasicLexer', 'VBScriptLexer', 'BBCBasicLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class BlitzMaxLexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
For BlitzMax source code.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
name = 'BlitzMax'
|
| 29 |
+
url = 'http://blitzbasic.com'
|
| 30 |
+
aliases = ['blitzmax', 'bmax']
|
| 31 |
+
filenames = ['*.bmx']
|
| 32 |
+
mimetypes = ['text/x-bmx']
|
| 33 |
+
version_added = '1.4'
|
| 34 |
+
|
| 35 |
+
bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b'
|
| 36 |
+
bmax_sktypes = r'@{1,2}|[!#$%]'
|
| 37 |
+
bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
|
| 38 |
+
bmax_name = r'[a-z_]\w*'
|
| 39 |
+
bmax_var = (rf'({bmax_name})(?:(?:([ \t]*)({bmax_sktypes})|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
|
| 40 |
+
rf'|([ \t]*)(:)([ \t]*)(?:{bmax_lktypes}|({bmax_name})))(?:([ \t]*)(Ptr))?)')
|
| 41 |
+
bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
|
| 42 |
+
|
| 43 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 44 |
+
tokens = {
|
| 45 |
+
'root': [
|
| 46 |
+
# Text
|
| 47 |
+
(r'\s+', Whitespace),
|
| 48 |
+
(r'(\.\.)(\n)', bygroups(Text, Whitespace)), # Line continuation
|
| 49 |
+
# Comments
|
| 50 |
+
(r"'.*?\n", Comment.Single),
|
| 51 |
+
(r'([ \t]*)\bRem\n(\n|.)*?\s*\bEnd([ \t]*)Rem', Comment.Multiline),
|
| 52 |
+
# Data types
|
| 53 |
+
('"', String.Double, 'string'),
|
| 54 |
+
# Numbers
|
| 55 |
+
(r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
|
| 56 |
+
(r'\.[0-9]*(?!\.)', Number.Float),
|
| 57 |
+
(r'[0-9]+', Number.Integer),
|
| 58 |
+
(r'\$[0-9a-f]+', Number.Hex),
|
| 59 |
+
(r'\%[10]+', Number.Bin),
|
| 60 |
+
# Other
|
| 61 |
+
(rf'(?:(?:(:)?([ \t]*)(:?{bmax_vopwords}|([+\-*/&|~]))|Or|And|Not|[=<>^]))', Operator),
|
| 62 |
+
(r'[(),.:\[\]]', Punctuation),
|
| 63 |
+
(r'(?:#[\w \t]*)', Name.Label),
|
| 64 |
+
(r'(?:\?[\w \t]*)', Comment.Preproc),
|
| 65 |
+
# Identifiers
|
| 66 |
+
(rf'\b(New)\b([ \t]?)([(]?)({bmax_name})',
|
| 67 |
+
bygroups(Keyword.Reserved, Whitespace, Punctuation, Name.Class)),
|
| 68 |
+
(rf'\b(Import|Framework|Module)([ \t]+)({bmax_name}\.{bmax_name})',
|
| 69 |
+
bygroups(Keyword.Reserved, Whitespace, Keyword.Namespace)),
|
| 70 |
+
(bmax_func, bygroups(Name.Function, Whitespace, Keyword.Type,
|
| 71 |
+
Operator, Whitespace, Punctuation, Whitespace,
|
| 72 |
+
Keyword.Type, Name.Class, Whitespace,
|
| 73 |
+
Keyword.Type, Whitespace, Punctuation)),
|
| 74 |
+
(bmax_var, bygroups(Name.Variable, Whitespace, Keyword.Type, Operator,
|
| 75 |
+
Whitespace, Punctuation, Whitespace, Keyword.Type,
|
| 76 |
+
Name.Class, Whitespace, Keyword.Type)),
|
| 77 |
+
(rf'\b(Type|Extends)([ \t]+)({bmax_name})',
|
| 78 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Class)),
|
| 79 |
+
# Keywords
|
| 80 |
+
(r'\b(Ptr)\b', Keyword.Type),
|
| 81 |
+
(r'\b(Pi|True|False|Null|Self|Super)\b', Keyword.Constant),
|
| 82 |
+
(r'\b(Local|Global|Const|Field)\b', Keyword.Declaration),
|
| 83 |
+
(words((
|
| 84 |
+
'TNullMethodException', 'TNullFunctionException',
|
| 85 |
+
'TNullObjectException', 'TArrayBoundsException',
|
| 86 |
+
'TRuntimeException'), prefix=r'\b', suffix=r'\b'), Name.Exception),
|
| 87 |
+
(words((
|
| 88 |
+
'Strict', 'SuperStrict', 'Module', 'ModuleInfo',
|
| 89 |
+
'End', 'Return', 'Continue', 'Exit', 'Public', 'Private',
|
| 90 |
+
'Var', 'VarPtr', 'Chr', 'Len', 'Asc', 'SizeOf', 'Sgn', 'Abs', 'Min', 'Max',
|
| 91 |
+
'New', 'Release', 'Delete', 'Incbin', 'IncbinPtr', 'IncbinLen',
|
| 92 |
+
'Framework', 'Include', 'Import', 'Extern', 'EndExtern',
|
| 93 |
+
'Function', 'EndFunction', 'Type', 'EndType', 'Extends', 'Method', 'EndMethod',
|
| 94 |
+
'Abstract', 'Final', 'If', 'Then', 'Else', 'ElseIf', 'EndIf',
|
| 95 |
+
'For', 'To', 'Next', 'Step', 'EachIn', 'While', 'Wend', 'EndWhile',
|
| 96 |
+
'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', 'EndSelect',
|
| 97 |
+
'Try', 'Catch', 'EndTry', 'Throw', 'Assert', 'Goto', 'DefData', 'ReadData',
|
| 98 |
+
'RestoreData'), prefix=r'\b', suffix=r'\b'),
|
| 99 |
+
Keyword.Reserved),
|
| 100 |
+
# Final resolve (for variable names and such)
|
| 101 |
+
(rf'({bmax_name})', Name.Variable),
|
| 102 |
+
],
|
| 103 |
+
'string': [
|
| 104 |
+
(r'""', String.Double),
|
| 105 |
+
(r'"C?', String.Double, '#pop'),
|
| 106 |
+
(r'[^"]+', String.Double),
|
| 107 |
+
],
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class BlitzBasicLexer(RegexLexer):
|
| 112 |
+
"""
|
| 113 |
+
For BlitzBasic source code.
|
| 114 |
+
"""
|
| 115 |
+
|
| 116 |
+
name = 'BlitzBasic'
|
| 117 |
+
url = 'http://blitzbasic.com'
|
| 118 |
+
aliases = ['blitzbasic', 'b3d', 'bplus']
|
| 119 |
+
filenames = ['*.bb', '*.decls']
|
| 120 |
+
mimetypes = ['text/x-bb']
|
| 121 |
+
version_added = '2.0'
|
| 122 |
+
|
| 123 |
+
bb_sktypes = r'@{1,2}|[#$%]'
|
| 124 |
+
bb_name = r'[a-z]\w*'
|
| 125 |
+
bb_var = (rf'({bb_name})(?:([ \t]*)({bb_sktypes})|([ \t]*)([.])([ \t]*)(?:({bb_name})))?')
|
| 126 |
+
|
| 127 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 128 |
+
tokens = {
|
| 129 |
+
'root': [
|
| 130 |
+
# Text
|
| 131 |
+
(r'\s+', Whitespace),
|
| 132 |
+
# Comments
|
| 133 |
+
(r";.*?\n", Comment.Single),
|
| 134 |
+
# Data types
|
| 135 |
+
('"', String.Double, 'string'),
|
| 136 |
+
# Numbers
|
| 137 |
+
(r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
|
| 138 |
+
(r'\.[0-9]+(?!\.)', Number.Float),
|
| 139 |
+
(r'[0-9]+', Number.Integer),
|
| 140 |
+
(r'\$[0-9a-f]+', Number.Hex),
|
| 141 |
+
(r'\%[10]+', Number.Bin),
|
| 142 |
+
# Other
|
| 143 |
+
(words(('Shl', 'Shr', 'Sar', 'Mod', 'Or', 'And', 'Not',
|
| 144 |
+
'Abs', 'Sgn', 'Handle', 'Int', 'Float', 'Str',
|
| 145 |
+
'First', 'Last', 'Before', 'After'),
|
| 146 |
+
prefix=r'\b', suffix=r'\b'),
|
| 147 |
+
Operator),
|
| 148 |
+
(r'([+\-*/~=<>^])', Operator),
|
| 149 |
+
(r'[(),:\[\]\\]', Punctuation),
|
| 150 |
+
(rf'\.([ \t]*)({bb_name})', Name.Label),
|
| 151 |
+
# Identifiers
|
| 152 |
+
(rf'\b(New)\b([ \t]+)({bb_name})',
|
| 153 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Class)),
|
| 154 |
+
(rf'\b(Gosub|Goto)\b([ \t]+)({bb_name})',
|
| 155 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Label)),
|
| 156 |
+
(rf'\b(Object)\b([ \t]*)([.])([ \t]*)({bb_name})\b',
|
| 157 |
+
bygroups(Operator, Whitespace, Punctuation, Whitespace, Name.Class)),
|
| 158 |
+
(rf'\b{bb_var}\b([ \t]*)(\()',
|
| 159 |
+
bygroups(Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation,
|
| 160 |
+
Whitespace, Name.Class, Whitespace, Punctuation)),
|
| 161 |
+
(rf'\b(Function)\b([ \t]+){bb_var}',
|
| 162 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Function, Whitespace, Keyword.Type,
|
| 163 |
+
Whitespace, Punctuation, Whitespace, Name.Class)),
|
| 164 |
+
(rf'\b(Type)([ \t]+)({bb_name})',
|
| 165 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Class)),
|
| 166 |
+
# Keywords
|
| 167 |
+
(r'\b(Pi|True|False|Null)\b', Keyword.Constant),
|
| 168 |
+
(r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration),
|
| 169 |
+
(words((
|
| 170 |
+
'End', 'Return', 'Exit', 'Chr', 'Len', 'Asc', 'New', 'Delete', 'Insert',
|
| 171 |
+
'Include', 'Function', 'Type', 'If', 'Then', 'Else', 'ElseIf', 'EndIf',
|
| 172 |
+
'For', 'To', 'Next', 'Step', 'Each', 'While', 'Wend',
|
| 173 |
+
'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default',
|
| 174 |
+
'Goto', 'Gosub', 'Data', 'Read', 'Restore'), prefix=r'\b', suffix=r'\b'),
|
| 175 |
+
Keyword.Reserved),
|
| 176 |
+
# Final resolve (for variable names and such)
|
| 177 |
+
# (r'(%s)' % (bb_name), Name.Variable),
|
| 178 |
+
(bb_var, bygroups(Name.Variable, Whitespace, Keyword.Type,
|
| 179 |
+
Whitespace, Punctuation, Whitespace, Name.Class)),
|
| 180 |
+
],
|
| 181 |
+
'string': [
|
| 182 |
+
(r'""', String.Double),
|
| 183 |
+
(r'"C?', String.Double, '#pop'),
|
| 184 |
+
(r'[^"\n]+', String.Double),
|
| 185 |
+
],
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
class MonkeyLexer(RegexLexer):
|
| 190 |
+
"""
|
| 191 |
+
For Monkey source code.
|
| 192 |
+
"""
|
| 193 |
+
|
| 194 |
+
name = 'Monkey'
|
| 195 |
+
aliases = ['monkey']
|
| 196 |
+
filenames = ['*.monkey']
|
| 197 |
+
mimetypes = ['text/x-monkey']
|
| 198 |
+
url = 'https://blitzresearch.itch.io/monkeyx'
|
| 199 |
+
version_added = '1.6'
|
| 200 |
+
|
| 201 |
+
name_variable = r'[a-z_]\w*'
|
| 202 |
+
name_function = r'[A-Z]\w*'
|
| 203 |
+
name_constant = r'[A-Z_][A-Z0-9_]*'
|
| 204 |
+
name_class = r'[A-Z]\w*'
|
| 205 |
+
name_module = r'[a-z0-9_]*'
|
| 206 |
+
|
| 207 |
+
keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
|
| 208 |
+
# ? == Bool // % == Int // # == Float // $ == String
|
| 209 |
+
keyword_type_special = r'[?%#$]'
|
| 210 |
+
|
| 211 |
+
flags = re.MULTILINE
|
| 212 |
+
|
| 213 |
+
tokens = {
|
| 214 |
+
'root': [
|
| 215 |
+
# Text
|
| 216 |
+
(r'\s+', Whitespace),
|
| 217 |
+
# Comments
|
| 218 |
+
(r"'.*", Comment),
|
| 219 |
+
(r'(?i)^#rem\b', Comment.Multiline, 'comment'),
|
| 220 |
+
# preprocessor directives
|
| 221 |
+
(r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc),
|
| 222 |
+
# preprocessor variable (any line starting with '#' that is not a directive)
|
| 223 |
+
(r'^#', Comment.Preproc, 'variables'),
|
| 224 |
+
# String
|
| 225 |
+
('"', String.Double, 'string'),
|
| 226 |
+
# Numbers
|
| 227 |
+
(r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
|
| 228 |
+
(r'\.[0-9]+(?!\.)', Number.Float),
|
| 229 |
+
(r'[0-9]+', Number.Integer),
|
| 230 |
+
(r'\$[0-9a-fA-Z]+', Number.Hex),
|
| 231 |
+
(r'\%[10]+', Number.Bin),
|
| 232 |
+
# Native data types
|
| 233 |
+
(rf'\b{keyword_type}\b', Keyword.Type),
|
| 234 |
+
# Exception handling
|
| 235 |
+
(r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved),
|
| 236 |
+
(r'Throwable', Name.Exception),
|
| 237 |
+
# Builtins
|
| 238 |
+
(r'(?i)\b(?:Null|True|False)\b', Name.Builtin),
|
| 239 |
+
(r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
|
| 240 |
+
(r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
|
| 241 |
+
# Keywords
|
| 242 |
+
(r'(?i)^(Import)(\s+)(.*)(\n)',
|
| 243 |
+
bygroups(Keyword.Namespace, Whitespace, Name.Namespace, Whitespace)),
|
| 244 |
+
(r'(?i)^Strict\b.*\n', Keyword.Reserved),
|
| 245 |
+
(r'(?i)(Const|Local|Global|Field)(\s+)',
|
| 246 |
+
bygroups(Keyword.Declaration, Whitespace), 'variables'),
|
| 247 |
+
(r'(?i)(New|Class|Interface|Extends|Implements)(\s+)',
|
| 248 |
+
bygroups(Keyword.Reserved, Whitespace), 'classname'),
|
| 249 |
+
(r'(?i)(Function|Method)(\s+)',
|
| 250 |
+
bygroups(Keyword.Reserved, Whitespace), 'funcname'),
|
| 251 |
+
(r'(?i)(?:End|Return|Public|Private|Extern|Property|'
|
| 252 |
+
r'Final|Abstract)\b', Keyword.Reserved),
|
| 253 |
+
# Flow Control stuff
|
| 254 |
+
(r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
|
| 255 |
+
r'Select|Case|Default|'
|
| 256 |
+
r'While|Wend|'
|
| 257 |
+
r'Repeat|Until|Forever|'
|
| 258 |
+
r'For|To|Until|Step|EachIn|Next|'
|
| 259 |
+
r'Exit|Continue)(?=\s)', Keyword.Reserved),
|
| 260 |
+
# not used yet
|
| 261 |
+
(r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
|
| 262 |
+
# Array
|
| 263 |
+
(r'[\[\]]', Punctuation),
|
| 264 |
+
# Other
|
| 265 |
+
(r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator),
|
| 266 |
+
(r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word),
|
| 267 |
+
(r'[(){}!#,.:]', Punctuation),
|
| 268 |
+
# catch the rest
|
| 269 |
+
(rf'{name_constant}\b', Name.Constant),
|
| 270 |
+
(rf'{name_function}\b', Name.Function),
|
| 271 |
+
(rf'{name_variable}\b', Name.Variable),
|
| 272 |
+
],
|
| 273 |
+
'funcname': [
|
| 274 |
+
(rf'(?i){name_function}\b', Name.Function),
|
| 275 |
+
(r':', Punctuation, 'classname'),
|
| 276 |
+
(r'\s+', Whitespace),
|
| 277 |
+
(r'\(', Punctuation, 'variables'),
|
| 278 |
+
(r'\)', Punctuation, '#pop')
|
| 279 |
+
],
|
| 280 |
+
'classname': [
|
| 281 |
+
(rf'{name_module}\.', Name.Namespace),
|
| 282 |
+
(rf'{keyword_type}\b', Keyword.Type),
|
| 283 |
+
(rf'{name_class}\b', Name.Class),
|
| 284 |
+
# array (of given size)
|
| 285 |
+
(r'(\[)(\s*)(\d*)(\s*)(\])',
|
| 286 |
+
bygroups(Punctuation, Whitespace, Number.Integer, Whitespace, Punctuation)),
|
| 287 |
+
# generics
|
| 288 |
+
(r'\s+(?!<)', Whitespace, '#pop'),
|
| 289 |
+
(r'<', Punctuation, '#push'),
|
| 290 |
+
(r'>', Punctuation, '#pop'),
|
| 291 |
+
(r'\n', Whitespace, '#pop'),
|
| 292 |
+
default('#pop')
|
| 293 |
+
],
|
| 294 |
+
'variables': [
|
| 295 |
+
(rf'{name_constant}\b', Name.Constant),
|
| 296 |
+
(rf'{name_variable}\b', Name.Variable),
|
| 297 |
+
(rf'{keyword_type_special}', Keyword.Type),
|
| 298 |
+
(r'\s+', Whitespace),
|
| 299 |
+
(r':', Punctuation, 'classname'),
|
| 300 |
+
(r',', Punctuation, '#push'),
|
| 301 |
+
default('#pop')
|
| 302 |
+
],
|
| 303 |
+
'string': [
|
| 304 |
+
(r'[^"~]+', String.Double),
|
| 305 |
+
(r'~q|~n|~r|~t|~z|~~', String.Escape),
|
| 306 |
+
(r'"', String.Double, '#pop'),
|
| 307 |
+
],
|
| 308 |
+
'comment': [
|
| 309 |
+
(r'(?i)^#rem.*?', Comment.Multiline, "#push"),
|
| 310 |
+
(r'(?i)^#end.*?', Comment.Multiline, "#pop"),
|
| 311 |
+
(r'\n', Comment.Multiline),
|
| 312 |
+
(r'.+', Comment.Multiline),
|
| 313 |
+
],
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
class CbmBasicV2Lexer(RegexLexer):
|
| 318 |
+
"""
|
| 319 |
+
For CBM BASIC V2 sources.
|
| 320 |
+
"""
|
| 321 |
+
name = 'CBM BASIC V2'
|
| 322 |
+
aliases = ['cbmbas']
|
| 323 |
+
filenames = ['*.bas']
|
| 324 |
+
url = 'https://en.wikipedia.org/wiki/Commodore_BASIC'
|
| 325 |
+
version_added = '1.6'
|
| 326 |
+
|
| 327 |
+
flags = re.IGNORECASE
|
| 328 |
+
|
| 329 |
+
tokens = {
|
| 330 |
+
'root': [
|
| 331 |
+
(r'rem.*\n', Comment.Single),
|
| 332 |
+
(r'\s+', Whitespace),
|
| 333 |
+
(r'new|run|end|for|to|next|step|go(to|sub)?|on|return|stop|cont'
|
| 334 |
+
r'|if|then|input#?|read|wait|load|save|verify|poke|sys|print#?'
|
| 335 |
+
r'|list|clr|cmd|open|close|get#?', Keyword.Reserved),
|
| 336 |
+
(r'data|restore|dim|let|def|fn', Keyword.Declaration),
|
| 337 |
+
(r'tab|spc|sgn|int|abs|usr|fre|pos|sqr|rnd|log|exp|cos|sin|tan|atn'
|
| 338 |
+
r'|peek|len|val|asc|(str|chr|left|right|mid)\$', Name.Builtin),
|
| 339 |
+
(r'[-+*/^<>=]', Operator),
|
| 340 |
+
(r'not|and|or', Operator.Word),
|
| 341 |
+
(r'"[^"\n]*.', String),
|
| 342 |
+
(r'\d+|[-+]?\d*\.\d*(e[-+]?\d+)?', Number.Float),
|
| 343 |
+
(r'[(),:;]', Punctuation),
|
| 344 |
+
(r'\w+[$%]?', Name),
|
| 345 |
+
]
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
def analyse_text(text):
|
| 349 |
+
# if it starts with a line number, it shouldn't be a "modern" Basic
|
| 350 |
+
# like VB.net
|
| 351 |
+
if re.match(r'^\d+', text):
|
| 352 |
+
return 0.2
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
class QBasicLexer(RegexLexer):
|
| 356 |
+
"""
|
| 357 |
+
For QBasic source code.
|
| 358 |
+
"""
|
| 359 |
+
|
| 360 |
+
name = 'QBasic'
|
| 361 |
+
aliases = ['qbasic', 'basic']
|
| 362 |
+
filenames = ['*.BAS', '*.bas']
|
| 363 |
+
mimetypes = ['text/basic']
|
| 364 |
+
url = 'https://en.wikipedia.org/wiki/QBasic'
|
| 365 |
+
version_added = '2.0'
|
| 366 |
+
|
| 367 |
+
declarations = ('DATA', 'LET')
|
| 368 |
+
|
| 369 |
+
functions = (
|
| 370 |
+
'ABS', 'ASC', 'ATN', 'CDBL', 'CHR$', 'CINT', 'CLNG',
|
| 371 |
+
'COMMAND$', 'COS', 'CSNG', 'CSRLIN', 'CVD', 'CVDMBF', 'CVI',
|
| 372 |
+
'CVL', 'CVS', 'CVSMBF', 'DATE$', 'ENVIRON$', 'EOF', 'ERDEV',
|
| 373 |
+
'ERDEV$', 'ERL', 'ERR', 'EXP', 'FILEATTR', 'FIX', 'FRE',
|
| 374 |
+
'FREEFILE', 'HEX$', 'INKEY$', 'INP', 'INPUT$', 'INSTR', 'INT',
|
| 375 |
+
'IOCTL$', 'LBOUND', 'LCASE$', 'LEFT$', 'LEN', 'LOC', 'LOF',
|
| 376 |
+
'LOG', 'LPOS', 'LTRIM$', 'MID$', 'MKD$', 'MKDMBF$', 'MKI$',
|
| 377 |
+
'MKL$', 'MKS$', 'MKSMBF$', 'OCT$', 'PEEK', 'PEN', 'PLAY',
|
| 378 |
+
'PMAP', 'POINT', 'POS', 'RIGHT$', 'RND', 'RTRIM$', 'SADD',
|
| 379 |
+
'SCREEN', 'SEEK', 'SETMEM', 'SGN', 'SIN', 'SPACE$', 'SPC',
|
| 380 |
+
'SQR', 'STICK', 'STR$', 'STRIG', 'STRING$', 'TAB', 'TAN',
|
| 381 |
+
'TIME$', 'TIMER', 'UBOUND', 'UCASE$', 'VAL', 'VARPTR',
|
| 382 |
+
'VARPTR$', 'VARSEG'
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
metacommands = ('$DYNAMIC', '$INCLUDE', '$STATIC')
|
| 386 |
+
|
| 387 |
+
operators = ('AND', 'EQV', 'IMP', 'NOT', 'OR', 'XOR')
|
| 388 |
+
|
| 389 |
+
statements = (
|
| 390 |
+
'BEEP', 'BLOAD', 'BSAVE', 'CALL', 'CALL ABSOLUTE',
|
| 391 |
+
'CALL INTERRUPT', 'CALLS', 'CHAIN', 'CHDIR', 'CIRCLE', 'CLEAR',
|
| 392 |
+
'CLOSE', 'CLS', 'COLOR', 'COM', 'COMMON', 'CONST', 'DATA',
|
| 393 |
+
'DATE$', 'DECLARE', 'DEF FN', 'DEF SEG', 'DEFDBL', 'DEFINT',
|
| 394 |
+
'DEFLNG', 'DEFSNG', 'DEFSTR', 'DEF', 'DIM', 'DO', 'LOOP',
|
| 395 |
+
'DRAW', 'END', 'ENVIRON', 'ERASE', 'ERROR', 'EXIT', 'FIELD',
|
| 396 |
+
'FILES', 'FOR', 'NEXT', 'FUNCTION', 'GET', 'GOSUB', 'GOTO',
|
| 397 |
+
'IF', 'THEN', 'INPUT', 'INPUT #', 'IOCTL', 'KEY', 'KEY',
|
| 398 |
+
'KILL', 'LET', 'LINE', 'LINE INPUT', 'LINE INPUT #', 'LOCATE',
|
| 399 |
+
'LOCK', 'UNLOCK', 'LPRINT', 'LSET', 'MID$', 'MKDIR', 'NAME',
|
| 400 |
+
'ON COM', 'ON ERROR', 'ON KEY', 'ON PEN', 'ON PLAY',
|
| 401 |
+
'ON STRIG', 'ON TIMER', 'ON UEVENT', 'ON', 'OPEN', 'OPEN COM',
|
| 402 |
+
'OPTION BASE', 'OUT', 'PAINT', 'PALETTE', 'PCOPY', 'PEN',
|
| 403 |
+
'PLAY', 'POKE', 'PRESET', 'PRINT', 'PRINT #', 'PRINT USING',
|
| 404 |
+
'PSET', 'PUT', 'PUT', 'RANDOMIZE', 'READ', 'REDIM', 'REM',
|
| 405 |
+
'RESET', 'RESTORE', 'RESUME', 'RETURN', 'RMDIR', 'RSET', 'RUN',
|
| 406 |
+
'SCREEN', 'SEEK', 'SELECT CASE', 'SHARED', 'SHELL', 'SLEEP',
|
| 407 |
+
'SOUND', 'STATIC', 'STOP', 'STRIG', 'SUB', 'SWAP', 'SYSTEM',
|
| 408 |
+
'TIME$', 'TIMER', 'TROFF', 'TRON', 'TYPE', 'UEVENT', 'UNLOCK',
|
| 409 |
+
'VIEW', 'WAIT', 'WHILE', 'WEND', 'WIDTH', 'WINDOW', 'WRITE'
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
keywords = (
|
| 413 |
+
'ACCESS', 'ALIAS', 'ANY', 'APPEND', 'AS', 'BASE', 'BINARY',
|
| 414 |
+
'BYVAL', 'CASE', 'CDECL', 'DOUBLE', 'ELSE', 'ELSEIF', 'ENDIF',
|
| 415 |
+
'INTEGER', 'IS', 'LIST', 'LOCAL', 'LONG', 'LOOP', 'MOD',
|
| 416 |
+
'NEXT', 'OFF', 'ON', 'OUTPUT', 'RANDOM', 'SIGNAL', 'SINGLE',
|
| 417 |
+
'STEP', 'STRING', 'THEN', 'TO', 'UNTIL', 'USING', 'WEND'
|
| 418 |
+
)
|
| 419 |
+
|
| 420 |
+
tokens = {
|
| 421 |
+
'root': [
|
| 422 |
+
(r'\n+', Text),
|
| 423 |
+
(r'\s+', Text.Whitespace),
|
| 424 |
+
(r'^(\s*)(\d*)(\s*)(REM .*)$',
|
| 425 |
+
bygroups(Text.Whitespace, Name.Label, Text.Whitespace,
|
| 426 |
+
Comment.Single)),
|
| 427 |
+
(r'^(\s*)(\d+)(\s*)',
|
| 428 |
+
bygroups(Text.Whitespace, Name.Label, Text.Whitespace)),
|
| 429 |
+
(r'(?=[\s]*)(\w+)(?=[\s]*=)', Name.Variable.Global),
|
| 430 |
+
(r'(?=[^"]*)\'.*$', Comment.Single),
|
| 431 |
+
(r'"[^\n"]*"', String.Double),
|
| 432 |
+
(r'(END)(\s+)(FUNCTION|IF|SELECT|SUB)',
|
| 433 |
+
bygroups(Keyword.Reserved, Text.Whitespace, Keyword.Reserved)),
|
| 434 |
+
(r'(DECLARE)(\s+)([A-Z]+)(\s+)(\S+)',
|
| 435 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable,
|
| 436 |
+
Text.Whitespace, Name)),
|
| 437 |
+
(r'(DIM)(\s+)(SHARED)(\s+)([^\s(]+)',
|
| 438 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable,
|
| 439 |
+
Text.Whitespace, Name.Variable.Global)),
|
| 440 |
+
(r'(DIM)(\s+)([^\s(]+)',
|
| 441 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable.Global)),
|
| 442 |
+
(r'^(\s*)([a-zA-Z_]+)(\s*)(\=)',
|
| 443 |
+
bygroups(Text.Whitespace, Name.Variable.Global, Text.Whitespace,
|
| 444 |
+
Operator)),
|
| 445 |
+
(r'(GOTO|GOSUB)(\s+)(\w+\:?)',
|
| 446 |
+
bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)),
|
| 447 |
+
(r'(SUB)(\s+)(\w+\:?)',
|
| 448 |
+
bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)),
|
| 449 |
+
include('declarations'),
|
| 450 |
+
include('functions'),
|
| 451 |
+
include('metacommands'),
|
| 452 |
+
include('operators'),
|
| 453 |
+
include('statements'),
|
| 454 |
+
include('keywords'),
|
| 455 |
+
(r'[a-zA-Z_]\w*[$@#&!]', Name.Variable.Global),
|
| 456 |
+
(r'[a-zA-Z_]\w*\:', Name.Label),
|
| 457 |
+
(r'\-?\d*\.\d+[@|#]?', Number.Float),
|
| 458 |
+
(r'\-?\d+[@|#]', Number.Float),
|
| 459 |
+
(r'\-?\d+#?', Number.Integer.Long),
|
| 460 |
+
(r'\-?\d+#?', Number.Integer),
|
| 461 |
+
(r'!=|==|:=|\.=|<<|>>|[-~+/\\*%=<>&^|?:!.]', Operator),
|
| 462 |
+
(r'[\[\]{}(),;]', Punctuation),
|
| 463 |
+
(r'[\w]+', Name.Variable.Global),
|
| 464 |
+
],
|
| 465 |
+
# can't use regular \b because of X$()
|
| 466 |
+
# XXX: use words() here
|
| 467 |
+
'declarations': [
|
| 468 |
+
(r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, declarations))),
|
| 469 |
+
Keyword.Declaration),
|
| 470 |
+
],
|
| 471 |
+
'functions': [
|
| 472 |
+
(r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, functions))),
|
| 473 |
+
Keyword.Reserved),
|
| 474 |
+
],
|
| 475 |
+
'metacommands': [
|
| 476 |
+
(r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, metacommands))),
|
| 477 |
+
Keyword.Constant),
|
| 478 |
+
],
|
| 479 |
+
'operators': [
|
| 480 |
+
(r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, operators))), Operator.Word),
|
| 481 |
+
],
|
| 482 |
+
'statements': [
|
| 483 |
+
(r'\b({})\b'.format('|'.join(map(re.escape, statements))),
|
| 484 |
+
Keyword.Reserved),
|
| 485 |
+
],
|
| 486 |
+
'keywords': [
|
| 487 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 488 |
+
],
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
def analyse_text(text):
|
| 492 |
+
if '$DYNAMIC' in text or '$STATIC' in text:
|
| 493 |
+
return 0.9
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
class VBScriptLexer(RegexLexer):
|
| 497 |
+
"""
|
| 498 |
+
VBScript is scripting language that is modeled on Visual Basic.
|
| 499 |
+
"""
|
| 500 |
+
name = 'VBScript'
|
| 501 |
+
aliases = ['vbscript']
|
| 502 |
+
filenames = ['*.vbs', '*.VBS']
|
| 503 |
+
url = 'https://learn.microsoft.com/en-us/previous-versions/t0aew7h6(v=vs.85)'
|
| 504 |
+
version_added = '2.4'
|
| 505 |
+
|
| 506 |
+
flags = re.IGNORECASE
|
| 507 |
+
|
| 508 |
+
tokens = {
|
| 509 |
+
'root': [
|
| 510 |
+
(r"'[^\n]*", Comment.Single),
|
| 511 |
+
(r'\s+', Whitespace),
|
| 512 |
+
('"', String.Double, 'string'),
|
| 513 |
+
('&h[0-9a-f]+', Number.Hex),
|
| 514 |
+
# Float variant 1, for example: 1., 1.e2, 1.2e3
|
| 515 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float),
|
| 516 |
+
(r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Float variant 2, for example: .1, .1e2
|
| 517 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float), # Float variant 3, for example: 123e45
|
| 518 |
+
(r'[0-9]+', Number.Integer),
|
| 519 |
+
('#.+#', String), # date or time value
|
| 520 |
+
(r'(dim)(\s+)([a-z_][a-z0-9_]*)',
|
| 521 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Variable), 'dim_more'),
|
| 522 |
+
(r'(function|sub)(\s+)([a-z_][a-z0-9_]*)',
|
| 523 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Function)),
|
| 524 |
+
(r'(class)(\s+)([a-z_][a-z0-9_]*)',
|
| 525 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class)),
|
| 526 |
+
(r'(const)(\s+)([a-z_][a-z0-9_]*)',
|
| 527 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Constant)),
|
| 528 |
+
(r'(end)(\s+)(class|function|if|property|sub|with)',
|
| 529 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 530 |
+
(r'(on)(\s+)(error)(\s+)(goto)(\s+)(0)',
|
| 531 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Number.Integer)),
|
| 532 |
+
(r'(on)(\s+)(error)(\s+)(resume)(\s+)(next)',
|
| 533 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Keyword)),
|
| 534 |
+
(r'(option)(\s+)(explicit)', bygroups(Keyword, Whitespace, Keyword)),
|
| 535 |
+
(r'(property)(\s+)(get|let|set)(\s+)([a-z_][a-z0-9_]*)',
|
| 536 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Property)),
|
| 537 |
+
(r'rem\s.*[^\n]*', Comment.Single),
|
| 538 |
+
(words(_vbscript_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 539 |
+
(words(_vbscript_builtins.OPERATORS), Operator),
|
| 540 |
+
(words(_vbscript_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word),
|
| 541 |
+
(words(_vbscript_builtins.BUILTIN_CONSTANTS, suffix=r'\b'), Name.Constant),
|
| 542 |
+
(words(_vbscript_builtins.BUILTIN_FUNCTIONS, suffix=r'\b'), Name.Builtin),
|
| 543 |
+
(words(_vbscript_builtins.BUILTIN_VARIABLES, suffix=r'\b'), Name.Builtin),
|
| 544 |
+
(r'[a-z_][a-z0-9_]*', Name),
|
| 545 |
+
(r'\b_\n', Operator),
|
| 546 |
+
(words(r'(),.:'), Punctuation),
|
| 547 |
+
(r'.+(\n)?', Error)
|
| 548 |
+
],
|
| 549 |
+
'dim_more': [
|
| 550 |
+
(r'(\s*)(,)(\s*)([a-z_][a-z0-9]*)',
|
| 551 |
+
bygroups(Whitespace, Punctuation, Whitespace, Name.Variable)),
|
| 552 |
+
default('#pop'),
|
| 553 |
+
],
|
| 554 |
+
'string': [
|
| 555 |
+
(r'[^"\n]+', String.Double),
|
| 556 |
+
(r'\"\"', String.Double),
|
| 557 |
+
(r'"', String.Double, '#pop'),
|
| 558 |
+
(r'\n', Error, '#pop'), # Unterminated string
|
| 559 |
+
],
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
class BBCBasicLexer(RegexLexer):
|
| 564 |
+
"""
|
| 565 |
+
BBC Basic was supplied on the BBC Micro, and later Acorn RISC OS.
|
| 566 |
+
It is also used by BBC Basic For Windows.
|
| 567 |
+
"""
|
| 568 |
+
base_keywords = ['OTHERWISE', 'AND', 'DIV', 'EOR', 'MOD', 'OR', 'ERROR',
|
| 569 |
+
'LINE', 'OFF', 'STEP', 'SPC', 'TAB', 'ELSE', 'THEN',
|
| 570 |
+
'OPENIN', 'PTR', 'PAGE', 'TIME', 'LOMEM', 'HIMEM', 'ABS',
|
| 571 |
+
'ACS', 'ADVAL', 'ASC', 'ASN', 'ATN', 'BGET', 'COS', 'COUNT',
|
| 572 |
+
'DEG', 'ERL', 'ERR', 'EVAL', 'EXP', 'EXT', 'FALSE', 'FN',
|
| 573 |
+
'GET', 'INKEY', 'INSTR', 'INT', 'LEN', 'LN', 'LOG', 'NOT',
|
| 574 |
+
'OPENUP', 'OPENOUT', 'PI', 'POINT', 'POS', 'RAD', 'RND',
|
| 575 |
+
'SGN', 'SIN', 'SQR', 'TAN', 'TO', 'TRUE', 'USR', 'VAL',
|
| 576 |
+
'VPOS', 'CHR$', 'GET$', 'INKEY$', 'LEFT$', 'MID$',
|
| 577 |
+
'RIGHT$', 'STR$', 'STRING$', 'EOF', 'PTR', 'PAGE', 'TIME',
|
| 578 |
+
'LOMEM', 'HIMEM', 'SOUND', 'BPUT', 'CALL', 'CHAIN', 'CLEAR',
|
| 579 |
+
'CLOSE', 'CLG', 'CLS', 'DATA', 'DEF', 'DIM', 'DRAW', 'END',
|
| 580 |
+
'ENDPROC', 'ENVELOPE', 'FOR', 'GOSUB', 'GOTO', 'GCOL', 'IF',
|
| 581 |
+
'INPUT', 'LET', 'LOCAL', 'MODE', 'MOVE', 'NEXT', 'ON',
|
| 582 |
+
'VDU', 'PLOT', 'PRINT', 'PROC', 'READ', 'REM', 'REPEAT',
|
| 583 |
+
'REPORT', 'RESTORE', 'RETURN', 'RUN', 'STOP', 'COLOUR',
|
| 584 |
+
'TRACE', 'UNTIL', 'WIDTH', 'OSCLI']
|
| 585 |
+
|
| 586 |
+
basic5_keywords = ['WHEN', 'OF', 'ENDCASE', 'ENDIF', 'ENDWHILE', 'CASE',
|
| 587 |
+
'CIRCLE', 'FILL', 'ORIGIN', 'POINT', 'RECTANGLE', 'SWAP',
|
| 588 |
+
'WHILE', 'WAIT', 'MOUSE', 'QUIT', 'SYS', 'INSTALL',
|
| 589 |
+
'LIBRARY', 'TINT', 'ELLIPSE', 'BEATS', 'TEMPO', 'VOICES',
|
| 590 |
+
'VOICE', 'STEREO', 'OVERLAY', 'APPEND', 'AUTO', 'CRUNCH',
|
| 591 |
+
'DELETE', 'EDIT', 'HELP', 'LIST', 'LOAD', 'LVAR', 'NEW',
|
| 592 |
+
'OLD', 'RENUMBER', 'SAVE', 'TEXTLOAD', 'TEXTSAVE',
|
| 593 |
+
'TWIN', 'TWINO', 'INSTALL', 'SUM', 'BEAT']
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
name = 'BBC Basic'
|
| 597 |
+
aliases = ['bbcbasic']
|
| 598 |
+
filenames = ['*.bbc']
|
| 599 |
+
url = 'https://www.bbcbasic.co.uk/bbcbasic.html'
|
| 600 |
+
version_added = '2.4'
|
| 601 |
+
|
| 602 |
+
tokens = {
|
| 603 |
+
'root': [
|
| 604 |
+
(r"[0-9]+", Name.Label),
|
| 605 |
+
(r"(\*)([^\n]*)",
|
| 606 |
+
bygroups(Keyword.Pseudo, Comment.Special)),
|
| 607 |
+
default('code'),
|
| 608 |
+
],
|
| 609 |
+
|
| 610 |
+
'code': [
|
| 611 |
+
(r"(REM)([^\n]*)",
|
| 612 |
+
bygroups(Keyword.Declaration, Comment.Single)),
|
| 613 |
+
(r'\n', Whitespace, 'root'),
|
| 614 |
+
(r'\s+', Whitespace),
|
| 615 |
+
(r':', Comment.Preproc),
|
| 616 |
+
|
| 617 |
+
# Some special cases to make functions come out nicer
|
| 618 |
+
(r'(DEF)(\s*)(FN|PROC)([A-Za-z_@][\w@]*)',
|
| 619 |
+
bygroups(Keyword.Declaration, Whitespace,
|
| 620 |
+
Keyword.Declaration, Name.Function)),
|
| 621 |
+
(r'(FN|PROC)([A-Za-z_@][\w@]*)',
|
| 622 |
+
bygroups(Keyword, Name.Function)),
|
| 623 |
+
|
| 624 |
+
(r'(GOTO|GOSUB|THEN|RESTORE)(\s*)(\d+)',
|
| 625 |
+
bygroups(Keyword, Whitespace, Name.Label)),
|
| 626 |
+
|
| 627 |
+
(r'(TRUE|FALSE)', Keyword.Constant),
|
| 628 |
+
(r'(PAGE|LOMEM|HIMEM|TIME|WIDTH|ERL|ERR|REPORT\$|POS|VPOS|VOICES)',
|
| 629 |
+
Keyword.Pseudo),
|
| 630 |
+
|
| 631 |
+
(words(base_keywords), Keyword),
|
| 632 |
+
(words(basic5_keywords), Keyword),
|
| 633 |
+
|
| 634 |
+
('"', String.Double, 'string'),
|
| 635 |
+
|
| 636 |
+
('%[01]{1,32}', Number.Bin),
|
| 637 |
+
('&[0-9a-f]{1,8}', Number.Hex),
|
| 638 |
+
|
| 639 |
+
(r'[+-]?[0-9]+\.[0-9]*(E[+-]?[0-9]+)?', Number.Float),
|
| 640 |
+
(r'[+-]?\.[0-9]+(E[+-]?[0-9]+)?', Number.Float),
|
| 641 |
+
(r'[+-]?[0-9]+E[+-]?[0-9]+', Number.Float),
|
| 642 |
+
(r'[+-]?\d+', Number.Integer),
|
| 643 |
+
|
| 644 |
+
(r'([A-Za-z_@][\w@]*[%$]?)', Name.Variable),
|
| 645 |
+
(r'([+\-]=|[$!|?+\-*/%^=><();]|>=|<=|<>|<<|>>|>>>|,)', Operator),
|
| 646 |
+
],
|
| 647 |
+
'string': [
|
| 648 |
+
(r'[^"\n]+', String.Double),
|
| 649 |
+
(r'"', String.Double, '#pop'),
|
| 650 |
+
(r'\n', Error, 'root'), # Unterminated string
|
| 651 |
+
],
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
def analyse_text(text):
|
| 655 |
+
if text.startswith('10REM >') or text.startswith('REM >'):
|
| 656 |
+
return 0.9
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bibtex.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.bibtex
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for BibTeX bibliography data and styles
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, default, \
|
| 14 |
+
words
|
| 15 |
+
from pygments.token import Name, Comment, String, Error, Number, Keyword, \
|
| 16 |
+
Punctuation, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['BibTeXLexer', 'BSTLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class BibTeXLexer(ExtendedRegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
A lexer for BibTeX bibliography data format.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'BibTeX'
|
| 27 |
+
aliases = ['bibtex', 'bib']
|
| 28 |
+
filenames = ['*.bib']
|
| 29 |
+
mimetypes = ["text/x-bibtex"]
|
| 30 |
+
version_added = '2.2'
|
| 31 |
+
flags = re.IGNORECASE
|
| 32 |
+
url = 'https://texfaq.org/FAQ-BibTeXing'
|
| 33 |
+
|
| 34 |
+
ALLOWED_CHARS = r'@!$&*+\-./:;<>?\[\\\]^`|~'
|
| 35 |
+
IDENTIFIER = '[{}][{}]*'.format('a-z_' + ALLOWED_CHARS, r'\w' + ALLOWED_CHARS)
|
| 36 |
+
|
| 37 |
+
def open_brace_callback(self, match, ctx):
|
| 38 |
+
opening_brace = match.group()
|
| 39 |
+
ctx.opening_brace = opening_brace
|
| 40 |
+
yield match.start(), Punctuation, opening_brace
|
| 41 |
+
ctx.pos = match.end()
|
| 42 |
+
|
| 43 |
+
def close_brace_callback(self, match, ctx):
|
| 44 |
+
closing_brace = match.group()
|
| 45 |
+
if (
|
| 46 |
+
ctx.opening_brace == '{' and closing_brace != '}' or
|
| 47 |
+
ctx.opening_brace == '(' and closing_brace != ')'
|
| 48 |
+
):
|
| 49 |
+
yield match.start(), Error, closing_brace
|
| 50 |
+
else:
|
| 51 |
+
yield match.start(), Punctuation, closing_brace
|
| 52 |
+
del ctx.opening_brace
|
| 53 |
+
ctx.pos = match.end()
|
| 54 |
+
|
| 55 |
+
tokens = {
|
| 56 |
+
'root': [
|
| 57 |
+
include('whitespace'),
|
| 58 |
+
(r'@comment(?!ary)', Comment),
|
| 59 |
+
('@preamble', Name.Class, ('closing-brace', 'value', 'opening-brace')),
|
| 60 |
+
('@string', Name.Class, ('closing-brace', 'field', 'opening-brace')),
|
| 61 |
+
('@' + IDENTIFIER, Name.Class,
|
| 62 |
+
('closing-brace', 'command-body', 'opening-brace')),
|
| 63 |
+
('.+', Comment),
|
| 64 |
+
],
|
| 65 |
+
'opening-brace': [
|
| 66 |
+
include('whitespace'),
|
| 67 |
+
(r'[{(]', open_brace_callback, '#pop'),
|
| 68 |
+
],
|
| 69 |
+
'closing-brace': [
|
| 70 |
+
include('whitespace'),
|
| 71 |
+
(r'[})]', close_brace_callback, '#pop'),
|
| 72 |
+
],
|
| 73 |
+
'command-body': [
|
| 74 |
+
include('whitespace'),
|
| 75 |
+
(r'[^\s\,\}]+', Name.Label, ('#pop', 'fields')),
|
| 76 |
+
],
|
| 77 |
+
'fields': [
|
| 78 |
+
include('whitespace'),
|
| 79 |
+
(',', Punctuation, 'field'),
|
| 80 |
+
default('#pop'),
|
| 81 |
+
],
|
| 82 |
+
'field': [
|
| 83 |
+
include('whitespace'),
|
| 84 |
+
(IDENTIFIER, Name.Attribute, ('value', '=')),
|
| 85 |
+
default('#pop'),
|
| 86 |
+
],
|
| 87 |
+
'=': [
|
| 88 |
+
include('whitespace'),
|
| 89 |
+
('=', Punctuation, '#pop'),
|
| 90 |
+
],
|
| 91 |
+
'value': [
|
| 92 |
+
include('whitespace'),
|
| 93 |
+
(IDENTIFIER, Name.Variable),
|
| 94 |
+
('"', String, 'quoted-string'),
|
| 95 |
+
(r'\{', String, 'braced-string'),
|
| 96 |
+
(r'[\d]+', Number),
|
| 97 |
+
('#', Punctuation),
|
| 98 |
+
default('#pop'),
|
| 99 |
+
],
|
| 100 |
+
'quoted-string': [
|
| 101 |
+
(r'\{', String, 'braced-string'),
|
| 102 |
+
('"', String, '#pop'),
|
| 103 |
+
(r'[^\{\"]+', String),
|
| 104 |
+
],
|
| 105 |
+
'braced-string': [
|
| 106 |
+
(r'\{', String, '#push'),
|
| 107 |
+
(r'\}', String, '#pop'),
|
| 108 |
+
(r'[^\{\}]+', String),
|
| 109 |
+
],
|
| 110 |
+
'whitespace': [
|
| 111 |
+
(r'\s+', Whitespace),
|
| 112 |
+
],
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class BSTLexer(RegexLexer):
|
| 117 |
+
"""
|
| 118 |
+
A lexer for BibTeX bibliography styles.
|
| 119 |
+
"""
|
| 120 |
+
|
| 121 |
+
name = 'BST'
|
| 122 |
+
aliases = ['bst', 'bst-pybtex']
|
| 123 |
+
filenames = ['*.bst']
|
| 124 |
+
version_added = '2.2'
|
| 125 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 126 |
+
url = 'https://texfaq.org/FAQ-BibTeXing'
|
| 127 |
+
|
| 128 |
+
tokens = {
|
| 129 |
+
'root': [
|
| 130 |
+
include('whitespace'),
|
| 131 |
+
(words(['read', 'sort']), Keyword),
|
| 132 |
+
(words(['execute', 'integers', 'iterate', 'reverse', 'strings']),
|
| 133 |
+
Keyword, ('group')),
|
| 134 |
+
(words(['function', 'macro']), Keyword, ('group', 'group')),
|
| 135 |
+
(words(['entry']), Keyword, ('group', 'group', 'group')),
|
| 136 |
+
],
|
| 137 |
+
'group': [
|
| 138 |
+
include('whitespace'),
|
| 139 |
+
(r'\{', Punctuation, ('#pop', 'group-end', 'body')),
|
| 140 |
+
],
|
| 141 |
+
'group-end': [
|
| 142 |
+
include('whitespace'),
|
| 143 |
+
(r'\}', Punctuation, '#pop'),
|
| 144 |
+
],
|
| 145 |
+
'body': [
|
| 146 |
+
include('whitespace'),
|
| 147 |
+
(r"\'[^#\"\{\}\s]+", Name.Function),
|
| 148 |
+
(r'[^#\"\{\}\s]+\$', Name.Builtin),
|
| 149 |
+
(r'[^#\"\{\}\s]+', Name.Variable),
|
| 150 |
+
(r'"[^\"]*"', String),
|
| 151 |
+
(r'#-?\d+', Number),
|
| 152 |
+
(r'\{', Punctuation, ('group-end', 'body')),
|
| 153 |
+
default('#pop'),
|
| 154 |
+
],
|
| 155 |
+
'whitespace': [
|
| 156 |
+
(r'\s+', Whitespace),
|
| 157 |
+
('%.*?$', Comment.Single),
|
| 158 |
+
],
|
| 159 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.blueprint
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Blueprint UI markup language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, words
|
| 14 |
+
from pygments.token import (
|
| 15 |
+
Comment,
|
| 16 |
+
Operator,
|
| 17 |
+
Keyword,
|
| 18 |
+
Name,
|
| 19 |
+
String,
|
| 20 |
+
Number,
|
| 21 |
+
Punctuation,
|
| 22 |
+
Whitespace,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
__all__ = ["BlueprintLexer"]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class BlueprintLexer(RegexLexer):
|
| 29 |
+
"""
|
| 30 |
+
For Blueprint UI markup.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
name = "Blueprint"
|
| 34 |
+
aliases = ["blueprint"]
|
| 35 |
+
filenames = ["*.blp"]
|
| 36 |
+
mimetypes = ["text/x-blueprint"]
|
| 37 |
+
url = "https://gitlab.gnome.org/jwestman/blueprint-compiler"
|
| 38 |
+
version_added = '2.16'
|
| 39 |
+
|
| 40 |
+
flags = re.IGNORECASE
|
| 41 |
+
tokens = {
|
| 42 |
+
"root": [
|
| 43 |
+
include("block-content"),
|
| 44 |
+
],
|
| 45 |
+
"type": [
|
| 46 |
+
(r"\$\s*[a-z_][a-z0-9_\-]*", Name.Class),
|
| 47 |
+
(r"(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*)",
|
| 48 |
+
bygroups(Name.Namespace, Whitespace, Punctuation, Whitespace, Name.Class)),
|
| 49 |
+
],
|
| 50 |
+
"whitespace": [
|
| 51 |
+
(r"\s+", Whitespace),
|
| 52 |
+
(r"//.*?\n", Comment.Single),
|
| 53 |
+
(r"/\*", Comment.Multiline, "comment-multiline"),
|
| 54 |
+
],
|
| 55 |
+
"comment-multiline": [
|
| 56 |
+
(r"\*/", Comment.Multiline, "#pop"),
|
| 57 |
+
(r"[^*]+", Comment.Multiline),
|
| 58 |
+
(r"\*", Comment.Multiline),
|
| 59 |
+
],
|
| 60 |
+
"value": [
|
| 61 |
+
(r"(typeof)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"),
|
| 62 |
+
(words(("true", "false", "null")), Keyword.Constant),
|
| 63 |
+
(r"[a-z_][a-z0-9_\-]*", Name.Variable),
|
| 64 |
+
(r"\|", Operator),
|
| 65 |
+
(r'".*?"', String.Double),
|
| 66 |
+
(r"\'.*?\'", String.Single),
|
| 67 |
+
(r"0x[\d_]*", Number.Hex),
|
| 68 |
+
(r"[0-9_]+", Number.Integer),
|
| 69 |
+
(r"\d[\d\.a-z_]*", Number),
|
| 70 |
+
],
|
| 71 |
+
"typeof": [
|
| 72 |
+
include("whitespace"),
|
| 73 |
+
include("type"),
|
| 74 |
+
(r">", Punctuation, "#pop"),
|
| 75 |
+
],
|
| 76 |
+
"content": [
|
| 77 |
+
include("whitespace"),
|
| 78 |
+
# Keywords
|
| 79 |
+
(words(("after", "bidirectional", "bind-property", "bind", "default",
|
| 80 |
+
"destructive", "disabled", "inverted", "no-sync-create",
|
| 81 |
+
"suggested", "swapped", "sync-create", "template")),
|
| 82 |
+
Keyword),
|
| 83 |
+
# Translated strings
|
| 84 |
+
(r"(C?_)(\s*)(\()",
|
| 85 |
+
bygroups(Name.Function.Builtin, Whitespace, Punctuation),
|
| 86 |
+
"paren-content"),
|
| 87 |
+
# Cast expressions
|
| 88 |
+
(r"(as)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"),
|
| 89 |
+
# Closures
|
| 90 |
+
(r"(\$?[a-z_][a-z0-9_\-]*)(\s*)(\()",
|
| 91 |
+
bygroups(Name.Function, Whitespace, Punctuation),
|
| 92 |
+
"paren-content"),
|
| 93 |
+
# Objects
|
| 94 |
+
(r"(?:(\$\s*[a-z_][a-z0-9_\-]+)|(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*))(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)",
|
| 95 |
+
bygroups(Name.Class, Name.Namespace, Whitespace, Punctuation, Whitespace,
|
| 96 |
+
Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation),
|
| 97 |
+
"brace-block"),
|
| 98 |
+
# Misc
|
| 99 |
+
include("value"),
|
| 100 |
+
(r",|\.", Punctuation),
|
| 101 |
+
],
|
| 102 |
+
"block-content": [
|
| 103 |
+
# Import statements
|
| 104 |
+
(r"(using)(\s+)([a-z_][a-z0-9_\-]*)(\s+)(\d[\d\.]*)(;)",
|
| 105 |
+
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
|
| 106 |
+
Name.Namespace, Punctuation)),
|
| 107 |
+
# Menus
|
| 108 |
+
(r"(menu|section|submenu)(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)",
|
| 109 |
+
bygroups(Keyword, Whitespace, Name.Variable, Whitespace, Punctuation),
|
| 110 |
+
"brace-block"),
|
| 111 |
+
(r"(item)(\s*)(\{)",
|
| 112 |
+
bygroups(Keyword, Whitespace, Punctuation),
|
| 113 |
+
"brace-block"),
|
| 114 |
+
(r"(item)(\s*)(\()",
|
| 115 |
+
bygroups(Keyword, Whitespace, Punctuation),
|
| 116 |
+
"paren-block"),
|
| 117 |
+
# Templates
|
| 118 |
+
(r"template", Keyword.Declaration, "template"),
|
| 119 |
+
# Nested blocks. When extensions are added, this is where they go.
|
| 120 |
+
(r"(responses|items|mime-types|patterns|suffixes|marks|widgets|strings|styles)(\s*)(\[)",
|
| 121 |
+
bygroups(Keyword, Whitespace, Punctuation),
|
| 122 |
+
"bracket-block"),
|
| 123 |
+
(r"(accessibility|setters|layout|item)(\s*)(\{)",
|
| 124 |
+
bygroups(Keyword, Whitespace, Punctuation),
|
| 125 |
+
"brace-block"),
|
| 126 |
+
(r"(condition|mark|item)(\s*)(\()",
|
| 127 |
+
bygroups(Keyword, Whitespace, Punctuation),
|
| 128 |
+
"paren-content"),
|
| 129 |
+
(r"\[", Punctuation, "child-type"),
|
| 130 |
+
# Properties and signals
|
| 131 |
+
(r"([a-z_][a-z0-9_\-]*(?:::[a-z0-9_]+)?)(\s*)(:|=>)",
|
| 132 |
+
bygroups(Name.Property, Whitespace, Punctuation),
|
| 133 |
+
"statement"),
|
| 134 |
+
include("content"),
|
| 135 |
+
],
|
| 136 |
+
"paren-block": [
|
| 137 |
+
include("block-content"),
|
| 138 |
+
(r"\)", Punctuation, "#pop"),
|
| 139 |
+
],
|
| 140 |
+
"paren-content": [
|
| 141 |
+
include("content"),
|
| 142 |
+
(r"\)", Punctuation, "#pop"),
|
| 143 |
+
],
|
| 144 |
+
"bracket-block": [
|
| 145 |
+
include("block-content"),
|
| 146 |
+
(r"\]", Punctuation, "#pop"),
|
| 147 |
+
],
|
| 148 |
+
"brace-block": [
|
| 149 |
+
include("block-content"),
|
| 150 |
+
(r"\}", Punctuation, "#pop"),
|
| 151 |
+
],
|
| 152 |
+
"statement": [
|
| 153 |
+
include("content"),
|
| 154 |
+
(r";", Punctuation, "#pop"),
|
| 155 |
+
],
|
| 156 |
+
"child-type": [
|
| 157 |
+
include("whitespace"),
|
| 158 |
+
(r"(action)(\s+)(response)(\s*)(=)(\s*)",
|
| 159 |
+
bygroups(Keyword, Whitespace, Name.Attribute, Whitespace,
|
| 160 |
+
Punctuation, Whitespace)),
|
| 161 |
+
(words(("default", "internal-child", "response")), Keyword),
|
| 162 |
+
(r"[a-z_][a-z0-9_\-]*", Name.Decorator),
|
| 163 |
+
include("value"),
|
| 164 |
+
(r"=", Punctuation),
|
| 165 |
+
(r"\]", Punctuation, "#pop"),
|
| 166 |
+
],
|
| 167 |
+
"template": [
|
| 168 |
+
include("whitespace"),
|
| 169 |
+
include("type"),
|
| 170 |
+
(r":", Punctuation),
|
| 171 |
+
(r"\{", Punctuation, ("#pop", "brace-block")),
|
| 172 |
+
],
|
| 173 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/boa.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.boa
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Boa language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import String, Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['BoaLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class BoaLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the Boa language.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Boa'
|
| 23 |
+
aliases = ['boa']
|
| 24 |
+
filenames = ['*.boa']
|
| 25 |
+
url = 'https://boa.cs.iastate.edu/docs'
|
| 26 |
+
version_added = '2.4'
|
| 27 |
+
|
| 28 |
+
reserved = words(
|
| 29 |
+
('input', 'output', 'of', 'weight', 'before', 'after', 'stop',
|
| 30 |
+
'ifall', 'foreach', 'exists', 'function', 'break', 'switch', 'case',
|
| 31 |
+
'visitor', 'default', 'return', 'visit', 'while', 'if', 'else'),
|
| 32 |
+
suffix=r'\b', prefix=r'\b')
|
| 33 |
+
keywords = words(
|
| 34 |
+
('bottom', 'collection', 'maximum', 'mean', 'minimum', 'set', 'sum',
|
| 35 |
+
'top', 'string', 'int', 'bool', 'float', 'time', 'false', 'true',
|
| 36 |
+
'array', 'map', 'stack', 'enum', 'type'), suffix=r'\b', prefix=r'\b')
|
| 37 |
+
classes = words(
|
| 38 |
+
('Project', 'ForgeKind', 'CodeRepository', 'Revision', 'RepositoryKind',
|
| 39 |
+
'ChangedFile', 'FileKind', 'ASTRoot', 'Namespace', 'Declaration', 'Type',
|
| 40 |
+
'Method', 'Variable', 'Statement', 'Expression', 'Modifier',
|
| 41 |
+
'StatementKind', 'ExpressionKind', 'ModifierKind', 'Visibility',
|
| 42 |
+
'TypeKind', 'Person', 'ChangeKind'),
|
| 43 |
+
suffix=r'\b', prefix=r'\b')
|
| 44 |
+
operators = ('->', ':=', ':', '=', '<<', '!', '++', '||',
|
| 45 |
+
'&&', '+', '-', '*', ">", "<")
|
| 46 |
+
string_sep = ('`', '\"')
|
| 47 |
+
built_in_functions = words(
|
| 48 |
+
(
|
| 49 |
+
# Array functions
|
| 50 |
+
'new', 'sort',
|
| 51 |
+
# Date & Time functions
|
| 52 |
+
'yearof', 'dayofyear', 'hourof', 'minuteof', 'secondof', 'now',
|
| 53 |
+
'addday', 'addmonth', 'addweek', 'addyear', 'dayofmonth', 'dayofweek',
|
| 54 |
+
'dayofyear', 'formattime', 'trunctoday', 'trunctohour', 'trunctominute',
|
| 55 |
+
'trunctomonth', 'trunctosecond', 'trunctoyear',
|
| 56 |
+
# Map functions
|
| 57 |
+
'clear', 'haskey', 'keys', 'lookup', 'remove', 'values',
|
| 58 |
+
# Math functions
|
| 59 |
+
'abs', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh',
|
| 60 |
+
'ceil', 'cos', 'cosh', 'exp', 'floor', 'highbit', 'isfinite', 'isinf',
|
| 61 |
+
'isnan', 'isnormal', 'log', 'log10', 'max', 'min', 'nrand', 'pow',
|
| 62 |
+
'rand', 'round', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc',
|
| 63 |
+
# Other functions
|
| 64 |
+
'def', 'hash', 'len',
|
| 65 |
+
# Set functions
|
| 66 |
+
'add', 'contains', 'remove',
|
| 67 |
+
# String functions
|
| 68 |
+
'format', 'lowercase', 'match', 'matchposns', 'matchstrs', 'regex',
|
| 69 |
+
'split', 'splitall', 'splitn', 'strfind', 'strreplace', 'strrfind',
|
| 70 |
+
'substring', 'trim', 'uppercase',
|
| 71 |
+
# Type Conversion functions
|
| 72 |
+
'bool', 'float', 'int', 'string', 'time',
|
| 73 |
+
# Domain-Specific functions
|
| 74 |
+
'getast', 'getsnapshot', 'hasfiletype', 'isfixingrevision', 'iskind',
|
| 75 |
+
'isliteral',
|
| 76 |
+
),
|
| 77 |
+
prefix=r'\b',
|
| 78 |
+
suffix=r'\(')
|
| 79 |
+
|
| 80 |
+
tokens = {
|
| 81 |
+
'root': [
|
| 82 |
+
(r'#.*?$', Comment.Single),
|
| 83 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 84 |
+
(reserved, Keyword.Reserved),
|
| 85 |
+
(built_in_functions, Name.Function),
|
| 86 |
+
(keywords, Keyword.Type),
|
| 87 |
+
(classes, Name.Classes),
|
| 88 |
+
(words(operators), Operator),
|
| 89 |
+
(r'[][(),;{}\\.]', Punctuation),
|
| 90 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 91 |
+
(r"`(\\\\|\\[^\\]|[^`\\])*`", String.Backtick),
|
| 92 |
+
(words(string_sep), String.Delimiter),
|
| 93 |
+
(r'[a-zA-Z_]+', Name.Variable),
|
| 94 |
+
(r'[0-9]+', Number.Integer),
|
| 95 |
+
(r'\s+', Whitespace), # Whitespace
|
| 96 |
+
]
|
| 97 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/bqn.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.bqn
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for BQN.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['BQNLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class BQNLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
A simple BQN lexer.
|
| 21 |
+
"""
|
| 22 |
+
name = 'BQN'
|
| 23 |
+
url = 'https://mlochbaum.github.io/BQN/index.html'
|
| 24 |
+
aliases = ['bqn']
|
| 25 |
+
filenames = ['*.bqn']
|
| 26 |
+
mimetypes = []
|
| 27 |
+
version_added = '2.16'
|
| 28 |
+
|
| 29 |
+
# An inter_word_char. Necessary because \w matches all alphanumeric
|
| 30 |
+
# Unicode characters, including ones (e.g., 𝕊) that BQN treats special.
|
| 31 |
+
_iwc = r'((?=[^𝕎𝕏𝔽𝔾𝕊𝕨𝕩𝕗𝕘𝕤𝕣])\w)'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
# Whitespace
|
| 36 |
+
# ==========
|
| 37 |
+
(r'\s+', Whitespace),
|
| 38 |
+
#
|
| 39 |
+
# Comment
|
| 40 |
+
# =======
|
| 41 |
+
# '#' is a comment that continues to the end of the line
|
| 42 |
+
(r'#.*$', Comment.Single),
|
| 43 |
+
#
|
| 44 |
+
# Strings
|
| 45 |
+
# =======
|
| 46 |
+
(r'\'((\'\')|[^\'])*\'', String.Single),
|
| 47 |
+
(r'"(("")|[^"])*"', String.Double),
|
| 48 |
+
#
|
| 49 |
+
# Null Character
|
| 50 |
+
# ==============
|
| 51 |
+
# Literal representation of the null character
|
| 52 |
+
(r'@', String.Symbol),
|
| 53 |
+
#
|
| 54 |
+
# Punctuation
|
| 55 |
+
# ===========
|
| 56 |
+
# This token type is used for diamond, commas
|
| 57 |
+
# and array and list brackets and strand syntax
|
| 58 |
+
(r'[\.⋄,\[\]⟨⟩‿]', Punctuation),
|
| 59 |
+
#
|
| 60 |
+
# Expression Grouping
|
| 61 |
+
# ===================
|
| 62 |
+
# Since this token type is important in BQN, it is not included in
|
| 63 |
+
# the punctuation token type but rather in the following one
|
| 64 |
+
(r'[\(\)]', String.Regex),
|
| 65 |
+
#
|
| 66 |
+
# Numbers
|
| 67 |
+
# =======
|
| 68 |
+
# Includes the numeric literals and the Nothing character
|
| 69 |
+
(r'¯?[0-9](([0-9]|_)*\.?([0-9]|_)+|([0-9]|_)*)([Ee][¯]?([0-9]|_)+)?|¯|∞|π|·', Number),
|
| 70 |
+
#
|
| 71 |
+
# Variables
|
| 72 |
+
# =========
|
| 73 |
+
(r'[a-z]' + _iwc + r'*', Name.Variable),
|
| 74 |
+
#
|
| 75 |
+
# 2-Modifiers
|
| 76 |
+
# ===========
|
| 77 |
+
# Needs to come before the 1-modifiers due to _𝕣 and _𝕣_
|
| 78 |
+
(r'[∘○⊸⟜⌾⊘◶⎉⚇⍟⎊]', Name.Property),
|
| 79 |
+
(r'_(𝕣|[a-zA-Z0-9]+)_', Name.Property),
|
| 80 |
+
#
|
| 81 |
+
# 1-Modifiers
|
| 82 |
+
# ===========
|
| 83 |
+
(r'[˙˜˘¨⌜⁼´˝`𝕣]', Name.Attribute),
|
| 84 |
+
(r'_(𝕣|[a-zA-Z0-9]+)', Name.Attribute),
|
| 85 |
+
#
|
| 86 |
+
# Functions
|
| 87 |
+
# =========
|
| 88 |
+
# The monadic or dyadic function primitives and function
|
| 89 |
+
# operands and arguments, along with function self-reference
|
| 90 |
+
(r'[+\-×÷\⋆√⌊⌈∧∨¬|≤<>≥=≠≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!𝕎𝕏𝔽𝔾𝕊]',
|
| 91 |
+
Operator),
|
| 92 |
+
(r'[A-Z]' + _iwc + r'*|•' + _iwc + r'+', Operator),
|
| 93 |
+
#
|
| 94 |
+
# Constant
|
| 95 |
+
# ========
|
| 96 |
+
(r'˙', Name.Constant),
|
| 97 |
+
#
|
| 98 |
+
# Define/Export/Change
|
| 99 |
+
# ====================
|
| 100 |
+
(r'[←↩⇐]', Keyword.Declaration),
|
| 101 |
+
#
|
| 102 |
+
# Blocks
|
| 103 |
+
# ======
|
| 104 |
+
(r'[{}]', Keyword.Type),
|
| 105 |
+
#
|
| 106 |
+
# Extra characters
|
| 107 |
+
# ================
|
| 108 |
+
(r'[;:?𝕨𝕩𝕗𝕘𝕤]', Name.Entity),
|
| 109 |
+
#
|
| 110 |
+
|
| 111 |
+
],
|
| 112 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/business.py
ADDED
|
@@ -0,0 +1,625 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.business
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for "business-oriented" languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, words, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Error, Whitespace
|
| 16 |
+
|
| 17 |
+
from pygments.lexers._openedge_builtins import OPENEDGEKEYWORDS
|
| 18 |
+
|
| 19 |
+
__all__ = ['CobolLexer', 'CobolFreeformatLexer', 'ABAPLexer', 'OpenEdgeLexer',
|
| 20 |
+
'GoodDataCLLexer', 'MaqlLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class CobolLexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
Lexer for OpenCOBOL code.
|
| 26 |
+
"""
|
| 27 |
+
name = 'COBOL'
|
| 28 |
+
aliases = ['cobol']
|
| 29 |
+
filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY']
|
| 30 |
+
mimetypes = ['text/x-cobol']
|
| 31 |
+
url = 'https://en.wikipedia.org/wiki/COBOL'
|
| 32 |
+
version_added = '1.6'
|
| 33 |
+
|
| 34 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 35 |
+
|
| 36 |
+
# Data Types: by PICTURE and USAGE
|
| 37 |
+
# Operators: **, *, +, -, /, <, >, <=, >=, =, <>
|
| 38 |
+
# Logical (?): NOT, AND, OR
|
| 39 |
+
|
| 40 |
+
# Reserved words:
|
| 41 |
+
# http://opencobol.add1tocobol.com/#reserved-words
|
| 42 |
+
# Intrinsics:
|
| 43 |
+
# http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
'root': [
|
| 47 |
+
include('comment'),
|
| 48 |
+
include('strings'),
|
| 49 |
+
include('core'),
|
| 50 |
+
include('nums'),
|
| 51 |
+
(r'[a-z0-9]([\w\-]*[a-z0-9]+)?', Name.Variable),
|
| 52 |
+
# (r'[\s]+', Text),
|
| 53 |
+
(r'[ \t]+', Whitespace),
|
| 54 |
+
],
|
| 55 |
+
'comment': [
|
| 56 |
+
(r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment),
|
| 57 |
+
],
|
| 58 |
+
'core': [
|
| 59 |
+
# Figurative constants
|
| 60 |
+
(r'(^|(?<=[^\w\-]))(ALL\s+)?'
|
| 61 |
+
r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)'
|
| 62 |
+
r'\s*($|(?=[^\w\-]))',
|
| 63 |
+
Name.Constant),
|
| 64 |
+
|
| 65 |
+
# Reserved words STATEMENTS and other bolds
|
| 66 |
+
(words((
|
| 67 |
+
'ACCEPT', 'ADD', 'ALLOCATE', 'CALL', 'CANCEL', 'CLOSE', 'COMPUTE',
|
| 68 |
+
'CONFIGURATION', 'CONTINUE', 'DATA', 'DELETE', 'DISPLAY', 'DIVIDE',
|
| 69 |
+
'DIVISION', 'ELSE', 'END', 'END-ACCEPT',
|
| 70 |
+
'END-ADD', 'END-CALL', 'END-COMPUTE', 'END-DELETE', 'END-DISPLAY',
|
| 71 |
+
'END-DIVIDE', 'END-EVALUATE', 'END-IF', 'END-MULTIPLY', 'END-OF-PAGE',
|
| 72 |
+
'END-PERFORM', 'END-READ', 'END-RETURN', 'END-REWRITE', 'END-SEARCH',
|
| 73 |
+
'END-START', 'END-STRING', 'END-SUBTRACT', 'END-UNSTRING', 'END-WRITE',
|
| 74 |
+
'ENVIRONMENT', 'EVALUATE', 'EXIT', 'FD', 'FILE', 'FILE-CONTROL', 'FOREVER',
|
| 75 |
+
'FREE', 'GENERATE', 'GO', 'GOBACK', 'IDENTIFICATION', 'IF', 'INITIALIZE',
|
| 76 |
+
'INITIATE', 'INPUT-OUTPUT', 'INSPECT', 'INVOKE', 'I-O-CONTROL', 'LINKAGE',
|
| 77 |
+
'LOCAL-STORAGE', 'MERGE', 'MOVE', 'MULTIPLY', 'OPEN', 'PERFORM',
|
| 78 |
+
'PROCEDURE', 'PROGRAM-ID', 'RAISE', 'READ', 'RELEASE', 'RESUME',
|
| 79 |
+
'RETURN', 'REWRITE', 'SCREEN', 'SD', 'SEARCH', 'SECTION', 'SET',
|
| 80 |
+
'SORT', 'START', 'STOP', 'STRING', 'SUBTRACT', 'SUPPRESS',
|
| 81 |
+
'TERMINATE', 'THEN', 'UNLOCK', 'UNSTRING', 'USE', 'VALIDATE',
|
| 82 |
+
'WORKING-STORAGE', 'WRITE'), prefix=r'(^|(?<=[^\w\-]))',
|
| 83 |
+
suffix=r'\s*($|(?=[^\w\-]))'),
|
| 84 |
+
Keyword.Reserved),
|
| 85 |
+
|
| 86 |
+
# Reserved words
|
| 87 |
+
(words((
|
| 88 |
+
'ACCESS', 'ADDRESS', 'ADVANCING', 'AFTER', 'ALL',
|
| 89 |
+
'ALPHABET', 'ALPHABETIC', 'ALPHABETIC-LOWER', 'ALPHABETIC-UPPER',
|
| 90 |
+
'ALPHANUMERIC', 'ALPHANUMERIC-EDITED', 'ALSO', 'ALTER', 'ALTERNATE'
|
| 91 |
+
'ANY', 'ARE', 'AREA', 'AREAS', 'ARGUMENT-NUMBER', 'ARGUMENT-VALUE', 'AS',
|
| 92 |
+
'ASCENDING', 'ASSIGN', 'AT', 'AUTO', 'AUTO-SKIP', 'AUTOMATIC',
|
| 93 |
+
'AUTOTERMINATE', 'BACKGROUND-COLOR', 'BASED', 'BEEP', 'BEFORE', 'BELL',
|
| 94 |
+
'BLANK', 'BLINK', 'BLOCK', 'BOTTOM', 'BY', 'BYTE-LENGTH', 'CHAINING',
|
| 95 |
+
'CHARACTER', 'CHARACTERS', 'CLASS', 'CODE', 'CODE-SET', 'COL',
|
| 96 |
+
'COLLATING', 'COLS', 'COLUMN', 'COLUMNS', 'COMMA', 'COMMAND-LINE',
|
| 97 |
+
'COMMIT', 'COMMON', 'CONSTANT', 'CONTAINS', 'CONTENT', 'CONTROL',
|
| 98 |
+
'CONTROLS', 'CONVERTING', 'COPY', 'CORR', 'CORRESPONDING', 'COUNT', 'CRT',
|
| 99 |
+
'CURRENCY', 'CURSOR', 'CYCLE', 'DATE', 'DAY', 'DAY-OF-WEEK', 'DE',
|
| 100 |
+
'DEBUGGING', 'DECIMAL-POINT', 'DECLARATIVES', 'DEFAULT', 'DELIMITED',
|
| 101 |
+
'DELIMITER', 'DEPENDING', 'DESCENDING', 'DETAIL', 'DISK',
|
| 102 |
+
'DOWN', 'DUPLICATES', 'DYNAMIC', 'EBCDIC',
|
| 103 |
+
'ENTRY', 'ENVIRONMENT-NAME', 'ENVIRONMENT-VALUE', 'EOL', 'EOP',
|
| 104 |
+
'EOS', 'ERASE', 'ERROR', 'ESCAPE', 'EXCEPTION',
|
| 105 |
+
'EXCLUSIVE', 'EXTEND', 'EXTERNAL', 'FILE-ID', 'FILLER', 'FINAL',
|
| 106 |
+
'FIRST', 'FIXED', 'FLOAT-LONG', 'FLOAT-SHORT',
|
| 107 |
+
'FOOTING', 'FOR', 'FOREGROUND-COLOR', 'FORMAT', 'FROM', 'FULL',
|
| 108 |
+
'FUNCTION', 'FUNCTION-ID', 'GIVING', 'GLOBAL', 'GROUP',
|
| 109 |
+
'HEADING', 'HIGHLIGHT', 'I-O', 'ID',
|
| 110 |
+
'IGNORE', 'IGNORING', 'IN', 'INDEX', 'INDEXED', 'INDICATE',
|
| 111 |
+
'INITIAL', 'INITIALIZED', 'INPUT', 'INTO', 'INTRINSIC', 'INVALID',
|
| 112 |
+
'IS', 'JUST', 'JUSTIFIED', 'KEY', 'LABEL',
|
| 113 |
+
'LAST', 'LEADING', 'LEFT', 'LENGTH', 'LIMIT', 'LIMITS', 'LINAGE',
|
| 114 |
+
'LINAGE-COUNTER', 'LINE', 'LINES', 'LOCALE', 'LOCK',
|
| 115 |
+
'LOWLIGHT', 'MANUAL', 'MEMORY', 'MINUS', 'MODE', 'MULTIPLE',
|
| 116 |
+
'NATIONAL', 'NATIONAL-EDITED', 'NATIVE', 'NEGATIVE', 'NEXT', 'NO',
|
| 117 |
+
'NULL', 'NULLS', 'NUMBER', 'NUMBERS', 'NUMERIC', 'NUMERIC-EDITED',
|
| 118 |
+
'OBJECT-COMPUTER', 'OCCURS', 'OF', 'OFF', 'OMITTED', 'ON', 'ONLY',
|
| 119 |
+
'OPTIONAL', 'ORDER', 'ORGANIZATION', 'OTHER', 'OUTPUT', 'OVERFLOW',
|
| 120 |
+
'OVERLINE', 'PACKED-DECIMAL', 'PADDING', 'PAGE', 'PARAGRAPH',
|
| 121 |
+
'PLUS', 'POINTER', 'POSITION', 'POSITIVE', 'PRESENT', 'PREVIOUS',
|
| 122 |
+
'PRINTER', 'PRINTING', 'PROCEDURE-POINTER', 'PROCEDURES',
|
| 123 |
+
'PROCEED', 'PROGRAM', 'PROGRAM-POINTER', 'PROMPT', 'QUOTE',
|
| 124 |
+
'QUOTES', 'RANDOM', 'RD', 'RECORD', 'RECORDING', 'RECORDS', 'RECURSIVE',
|
| 125 |
+
'REDEFINES', 'REEL', 'REFERENCE', 'RELATIVE', 'REMAINDER', 'REMOVAL',
|
| 126 |
+
'RENAMES', 'REPLACING', 'REPORT', 'REPORTING', 'REPORTS', 'REPOSITORY',
|
| 127 |
+
'REQUIRED', 'RESERVE', 'RETURNING', 'REVERSE-VIDEO', 'REWIND',
|
| 128 |
+
'RIGHT', 'ROLLBACK', 'ROUNDED', 'RUN', 'SAME', 'SCROLL',
|
| 129 |
+
'SECURE', 'SEGMENT-LIMIT', 'SELECT', 'SENTENCE', 'SEPARATE',
|
| 130 |
+
'SEQUENCE', 'SEQUENTIAL', 'SHARING', 'SIGN', 'SIGNED', 'SIGNED-INT',
|
| 131 |
+
'SIGNED-LONG', 'SIGNED-SHORT', 'SIZE', 'SORT-MERGE', 'SOURCE',
|
| 132 |
+
'SOURCE-COMPUTER', 'SPECIAL-NAMES', 'STANDARD',
|
| 133 |
+
'STANDARD-1', 'STANDARD-2', 'STATUS', 'SUBKEY', 'SUM',
|
| 134 |
+
'SYMBOLIC', 'SYNC', 'SYNCHRONIZED', 'TALLYING', 'TAPE',
|
| 135 |
+
'TEST', 'THROUGH', 'THRU', 'TIME', 'TIMES', 'TO', 'TOP', 'TRAILING',
|
| 136 |
+
'TRANSFORM', 'TYPE', 'UNDERLINE', 'UNIT', 'UNSIGNED',
|
| 137 |
+
'UNSIGNED-INT', 'UNSIGNED-LONG', 'UNSIGNED-SHORT', 'UNTIL', 'UP',
|
| 138 |
+
'UPDATE', 'UPON', 'USAGE', 'USING', 'VALUE', 'VALUES', 'VARYING',
|
| 139 |
+
'WAIT', 'WHEN', 'WITH', 'WORDS', 'YYYYDDD', 'YYYYMMDD'),
|
| 140 |
+
prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'),
|
| 141 |
+
Keyword.Pseudo),
|
| 142 |
+
|
| 143 |
+
# inactive reserved words
|
| 144 |
+
(words((
|
| 145 |
+
'ACTIVE-CLASS', 'ALIGNED', 'ANYCASE', 'ARITHMETIC', 'ATTRIBUTE',
|
| 146 |
+
'B-AND', 'B-NOT', 'B-OR', 'B-XOR', 'BIT', 'BOOLEAN', 'CD', 'CENTER',
|
| 147 |
+
'CF', 'CH', 'CHAIN', 'CLASS-ID', 'CLASSIFICATION', 'COMMUNICATION',
|
| 148 |
+
'CONDITION', 'DATA-POINTER', 'DESTINATION', 'DISABLE', 'EC', 'EGI',
|
| 149 |
+
'EMI', 'ENABLE', 'END-RECEIVE', 'ENTRY-CONVENTION', 'EO', 'ESI',
|
| 150 |
+
'EXCEPTION-OBJECT', 'EXPANDS', 'FACTORY', 'FLOAT-BINARY-16',
|
| 151 |
+
'FLOAT-BINARY-34', 'FLOAT-BINARY-7', 'FLOAT-DECIMAL-16',
|
| 152 |
+
'FLOAT-DECIMAL-34', 'FLOAT-EXTENDED', 'FORMAT', 'FUNCTION-POINTER',
|
| 153 |
+
'GET', 'GROUP-USAGE', 'IMPLEMENTS', 'INFINITY', 'INHERITS',
|
| 154 |
+
'INTERFACE', 'INTERFACE-ID', 'INVOKE', 'LC_ALL', 'LC_COLLATE',
|
| 155 |
+
'LC_CTYPE', 'LC_MESSAGES', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME',
|
| 156 |
+
'LINE-COUNTER', 'MESSAGE', 'METHOD', 'METHOD-ID', 'NESTED', 'NONE',
|
| 157 |
+
'NORMAL', 'OBJECT', 'OBJECT-REFERENCE', 'OPTIONS', 'OVERRIDE',
|
| 158 |
+
'PAGE-COUNTER', 'PF', 'PH', 'PROPERTY', 'PROTOTYPE', 'PURGE',
|
| 159 |
+
'QUEUE', 'RAISE', 'RAISING', 'RECEIVE', 'RELATION', 'REPLACE',
|
| 160 |
+
'REPRESENTS-NOT-A-NUMBER', 'RESET', 'RESUME', 'RETRY', 'RF', 'RH',
|
| 161 |
+
'SECONDS', 'SEGMENT', 'SELF', 'SEND', 'SOURCES', 'STATEMENT',
|
| 162 |
+
'STEP', 'STRONG', 'SUB-QUEUE-1', 'SUB-QUEUE-2', 'SUB-QUEUE-3',
|
| 163 |
+
'SUPER', 'SYMBOL', 'SYSTEM-DEFAULT', 'TABLE', 'TERMINAL', 'TEXT',
|
| 164 |
+
'TYPEDEF', 'UCS-4', 'UNIVERSAL', 'USER-DEFAULT', 'UTF-16', 'UTF-8',
|
| 165 |
+
'VAL-STATUS', 'VALID', 'VALIDATE', 'VALIDATE-STATUS'),
|
| 166 |
+
prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'),
|
| 167 |
+
Error),
|
| 168 |
+
|
| 169 |
+
# Data Types
|
| 170 |
+
(r'(^|(?<=[^\w\-]))'
|
| 171 |
+
r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|'
|
| 172 |
+
r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|'
|
| 173 |
+
r'BINARY-C-LONG|'
|
| 174 |
+
r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|'
|
| 175 |
+
r'BINARY)\s*($|(?=[^\w\-]))', Keyword.Type),
|
| 176 |
+
|
| 177 |
+
# Operators
|
| 178 |
+
(r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator),
|
| 179 |
+
|
| 180 |
+
# (r'(::)', Keyword.Declaration),
|
| 181 |
+
|
| 182 |
+
(r'([(),;:&%.])', Punctuation),
|
| 183 |
+
|
| 184 |
+
# Intrinsics
|
| 185 |
+
(r'(^|(?<=[^\w\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|'
|
| 186 |
+
r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|'
|
| 187 |
+
r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|'
|
| 188 |
+
r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|'
|
| 189 |
+
r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|'
|
| 190 |
+
r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG(?:10)?|'
|
| 191 |
+
r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|'
|
| 192 |
+
r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|'
|
| 193 |
+
r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|'
|
| 194 |
+
r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|'
|
| 195 |
+
r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|'
|
| 196 |
+
r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*'
|
| 197 |
+
r'($|(?=[^\w\-]))', Name.Function),
|
| 198 |
+
|
| 199 |
+
# Booleans
|
| 200 |
+
(r'(^|(?<=[^\w\-]))(true|false)\s*($|(?=[^\w\-]))', Name.Builtin),
|
| 201 |
+
# Comparing Operators
|
| 202 |
+
(r'(^|(?<=[^\w\-]))(equal|equals|ne|lt|le|gt|ge|'
|
| 203 |
+
r'greater|less|than|not|and|or)\s*($|(?=[^\w\-]))', Operator.Word),
|
| 204 |
+
],
|
| 205 |
+
|
| 206 |
+
# \"[^\"\n]*\"|\'[^\'\n]*\'
|
| 207 |
+
'strings': [
|
| 208 |
+
# apparently strings can be delimited by EOL if they are continued
|
| 209 |
+
# in the next line
|
| 210 |
+
(r'"[^"\n]*("|\n)', String.Double),
|
| 211 |
+
(r"'[^'\n]*('|\n)", String.Single),
|
| 212 |
+
],
|
| 213 |
+
|
| 214 |
+
'nums': [
|
| 215 |
+
(r'\d+(\s*|\.$|$)', Number.Integer),
|
| 216 |
+
(r'[+-]?\d*\.\d+(E[-+]?\d+)?', Number.Float),
|
| 217 |
+
(r'[+-]?\d+\.\d*(E[-+]?\d+)?', Number.Float),
|
| 218 |
+
],
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
class CobolFreeformatLexer(CobolLexer):
|
| 223 |
+
"""
|
| 224 |
+
Lexer for Free format OpenCOBOL code.
|
| 225 |
+
"""
|
| 226 |
+
name = 'COBOLFree'
|
| 227 |
+
aliases = ['cobolfree']
|
| 228 |
+
filenames = ['*.cbl', '*.CBL']
|
| 229 |
+
mimetypes = []
|
| 230 |
+
url = 'https://opencobol.add1tocobol.com'
|
| 231 |
+
version_added = '1.6'
|
| 232 |
+
|
| 233 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 234 |
+
|
| 235 |
+
tokens = {
|
| 236 |
+
'comment': [
|
| 237 |
+
(r'(\*>.*\n|^\w*\*.*$)', Comment),
|
| 238 |
+
],
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
class ABAPLexer(RegexLexer):
|
| 243 |
+
"""
|
| 244 |
+
Lexer for ABAP, SAP's integrated language.
|
| 245 |
+
"""
|
| 246 |
+
name = 'ABAP'
|
| 247 |
+
aliases = ['abap']
|
| 248 |
+
filenames = ['*.abap', '*.ABAP']
|
| 249 |
+
mimetypes = ['text/x-abap']
|
| 250 |
+
url = 'https://community.sap.com/topics/abap'
|
| 251 |
+
version_added = '1.1'
|
| 252 |
+
|
| 253 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 254 |
+
|
| 255 |
+
tokens = {
|
| 256 |
+
'common': [
|
| 257 |
+
(r'\s+', Whitespace),
|
| 258 |
+
(r'^\*.*$', Comment.Single),
|
| 259 |
+
(r'\".*?\n', Comment.Single),
|
| 260 |
+
(r'##\w+', Comment.Special),
|
| 261 |
+
],
|
| 262 |
+
'variable-names': [
|
| 263 |
+
(r'<\S+>', Name.Variable),
|
| 264 |
+
(r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable),
|
| 265 |
+
],
|
| 266 |
+
'root': [
|
| 267 |
+
include('common'),
|
| 268 |
+
# function calls
|
| 269 |
+
(r'CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION)',
|
| 270 |
+
Keyword),
|
| 271 |
+
(r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|'
|
| 272 |
+
r'TRANSACTION|TRANSFORMATION))\b',
|
| 273 |
+
Keyword),
|
| 274 |
+
(r'(FORM|PERFORM)(\s+)(\w+)',
|
| 275 |
+
bygroups(Keyword, Whitespace, Name.Function)),
|
| 276 |
+
(r'(PERFORM)(\s+)(\()(\w+)(\))',
|
| 277 |
+
bygroups(Keyword, Whitespace, Punctuation, Name.Variable, Punctuation)),
|
| 278 |
+
(r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)',
|
| 279 |
+
bygroups(Keyword, Whitespace, Name.Function, Whitespace, Keyword)),
|
| 280 |
+
|
| 281 |
+
# method implementation
|
| 282 |
+
(r'(METHOD)(\s+)([\w~]+)',
|
| 283 |
+
bygroups(Keyword, Whitespace, Name.Function)),
|
| 284 |
+
# method calls
|
| 285 |
+
(r'(\s+)([\w\-]+)([=\-]>)([\w\-~]+)',
|
| 286 |
+
bygroups(Whitespace, Name.Variable, Operator, Name.Function)),
|
| 287 |
+
# call methodnames returning style
|
| 288 |
+
(r'(?<=(=|-)>)([\w\-~]+)(?=\()', Name.Function),
|
| 289 |
+
|
| 290 |
+
# text elements
|
| 291 |
+
(r'(TEXT)(-)(\d{3})',
|
| 292 |
+
bygroups(Keyword, Punctuation, Number.Integer)),
|
| 293 |
+
(r'(TEXT)(-)(\w{3})',
|
| 294 |
+
bygroups(Keyword, Punctuation, Name.Variable)),
|
| 295 |
+
|
| 296 |
+
# keywords with dashes in them.
|
| 297 |
+
# these need to be first, because for instance the -ID part
|
| 298 |
+
# of MESSAGE-ID wouldn't get highlighted if MESSAGE was
|
| 299 |
+
# first in the list of keywords.
|
| 300 |
+
(r'(ADD-CORRESPONDING|AUTHORITY-CHECK|'
|
| 301 |
+
r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|'
|
| 302 |
+
r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|'
|
| 303 |
+
r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|'
|
| 304 |
+
r'FIELD-GROUPS|FIELD-SYMBOLS|FIELD-SYMBOL|FUNCTION-POOL|'
|
| 305 |
+
r'INTERFACE-POOL|INVERTED-DATE|'
|
| 306 |
+
r'LOAD-OF-PROGRAM|LOG-POINT|'
|
| 307 |
+
r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|'
|
| 308 |
+
r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|'
|
| 309 |
+
r'OUTPUT-LENGTH|PRINT-CONTROL|'
|
| 310 |
+
r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|'
|
| 311 |
+
r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|'
|
| 312 |
+
r'TYPE-POOL|TYPE-POOLS|NO-DISPLAY'
|
| 313 |
+
r')\b', Keyword),
|
| 314 |
+
|
| 315 |
+
# keyword kombinations
|
| 316 |
+
(r'(?<![-\>])(CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|'
|
| 317 |
+
r'(PUBLIC|PRIVATE|PROTECTED)\s+SECTION|'
|
| 318 |
+
r'(TYPE|LIKE)\s+((LINE\s+OF|REF\s+TO|'
|
| 319 |
+
r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|'
|
| 320 |
+
r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|'
|
| 321 |
+
r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|'
|
| 322 |
+
r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|'
|
| 323 |
+
r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|'
|
| 324 |
+
r'RUN\s+TIME|TIME\s+(STAMP)?)?|'
|
| 325 |
+
r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|'
|
| 326 |
+
r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|'
|
| 327 |
+
r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|'
|
| 328 |
+
r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|'
|
| 329 |
+
r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|'
|
| 330 |
+
r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|'
|
| 331 |
+
r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|'
|
| 332 |
+
r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|'
|
| 333 |
+
r'DATABASE|SHARED\s+(MEMORY|BUFFER))|'
|
| 334 |
+
r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|'
|
| 335 |
+
r'FREE\s(MEMORY|OBJECT)?|'
|
| 336 |
+
r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|'
|
| 337 |
+
r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|'
|
| 338 |
+
r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|'
|
| 339 |
+
r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|'
|
| 340 |
+
r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|'
|
| 341 |
+
r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|'
|
| 342 |
+
r'SCREEN)|COMMENT|FUNCTION\s+KEY|'
|
| 343 |
+
r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|'
|
| 344 |
+
r'SKIP|ULINE)|'
|
| 345 |
+
r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|'
|
| 346 |
+
r'TO LIST-PROCESSING|TO TRANSACTION)'
|
| 347 |
+
r'(ENDING|STARTING)\s+AT|'
|
| 348 |
+
r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|'
|
| 349 |
+
r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|'
|
| 350 |
+
r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|'
|
| 351 |
+
r'(BEGIN|END)\s+OF|'
|
| 352 |
+
r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|'
|
| 353 |
+
r'COMPARING(\s+ALL\s+FIELDS)?|'
|
| 354 |
+
r'(INSERT|APPEND)(\s+INITIAL\s+LINE\s+(IN)?TO|\s+LINES\s+OF)?|'
|
| 355 |
+
r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|'
|
| 356 |
+
r'END-OF-(DEFINITION|PAGE|SELECTION)|'
|
| 357 |
+
r'WITH\s+FRAME(\s+TITLE)|'
|
| 358 |
+
r'(REPLACE|FIND)\s+((FIRST|ALL)\s+OCCURRENCES?\s+OF\s+)?(SUBSTRING|REGEX)?|'
|
| 359 |
+
r'MATCH\s+(LENGTH|COUNT|LINE|OFFSET)|'
|
| 360 |
+
r'(RESPECTING|IGNORING)\s+CASE|'
|
| 361 |
+
r'IN\s+UPDATE\s+TASK|'
|
| 362 |
+
r'(SOURCE|RESULT)\s+(XML)?|'
|
| 363 |
+
r'REFERENCE\s+INTO|'
|
| 364 |
+
|
| 365 |
+
# simple kombinations
|
| 366 |
+
r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|'
|
| 367 |
+
r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|'
|
| 368 |
+
r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|'
|
| 369 |
+
r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|'
|
| 370 |
+
r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|'
|
| 371 |
+
r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|'
|
| 372 |
+
r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE|COMMON\s+PART)\b', Keyword),
|
| 373 |
+
|
| 374 |
+
# single word keywords.
|
| 375 |
+
(r'(^|(?<=(\s|\.)))(ABBREVIATED|ABSTRACT|ADD|ALIASES|ALIGN|ALPHA|'
|
| 376 |
+
r'ASSERT|AS|ASSIGN(ING)?|AT(\s+FIRST)?|'
|
| 377 |
+
r'BACK|BLOCK|BREAK-POINT|'
|
| 378 |
+
r'CASE|CAST|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|COND|CONV|'
|
| 379 |
+
r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|'
|
| 380 |
+
r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|COUNTRY|CURRENCY|'
|
| 381 |
+
r'DATA|DATE|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|'
|
| 382 |
+
r'DETAIL|DIRECTORY|DIVIDE|DO|DUMMY|'
|
| 383 |
+
r'ELSE(IF)?|ENDAT|ENDCASE|ENDCATCH|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|'
|
| 384 |
+
r'ENDIF|ENDINTERFACE|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|ENDWHILE|'
|
| 385 |
+
r'ENHANCEMENT|EVENTS|EXACT|EXCEPTIONS?|EXIT|EXPONENT|EXPORT|EXPORTING|EXTRACT|'
|
| 386 |
+
r'FETCH|FIELDS?|FOR|FORM|FORMAT|FREE|FROM|FUNCTION|'
|
| 387 |
+
r'HIDE|'
|
| 388 |
+
r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|'
|
| 389 |
+
r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|'
|
| 390 |
+
r'LANGUAGE|LEAVE|LENGTH|LINES|LOAD|LOCAL|'
|
| 391 |
+
r'JOIN|'
|
| 392 |
+
r'KEY|'
|
| 393 |
+
r'NEW|NEXT|'
|
| 394 |
+
r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFIER|MODIFY|MOVE|MULTIPLY|'
|
| 395 |
+
r'NODES|NUMBER|'
|
| 396 |
+
r'OBLIGATORY|OBJECT|OF|OFF|ON|OTHERS|OVERLAY|'
|
| 397 |
+
r'PACK|PAD|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|PF\d\d|'
|
| 398 |
+
r'RAISE|RAISING|RANGES?|READ|RECEIVE|REDEFINITION|REFRESH|REJECT|REPORT|RESERVE|'
|
| 399 |
+
r'REF|RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|REPLACE|'
|
| 400 |
+
r'SCROLL|SEARCH|SELECT|SHIFT|SIGN|SINGLE|SIZE|SKIP|SORT|SPLIT|STATICS|STOP|'
|
| 401 |
+
r'STYLE|SUBMATCHES|SUBMIT|SUBTRACT|SUM(?!\()|SUMMARY|SUMMING|SUPPLY|SWITCH|'
|
| 402 |
+
r'TABLE|TABLES|TIMESTAMP|TIMES?|TIMEZONE|TITLE|\??TO|'
|
| 403 |
+
r'TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|'
|
| 404 |
+
r'ULINE|UNDER|UNPACK|UPDATE|USING|'
|
| 405 |
+
r'VALUE|VALUES|VIA|VARYING|VARY|'
|
| 406 |
+
r'WAIT|WHEN|WHERE|WIDTH|WHILE|WITH|WINDOW|WRITE|XSD|ZERO)\b', Keyword),
|
| 407 |
+
|
| 408 |
+
# builtins
|
| 409 |
+
(r'(abs|acos|asin|atan|'
|
| 410 |
+
r'boolc|boolx|bit_set|'
|
| 411 |
+
r'char_off|charlen|ceil|cmax|cmin|condense|contains|'
|
| 412 |
+
r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|'
|
| 413 |
+
r'count|count_any_of|count_any_not_of|'
|
| 414 |
+
r'dbmaxlen|distance|'
|
| 415 |
+
r'escape|exp|'
|
| 416 |
+
r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|'
|
| 417 |
+
r'insert|'
|
| 418 |
+
r'lines|log|log10|'
|
| 419 |
+
r'match|matches|'
|
| 420 |
+
r'nmax|nmin|numofchar|'
|
| 421 |
+
r'repeat|replace|rescale|reverse|round|'
|
| 422 |
+
r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|'
|
| 423 |
+
r'substring|substring_after|substring_from|substring_before|substring_to|'
|
| 424 |
+
r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|'
|
| 425 |
+
r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)),
|
| 426 |
+
|
| 427 |
+
(r'&[0-9]', Name),
|
| 428 |
+
(r'[0-9]+', Number.Integer),
|
| 429 |
+
|
| 430 |
+
# operators which look like variable names before
|
| 431 |
+
# parsing variable names.
|
| 432 |
+
(r'(?<=(\s|.))(AND|OR|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|'
|
| 433 |
+
r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|'
|
| 434 |
+
r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator.Word),
|
| 435 |
+
|
| 436 |
+
include('variable-names'),
|
| 437 |
+
|
| 438 |
+
# standard operators after variable names,
|
| 439 |
+
# because < and > are part of field symbols.
|
| 440 |
+
(r'[?*<>=\-+&]', Operator),
|
| 441 |
+
(r"'(''|[^'])*'", String.Single),
|
| 442 |
+
(r"`([^`])*`", String.Single),
|
| 443 |
+
(r"([|}])([^{}|]*?)([|{])",
|
| 444 |
+
bygroups(Punctuation, String.Single, Punctuation)),
|
| 445 |
+
(r'[/;:()\[\],.]', Punctuation),
|
| 446 |
+
(r'(!)(\w+)', bygroups(Operator, Name)),
|
| 447 |
+
],
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
class OpenEdgeLexer(RegexLexer):
|
| 452 |
+
"""
|
| 453 |
+
Lexer for OpenEdge ABL (formerly Progress) source code.
|
| 454 |
+
"""
|
| 455 |
+
name = 'OpenEdge ABL'
|
| 456 |
+
aliases = ['openedge', 'abl', 'progress']
|
| 457 |
+
filenames = ['*.p', '*.cls']
|
| 458 |
+
mimetypes = ['text/x-openedge', 'application/x-openedge']
|
| 459 |
+
url = 'https://www.progress.com/openedge/features/abl'
|
| 460 |
+
version_added = '1.5'
|
| 461 |
+
|
| 462 |
+
types = (r'(?i)(^|(?<=[^\w\-]))(CHARACTER|CHAR|CHARA|CHARAC|CHARACT|CHARACTE|'
|
| 463 |
+
r'COM-HANDLE|DATE|DATETIME|DATETIME-TZ|'
|
| 464 |
+
r'DECIMAL|DEC|DECI|DECIM|DECIMA|HANDLE|'
|
| 465 |
+
r'INT64|INTEGER|INT|INTE|INTEG|INTEGE|'
|
| 466 |
+
r'LOGICAL|LONGCHAR|MEMPTR|RAW|RECID|ROWID)\s*($|(?=[^\w\-]))')
|
| 467 |
+
|
| 468 |
+
keywords = words(OPENEDGEKEYWORDS,
|
| 469 |
+
prefix=r'(?i)(^|(?<=[^\w\-]))',
|
| 470 |
+
suffix=r'\s*($|(?=[^\w\-]))')
|
| 471 |
+
|
| 472 |
+
tokens = {
|
| 473 |
+
'root': [
|
| 474 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 475 |
+
(r'\{', Comment.Preproc, 'preprocessor'),
|
| 476 |
+
(r'\s*&.*', Comment.Preproc),
|
| 477 |
+
(r'0[xX][0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 478 |
+
(r'(?i)(DEFINE|DEF|DEFI|DEFIN)\b', Keyword.Declaration),
|
| 479 |
+
(types, Keyword.Type),
|
| 480 |
+
(keywords, Name.Builtin),
|
| 481 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 482 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 483 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 484 |
+
(r'[0-9]+', Number.Integer),
|
| 485 |
+
(r'\s+', Whitespace),
|
| 486 |
+
(r'[+*/=-]', Operator),
|
| 487 |
+
(r'[.:()]', Punctuation),
|
| 488 |
+
(r'.', Name.Variable), # Lazy catch-all
|
| 489 |
+
],
|
| 490 |
+
'comment': [
|
| 491 |
+
(r'[^*/]', Comment.Multiline),
|
| 492 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 493 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 494 |
+
(r'[*/]', Comment.Multiline)
|
| 495 |
+
],
|
| 496 |
+
'preprocessor': [
|
| 497 |
+
(r'[^{}]', Comment.Preproc),
|
| 498 |
+
(r'\{', Comment.Preproc, '#push'),
|
| 499 |
+
(r'\}', Comment.Preproc, '#pop'),
|
| 500 |
+
],
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
def analyse_text(text):
|
| 504 |
+
"""Try to identify OpenEdge ABL based on a few common constructs."""
|
| 505 |
+
result = 0
|
| 506 |
+
|
| 507 |
+
if 'END.' in text:
|
| 508 |
+
result += 0.05
|
| 509 |
+
|
| 510 |
+
if 'END PROCEDURE.' in text:
|
| 511 |
+
result += 0.05
|
| 512 |
+
|
| 513 |
+
if 'ELSE DO:' in text:
|
| 514 |
+
result += 0.05
|
| 515 |
+
|
| 516 |
+
return result
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
class GoodDataCLLexer(RegexLexer):
|
| 520 |
+
"""
|
| 521 |
+
Lexer for GoodData-CL script files.
|
| 522 |
+
"""
|
| 523 |
+
|
| 524 |
+
name = 'GoodData-CL'
|
| 525 |
+
aliases = ['gooddata-cl']
|
| 526 |
+
filenames = ['*.gdc']
|
| 527 |
+
mimetypes = ['text/x-gooddata-cl']
|
| 528 |
+
url = 'https://github.com/gooddata/GoodData-CL'
|
| 529 |
+
version_added = '1.4'
|
| 530 |
+
|
| 531 |
+
flags = re.IGNORECASE
|
| 532 |
+
|
| 533 |
+
# Syntax:
|
| 534 |
+
# https://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt
|
| 535 |
+
tokens = {
|
| 536 |
+
'root': [
|
| 537 |
+
# Comments
|
| 538 |
+
(r'#.*', Comment.Single),
|
| 539 |
+
# Function call
|
| 540 |
+
(r'[a-z]\w*', Name.Function),
|
| 541 |
+
# Argument list
|
| 542 |
+
(r'\(', Punctuation, 'args-list'),
|
| 543 |
+
# Punctuation
|
| 544 |
+
(r';', Punctuation),
|
| 545 |
+
# Space is not significant
|
| 546 |
+
(r'\s+', Text)
|
| 547 |
+
],
|
| 548 |
+
'args-list': [
|
| 549 |
+
(r'\)', Punctuation, '#pop'),
|
| 550 |
+
(r',', Punctuation),
|
| 551 |
+
(r'[a-z]\w*', Name.Variable),
|
| 552 |
+
(r'=', Operator),
|
| 553 |
+
(r'"', String, 'string-literal'),
|
| 554 |
+
(r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number),
|
| 555 |
+
# Space is not significant
|
| 556 |
+
(r'\s', Whitespace)
|
| 557 |
+
],
|
| 558 |
+
'string-literal': [
|
| 559 |
+
(r'\\[tnrfbae"\\]', String.Escape),
|
| 560 |
+
(r'"', String, '#pop'),
|
| 561 |
+
(r'[^\\"]+', String)
|
| 562 |
+
]
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
class MaqlLexer(RegexLexer):
|
| 567 |
+
"""
|
| 568 |
+
Lexer for GoodData MAQL scripts.
|
| 569 |
+
"""
|
| 570 |
+
|
| 571 |
+
name = 'MAQL'
|
| 572 |
+
aliases = ['maql']
|
| 573 |
+
filenames = ['*.maql']
|
| 574 |
+
mimetypes = ['text/x-gooddata-maql', 'application/x-gooddata-maql']
|
| 575 |
+
url = 'https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/maql-analytical-query-language'
|
| 576 |
+
version_added = '1.4'
|
| 577 |
+
|
| 578 |
+
flags = re.IGNORECASE
|
| 579 |
+
tokens = {
|
| 580 |
+
'root': [
|
| 581 |
+
# IDENTITY
|
| 582 |
+
(r'IDENTIFIER\b', Name.Builtin),
|
| 583 |
+
# IDENTIFIER
|
| 584 |
+
(r'\{[^}]+\}', Name.Variable),
|
| 585 |
+
# NUMBER
|
| 586 |
+
(r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number),
|
| 587 |
+
# STRING
|
| 588 |
+
(r'"', String, 'string-literal'),
|
| 589 |
+
# RELATION
|
| 590 |
+
(r'\<\>|\!\=', Operator),
|
| 591 |
+
(r'\=|\>\=|\>|\<\=|\<', Operator),
|
| 592 |
+
# :=
|
| 593 |
+
(r'\:\=', Operator),
|
| 594 |
+
# OBJECT
|
| 595 |
+
(r'\[[^]]+\]', Name.Variable.Class),
|
| 596 |
+
# keywords
|
| 597 |
+
(words((
|
| 598 |
+
'DIMENSION', 'DIMENSIONS', 'BOTTOM', 'METRIC', 'COUNT', 'OTHER',
|
| 599 |
+
'FACT', 'WITH', 'TOP', 'OR', 'ATTRIBUTE', 'CREATE', 'PARENT',
|
| 600 |
+
'FALSE', 'ROW', 'ROWS', 'FROM', 'ALL', 'AS', 'PF', 'COLUMN',
|
| 601 |
+
'COLUMNS', 'DEFINE', 'REPORT', 'LIMIT', 'TABLE', 'LIKE', 'AND',
|
| 602 |
+
'BY', 'BETWEEN', 'EXCEPT', 'SELECT', 'MATCH', 'WHERE', 'TRUE',
|
| 603 |
+
'FOR', 'IN', 'WITHOUT', 'FILTER', 'ALIAS', 'WHEN', 'NOT', 'ON',
|
| 604 |
+
'KEYS', 'KEY', 'FULLSET', 'PRIMARY', 'LABELS', 'LABEL',
|
| 605 |
+
'VISUAL', 'TITLE', 'DESCRIPTION', 'FOLDER', 'ALTER', 'DROP',
|
| 606 |
+
'ADD', 'DATASET', 'DATATYPE', 'INT', 'BIGINT', 'DOUBLE', 'DATE',
|
| 607 |
+
'VARCHAR', 'DECIMAL', 'SYNCHRONIZE', 'TYPE', 'DEFAULT', 'ORDER',
|
| 608 |
+
'ASC', 'DESC', 'HYPERLINK', 'INCLUDE', 'TEMPLATE', 'MODIFY'),
|
| 609 |
+
suffix=r'\b'),
|
| 610 |
+
Keyword),
|
| 611 |
+
# FUNCNAME
|
| 612 |
+
(r'[a-z]\w*\b', Name.Function),
|
| 613 |
+
# Comments
|
| 614 |
+
(r'#.*', Comment.Single),
|
| 615 |
+
# Punctuation
|
| 616 |
+
(r'[,;()]', Punctuation),
|
| 617 |
+
# Space is not significant
|
| 618 |
+
(r'\s+', Whitespace)
|
| 619 |
+
],
|
| 620 |
+
'string-literal': [
|
| 621 |
+
(r'\\[tnrfbae"\\]', String.Escape),
|
| 622 |
+
(r'"', String, '#pop'),
|
| 623 |
+
(r'[^\\"]+', String)
|
| 624 |
+
],
|
| 625 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/c_cpp.py
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.c_cpp
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for C/C++ languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, using, \
|
| 14 |
+
this, inherit, default, words
|
| 15 |
+
from pygments.util import get_bool_opt
|
| 16 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 17 |
+
Number, Punctuation, Whitespace
|
| 18 |
+
|
| 19 |
+
__all__ = ['CLexer', 'CppLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class CFamilyLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For C family source code. This is used as a base class to avoid repetitious
|
| 25 |
+
definitions.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
# The trailing ?, rather than *, avoids a geometric performance drop here.
|
| 29 |
+
#: only one /* */ style comment
|
| 30 |
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)?'
|
| 31 |
+
|
| 32 |
+
# Hexadecimal part in an hexadecimal integer/floating-point literal.
|
| 33 |
+
# This includes decimal separators matching.
|
| 34 |
+
_hexpart = r'[0-9a-fA-F](\'?[0-9a-fA-F])*'
|
| 35 |
+
# Decimal part in an decimal integer/floating-point literal.
|
| 36 |
+
# This includes decimal separators matching.
|
| 37 |
+
_decpart = r'\d(\'?\d)*'
|
| 38 |
+
# Integer literal suffix (e.g. 'ull' or 'll').
|
| 39 |
+
_intsuffix = r'(([uU]?[zZ])|([zZ][uU])|([uU][lL]{0,2})|([lL]{1,2}[uU]?))?'
|
| 40 |
+
|
| 41 |
+
# Identifier regex with C and C++ Universal Character Name (UCN) support.
|
| 42 |
+
_ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})+'
|
| 43 |
+
_namespaced_ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|::)+'
|
| 44 |
+
|
| 45 |
+
# Single and multiline comment regexes
|
| 46 |
+
# Beware not to use *? for the inner content! When these regexes
|
| 47 |
+
# are embedded in larger regexes, that can cause the stuff*? to
|
| 48 |
+
# match more than it would have if the regex had been used in
|
| 49 |
+
# a standalone way ...
|
| 50 |
+
_comment_single = r'//(?:.|(?<=\\)\n)*\n'
|
| 51 |
+
_comment_multiline = r'/(?:\\\n)?[*](?:[^*]|[*](?!(?:\\\n)?/))*[*](?:\\\n)?/'
|
| 52 |
+
|
| 53 |
+
# Regex to match optional comments
|
| 54 |
+
_possible_comments = rf'\s*(?:(?:(?:{_comment_single})|(?:{_comment_multiline}))\s*)*'
|
| 55 |
+
|
| 56 |
+
tokens = {
|
| 57 |
+
'whitespace': [
|
| 58 |
+
# preprocessor directives: without whitespace
|
| 59 |
+
(r'^#if\s+0', Comment.Preproc, 'if0'),
|
| 60 |
+
('^#', Comment.Preproc, 'macro'),
|
| 61 |
+
# or with whitespace
|
| 62 |
+
('^(' + _ws1 + r')(#if\s+0)',
|
| 63 |
+
bygroups(using(this), Comment.Preproc), 'if0'),
|
| 64 |
+
('^(' + _ws1 + ')(#)',
|
| 65 |
+
bygroups(using(this), Comment.Preproc), 'macro'),
|
| 66 |
+
# Labels:
|
| 67 |
+
# Line start and possible indentation.
|
| 68 |
+
(r'(^[ \t]*)'
|
| 69 |
+
# Not followed by keywords which can be mistaken as labels.
|
| 70 |
+
r'(?!(?:public|private|protected|default)\b)'
|
| 71 |
+
# Actual label, followed by a single colon.
|
| 72 |
+
r'(' + _ident + r')(\s*)(:)(?!:)',
|
| 73 |
+
bygroups(Whitespace, Name.Label, Whitespace, Punctuation)),
|
| 74 |
+
(r'\n', Whitespace),
|
| 75 |
+
(r'[^\S\n]+', Whitespace),
|
| 76 |
+
(r'\\\n', Text), # line continuation
|
| 77 |
+
(_comment_single, Comment.Single),
|
| 78 |
+
(_comment_multiline, Comment.Multiline),
|
| 79 |
+
# Open until EOF, so no ending delimiter
|
| 80 |
+
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline),
|
| 81 |
+
],
|
| 82 |
+
'statements': [
|
| 83 |
+
include('keywords'),
|
| 84 |
+
include('types'),
|
| 85 |
+
(r'([LuU]|u8)?(")', bygroups(String.Affix, String), 'string'),
|
| 86 |
+
(r"([LuU]|u8)?(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')",
|
| 87 |
+
bygroups(String.Affix, String.Char, String.Char, String.Char)),
|
| 88 |
+
|
| 89 |
+
# Hexadecimal floating-point literals (C11, C++17)
|
| 90 |
+
(r'0[xX](' + _hexpart + r'\.' + _hexpart + r'|\.' + _hexpart +
|
| 91 |
+
r'|' + _hexpart + r')[pP][+-]?' + _hexpart + r'[lL]?', Number.Float),
|
| 92 |
+
|
| 93 |
+
(r'(-)?(' + _decpart + r'\.' + _decpart + r'|\.' + _decpart + r'|' +
|
| 94 |
+
_decpart + r')[eE][+-]?' + _decpart + r'[fFlL]?', Number.Float),
|
| 95 |
+
(r'(-)?((' + _decpart + r'\.(' + _decpart + r')?|\.' +
|
| 96 |
+
_decpart + r')[fFlL]?)|(' + _decpart + r'[fFlL])', Number.Float),
|
| 97 |
+
(r'(-)?0[xX]' + _hexpart + _intsuffix, Number.Hex),
|
| 98 |
+
(r'(-)?0[bB][01](\'?[01])*' + _intsuffix, Number.Bin),
|
| 99 |
+
(r'(-)?0(\'?[0-7])+' + _intsuffix, Number.Oct),
|
| 100 |
+
(r'(-)?' + _decpart + _intsuffix, Number.Integer),
|
| 101 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 102 |
+
(r'[()\[\],.]', Punctuation),
|
| 103 |
+
(r'(true|false|NULL|nullptr)\b', Name.Builtin),
|
| 104 |
+
(_ident, Name)
|
| 105 |
+
],
|
| 106 |
+
'types': [
|
| 107 |
+
(words(('int8', 'int16', 'int32', 'int64', 'wchar_t'), prefix=r'__',
|
| 108 |
+
suffix=r'\b'), Keyword.Reserved),
|
| 109 |
+
(words(('bool', 'int', 'long', 'float', 'short', 'double', 'char',
|
| 110 |
+
'unsigned', 'signed', 'void', '_BitInt',
|
| 111 |
+
'__int128'), suffix=r'\b'), Keyword.Type)
|
| 112 |
+
],
|
| 113 |
+
'keywords': [
|
| 114 |
+
(r'(struct|union)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 115 |
+
(r'case\b', Keyword, 'case-value'),
|
| 116 |
+
(words(('asm', 'auto', 'break', 'const', 'constexpr', 'continue', 'default',
|
| 117 |
+
'do', 'else', 'enum', 'extern', 'for', 'goto', 'if', 'register',
|
| 118 |
+
'restricted', 'return', 'sizeof', 'struct', 'static', 'switch',
|
| 119 |
+
'typedef', 'typeof', 'typeof_unqual', 'volatile', 'while', 'union',
|
| 120 |
+
'thread_local', 'alignas', 'alignof', 'static_assert', '_Pragma', 'fortran'),
|
| 121 |
+
suffix=r'\b'), Keyword),
|
| 122 |
+
(words(('inline', '_inline', '__inline', 'naked', 'restrict',
|
| 123 |
+
'thread'), suffix=r'\b'), Keyword.Reserved),
|
| 124 |
+
# Vector intrinsics
|
| 125 |
+
(r'(__m(128i|128d|128|64))\b', Keyword.Reserved),
|
| 126 |
+
# Microsoft-isms
|
| 127 |
+
(words((
|
| 128 |
+
'asm', 'based', 'except', 'stdcall', 'cdecl',
|
| 129 |
+
'fastcall', 'declspec', 'finally', 'try',
|
| 130 |
+
'leave', 'w64', 'unaligned', 'raise', 'noop',
|
| 131 |
+
'identifier', 'forceinline', 'assume', 'null'),
|
| 132 |
+
prefix=r'__', suffix=r'\b'), Keyword.Reserved)
|
| 133 |
+
],
|
| 134 |
+
'root': [
|
| 135 |
+
include('whitespace'),
|
| 136 |
+
include('keywords'),
|
| 137 |
+
# functions
|
| 138 |
+
(r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments
|
| 139 |
+
r'(' + _possible_comments + r')'
|
| 140 |
+
r'(' + _namespaced_ident + r')' # method name
|
| 141 |
+
r'(' + _possible_comments + r')'
|
| 142 |
+
r'(\([^;"\')]*?\))' # signature
|
| 143 |
+
r'(' + _possible_comments + r')'
|
| 144 |
+
r'([^;{/"\']*)(\{)',
|
| 145 |
+
bygroups(using(this), using(this, state='whitespace'),
|
| 146 |
+
Name.Function, using(this, state='whitespace'),
|
| 147 |
+
using(this), using(this, state='whitespace'),
|
| 148 |
+
using(this), Punctuation),
|
| 149 |
+
'function'),
|
| 150 |
+
# function declarations
|
| 151 |
+
(r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments
|
| 152 |
+
r'(' + _possible_comments + r')'
|
| 153 |
+
r'(' + _namespaced_ident + r')' # method name
|
| 154 |
+
r'(' + _possible_comments + r')'
|
| 155 |
+
r'(\([^;"\')]*?\))' # signature
|
| 156 |
+
r'(' + _possible_comments + r')'
|
| 157 |
+
r'([^;/"\']*)(;)',
|
| 158 |
+
bygroups(using(this), using(this, state='whitespace'),
|
| 159 |
+
Name.Function, using(this, state='whitespace'),
|
| 160 |
+
using(this), using(this, state='whitespace'),
|
| 161 |
+
using(this), Punctuation)),
|
| 162 |
+
include('types'),
|
| 163 |
+
default('statement'),
|
| 164 |
+
],
|
| 165 |
+
'statement': [
|
| 166 |
+
include('whitespace'),
|
| 167 |
+
include('statements'),
|
| 168 |
+
(r'\}', Punctuation),
|
| 169 |
+
(r'[{;]', Punctuation, '#pop'),
|
| 170 |
+
],
|
| 171 |
+
'function': [
|
| 172 |
+
include('whitespace'),
|
| 173 |
+
include('statements'),
|
| 174 |
+
(';', Punctuation),
|
| 175 |
+
(r'\{', Punctuation, '#push'),
|
| 176 |
+
(r'\}', Punctuation, '#pop'),
|
| 177 |
+
],
|
| 178 |
+
'string': [
|
| 179 |
+
(r'"', String, '#pop'),
|
| 180 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
| 181 |
+
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
| 182 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 183 |
+
(r'\\\n', String), # line continuation
|
| 184 |
+
(r'\\', String), # stray backslash
|
| 185 |
+
],
|
| 186 |
+
'macro': [
|
| 187 |
+
(r'('+_ws1+r')(include)('+_ws1+r')("[^"]+")([^\n]*)',
|
| 188 |
+
bygroups(using(this), Comment.Preproc, using(this),
|
| 189 |
+
Comment.PreprocFile, Comment.Single)),
|
| 190 |
+
(r'('+_ws1+r')(include)('+_ws1+r')(<[^>]+>)([^\n]*)',
|
| 191 |
+
bygroups(using(this), Comment.Preproc, using(this),
|
| 192 |
+
Comment.PreprocFile, Comment.Single)),
|
| 193 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 194 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 195 |
+
(r'//.*?\n', Comment.Single, '#pop'),
|
| 196 |
+
(r'/', Comment.Preproc),
|
| 197 |
+
(r'(?<=\\)\n', Comment.Preproc),
|
| 198 |
+
(r'\n', Comment.Preproc, '#pop'),
|
| 199 |
+
],
|
| 200 |
+
'if0': [
|
| 201 |
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
| 202 |
+
(r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
|
| 203 |
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
| 204 |
+
(r'.*?\n', Comment),
|
| 205 |
+
],
|
| 206 |
+
'classname': [
|
| 207 |
+
(_ident, Name.Class, '#pop'),
|
| 208 |
+
# template specification
|
| 209 |
+
(r'\s*(?=>)', Text, '#pop'),
|
| 210 |
+
default('#pop')
|
| 211 |
+
],
|
| 212 |
+
# Mark identifiers preceded by `case` keyword as constants.
|
| 213 |
+
'case-value': [
|
| 214 |
+
(r'(?<!:)(:)(?!:)', Punctuation, '#pop'),
|
| 215 |
+
(_ident, Name.Constant),
|
| 216 |
+
include('whitespace'),
|
| 217 |
+
include('statements'),
|
| 218 |
+
]
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
stdlib_types = {
|
| 222 |
+
'size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t', 'sig_atomic_t', 'fpos_t',
|
| 223 |
+
'clock_t', 'time_t', 'va_list', 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t',
|
| 224 |
+
'mbstate_t', 'wctrans_t', 'wint_t', 'wctype_t'}
|
| 225 |
+
c99_types = {
|
| 226 |
+
'int8_t', 'int16_t', 'int32_t', 'int64_t', 'uint8_t',
|
| 227 |
+
'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t', 'int_least16_t',
|
| 228 |
+
'int_least32_t', 'int_least64_t', 'uint_least8_t', 'uint_least16_t',
|
| 229 |
+
'uint_least32_t', 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
|
| 230 |
+
'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t', 'uint_fast64_t',
|
| 231 |
+
'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t'}
|
| 232 |
+
linux_types = {
|
| 233 |
+
'clockid_t', 'cpu_set_t', 'cpumask_t', 'dev_t', 'gid_t', 'id_t', 'ino_t', 'key_t',
|
| 234 |
+
'mode_t', 'nfds_t', 'pid_t', 'rlim_t', 'sig_t', 'sighandler_t', 'siginfo_t',
|
| 235 |
+
'sigset_t', 'sigval_t', 'socklen_t', 'timer_t', 'uid_t'}
|
| 236 |
+
c11_atomic_types = {
|
| 237 |
+
'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short',
|
| 238 |
+
'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong',
|
| 239 |
+
'atomic_llong', 'atomic_ullong', 'atomic_char16_t', 'atomic_char32_t', 'atomic_wchar_t',
|
| 240 |
+
'atomic_int_least8_t', 'atomic_uint_least8_t', 'atomic_int_least16_t',
|
| 241 |
+
'atomic_uint_least16_t', 'atomic_int_least32_t', 'atomic_uint_least32_t',
|
| 242 |
+
'atomic_int_least64_t', 'atomic_uint_least64_t', 'atomic_int_fast8_t',
|
| 243 |
+
'atomic_uint_fast8_t', 'atomic_int_fast16_t', 'atomic_uint_fast16_t',
|
| 244 |
+
'atomic_int_fast32_t', 'atomic_uint_fast32_t', 'atomic_int_fast64_t',
|
| 245 |
+
'atomic_uint_fast64_t', 'atomic_intptr_t', 'atomic_uintptr_t', 'atomic_size_t',
|
| 246 |
+
'atomic_ptrdiff_t', 'atomic_intmax_t', 'atomic_uintmax_t'}
|
| 247 |
+
|
| 248 |
+
def __init__(self, **options):
|
| 249 |
+
self.stdlibhighlighting = get_bool_opt(options, 'stdlibhighlighting', True)
|
| 250 |
+
self.c99highlighting = get_bool_opt(options, 'c99highlighting', True)
|
| 251 |
+
self.c11highlighting = get_bool_opt(options, 'c11highlighting', True)
|
| 252 |
+
self.platformhighlighting = get_bool_opt(options, 'platformhighlighting', True)
|
| 253 |
+
RegexLexer.__init__(self, **options)
|
| 254 |
+
|
| 255 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 256 |
+
for index, token, value in \
|
| 257 |
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
| 258 |
+
if token is Name:
|
| 259 |
+
if self.stdlibhighlighting and value in self.stdlib_types:
|
| 260 |
+
token = Keyword.Type
|
| 261 |
+
elif self.c99highlighting and value in self.c99_types:
|
| 262 |
+
token = Keyword.Type
|
| 263 |
+
elif self.c11highlighting and value in self.c11_atomic_types:
|
| 264 |
+
token = Keyword.Type
|
| 265 |
+
elif self.platformhighlighting and value in self.linux_types:
|
| 266 |
+
token = Keyword.Type
|
| 267 |
+
yield index, token, value
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
class CLexer(CFamilyLexer):
|
| 271 |
+
"""
|
| 272 |
+
For C source code with preprocessor directives.
|
| 273 |
+
|
| 274 |
+
Additional options accepted:
|
| 275 |
+
|
| 276 |
+
`stdlibhighlighting`
|
| 277 |
+
Highlight common types found in the C/C++ standard library (e.g. `size_t`).
|
| 278 |
+
(default: ``True``).
|
| 279 |
+
|
| 280 |
+
`c99highlighting`
|
| 281 |
+
Highlight common types found in the C99 standard library (e.g. `int8_t`).
|
| 282 |
+
Actually, this includes all fixed-width integer types.
|
| 283 |
+
(default: ``True``).
|
| 284 |
+
|
| 285 |
+
`c11highlighting`
|
| 286 |
+
Highlight atomic types found in the C11 standard library (e.g. `atomic_bool`).
|
| 287 |
+
(default: ``True``).
|
| 288 |
+
|
| 289 |
+
`platformhighlighting`
|
| 290 |
+
Highlight common types found in the platform SDK headers (e.g. `clockid_t` on Linux).
|
| 291 |
+
(default: ``True``).
|
| 292 |
+
"""
|
| 293 |
+
name = 'C'
|
| 294 |
+
aliases = ['c']
|
| 295 |
+
filenames = ['*.c', '*.h', '*.idc', '*.x[bp]m']
|
| 296 |
+
mimetypes = ['text/x-chdr', 'text/x-csrc', 'image/x-xbitmap', 'image/x-xpixmap']
|
| 297 |
+
url = 'https://en.wikipedia.org/wiki/C_(programming_language)'
|
| 298 |
+
version_added = ''
|
| 299 |
+
priority = 0.1
|
| 300 |
+
|
| 301 |
+
tokens = {
|
| 302 |
+
'keywords': [
|
| 303 |
+
(words((
|
| 304 |
+
'_Alignas', '_Alignof', '_Noreturn', '_Countof', '_Generic', '_Thread_local',
|
| 305 |
+
'_Static_assert', '_Imaginary', 'countof', 'noreturn', 'imaginary', 'complex'),
|
| 306 |
+
suffix=r'\b'), Keyword),
|
| 307 |
+
inherit
|
| 308 |
+
],
|
| 309 |
+
'types': [
|
| 310 |
+
(words(('_Bool', '_Complex', '_Atomic', '_Decimal32', '_Decimal64', '_Decimal128'), suffix=r'\b'), Keyword.Type),
|
| 311 |
+
inherit
|
| 312 |
+
]
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
def analyse_text(text):
|
| 316 |
+
if re.search(r'^\s*#include [<"]', text, re.MULTILINE):
|
| 317 |
+
return 0.1
|
| 318 |
+
if re.search(r'^\s*#ifn?def ', text, re.MULTILINE):
|
| 319 |
+
return 0.1
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
class CppLexer(CFamilyLexer):
|
| 323 |
+
"""
|
| 324 |
+
For C++ source code with preprocessor directives.
|
| 325 |
+
|
| 326 |
+
Additional options accepted:
|
| 327 |
+
|
| 328 |
+
`stdlibhighlighting`
|
| 329 |
+
Highlight common types found in the C/C++ standard library (e.g. `size_t`).
|
| 330 |
+
(default: ``True``).
|
| 331 |
+
|
| 332 |
+
`c99highlighting`
|
| 333 |
+
Highlight common types found in the C99 standard library (e.g. `int8_t`).
|
| 334 |
+
Actually, this includes all fixed-width integer types.
|
| 335 |
+
(default: ``True``).
|
| 336 |
+
|
| 337 |
+
`c11highlighting`
|
| 338 |
+
Highlight atomic types found in the C11 standard library (e.g. `atomic_bool`).
|
| 339 |
+
(default: ``True``).
|
| 340 |
+
|
| 341 |
+
`platformhighlighting`
|
| 342 |
+
Highlight common types found in the platform SDK headers (e.g. `clockid_t` on Linux).
|
| 343 |
+
(default: ``True``).
|
| 344 |
+
"""
|
| 345 |
+
name = 'C++'
|
| 346 |
+
url = 'https://isocpp.org/'
|
| 347 |
+
aliases = ['cpp', 'c++']
|
| 348 |
+
filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++',
|
| 349 |
+
'*.cc', '*.hh', '*.cxx', '*.hxx',
|
| 350 |
+
'*.C', '*.H', '*.cp', '*.CPP', '*.tpp',
|
| 351 |
+
'*.cppm', '*.ixx', '*.mxx']
|
| 352 |
+
mimetypes = ['text/x-c++hdr', 'text/x-c++src']
|
| 353 |
+
version_added = ''
|
| 354 |
+
priority = 0.1
|
| 355 |
+
|
| 356 |
+
tokens = {
|
| 357 |
+
'statements': [
|
| 358 |
+
# C++11 raw strings
|
| 359 |
+
(r'((?:[LuU]|u8)?R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")',
|
| 360 |
+
bygroups(String.Affix, String, String.Delimiter, String.Delimiter,
|
| 361 |
+
String, String.Delimiter, String)),
|
| 362 |
+
inherit,
|
| 363 |
+
],
|
| 364 |
+
'root': [
|
| 365 |
+
inherit,
|
| 366 |
+
# C++ Microsoft-isms
|
| 367 |
+
(words(('virtual_inheritance', 'uuidof', 'super', 'extends', 'single_inheritance',
|
| 368 |
+
'multiple_inheritance', 'interface', 'implements', 'event', 'finally', 'null'),
|
| 369 |
+
prefix=r'__', suffix=r'\b'), Keyword.Reserved),
|
| 370 |
+
# Offload C++ extensions, http://offload.codeplay.com/
|
| 371 |
+
(r'__(offload|blockingoffload|outer)\b', Keyword.Pseudo),
|
| 372 |
+
],
|
| 373 |
+
'enumname': [
|
| 374 |
+
include('whitespace'),
|
| 375 |
+
# 'enum class' and 'enum struct' C++11 support
|
| 376 |
+
(words(('class', 'struct'), suffix=r'\b'), Keyword),
|
| 377 |
+
(CFamilyLexer._ident, Name.Class, '#pop'),
|
| 378 |
+
# template specification
|
| 379 |
+
(r'\s*(?=>)', Text, '#pop'),
|
| 380 |
+
default('#pop')
|
| 381 |
+
],
|
| 382 |
+
'keywords': [
|
| 383 |
+
(r'(class|concept|typename)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 384 |
+
(words((
|
| 385 |
+
'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit',
|
| 386 |
+
'export', 'friend', 'mutable', 'new', 'operator',
|
| 387 |
+
'private', 'protected', 'public', 'reinterpret_cast', 'class',
|
| 388 |
+
'__restrict', 'static_cast', 'template', 'this', 'throw', 'throws',
|
| 389 |
+
'try', 'typeid', 'using', 'virtual', 'concept',
|
| 390 |
+
'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval',
|
| 391 |
+
'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module',
|
| 392 |
+
'typename', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
|
| 393 |
+
'not_eq', 'or', 'or_eq', 'xor', 'xor_eq', 'contract_assert', 'pre', 'post'),
|
| 394 |
+
suffix=r'\b'), Keyword),
|
| 395 |
+
(r'namespace\b', Keyword, 'namespace'),
|
| 396 |
+
(r'(enum)(\s+)', bygroups(Keyword, Whitespace), 'enumname'),
|
| 397 |
+
inherit
|
| 398 |
+
],
|
| 399 |
+
'types': [
|
| 400 |
+
(r'char(16_t|32_t|8_t)\b', Keyword.Type),
|
| 401 |
+
inherit
|
| 402 |
+
],
|
| 403 |
+
'namespace': [
|
| 404 |
+
(r'[;{]', Punctuation, ('#pop', 'root')),
|
| 405 |
+
(r'inline\b', Keyword.Reserved),
|
| 406 |
+
(CFamilyLexer._ident, Name.Namespace),
|
| 407 |
+
include('statement')
|
| 408 |
+
]
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
def analyse_text(text):
|
| 412 |
+
if re.search('#include <[a-z_]+>', text):
|
| 413 |
+
return 0.2
|
| 414 |
+
if re.search('using namespace ', text):
|
| 415 |
+
return 0.4
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/c_like.py
ADDED
|
@@ -0,0 +1,738 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.c_like
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for other C-like languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \
|
| 14 |
+
default
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Whitespace
|
| 17 |
+
|
| 18 |
+
from pygments.lexers.c_cpp import CLexer, CppLexer
|
| 19 |
+
from pygments.lexers import _mql_builtins
|
| 20 |
+
|
| 21 |
+
__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer',
|
| 22 |
+
'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer',
|
| 23 |
+
'OmgIdlLexer', 'PromelaLexer']
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class PikeLexer(CppLexer):
|
| 27 |
+
"""
|
| 28 |
+
For `Pike <http://pike.lysator.liu.se/>`_ source code.
|
| 29 |
+
"""
|
| 30 |
+
name = 'Pike'
|
| 31 |
+
aliases = ['pike']
|
| 32 |
+
filenames = ['*.pike', '*.pmod']
|
| 33 |
+
mimetypes = ['text/x-pike']
|
| 34 |
+
version_added = '2.0'
|
| 35 |
+
|
| 36 |
+
tokens = {
|
| 37 |
+
'statements': [
|
| 38 |
+
(words((
|
| 39 |
+
'catch', 'new', 'private', 'protected', 'public', 'gauge',
|
| 40 |
+
'throw', 'throws', 'class', 'interface', 'implement', 'abstract',
|
| 41 |
+
'extends', 'from', 'this', 'super', 'constant', 'final', 'static',
|
| 42 |
+
'import', 'use', 'extern', 'inline', 'proto', 'break', 'continue',
|
| 43 |
+
'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'as', 'in',
|
| 44 |
+
'version', 'return', 'true', 'false', 'null',
|
| 45 |
+
'__VERSION__', '__MAJOR__', '__MINOR__', '__BUILD__', '__REAL_VERSION__',
|
| 46 |
+
'__REAL_MAJOR__', '__REAL_MINOR__', '__REAL_BUILD__', '__DATE__', '__TIME__',
|
| 47 |
+
'__FILE__', '__DIR__', '__LINE__', '__AUTO_BIGNUM__', '__NT__', '__PIKE__',
|
| 48 |
+
'__amigaos__', '_Pragma', 'static_assert', 'defined', 'sscanf'), suffix=r'\b'),
|
| 49 |
+
Keyword),
|
| 50 |
+
(r'(bool|int|long|float|short|double|char|string|object|void|mapping|'
|
| 51 |
+
r'array|multiset|program|function|lambda|mixed|'
|
| 52 |
+
r'[a-z_][a-z0-9_]*_t)\b',
|
| 53 |
+
Keyword.Type),
|
| 54 |
+
(r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 55 |
+
(r'[~!%^&*+=|?:<>/@-]', Operator),
|
| 56 |
+
inherit,
|
| 57 |
+
],
|
| 58 |
+
'classname': [
|
| 59 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop'),
|
| 60 |
+
# template specification
|
| 61 |
+
(r'\s*(?=>)', Whitespace, '#pop'),
|
| 62 |
+
],
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class NesCLexer(CLexer):
|
| 67 |
+
"""
|
| 68 |
+
For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor
|
| 69 |
+
directives.
|
| 70 |
+
"""
|
| 71 |
+
name = 'nesC'
|
| 72 |
+
aliases = ['nesc']
|
| 73 |
+
filenames = ['*.nc']
|
| 74 |
+
mimetypes = ['text/x-nescsrc']
|
| 75 |
+
version_added = '2.0'
|
| 76 |
+
|
| 77 |
+
tokens = {
|
| 78 |
+
'statements': [
|
| 79 |
+
(words((
|
| 80 |
+
'abstract', 'as', 'async', 'atomic', 'call', 'command', 'component',
|
| 81 |
+
'components', 'configuration', 'event', 'extends', 'generic',
|
| 82 |
+
'implementation', 'includes', 'interface', 'module', 'new', 'norace',
|
| 83 |
+
'post', 'provides', 'signal', 'task', 'uses'), suffix=r'\b'),
|
| 84 |
+
Keyword),
|
| 85 |
+
(words(('nx_struct', 'nx_union', 'nx_int8_t', 'nx_int16_t', 'nx_int32_t',
|
| 86 |
+
'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t',
|
| 87 |
+
'nx_uint64_t'), suffix=r'\b'),
|
| 88 |
+
Keyword.Type),
|
| 89 |
+
inherit,
|
| 90 |
+
],
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class ClayLexer(RegexLexer):
|
| 95 |
+
"""
|
| 96 |
+
For Clay source.
|
| 97 |
+
"""
|
| 98 |
+
name = 'Clay'
|
| 99 |
+
filenames = ['*.clay']
|
| 100 |
+
aliases = ['clay']
|
| 101 |
+
mimetypes = ['text/x-clay']
|
| 102 |
+
url = 'http://claylabs.com/clay'
|
| 103 |
+
version_added = '2.0'
|
| 104 |
+
|
| 105 |
+
tokens = {
|
| 106 |
+
'root': [
|
| 107 |
+
(r'\s+', Whitespace),
|
| 108 |
+
(r'//.*?$', Comment.Single),
|
| 109 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 110 |
+
(r'\b(public|private|import|as|record|variant|instance'
|
| 111 |
+
r'|define|overload|default|external|alias'
|
| 112 |
+
r'|rvalue|ref|forward|inline|noinline|forceinline'
|
| 113 |
+
r'|enum|var|and|or|not|if|else|goto|return|while'
|
| 114 |
+
r'|switch|case|break|continue|for|in|true|false|try|catch|throw'
|
| 115 |
+
r'|finally|onerror|staticassert|eval|when|newtype'
|
| 116 |
+
r'|__FILE__|__LINE__|__COLUMN__|__ARG__'
|
| 117 |
+
r')\b', Keyword),
|
| 118 |
+
(r'[~!%^&*+=|:<>/-]', Operator),
|
| 119 |
+
(r'[#(){}\[\],;.]', Punctuation),
|
| 120 |
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 121 |
+
(r'\d+[LlUu]*', Number.Integer),
|
| 122 |
+
(r'\b(true|false)\b', Name.Builtin),
|
| 123 |
+
(r'(?i)[a-z_?][\w?]*', Name),
|
| 124 |
+
(r'"""', String, 'tdqs'),
|
| 125 |
+
(r'"', String, 'dqs'),
|
| 126 |
+
],
|
| 127 |
+
'strings': [
|
| 128 |
+
(r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape),
|
| 129 |
+
(r'[^\\"]+', String),
|
| 130 |
+
],
|
| 131 |
+
'nl': [
|
| 132 |
+
(r'\n', String),
|
| 133 |
+
],
|
| 134 |
+
'dqs': [
|
| 135 |
+
(r'"', String, '#pop'),
|
| 136 |
+
include('strings'),
|
| 137 |
+
],
|
| 138 |
+
'tdqs': [
|
| 139 |
+
(r'"""', String, '#pop'),
|
| 140 |
+
include('strings'),
|
| 141 |
+
include('nl'),
|
| 142 |
+
],
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class ECLexer(CLexer):
|
| 147 |
+
"""
|
| 148 |
+
For eC source code with preprocessor directives.
|
| 149 |
+
"""
|
| 150 |
+
name = 'eC'
|
| 151 |
+
aliases = ['ec']
|
| 152 |
+
filenames = ['*.ec', '*.eh']
|
| 153 |
+
mimetypes = ['text/x-echdr', 'text/x-ecsrc']
|
| 154 |
+
url = 'https://ec-lang.org'
|
| 155 |
+
version_added = '1.5'
|
| 156 |
+
|
| 157 |
+
tokens = {
|
| 158 |
+
'statements': [
|
| 159 |
+
(words((
|
| 160 |
+
'virtual', 'class', 'private', 'public', 'property', 'import',
|
| 161 |
+
'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get',
|
| 162 |
+
'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass',
|
| 163 |
+
'__on_register_module', 'namespace', 'using', 'typed_object',
|
| 164 |
+
'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers',
|
| 165 |
+
'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset',
|
| 166 |
+
'class_default_property', 'property_category', 'class_data',
|
| 167 |
+
'class_property', 'thisclass', 'dbtable', 'dbindex',
|
| 168 |
+
'database_open', 'dbfield'), suffix=r'\b'), Keyword),
|
| 169 |
+
(words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte',
|
| 170 |
+
'unichar', 'int64'), suffix=r'\b'),
|
| 171 |
+
Keyword.Type),
|
| 172 |
+
(r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 173 |
+
(r'(null|value|this)\b', Name.Builtin),
|
| 174 |
+
inherit,
|
| 175 |
+
]
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
class ValaLexer(RegexLexer):
|
| 180 |
+
"""
|
| 181 |
+
For Vala source code with preprocessor directives.
|
| 182 |
+
"""
|
| 183 |
+
name = 'Vala'
|
| 184 |
+
aliases = ['vala', 'vapi']
|
| 185 |
+
filenames = ['*.vala', '*.vapi']
|
| 186 |
+
mimetypes = ['text/x-vala']
|
| 187 |
+
url = 'https://vala.dev'
|
| 188 |
+
version_added = '1.1'
|
| 189 |
+
|
| 190 |
+
tokens = {
|
| 191 |
+
'whitespace': [
|
| 192 |
+
(r'^\s*#if\s+0', Comment.Preproc, 'if0'),
|
| 193 |
+
(r'\n', Whitespace),
|
| 194 |
+
(r'\s+', Whitespace),
|
| 195 |
+
(r'\\\n', Text), # line continuation
|
| 196 |
+
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 197 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 198 |
+
],
|
| 199 |
+
'statements': [
|
| 200 |
+
(r'[L@]?"', String, 'string'),
|
| 201 |
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
| 202 |
+
String.Char),
|
| 203 |
+
(r'(?s)""".*?"""', String), # verbatim strings
|
| 204 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
| 205 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 206 |
+
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
| 207 |
+
(r'0[0-7]+[Ll]?', Number.Oct),
|
| 208 |
+
(r'\d+[Ll]?', Number.Integer),
|
| 209 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 210 |
+
(r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])',
|
| 211 |
+
bygroups(Punctuation, Name.Decorator, Punctuation)),
|
| 212 |
+
# TODO: "correctly" parse complex code attributes
|
| 213 |
+
(r'(\[)(CCode|(?:Integer|Floating)Type)',
|
| 214 |
+
bygroups(Punctuation, Name.Decorator)),
|
| 215 |
+
(r'[()\[\],.]', Punctuation),
|
| 216 |
+
(words((
|
| 217 |
+
'as', 'base', 'break', 'case', 'catch', 'construct', 'continue',
|
| 218 |
+
'default', 'delete', 'do', 'else', 'enum', 'finally', 'for',
|
| 219 |
+
'foreach', 'get', 'if', 'in', 'is', 'lock', 'new', 'out', 'params',
|
| 220 |
+
'return', 'set', 'sizeof', 'switch', 'this', 'throw', 'try',
|
| 221 |
+
'typeof', 'while', 'yield'), suffix=r'\b'),
|
| 222 |
+
Keyword),
|
| 223 |
+
(words((
|
| 224 |
+
'abstract', 'const', 'delegate', 'dynamic', 'ensures', 'extern',
|
| 225 |
+
'inline', 'internal', 'override', 'owned', 'private', 'protected',
|
| 226 |
+
'public', 'ref', 'requires', 'signal', 'static', 'throws', 'unowned',
|
| 227 |
+
'var', 'virtual', 'volatile', 'weak', 'yields'), suffix=r'\b'),
|
| 228 |
+
Keyword.Declaration),
|
| 229 |
+
(r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Whitespace),
|
| 230 |
+
'namespace'),
|
| 231 |
+
(r'(class|errordomain|interface|struct)(\s+)',
|
| 232 |
+
bygroups(Keyword.Declaration, Whitespace), 'class'),
|
| 233 |
+
(r'(\.)([a-zA-Z_]\w*)',
|
| 234 |
+
bygroups(Operator, Name.Attribute)),
|
| 235 |
+
# void is an actual keyword, others are in glib-2.0.vapi
|
| 236 |
+
(words((
|
| 237 |
+
'void', 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16',
|
| 238 |
+
'int32', 'int64', 'long', 'short', 'size_t', 'ssize_t', 'string',
|
| 239 |
+
'time_t', 'uchar', 'uint', 'uint8', 'uint16', 'uint32', 'uint64',
|
| 240 |
+
'ulong', 'unichar', 'ushort'), suffix=r'\b'),
|
| 241 |
+
Keyword.Type),
|
| 242 |
+
(r'(true|false|null)\b', Name.Builtin),
|
| 243 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 244 |
+
],
|
| 245 |
+
'root': [
|
| 246 |
+
include('whitespace'),
|
| 247 |
+
default('statement'),
|
| 248 |
+
],
|
| 249 |
+
'statement': [
|
| 250 |
+
include('whitespace'),
|
| 251 |
+
include('statements'),
|
| 252 |
+
('[{}]', Punctuation),
|
| 253 |
+
(';', Punctuation, '#pop'),
|
| 254 |
+
],
|
| 255 |
+
'string': [
|
| 256 |
+
(r'"', String, '#pop'),
|
| 257 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 258 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 259 |
+
(r'\\\n', String), # line continuation
|
| 260 |
+
(r'\\', String), # stray backslash
|
| 261 |
+
],
|
| 262 |
+
'if0': [
|
| 263 |
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
| 264 |
+
(r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
|
| 265 |
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
| 266 |
+
(r'.*?\n', Comment),
|
| 267 |
+
],
|
| 268 |
+
'class': [
|
| 269 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
| 270 |
+
],
|
| 271 |
+
'namespace': [
|
| 272 |
+
(r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop')
|
| 273 |
+
],
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class CudaLexer(CLexer):
|
| 278 |
+
"""
|
| 279 |
+
For NVIDIA CUDA™ source.
|
| 280 |
+
"""
|
| 281 |
+
name = 'CUDA'
|
| 282 |
+
filenames = ['*.cu', '*.cuh']
|
| 283 |
+
aliases = ['cuda', 'cu']
|
| 284 |
+
mimetypes = ['text/x-cuda']
|
| 285 |
+
url = 'https://developer.nvidia.com/category/zone/cuda-zone'
|
| 286 |
+
version_added = '1.6'
|
| 287 |
+
|
| 288 |
+
function_qualifiers = {'__device__', '__global__', '__host__',
|
| 289 |
+
'__noinline__', '__forceinline__'}
|
| 290 |
+
variable_qualifiers = {'__device__', '__constant__', '__shared__',
|
| 291 |
+
'__restrict__'}
|
| 292 |
+
vector_types = {'char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3',
|
| 293 |
+
'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2',
|
| 294 |
+
'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1',
|
| 295 |
+
'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1',
|
| 296 |
+
'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4',
|
| 297 |
+
'ulong4', 'longlong1', 'ulonglong1', 'longlong2',
|
| 298 |
+
'ulonglong2', 'float1', 'float2', 'float3', 'float4',
|
| 299 |
+
'double1', 'double2', 'dim3'}
|
| 300 |
+
variables = {'gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize'}
|
| 301 |
+
functions = {'__threadfence_block', '__threadfence', '__threadfence_system',
|
| 302 |
+
'__syncthreads', '__syncthreads_count', '__syncthreads_and',
|
| 303 |
+
'__syncthreads_or'}
|
| 304 |
+
execution_confs = {'<<<', '>>>'}
|
| 305 |
+
|
| 306 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 307 |
+
for index, token, value in CLexer.get_tokens_unprocessed(self, text, stack):
|
| 308 |
+
if token is Name:
|
| 309 |
+
if value in self.variable_qualifiers:
|
| 310 |
+
token = Keyword.Type
|
| 311 |
+
elif value in self.vector_types:
|
| 312 |
+
token = Keyword.Type
|
| 313 |
+
elif value in self.variables:
|
| 314 |
+
token = Name.Builtin
|
| 315 |
+
elif value in self.execution_confs:
|
| 316 |
+
token = Keyword.Pseudo
|
| 317 |
+
elif value in self.function_qualifiers:
|
| 318 |
+
token = Keyword.Reserved
|
| 319 |
+
elif value in self.functions:
|
| 320 |
+
token = Name.Function
|
| 321 |
+
yield index, token, value
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
class SwigLexer(CppLexer):
|
| 325 |
+
"""
|
| 326 |
+
For `SWIG <http://www.swig.org/>`_ source code.
|
| 327 |
+
"""
|
| 328 |
+
name = 'SWIG'
|
| 329 |
+
aliases = ['swig']
|
| 330 |
+
filenames = ['*.swg', '*.i']
|
| 331 |
+
mimetypes = ['text/swig']
|
| 332 |
+
version_added = '2.0'
|
| 333 |
+
priority = 0.04 # Lower than C/C++ and Objective C/C++
|
| 334 |
+
|
| 335 |
+
tokens = {
|
| 336 |
+
'root': [
|
| 337 |
+
# Match it here so it won't be matched as a function in the rest of root
|
| 338 |
+
(r'\$\**\&?\w+', Name),
|
| 339 |
+
inherit
|
| 340 |
+
],
|
| 341 |
+
'statements': [
|
| 342 |
+
# SWIG directives
|
| 343 |
+
(r'(%[a-z_][a-z0-9_]*)', Name.Function),
|
| 344 |
+
# Special variables
|
| 345 |
+
(r'\$\**\&?\w+', Name),
|
| 346 |
+
# Stringification / additional preprocessor directives
|
| 347 |
+
(r'##*[a-zA-Z_]\w*', Comment.Preproc),
|
| 348 |
+
inherit,
|
| 349 |
+
],
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
# This is a far from complete set of SWIG directives
|
| 353 |
+
swig_directives = {
|
| 354 |
+
# Most common directives
|
| 355 |
+
'%apply', '%define', '%director', '%enddef', '%exception', '%extend',
|
| 356 |
+
'%feature', '%fragment', '%ignore', '%immutable', '%import', '%include',
|
| 357 |
+
'%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma',
|
| 358 |
+
'%rename', '%shared_ptr', '%template', '%typecheck', '%typemap',
|
| 359 |
+
# Less common directives
|
| 360 |
+
'%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear',
|
| 361 |
+
'%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum',
|
| 362 |
+
'%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor',
|
| 363 |
+
'%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor',
|
| 364 |
+
'%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments',
|
| 365 |
+
'%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv',
|
| 366 |
+
'%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception',
|
| 367 |
+
'%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar',
|
| 368 |
+
'%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend',
|
| 369 |
+
'%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall',
|
| 370 |
+
'%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof',
|
| 371 |
+
'%trackobjects', '%types', '%unrefobject', '%varargs', '%warn',
|
| 372 |
+
'%warnfilter'}
|
| 373 |
+
|
| 374 |
+
def analyse_text(text):
|
| 375 |
+
rv = 0
|
| 376 |
+
# Search for SWIG directives, which are conventionally at the beginning of
|
| 377 |
+
# a line. The probability of them being within a line is low, so let another
|
| 378 |
+
# lexer win in this case.
|
| 379 |
+
matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M)
|
| 380 |
+
for m in matches:
|
| 381 |
+
if m in SwigLexer.swig_directives:
|
| 382 |
+
rv = 0.98
|
| 383 |
+
break
|
| 384 |
+
else:
|
| 385 |
+
rv = 0.91 # Fraction higher than MatlabLexer
|
| 386 |
+
return rv
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
class MqlLexer(CppLexer):
|
| 390 |
+
"""
|
| 391 |
+
For `MQL4 <http://docs.mql4.com/>`_ and
|
| 392 |
+
`MQL5 <http://www.mql5.com/en/docs>`_ source code.
|
| 393 |
+
"""
|
| 394 |
+
name = 'MQL'
|
| 395 |
+
aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5']
|
| 396 |
+
filenames = ['*.mq4', '*.mq5', '*.mqh']
|
| 397 |
+
mimetypes = ['text/x-mql']
|
| 398 |
+
version_added = '2.0'
|
| 399 |
+
|
| 400 |
+
tokens = {
|
| 401 |
+
'statements': [
|
| 402 |
+
(words(_mql_builtins.keywords, suffix=r'\b'), Keyword),
|
| 403 |
+
(words(_mql_builtins.c_types, suffix=r'\b'), Keyword.Type),
|
| 404 |
+
(words(_mql_builtins.types, suffix=r'\b'), Name.Function),
|
| 405 |
+
(words(_mql_builtins.constants, suffix=r'\b'), Name.Constant),
|
| 406 |
+
(words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'),
|
| 407 |
+
Name.Constant),
|
| 408 |
+
inherit,
|
| 409 |
+
],
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
class ArduinoLexer(CppLexer):
|
| 414 |
+
"""
|
| 415 |
+
For `Arduino(tm) <https://arduino.cc/>`_ source.
|
| 416 |
+
|
| 417 |
+
This is an extension of the CppLexer, as the Arduino® Language is a superset
|
| 418 |
+
of C++
|
| 419 |
+
"""
|
| 420 |
+
|
| 421 |
+
name = 'Arduino'
|
| 422 |
+
aliases = ['arduino']
|
| 423 |
+
filenames = ['*.ino']
|
| 424 |
+
mimetypes = ['text/x-arduino']
|
| 425 |
+
version_added = '2.1'
|
| 426 |
+
|
| 427 |
+
# Language sketch main structure functions
|
| 428 |
+
structure = {'setup', 'loop'}
|
| 429 |
+
|
| 430 |
+
# Language operators
|
| 431 |
+
operators = {'not', 'or', 'and', 'xor'}
|
| 432 |
+
|
| 433 |
+
# Language 'variables'
|
| 434 |
+
variables = {
|
| 435 |
+
'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL',
|
| 436 |
+
'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET',
|
| 437 |
+
'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH',
|
| 438 |
+
'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false',
|
| 439 |
+
'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int',
|
| 440 |
+
'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String',
|
| 441 |
+
'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string',
|
| 442 |
+
'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator',
|
| 443 |
+
'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t',
|
| 444 |
+
'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const',
|
| 445 |
+
'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static',
|
| 446 |
+
'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern',
|
| 447 |
+
'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit',
|
| 448 |
+
'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary',
|
| 449 |
+
'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short',
|
| 450 |
+
'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong',
|
| 451 |
+
'atomic_llong', 'atomic_ullong', 'PROGMEM'}
|
| 452 |
+
|
| 453 |
+
# Language shipped functions and class ( )
|
| 454 |
+
functions = {
|
| 455 |
+
'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer',
|
| 456 |
+
'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall',
|
| 457 |
+
'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient',
|
| 458 |
+
'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer',
|
| 459 |
+
'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console',
|
| 460 |
+
'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox',
|
| 461 |
+
'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO',
|
| 462 |
+
'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File',
|
| 463 |
+
'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD',
|
| 464 |
+
'runShellCommandAsynchronously', 'analogWriteResolution',
|
| 465 |
+
'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution',
|
| 466 |
+
'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton',
|
| 467 |
+
'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight',
|
| 468 |
+
'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds',
|
| 469 |
+
'delayMicroseconds', 'beginTransmission', 'getSignalStrength',
|
| 470 |
+
'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost',
|
| 471 |
+
'getCurrentCarrier', 'readAccelerometer', 'messageAvailable',
|
| 472 |
+
'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand',
|
| 473 |
+
'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider',
|
| 474 |
+
'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt',
|
| 475 |
+
'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil',
|
| 476 |
+
'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite',
|
| 477 |
+
'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased',
|
| 478 |
+
'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker',
|
| 479 |
+
'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll',
|
| 480 |
+
'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead',
|
| 481 |
+
'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks',
|
| 482 |
+
'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode',
|
| 483 |
+
'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory',
|
| 484 |
+
'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent',
|
| 485 |
+
'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased',
|
| 486 |
+
'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect',
|
| 487 |
+
'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed',
|
| 488 |
+
'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite',
|
| 489 |
+
'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton',
|
| 490 |
+
'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed',
|
| 491 |
+
'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll',
|
| 492 |
+
'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall',
|
| 493 |
+
'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON',
|
| 494 |
+
'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue',
|
| 495 |
+
'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex',
|
| 496 |
+
'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay',
|
| 497 |
+
'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile',
|
| 498 |
+
'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT',
|
| 499 |
+
'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte',
|
| 500 |
+
'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer',
|
| 501 |
+
'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain',
|
| 502 |
+
'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn',
|
| 503 |
+
'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink',
|
| 504 |
+
'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand',
|
| 505 |
+
'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill',
|
| 506 |
+
'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer',
|
| 507 |
+
'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS',
|
| 508 |
+
'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready',
|
| 509 |
+
'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close',
|
| 510 |
+
'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move',
|
| 511 |
+
'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop',
|
| 512 |
+
'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan',
|
| 513 |
+
'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put',
|
| 514 |
+
'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit',
|
| 515 |
+
'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase',
|
| 516 |
+
'isHexadecimalDigit'}
|
| 517 |
+
|
| 518 |
+
# do not highlight
|
| 519 |
+
suppress_highlight = {
|
| 520 |
+
'namespace', 'template', 'mutable', 'using', 'asm', 'typeid',
|
| 521 |
+
'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept',
|
| 522 |
+
'static_assert', 'thread_local', 'restrict'}
|
| 523 |
+
|
| 524 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 525 |
+
for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack):
|
| 526 |
+
if value in self.structure:
|
| 527 |
+
yield index, Name.Builtin, value
|
| 528 |
+
elif value in self.operators:
|
| 529 |
+
yield index, Operator, value
|
| 530 |
+
elif value in self.variables:
|
| 531 |
+
yield index, Keyword.Reserved, value
|
| 532 |
+
elif value in self.suppress_highlight:
|
| 533 |
+
yield index, Name, value
|
| 534 |
+
elif value in self.functions:
|
| 535 |
+
yield index, Name.Function, value
|
| 536 |
+
else:
|
| 537 |
+
yield index, token, value
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
class CharmciLexer(CppLexer):
|
| 541 |
+
"""
|
| 542 |
+
For `Charm++ <https://charm.cs.illinois.edu>`_ interface files (.ci).
|
| 543 |
+
"""
|
| 544 |
+
|
| 545 |
+
name = 'Charmci'
|
| 546 |
+
aliases = ['charmci']
|
| 547 |
+
filenames = ['*.ci']
|
| 548 |
+
version_added = '2.4'
|
| 549 |
+
|
| 550 |
+
mimetypes = []
|
| 551 |
+
|
| 552 |
+
tokens = {
|
| 553 |
+
'keywords': [
|
| 554 |
+
(r'(module)(\s+)', bygroups(Keyword, Text), 'classname'),
|
| 555 |
+
(words(('mainmodule', 'mainchare', 'chare', 'array', 'group',
|
| 556 |
+
'nodegroup', 'message', 'conditional')), Keyword),
|
| 557 |
+
(words(('entry', 'aggregate', 'threaded', 'sync', 'exclusive',
|
| 558 |
+
'nokeep', 'notrace', 'immediate', 'expedited', 'inline',
|
| 559 |
+
'local', 'python', 'accel', 'readwrite', 'writeonly',
|
| 560 |
+
'accelblock', 'memcritical', 'packed', 'varsize',
|
| 561 |
+
'initproc', 'initnode', 'initcall', 'stacksize',
|
| 562 |
+
'createhere', 'createhome', 'reductiontarget', 'iget',
|
| 563 |
+
'nocopy', 'mutable', 'migratable', 'readonly')), Keyword),
|
| 564 |
+
inherit,
|
| 565 |
+
],
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
class OmgIdlLexer(CLexer):
|
| 570 |
+
"""
|
| 571 |
+
Lexer for Object Management Group Interface Definition Language.
|
| 572 |
+
"""
|
| 573 |
+
|
| 574 |
+
name = 'OMG Interface Definition Language'
|
| 575 |
+
url = 'https://www.omg.org/spec/IDL/About-IDL/'
|
| 576 |
+
aliases = ['omg-idl']
|
| 577 |
+
filenames = ['*.idl', '*.pidl']
|
| 578 |
+
mimetypes = []
|
| 579 |
+
version_added = '2.9'
|
| 580 |
+
|
| 581 |
+
scoped_name = r'((::)?\w+)+'
|
| 582 |
+
|
| 583 |
+
tokens = {
|
| 584 |
+
'values': [
|
| 585 |
+
(words(('true', 'false'), prefix=r'(?i)', suffix=r'\b'), Number),
|
| 586 |
+
(r'([Ll]?)(")', bygroups(String.Affix, String.Double), 'string'),
|
| 587 |
+
(r'([Ll]?)(\')(\\[^\']+)(\')',
|
| 588 |
+
bygroups(String.Affix, String.Char, String.Escape, String.Char)),
|
| 589 |
+
(r'([Ll]?)(\')(\\\')(\')',
|
| 590 |
+
bygroups(String.Affix, String.Char, String.Escape, String.Char)),
|
| 591 |
+
(r'([Ll]?)(\'.\')', bygroups(String.Affix, String.Char)),
|
| 592 |
+
(r'[+-]?\d+(\.\d*)?[Ee][+-]?\d+', Number.Float),
|
| 593 |
+
(r'[+-]?(\d+\.\d*)|(\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
|
| 594 |
+
(r'(?i)[+-]?0x[0-9a-f]+', Number.Hex),
|
| 595 |
+
(r'[+-]?[1-9]\d*', Number.Integer),
|
| 596 |
+
(r'[+-]?0[0-7]*', Number.Oct),
|
| 597 |
+
(r'[\+\-\*\/%^&\|~]', Operator),
|
| 598 |
+
(words(('<<', '>>')), Operator),
|
| 599 |
+
(scoped_name, Name),
|
| 600 |
+
(r'[{};:,<>\[\]]', Punctuation),
|
| 601 |
+
],
|
| 602 |
+
'annotation_params': [
|
| 603 |
+
include('whitespace'),
|
| 604 |
+
(r'\(', Punctuation, '#push'),
|
| 605 |
+
include('values'),
|
| 606 |
+
(r'=', Punctuation),
|
| 607 |
+
(r'\)', Punctuation, '#pop'),
|
| 608 |
+
],
|
| 609 |
+
'annotation_params_maybe': [
|
| 610 |
+
(r'\(', Punctuation, 'annotation_params'),
|
| 611 |
+
include('whitespace'),
|
| 612 |
+
default('#pop'),
|
| 613 |
+
],
|
| 614 |
+
'annotation_appl': [
|
| 615 |
+
(r'@' + scoped_name, Name.Decorator, 'annotation_params_maybe'),
|
| 616 |
+
],
|
| 617 |
+
'enum': [
|
| 618 |
+
include('whitespace'),
|
| 619 |
+
(r'[{,]', Punctuation),
|
| 620 |
+
(r'\w+', Name.Constant),
|
| 621 |
+
include('annotation_appl'),
|
| 622 |
+
(r'\}', Punctuation, '#pop'),
|
| 623 |
+
],
|
| 624 |
+
'root': [
|
| 625 |
+
include('whitespace'),
|
| 626 |
+
(words((
|
| 627 |
+
'typedef', 'const',
|
| 628 |
+
'in', 'out', 'inout', 'local',
|
| 629 |
+
), prefix=r'(?i)', suffix=r'\b'), Keyword.Declaration),
|
| 630 |
+
(words((
|
| 631 |
+
'void', 'any', 'native', 'bitfield',
|
| 632 |
+
'unsigned', 'boolean', 'char', 'wchar', 'octet', 'short', 'long',
|
| 633 |
+
'int8', 'uint8', 'int16', 'int32', 'int64', 'uint16', 'uint32', 'uint64',
|
| 634 |
+
'float', 'double', 'fixed',
|
| 635 |
+
'sequence', 'string', 'wstring', 'map',
|
| 636 |
+
), prefix=r'(?i)', suffix=r'\b'), Keyword.Type),
|
| 637 |
+
(words((
|
| 638 |
+
'@annotation', 'struct', 'union', 'bitset', 'interface',
|
| 639 |
+
'exception', 'valuetype', 'eventtype', 'component',
|
| 640 |
+
), prefix=r'(?i)', suffix=r'(\s+)(\w+)'), bygroups(Keyword, Whitespace, Name.Class)),
|
| 641 |
+
(words((
|
| 642 |
+
'abstract', 'alias', 'attribute', 'case', 'connector',
|
| 643 |
+
'consumes', 'context', 'custom', 'default', 'emits', 'factory',
|
| 644 |
+
'finder', 'getraises', 'home', 'import', 'manages', 'mirrorport',
|
| 645 |
+
'multiple', 'Object', 'oneway', 'primarykey', 'private', 'port',
|
| 646 |
+
'porttype', 'provides', 'public', 'publishes', 'raises',
|
| 647 |
+
'readonly', 'setraises', 'supports', 'switch', 'truncatable',
|
| 648 |
+
'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase',
|
| 649 |
+
), prefix=r'(?i)', suffix=r'\b'), Keyword),
|
| 650 |
+
(r'(?i)(enum|bitmask)(\s+)(\w+)',
|
| 651 |
+
bygroups(Keyword, Whitespace, Name.Class), 'enum'),
|
| 652 |
+
(r'(?i)(module)(\s+)(\w+)',
|
| 653 |
+
bygroups(Keyword.Namespace, Whitespace, Name.Namespace)),
|
| 654 |
+
(r'(\w+)(\s*)(=)', bygroups(Name.Constant, Whitespace, Operator)),
|
| 655 |
+
(r'[\(\)]', Punctuation),
|
| 656 |
+
include('values'),
|
| 657 |
+
include('annotation_appl'),
|
| 658 |
+
],
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
|
| 662 |
+
class PromelaLexer(CLexer):
|
| 663 |
+
"""
|
| 664 |
+
For the Promela language used with SPIN.
|
| 665 |
+
"""
|
| 666 |
+
|
| 667 |
+
name = 'Promela'
|
| 668 |
+
aliases = ['promela']
|
| 669 |
+
filenames = ['*.pml', '*.prom', '*.prm', '*.promela', '*.pr', '*.pm']
|
| 670 |
+
mimetypes = ['text/x-promela']
|
| 671 |
+
url = 'https://spinroot.com/spin/whatispin.html'
|
| 672 |
+
version_added = '2.18'
|
| 673 |
+
|
| 674 |
+
# Promela's language reference:
|
| 675 |
+
# https://spinroot.com/spin/Man/promela.html
|
| 676 |
+
# Promela's grammar definition:
|
| 677 |
+
# https://spinroot.com/spin/Man/grammar.html
|
| 678 |
+
|
| 679 |
+
tokens = {
|
| 680 |
+
'statements': [
|
| 681 |
+
(r'(\[\]|<>|/\\|\\/)|(U|W|V)\b', Operator), # LTL Operators
|
| 682 |
+
(r'@', Punctuation), #remoterefs
|
| 683 |
+
(r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
|
| 684 |
+
inherit
|
| 685 |
+
],
|
| 686 |
+
'types': [
|
| 687 |
+
# Predefined (data types)
|
| 688 |
+
(words((
|
| 689 |
+
'bit', 'bool', 'byte', 'pid', 'short', 'int', 'unsigned'),
|
| 690 |
+
suffix=r'\b'),
|
| 691 |
+
Keyword.Type),
|
| 692 |
+
],
|
| 693 |
+
'keywords': [
|
| 694 |
+
# ControlFlow
|
| 695 |
+
(words((
|
| 696 |
+
'atomic', 'break', 'd_step', 'do', 'od', 'for', 'in', 'goto',
|
| 697 |
+
'if', 'fi', 'unless'), suffix=r'\b'),
|
| 698 |
+
Keyword),
|
| 699 |
+
# BasicStatements
|
| 700 |
+
(words((
|
| 701 |
+
'assert', 'get_priority', 'printf', 'printm', 'set_priority'),
|
| 702 |
+
suffix=r'\b'),
|
| 703 |
+
Name.Function),
|
| 704 |
+
# Embedded C Code
|
| 705 |
+
(words((
|
| 706 |
+
'c_code', 'c_decl', 'c_expr', 'c_state', 'c_track'),
|
| 707 |
+
suffix=r'\b'),
|
| 708 |
+
Keyword),
|
| 709 |
+
# Predefined (local/global variables)
|
| 710 |
+
(words((
|
| 711 |
+
'_', '_last', '_nr_pr', '_pid', '_priority', 'else', 'np_',
|
| 712 |
+
'STDIN'), suffix=r'\b'),
|
| 713 |
+
Name.Builtin),
|
| 714 |
+
# Predefined (functions)
|
| 715 |
+
(words((
|
| 716 |
+
'empty', 'enabled', 'eval', 'full', 'len', 'nempty', 'nfull',
|
| 717 |
+
'pc_value'), suffix=r'\b'),
|
| 718 |
+
Name.Function),
|
| 719 |
+
# Predefined (operators)
|
| 720 |
+
(r'run\b', Operator.Word),
|
| 721 |
+
# Declarators
|
| 722 |
+
(words((
|
| 723 |
+
'active', 'chan', 'D_proctype', 'hidden', 'init', 'local',
|
| 724 |
+
'mtype', 'never', 'notrace', 'proctype', 'show', 'trace',
|
| 725 |
+
'typedef', 'xr', 'xs'), suffix=r'\b'),
|
| 726 |
+
Keyword.Declaration),
|
| 727 |
+
# Declarators (suffixes)
|
| 728 |
+
(words((
|
| 729 |
+
'priority', 'provided'), suffix=r'\b'),
|
| 730 |
+
Keyword),
|
| 731 |
+
# MetaTerms (declarators)
|
| 732 |
+
(words((
|
| 733 |
+
'inline', 'ltl', 'select'), suffix=r'\b'),
|
| 734 |
+
Keyword.Declaration),
|
| 735 |
+
# MetaTerms (keywords)
|
| 736 |
+
(r'skip\b', Keyword),
|
| 737 |
+
],
|
| 738 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/capnproto.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.capnproto
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Cap'n Proto schema language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, default
|
| 12 |
+
from pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace
|
| 13 |
+
|
| 14 |
+
__all__ = ['CapnProtoLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class CapnProtoLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For Cap'n Proto source.
|
| 20 |
+
"""
|
| 21 |
+
name = 'Cap\'n Proto'
|
| 22 |
+
url = 'https://capnproto.org'
|
| 23 |
+
filenames = ['*.capnp']
|
| 24 |
+
aliases = ['capnp']
|
| 25 |
+
version_added = '2.2'
|
| 26 |
+
|
| 27 |
+
tokens = {
|
| 28 |
+
'root': [
|
| 29 |
+
(r'#.*?$', Comment.Single),
|
| 30 |
+
(r'@[0-9a-zA-Z]*', Name.Decorator),
|
| 31 |
+
(r'=', Literal, 'expression'),
|
| 32 |
+
(r':', Name.Class, 'type'),
|
| 33 |
+
(r'\$', Name.Attribute, 'annotation'),
|
| 34 |
+
(r'(struct|enum|interface|union|import|using|const|annotation|'
|
| 35 |
+
r'extends|in|of|on|as|with|from|fixed)\b',
|
| 36 |
+
Keyword),
|
| 37 |
+
(r'[\w.]+', Name),
|
| 38 |
+
(r'[^#@=:$\w\s]+', Text),
|
| 39 |
+
(r'\s+', Whitespace),
|
| 40 |
+
],
|
| 41 |
+
'type': [
|
| 42 |
+
(r'[^][=;,(){}$]+', Name.Class),
|
| 43 |
+
(r'[\[(]', Name.Class, 'parentype'),
|
| 44 |
+
default('#pop'),
|
| 45 |
+
],
|
| 46 |
+
'parentype': [
|
| 47 |
+
(r'[^][;()]+', Name.Class),
|
| 48 |
+
(r'[\[(]', Name.Class, '#push'),
|
| 49 |
+
(r'[])]', Name.Class, '#pop'),
|
| 50 |
+
default('#pop'),
|
| 51 |
+
],
|
| 52 |
+
'expression': [
|
| 53 |
+
(r'[^][;,(){}$]+', Literal),
|
| 54 |
+
(r'[\[(]', Literal, 'parenexp'),
|
| 55 |
+
default('#pop'),
|
| 56 |
+
],
|
| 57 |
+
'parenexp': [
|
| 58 |
+
(r'[^][;()]+', Literal),
|
| 59 |
+
(r'[\[(]', Literal, '#push'),
|
| 60 |
+
(r'[])]', Literal, '#pop'),
|
| 61 |
+
default('#pop'),
|
| 62 |
+
],
|
| 63 |
+
'annotation': [
|
| 64 |
+
(r'[^][;,(){}=:]+', Name.Attribute),
|
| 65 |
+
(r'[\[(]', Name.Attribute, 'annexp'),
|
| 66 |
+
default('#pop'),
|
| 67 |
+
],
|
| 68 |
+
'annexp': [
|
| 69 |
+
(r'[^][;()]+', Name.Attribute),
|
| 70 |
+
(r'[\[(]', Name.Attribute, '#push'),
|
| 71 |
+
(r'[])]', Name.Attribute, '#pop'),
|
| 72 |
+
default('#pop'),
|
| 73 |
+
],
|
| 74 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/carbon.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.carbon
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Carbon programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
import re
|
| 11 |
+
|
| 12 |
+
from pygments.lexer import RegexLexer, words
|
| 13 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation, Whitespace
|
| 15 |
+
|
| 16 |
+
__all__ = ['CarbonLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class CarbonLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For Carbon source.
|
| 22 |
+
"""
|
| 23 |
+
name = 'Carbon'
|
| 24 |
+
url = 'https://github.com/carbon-language/carbon-lang'
|
| 25 |
+
filenames = ['*.carbon']
|
| 26 |
+
aliases = ['carbon']
|
| 27 |
+
mimetypes = ['text/x-carbon']
|
| 28 |
+
version_added = '2.15'
|
| 29 |
+
|
| 30 |
+
flags = re.MULTILINE | re.DOTALL
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
(r'\n', Whitespace),
|
| 35 |
+
(r'\s+', Whitespace),
|
| 36 |
+
(r'\\\n', Text),
|
| 37 |
+
# comments
|
| 38 |
+
(r'//(.*?)\n', Comment.Single),
|
| 39 |
+
(r'/(\\\n)?[*].*?[*](\\\n)?/', Comment.Multiline),
|
| 40 |
+
# Declaration
|
| 41 |
+
(r'(package|import|api|namespace|library)\b', Keyword.Namespace),
|
| 42 |
+
(r'(abstract|alias|fn|class|interface|let|var|virtual|external|'
|
| 43 |
+
r'base|addr|extends|choice|constraint|impl)\b', Keyword.Declaration),
|
| 44 |
+
# Keywords
|
| 45 |
+
(words(('as', 'or', 'not', 'and', 'break', 'continue', 'case',
|
| 46 |
+
'default', 'if', 'else', 'destructor', 'for', 'forall',
|
| 47 |
+
'while', 'where', 'then', 'in', 'is', 'return', 'returned',
|
| 48 |
+
'friend', 'partial', 'private', 'protected', 'observe', 'Self',
|
| 49 |
+
'override', 'final', 'match', 'type', 'like'), suffix=r'\b'), Keyword),
|
| 50 |
+
(r'(self)\b', Keyword.Pseudo),
|
| 51 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 52 |
+
(r'(auto|bool|string|i8|i16|i32|i64|u8|u16|u32|u64|'
|
| 53 |
+
r'f8|f16|f32|f64)\b', Keyword.Type),
|
| 54 |
+
# numeric literals
|
| 55 |
+
(r'[0-9]*[.][0-9]+', Number.Double),
|
| 56 |
+
(r'0b[01]+', Number.Bin),
|
| 57 |
+
(r'0o[0-7]+', Number.Oct),
|
| 58 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 59 |
+
(r'[0-9]+', Number.Integer),
|
| 60 |
+
# string literal
|
| 61 |
+
(r'"(\\.|[^"\\])*"', String),
|
| 62 |
+
# char literal
|
| 63 |
+
(r'\'(\\.|[^\'\\])\'', String.Char),
|
| 64 |
+
# tokens
|
| 65 |
+
(r'<<=|>>=|<<|>>|<=|>=|\+=|-=|\*=|/=|\%=|\|=|&=|\^=|&&|\|\||&|\||'
|
| 66 |
+
r'\+\+|--|\%|\^|\~|==|!=|::|[.]{3}|->|=>|[+\-*/&]', Operator),
|
| 67 |
+
(r'[|<>=!()\[\]{}.,;:\?]', Punctuation),
|
| 68 |
+
# identifiers
|
| 69 |
+
(r'[^\W\d]\w*', Name.Other),
|
| 70 |
+
]
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
def analyse_text(text):
|
| 74 |
+
result = 0
|
| 75 |
+
if 'forall' in text:
|
| 76 |
+
result += 0.1
|
| 77 |
+
if 'type' in text:
|
| 78 |
+
result += 0.1
|
| 79 |
+
if 'Self' in text:
|
| 80 |
+
result += 0.1
|
| 81 |
+
if 'observe' in text:
|
| 82 |
+
result += 0.1
|
| 83 |
+
if 'package' in text:
|
| 84 |
+
result += 0.1
|
| 85 |
+
if 'library' in text:
|
| 86 |
+
result += 0.1
|
| 87 |
+
if 'choice' in text:
|
| 88 |
+
result += 0.1
|
| 89 |
+
if 'addr' in text:
|
| 90 |
+
result += 0.1
|
| 91 |
+
if 'constraint' in text:
|
| 92 |
+
result += 0.1
|
| 93 |
+
if 'impl' in text:
|
| 94 |
+
result += 0.1
|
| 95 |
+
return result
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/cddl.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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definition language (CDDL), a notational
|
| 6 |
+
convention to express CBOR and JSON data structures.
|
| 7 |
+
|
| 8 |
+
More information:
|
| 9 |
+
https://datatracker.ietf.org/doc/rfc8610/
|
| 10 |
+
|
| 11 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 12 |
+
:license: BSD, see LICENSE for details.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from pygments.lexer import RegexLexer, bygroups, include, words
|
| 16 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \
|
| 17 |
+
Punctuation, String, Whitespace
|
| 18 |
+
|
| 19 |
+
__all__ = ['CddlLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class CddlLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
Lexer for CDDL definitions.
|
| 25 |
+
"""
|
| 26 |
+
name = "CDDL"
|
| 27 |
+
url = 'https://datatracker.ietf.org/doc/rfc8610/'
|
| 28 |
+
aliases = ["cddl"]
|
| 29 |
+
filenames = ["*.cddl"]
|
| 30 |
+
mimetypes = ["text/x-cddl"]
|
| 31 |
+
version_added = '2.8'
|
| 32 |
+
|
| 33 |
+
_prelude_types = [
|
| 34 |
+
"any",
|
| 35 |
+
"b64legacy",
|
| 36 |
+
"b64url",
|
| 37 |
+
"bigfloat",
|
| 38 |
+
"bigint",
|
| 39 |
+
"bignint",
|
| 40 |
+
"biguint",
|
| 41 |
+
"bool",
|
| 42 |
+
"bstr",
|
| 43 |
+
"bytes",
|
| 44 |
+
"cbor-any",
|
| 45 |
+
"decfrac",
|
| 46 |
+
"eb16",
|
| 47 |
+
"eb64legacy",
|
| 48 |
+
"eb64url",
|
| 49 |
+
"encoded-cbor",
|
| 50 |
+
"false",
|
| 51 |
+
"float",
|
| 52 |
+
"float16",
|
| 53 |
+
"float16-32",
|
| 54 |
+
"float32",
|
| 55 |
+
"float32-64",
|
| 56 |
+
"float64",
|
| 57 |
+
"int",
|
| 58 |
+
"integer",
|
| 59 |
+
"mime-message",
|
| 60 |
+
"nil",
|
| 61 |
+
"nint",
|
| 62 |
+
"null",
|
| 63 |
+
"number",
|
| 64 |
+
"regexp",
|
| 65 |
+
"tdate",
|
| 66 |
+
"text",
|
| 67 |
+
"time",
|
| 68 |
+
"true",
|
| 69 |
+
"tstr",
|
| 70 |
+
"uint",
|
| 71 |
+
"undefined",
|
| 72 |
+
"unsigned",
|
| 73 |
+
"uri",
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
_controls = [
|
| 77 |
+
".and",
|
| 78 |
+
".bits",
|
| 79 |
+
".cbor",
|
| 80 |
+
".cborseq",
|
| 81 |
+
".default",
|
| 82 |
+
".eq",
|
| 83 |
+
".ge",
|
| 84 |
+
".gt",
|
| 85 |
+
".le",
|
| 86 |
+
".lt",
|
| 87 |
+
".ne",
|
| 88 |
+
".regexp",
|
| 89 |
+
".size",
|
| 90 |
+
".within",
|
| 91 |
+
]
|
| 92 |
+
|
| 93 |
+
_re_id = (
|
| 94 |
+
r"[$@A-Z_a-z]"
|
| 95 |
+
r"(?:[\-\.]+(?=[$@0-9A-Z_a-z])|[$@0-9A-Z_a-z])*"
|
| 96 |
+
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
# While the spec reads more like "an int must not start with 0" we use a
|
| 100 |
+
# lookahead here that says "after a 0 there must be no digit". This makes the
|
| 101 |
+
# '0' the invalid character in '01', which looks nicer when highlighted.
|
| 102 |
+
_re_uint = r"(?:0b[01]+|0x[0-9a-fA-F]+|[1-9]\d*|0(?!\d))"
|
| 103 |
+
_re_int = r"-?" + _re_uint
|
| 104 |
+
|
| 105 |
+
tokens = {
|
| 106 |
+
"commentsandwhitespace": [(r"\s+", Whitespace), (r";.+$", Comment.Single)],
|
| 107 |
+
"root": [
|
| 108 |
+
include("commentsandwhitespace"),
|
| 109 |
+
# tag types
|
| 110 |
+
(rf"#(\d\.{_re_uint})?", Keyword.Type), # type or any
|
| 111 |
+
# occurrence
|
| 112 |
+
(
|
| 113 |
+
rf"({_re_uint})?(\*)({_re_uint})?",
|
| 114 |
+
bygroups(Number, Operator, Number),
|
| 115 |
+
),
|
| 116 |
+
(r"\?|\+", Operator), # occurrence
|
| 117 |
+
(r"\^", Operator), # cuts
|
| 118 |
+
(r"(\.\.\.|\.\.)", Operator), # rangeop
|
| 119 |
+
(words(_controls, suffix=r"\b"), Operator.Word), # ctlops
|
| 120 |
+
# into choice op
|
| 121 |
+
(rf"&(?=\s*({_re_id}|\())", Operator),
|
| 122 |
+
(rf"~(?=\s*{_re_id})", Operator), # unwrap op
|
| 123 |
+
(r"//|/(?!/)", Operator), # double und single slash
|
| 124 |
+
(r"=>|/==|/=|=", Operator),
|
| 125 |
+
(r"[\[\]{}\(\),<>:]", Punctuation),
|
| 126 |
+
# Bytestrings
|
| 127 |
+
(r"(b64)(')", bygroups(String.Affix, String.Single), "bstrb64url"),
|
| 128 |
+
(r"(h)(')", bygroups(String.Affix, String.Single), "bstrh"),
|
| 129 |
+
(r"'", String.Single, "bstr"),
|
| 130 |
+
# Barewords as member keys (must be matched before values, types, typenames,
|
| 131 |
+
# groupnames).
|
| 132 |
+
# Token type is String as barewords are always interpreted as such.
|
| 133 |
+
(rf"({_re_id})(\s*)(:)",
|
| 134 |
+
bygroups(String, Whitespace, Punctuation)),
|
| 135 |
+
# predefined types
|
| 136 |
+
(words(_prelude_types, prefix=r"(?![\-_$@])\b", suffix=r"\b(?![\-_$@])"),
|
| 137 |
+
Name.Builtin),
|
| 138 |
+
# user-defined groupnames, typenames
|
| 139 |
+
(_re_id, Name.Class),
|
| 140 |
+
# values
|
| 141 |
+
(r"0b[01]+", Number.Bin),
|
| 142 |
+
(r"0o[0-7]+", Number.Oct),
|
| 143 |
+
(r"0x[0-9a-fA-F]+(\.[0-9a-fA-F]+)?p[+-]?\d+", Number.Hex), # hexfloat
|
| 144 |
+
(r"0x[0-9a-fA-F]+", Number.Hex), # hex
|
| 145 |
+
# Float
|
| 146 |
+
(rf"{_re_int}(?=(\.\d|e[+-]?\d))(?:\.\d+)?(?:e[+-]?\d+)?",
|
| 147 |
+
Number.Float),
|
| 148 |
+
# Int
|
| 149 |
+
(_re_int, Number.Integer),
|
| 150 |
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
| 151 |
+
],
|
| 152 |
+
"bstrb64url": [
|
| 153 |
+
(r"'", String.Single, "#pop"),
|
| 154 |
+
include("commentsandwhitespace"),
|
| 155 |
+
(r"\\.", String.Escape),
|
| 156 |
+
(r"[0-9a-zA-Z\-_=]+", String.Single),
|
| 157 |
+
(r".", Error),
|
| 158 |
+
# (r";.+$", Token.Other),
|
| 159 |
+
],
|
| 160 |
+
"bstrh": [
|
| 161 |
+
(r"'", String.Single, "#pop"),
|
| 162 |
+
include("commentsandwhitespace"),
|
| 163 |
+
(r"\\.", String.Escape),
|
| 164 |
+
(r"[0-9a-fA-F]+", String.Single),
|
| 165 |
+
(r".", Error),
|
| 166 |
+
],
|
| 167 |
+
"bstr": [
|
| 168 |
+
(r"'", String.Single, "#pop"),
|
| 169 |
+
(r"\\.", String.Escape),
|
| 170 |
+
(r"[^'\\]+", String.Single),
|
| 171 |
+
],
|
| 172 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/chapel.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.chapel
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Chapel language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['ChapelLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ChapelLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Chapel source.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Chapel'
|
| 23 |
+
url = 'https://chapel-lang.org/'
|
| 24 |
+
filenames = ['*.chpl']
|
| 25 |
+
aliases = ['chapel', 'chpl']
|
| 26 |
+
version_added = '2.0'
|
| 27 |
+
# mimetypes = ['text/x-chapel']
|
| 28 |
+
|
| 29 |
+
known_types = ('bool', 'bytes', 'complex', 'imag', 'int', 'locale',
|
| 30 |
+
'nothing', 'opaque', 'range', 'real', 'string', 'uint',
|
| 31 |
+
'void')
|
| 32 |
+
|
| 33 |
+
type_modifiers_par = ('atomic', 'single', 'sync')
|
| 34 |
+
type_modifiers_mem = ('borrowed', 'owned', 'shared', 'unmanaged')
|
| 35 |
+
type_modifiers = (*type_modifiers_par, *type_modifiers_mem)
|
| 36 |
+
|
| 37 |
+
declarations = ('config', 'const', 'in', 'inout', 'out', 'param', 'ref',
|
| 38 |
+
'type', 'var')
|
| 39 |
+
|
| 40 |
+
constants = ('false', 'nil', 'none', 'true')
|
| 41 |
+
|
| 42 |
+
other_keywords = ('align', 'as',
|
| 43 |
+
'begin', 'break', 'by',
|
| 44 |
+
'catch', 'cobegin', 'coforall', 'continue',
|
| 45 |
+
'defer', 'delete', 'dmapped', 'do', 'domain',
|
| 46 |
+
'else', 'enum', 'except', 'export', 'extern',
|
| 47 |
+
'for', 'forall', 'foreach', 'forwarding',
|
| 48 |
+
'if', 'implements', 'import', 'index', 'init', 'inline',
|
| 49 |
+
'label', 'lambda', 'let', 'lifetime', 'local',
|
| 50 |
+
'new', 'noinit',
|
| 51 |
+
'on', 'only', 'otherwise', 'override',
|
| 52 |
+
'pragma', 'primitive', 'private', 'prototype', 'public',
|
| 53 |
+
'reduce', 'require', 'return',
|
| 54 |
+
'scan', 'select', 'serial', 'sparse', 'subdomain',
|
| 55 |
+
'then', 'this', 'throw', 'throws', 'try',
|
| 56 |
+
'use',
|
| 57 |
+
'when', 'where', 'while', 'with',
|
| 58 |
+
'yield',
|
| 59 |
+
'zip')
|
| 60 |
+
|
| 61 |
+
tokens = {
|
| 62 |
+
'root': [
|
| 63 |
+
(r'\n', Whitespace),
|
| 64 |
+
(r'\s+', Whitespace),
|
| 65 |
+
(r'\\\n', Text),
|
| 66 |
+
|
| 67 |
+
(r'//(.*?)\n', Comment.Single),
|
| 68 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 69 |
+
|
| 70 |
+
(words(declarations, suffix=r'\b'), Keyword.Declaration),
|
| 71 |
+
(words(constants, suffix=r'\b'), Keyword.Constant),
|
| 72 |
+
(words(known_types, suffix=r'\b'), Keyword.Type),
|
| 73 |
+
(words((*type_modifiers, *other_keywords), suffix=r'\b'), Keyword),
|
| 74 |
+
|
| 75 |
+
(r'@', Keyword, 'attributename'),
|
| 76 |
+
(r'(iter)(\s+)', bygroups(Keyword, Whitespace), 'procname'),
|
| 77 |
+
(r'(proc)(\s+)', bygroups(Keyword, Whitespace), 'procname'),
|
| 78 |
+
(r'(operator)(\s+)', bygroups(Keyword, Whitespace), 'procname'),
|
| 79 |
+
(r'(class|interface|module|record|union)(\s+)', bygroups(Keyword, Whitespace),
|
| 80 |
+
'classname'),
|
| 81 |
+
|
| 82 |
+
# imaginary integers
|
| 83 |
+
(r'\d+i', Number),
|
| 84 |
+
(r'\d+\.\d*([Ee][-+]\d+)?i', Number),
|
| 85 |
+
(r'\.\d+([Ee][-+]\d+)?i', Number),
|
| 86 |
+
(r'\d+[Ee][-+]\d+i', Number),
|
| 87 |
+
|
| 88 |
+
# reals cannot end with a period due to lexical ambiguity with
|
| 89 |
+
# .. operator. See reference for rationale.
|
| 90 |
+
(r'(\d*\.\d+)([eE][+-]?[0-9]+)?i?', Number.Float),
|
| 91 |
+
(r'\d+[eE][+-]?[0-9]+i?', Number.Float),
|
| 92 |
+
|
| 93 |
+
# integer literals
|
| 94 |
+
# -- binary
|
| 95 |
+
(r'0[bB][01]+', Number.Bin),
|
| 96 |
+
# -- hex
|
| 97 |
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
| 98 |
+
# -- octal
|
| 99 |
+
(r'0[oO][0-7]+', Number.Oct),
|
| 100 |
+
# -- decimal
|
| 101 |
+
(r'[0-9]+', Number.Integer),
|
| 102 |
+
|
| 103 |
+
# strings
|
| 104 |
+
(r'"(\\\\|\\"|[^"])*"', String),
|
| 105 |
+
(r"'(\\\\|\\'|[^'])*'", String),
|
| 106 |
+
|
| 107 |
+
# tokens
|
| 108 |
+
(r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
|
| 109 |
+
r'<=>|<~>|\.\.|by|#|\.\.\.|'
|
| 110 |
+
r'&&|\|\||!|&|\||\^|~|<<|>>|'
|
| 111 |
+
r'==|!=|<=|>=|<|>|'
|
| 112 |
+
r'[+\-*/%]|\*\*)', Operator),
|
| 113 |
+
(r'[:;,.?()\[\]{}]', Punctuation),
|
| 114 |
+
|
| 115 |
+
# identifiers
|
| 116 |
+
(r'[a-zA-Z_][\w$]*', Name.Other),
|
| 117 |
+
],
|
| 118 |
+
'classname': [
|
| 119 |
+
(r'[a-zA-Z_][\w$]*', Name.Class, '#pop'),
|
| 120 |
+
],
|
| 121 |
+
'procname': [
|
| 122 |
+
(r'([a-zA-Z_][.\w$]*|' # regular function name, including secondary
|
| 123 |
+
r'\~[a-zA-Z_][.\w$]*|' # support for legacy destructors
|
| 124 |
+
r'[+*/!~%<>=&^|\-:]{1,2})', # operators
|
| 125 |
+
Name.Function, '#pop'),
|
| 126 |
+
|
| 127 |
+
# allow `proc (atomic T).foo`
|
| 128 |
+
(r'\(', Punctuation, "receivertype"),
|
| 129 |
+
(r'\)+\.', Punctuation),
|
| 130 |
+
],
|
| 131 |
+
'receivertype': [
|
| 132 |
+
(words(type_modifiers, suffix=r'\b'), Keyword),
|
| 133 |
+
(words(known_types, suffix=r'\b'), Keyword.Type),
|
| 134 |
+
(r'[^()]*', Name.Other, '#pop'),
|
| 135 |
+
],
|
| 136 |
+
'attributename': [
|
| 137 |
+
(r'[a-zA-Z_][.\w$]*', Name.Decorator, '#pop'),
|
| 138 |
+
],
|
| 139 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/clean.py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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.clean
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Clean language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import ExtendedRegexLexer, words, default, include, bygroups
|
| 12 |
+
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \
|
| 13 |
+
Operator, Punctuation, String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['CleanLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class CleanLexer(ExtendedRegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the general purpose, state-of-the-art, pure and lazy functional
|
| 21 |
+
programming language Clean.
|
| 22 |
+
|
| 23 |
+
.. versionadded: 2.2
|
| 24 |
+
"""
|
| 25 |
+
name = 'Clean'
|
| 26 |
+
url = 'http://clean.cs.ru.nl/Clean'
|
| 27 |
+
aliases = ['clean']
|
| 28 |
+
filenames = ['*.icl', '*.dcl']
|
| 29 |
+
version_added = ''
|
| 30 |
+
|
| 31 |
+
keywords = (
|
| 32 |
+
'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export',
|
| 33 |
+
'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr',
|
| 34 |
+
'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where',
|
| 35 |
+
'with')
|
| 36 |
+
|
| 37 |
+
modulewords = ('implementation', 'definition', 'system')
|
| 38 |
+
|
| 39 |
+
lowerId = r'[a-z`][\w`]*'
|
| 40 |
+
upperId = r'[A-Z`][\w`]*'
|
| 41 |
+
funnyId = r'[~@#$%\^?!+\-*<>\\/|&=:]+'
|
| 42 |
+
scoreUpperId = r'_' + upperId
|
| 43 |
+
scoreLowerId = r'_' + lowerId
|
| 44 |
+
moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+'
|
| 45 |
+
classId = '|'.join([lowerId, upperId, funnyId])
|
| 46 |
+
|
| 47 |
+
tokens = {
|
| 48 |
+
'root': [
|
| 49 |
+
include('comments'),
|
| 50 |
+
include('keywords'),
|
| 51 |
+
include('module'),
|
| 52 |
+
include('import'),
|
| 53 |
+
include('whitespace'),
|
| 54 |
+
include('literals'),
|
| 55 |
+
include('operators'),
|
| 56 |
+
include('delimiters'),
|
| 57 |
+
include('names'),
|
| 58 |
+
],
|
| 59 |
+
'whitespace': [
|
| 60 |
+
(r'\s+', Whitespace),
|
| 61 |
+
],
|
| 62 |
+
'comments': [
|
| 63 |
+
(r'//.*\n', Comment.Single),
|
| 64 |
+
(r'/\*', Comment.Multiline, 'comments.in'),
|
| 65 |
+
(r'/\*\*', Comment.Special, 'comments.in'),
|
| 66 |
+
],
|
| 67 |
+
'comments.in': [
|
| 68 |
+
(r'\*\/', Comment.Multiline, '#pop'),
|
| 69 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 70 |
+
(r'[^*/]+', Comment.Multiline),
|
| 71 |
+
(r'\*(?!/)', Comment.Multiline),
|
| 72 |
+
(r'/', Comment.Multiline),
|
| 73 |
+
],
|
| 74 |
+
'keywords': [
|
| 75 |
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 76 |
+
],
|
| 77 |
+
'module': [
|
| 78 |
+
(words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
|
| 79 |
+
(r'\bmodule\b', Keyword.Namespace, 'module.name'),
|
| 80 |
+
],
|
| 81 |
+
'module.name': [
|
| 82 |
+
include('whitespace'),
|
| 83 |
+
(moduleId, Name.Class, '#pop'),
|
| 84 |
+
],
|
| 85 |
+
'import': [
|
| 86 |
+
(r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'),
|
| 87 |
+
(r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b',
|
| 88 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword),
|
| 89 |
+
'import.what'),
|
| 90 |
+
],
|
| 91 |
+
'import.module': [
|
| 92 |
+
(r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)),
|
| 93 |
+
(r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')),
|
| 94 |
+
(moduleId, Name.Class),
|
| 95 |
+
(r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)),
|
| 96 |
+
(r'\s+', Whitespace),
|
| 97 |
+
default('#pop'),
|
| 98 |
+
],
|
| 99 |
+
'import.module.as': [
|
| 100 |
+
include('whitespace'),
|
| 101 |
+
(lowerId, Name.Class, '#pop'),
|
| 102 |
+
(upperId, Name.Class, '#pop'),
|
| 103 |
+
],
|
| 104 |
+
'import.what': [
|
| 105 |
+
(r'\b(class)\b(\s+)(' + classId + r')',
|
| 106 |
+
bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'),
|
| 107 |
+
(r'\b(instance)(\s+)(' + classId + r')(\s+)',
|
| 108 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'),
|
| 109 |
+
(r'(::)(\s*)\b(' + upperId + r')\b',
|
| 110 |
+
bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'),
|
| 111 |
+
(r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b',
|
| 112 |
+
bygroups(Keyword, Whitespace, Name)),
|
| 113 |
+
include('names'),
|
| 114 |
+
(r'(,)(\s+)', bygroups(Punctuation, Whitespace)),
|
| 115 |
+
(r'$', Whitespace, '#pop'),
|
| 116 |
+
include('whitespace'),
|
| 117 |
+
],
|
| 118 |
+
'import.what.class': [
|
| 119 |
+
(r',', Punctuation, '#pop'),
|
| 120 |
+
(r'\(', Punctuation, 'import.what.class.members'),
|
| 121 |
+
(r'$', Whitespace, '#pop:2'),
|
| 122 |
+
include('whitespace'),
|
| 123 |
+
],
|
| 124 |
+
'import.what.class.members': [
|
| 125 |
+
(r',', Punctuation),
|
| 126 |
+
(r'\.\.', Punctuation),
|
| 127 |
+
(r'\)', Punctuation, '#pop'),
|
| 128 |
+
include('names'),
|
| 129 |
+
],
|
| 130 |
+
'import.what.instance': [
|
| 131 |
+
(r'[,)]', Punctuation, '#pop'),
|
| 132 |
+
(r'\(', Punctuation, 'import.what.instance'),
|
| 133 |
+
(r'$', Whitespace, '#pop:2'),
|
| 134 |
+
include('whitespace'),
|
| 135 |
+
include('names'),
|
| 136 |
+
],
|
| 137 |
+
'import.what.type': [
|
| 138 |
+
(r',', Punctuation, '#pop'),
|
| 139 |
+
(r'[({]', Punctuation, 'import.what.type.consesandfields'),
|
| 140 |
+
(r'$', Whitespace, '#pop:2'),
|
| 141 |
+
include('whitespace'),
|
| 142 |
+
],
|
| 143 |
+
'import.what.type.consesandfields': [
|
| 144 |
+
(r',', Punctuation),
|
| 145 |
+
(r'\.\.', Punctuation),
|
| 146 |
+
(r'[)}]', Punctuation, '#pop'),
|
| 147 |
+
include('names'),
|
| 148 |
+
],
|
| 149 |
+
'literals': [
|
| 150 |
+
(r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char),
|
| 151 |
+
(r'[+~-]?0[0-7]+\b', Number.Oct),
|
| 152 |
+
(r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float),
|
| 153 |
+
(r'[+~-]?\d+\b', Number.Integer),
|
| 154 |
+
(r'[+~-]?0x[\da-fA-F]+\b', Number.Hex),
|
| 155 |
+
(r'True|False', Literal),
|
| 156 |
+
(r'"', String.Double, 'literals.stringd'),
|
| 157 |
+
],
|
| 158 |
+
'literals.stringd': [
|
| 159 |
+
(r'[^\\"\n]+', String.Double),
|
| 160 |
+
(r'"', String.Double, '#pop'),
|
| 161 |
+
(r'\\.', String.Double),
|
| 162 |
+
(r'[$\n]', Error, '#pop'),
|
| 163 |
+
],
|
| 164 |
+
'operators': [
|
| 165 |
+
(r'[-~@#$%\^?!+*<>\\/|&=:.]+', Operator),
|
| 166 |
+
(r'\b_+\b', Operator),
|
| 167 |
+
],
|
| 168 |
+
'delimiters': [
|
| 169 |
+
(r'[,;(){}\[\]]', Punctuation),
|
| 170 |
+
(r'(\')([\w`.]+)(\')',
|
| 171 |
+
bygroups(Punctuation, Name.Class, Punctuation)),
|
| 172 |
+
],
|
| 173 |
+
'names': [
|
| 174 |
+
(lowerId, Name),
|
| 175 |
+
(scoreLowerId, Name),
|
| 176 |
+
(funnyId, Name.Function),
|
| 177 |
+
(upperId, Name.Class),
|
| 178 |
+
(scoreUpperId, Name.Class),
|
| 179 |
+
]
|
| 180 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/codeql.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.codeql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for CodeQL query language.
|
| 6 |
+
|
| 7 |
+
The grammar is originating from:
|
| 8 |
+
https://github.com/github/vscode-codeql/blob/main/syntaxes/README.md
|
| 9 |
+
|
| 10 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 11 |
+
:license: BSD, see LICENSE for details.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
__all__ = ['CodeQLLexer']
|
| 15 |
+
|
| 16 |
+
import re
|
| 17 |
+
|
| 18 |
+
from pygments.lexer import RegexLexer, words
|
| 19 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 20 |
+
Number, Punctuation, Whitespace
|
| 21 |
+
|
| 22 |
+
class CodeQLLexer(RegexLexer):
|
| 23 |
+
name = 'CodeQL'
|
| 24 |
+
aliases = ['codeql', 'ql']
|
| 25 |
+
filenames = ['*.ql', '*.qll']
|
| 26 |
+
mimetypes = []
|
| 27 |
+
url = 'https://github.com/github/codeql'
|
| 28 |
+
version_added = '2.19'
|
| 29 |
+
|
| 30 |
+
flags = re.MULTILINE | re.UNICODE
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
# Whitespace and comments
|
| 35 |
+
(r'\s+', Whitespace),
|
| 36 |
+
(r'//.*?\n', Comment.Single),
|
| 37 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 38 |
+
|
| 39 |
+
# Keywords
|
| 40 |
+
(words((
|
| 41 |
+
'module', 'import', 'class', 'extends', 'implements',
|
| 42 |
+
'predicate', 'select', 'where', 'from', 'as', 'and', 'or', 'not',
|
| 43 |
+
'in', 'if', 'then', 'else', 'exists', 'forall', 'instanceof',
|
| 44 |
+
'private', 'predicate', 'abstract', 'cached', 'external',
|
| 45 |
+
'final', 'library', 'override', 'query'
|
| 46 |
+
), suffix=r'\b'), Keyword.Builtin),
|
| 47 |
+
|
| 48 |
+
# Special Keywords
|
| 49 |
+
(words(('this'), # class related keywords
|
| 50 |
+
prefix=r'\b', suffix=r'\b\??:?'), Name.Builtin.Pseudo),
|
| 51 |
+
|
| 52 |
+
# Types
|
| 53 |
+
(words((
|
| 54 |
+
'boolean', 'date', 'float', 'int', 'string'
|
| 55 |
+
), suffix=r'\b'), Keyword.Type),
|
| 56 |
+
|
| 57 |
+
# Literals
|
| 58 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 59 |
+
(r'[0-9]+\.[0-9]+', Number.Float),
|
| 60 |
+
(r'[0-9]+', Number.Integer),
|
| 61 |
+
|
| 62 |
+
# Operators
|
| 63 |
+
(r'<=|>=|<|>|=|!=|\+|-|\*|/', Operator),
|
| 64 |
+
|
| 65 |
+
# Punctuation
|
| 66 |
+
(r'[.,;:\[\]{}()]+', Punctuation),
|
| 67 |
+
|
| 68 |
+
# Identifiers
|
| 69 |
+
(r'@[a-zA-Z_]\w*', Name.Variable), # Variables with @ prefix
|
| 70 |
+
(r'[A-Z][a-zA-Z0-9_]*', Name.Class), # Types and classes
|
| 71 |
+
(r'[a-z][a-zA-Z0-9_]*', Name.Variable), # Variables and predicates
|
| 72 |
+
],
|
| 73 |
+
'multiline-comments': [
|
| 74 |
+
(r'[^*/]+', Comment.Multiline),
|
| 75 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 76 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 77 |
+
(r'[*/]', Comment.Multiline),
|
| 78 |
+
],
|
| 79 |
+
|
| 80 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/comal.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.comal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for COMAL-80.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, words
|
| 14 |
+
from pygments.token import Comment, Whitespace, Operator, Keyword, String, \
|
| 15 |
+
Number, Name, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ["Comal80Lexer"]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class Comal80Lexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For COMAL-80 source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'COMAL-80'
|
| 26 |
+
url = 'https://en.wikipedia.org/wiki/COMAL'
|
| 27 |
+
aliases = ['comal', 'comal80']
|
| 28 |
+
filenames = ['*.cml', '*.comal']
|
| 29 |
+
version_added = ''
|
| 30 |
+
flags = re.IGNORECASE
|
| 31 |
+
#
|
| 32 |
+
# COMAL allows for some strange characters in names which we list here so
|
| 33 |
+
# keywords and word operators will not be recognized at the start of an
|
| 34 |
+
# identifier.
|
| 35 |
+
#
|
| 36 |
+
_suffix = r"\b(?!['\[\]←£\\])"
|
| 37 |
+
_identifier = r"[a-z]['\[\]←£\\\w]*"
|
| 38 |
+
|
| 39 |
+
tokens = {
|
| 40 |
+
'root': [
|
| 41 |
+
(r'//.*\n', Comment.Single),
|
| 42 |
+
(r'\s+', Whitespace),
|
| 43 |
+
(r':[=+-]|\<\>|[-+*/^↑<>=]', Operator),
|
| 44 |
+
(r'(and +then|or +else)' + _suffix, Operator.Word),
|
| 45 |
+
(words([
|
| 46 |
+
'and', 'bitand', 'bitor', 'bitxor', 'div', 'in', 'mod', 'not',
|
| 47 |
+
'or'], suffix=_suffix,), Operator.Word),
|
| 48 |
+
(words([
|
| 49 |
+
'append', 'at', 'case', 'chain', 'close', 'copy', 'create', 'cursor',
|
| 50 |
+
'data', 'delete', 'dir', 'do', 'elif', 'else', 'end', 'endcase', 'endif',
|
| 51 |
+
'endfor', 'endloop', 'endtrap', 'endwhile', 'exec', 'exit', 'file',
|
| 52 |
+
'for', 'goto', 'handler', 'if', 'input', 'let', 'loop', 'mount', 'null',
|
| 53 |
+
'of', 'open', 'otherwise', 'output', 'page', 'pass', 'poke', 'print',
|
| 54 |
+
'random', 'read', 'repeat', 'report', 'return', 'rename', 'restore',
|
| 55 |
+
'select', 'step', 'stop', 'sys', 'then', 'to', 'trap', 'unit', 'unit$',
|
| 56 |
+
'until', 'using', 'when', 'while', 'write', 'zone'], suffix=_suffix),
|
| 57 |
+
Keyword.Reserved),
|
| 58 |
+
(words([
|
| 59 |
+
'closed', 'dim', 'endfunc', 'endproc', 'external', 'func', 'import',
|
| 60 |
+
'proc', 'ref', 'use'], suffix=_suffix), Keyword.Declaration),
|
| 61 |
+
(words([
|
| 62 |
+
'abs', 'atn', 'chr$', 'cos', 'eod', 'eof', 'err', 'errfile', 'errtext',
|
| 63 |
+
'esc', 'exp', 'int', 'key$', 'len', 'log', 'ord', 'peek', 'randomize',
|
| 64 |
+
'rnd', 'sgn', 'sin', 'spc$', 'sqr', 'status$', 'str$', 'tab', 'tan',
|
| 65 |
+
'time', 'val'], suffix=_suffix), Name.Builtin),
|
| 66 |
+
(words(['false', 'pi', 'true'], suffix=_suffix), Keyword.Constant),
|
| 67 |
+
(r'"', String, 'string'),
|
| 68 |
+
(_identifier + r":(?=[ \n/])", Name.Label),
|
| 69 |
+
(_identifier + r"[$#]?", Name),
|
| 70 |
+
(r'%[01]+', Number.Bin),
|
| 71 |
+
(r'\$[0-9a-f]+', Number.Hex),
|
| 72 |
+
(r'\d*\.\d*(e[-+]?\d+)?', Number.Float),
|
| 73 |
+
(r'\d+', Number.Integer),
|
| 74 |
+
(r'[(),:;]', Punctuation),
|
| 75 |
+
],
|
| 76 |
+
'string': [
|
| 77 |
+
(r'[^"]+', String),
|
| 78 |
+
(r'"[0-9]*"', String.Escape),
|
| 79 |
+
(r'"', String, '#pop'),
|
| 80 |
+
],
|
| 81 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/compiled.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.compiled
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Just export lexer classes previously contained in this module.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
# ruff: noqa: F401
|
| 12 |
+
from pygments.lexers.jvm import JavaLexer, ScalaLexer
|
| 13 |
+
from pygments.lexers.c_cpp import CLexer, CppLexer
|
| 14 |
+
from pygments.lexers.d import DLexer
|
| 15 |
+
from pygments.lexers.objective import ObjectiveCLexer, \
|
| 16 |
+
ObjectiveCppLexer, LogosLexer
|
| 17 |
+
from pygments.lexers.go import GoLexer
|
| 18 |
+
from pygments.lexers.rust import RustLexer
|
| 19 |
+
from pygments.lexers.c_like import ECLexer, ValaLexer, CudaLexer
|
| 20 |
+
from pygments.lexers.pascal import DelphiLexer, PortugolLexer, Modula2Lexer
|
| 21 |
+
from pygments.lexers.ada import AdaLexer
|
| 22 |
+
from pygments.lexers.business import CobolLexer, CobolFreeformatLexer
|
| 23 |
+
from pygments.lexers.fortran import FortranLexer
|
| 24 |
+
from pygments.lexers.prolog import PrologLexer
|
| 25 |
+
from pygments.lexers.python import CythonLexer
|
| 26 |
+
from pygments.lexers.graphics import GLShaderLexer
|
| 27 |
+
from pygments.lexers.ml import OcamlLexer
|
| 28 |
+
from pygments.lexers.basic import BlitzBasicLexer, BlitzMaxLexer, MonkeyLexer
|
| 29 |
+
from pygments.lexers.dylan import DylanLexer, DylanLidLexer, DylanConsoleLexer
|
| 30 |
+
from pygments.lexers.ooc import OocLexer
|
| 31 |
+
from pygments.lexers.felix import FelixLexer
|
| 32 |
+
from pygments.lexers.nimrod import NimrodLexer
|
| 33 |
+
from pygments.lexers.crystal import CrystalLexer
|
| 34 |
+
|
| 35 |
+
__all__ = []
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/configs.py
ADDED
|
@@ -0,0 +1,1433 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.configs
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for configuration file formats.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import ExtendedRegexLexer, RegexLexer, default, words, \
|
| 14 |
+
bygroups, include, using, line_re
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Whitespace, Literal, Error, Generic
|
| 17 |
+
from pygments.lexers.shell import BashLexer
|
| 18 |
+
from pygments.lexers.data import JsonLexer
|
| 19 |
+
|
| 20 |
+
__all__ = ['IniLexer', 'SystemdLexer', 'DesktopLexer', 'RegeditLexer', 'PropertiesLexer',
|
| 21 |
+
'KconfigLexer', 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer',
|
| 22 |
+
'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer',
|
| 23 |
+
'TerraformLexer', 'TermcapLexer', 'TerminfoLexer',
|
| 24 |
+
'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer',
|
| 25 |
+
'NestedTextLexer', 'SingularityLexer', 'UnixConfigLexer']
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class IniLexer(RegexLexer):
|
| 29 |
+
"""
|
| 30 |
+
Lexer for configuration files in INI style.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
name = 'INI'
|
| 34 |
+
aliases = ['ini', 'cfg', 'dosini']
|
| 35 |
+
filenames = [
|
| 36 |
+
'*.ini', '*.cfg', '*.inf', '.editorconfig',
|
| 37 |
+
]
|
| 38 |
+
mimetypes = ['text/x-ini', 'text/inf']
|
| 39 |
+
url = 'https://en.wikipedia.org/wiki/INI_file'
|
| 40 |
+
version_added = ''
|
| 41 |
+
|
| 42 |
+
tokens = {
|
| 43 |
+
'root': [
|
| 44 |
+
(r'\s+', Whitespace),
|
| 45 |
+
(r'[;#].*', Comment.Single),
|
| 46 |
+
(r'(\[.*?\])([ \t]*)$', bygroups(Keyword, Whitespace)),
|
| 47 |
+
(r'''(.*?)([ \t]*)([=:])([ \t]*)(["'])''',
|
| 48 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String),
|
| 49 |
+
"quoted_value"),
|
| 50 |
+
(r'(.*?)([ \t]*)([=:])([ \t]*)([^;#\n]*)(\\)(\s+)',
|
| 51 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String,
|
| 52 |
+
Text, Whitespace),
|
| 53 |
+
"value"),
|
| 54 |
+
(r'(.*?)([ \t]*)([=:])([ \t]*)([^ ;#\n]*(?: +[^ ;#\n]+)*)',
|
| 55 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)),
|
| 56 |
+
# standalone option, supported by some INI parsers
|
| 57 |
+
(r'(.+?)$', Name.Attribute),
|
| 58 |
+
],
|
| 59 |
+
'quoted_value': [
|
| 60 |
+
(r'''([^"'\n]*)(["'])(\s*)''',
|
| 61 |
+
bygroups(String, String, Whitespace), "#pop"),
|
| 62 |
+
(r'[;#].*', Comment.Single),
|
| 63 |
+
(r'$', String, "#pop"),
|
| 64 |
+
],
|
| 65 |
+
'value': [ # line continuation
|
| 66 |
+
(r'\s+', Whitespace),
|
| 67 |
+
(r'(\s*)(.*)(\\)([ \t]*)',
|
| 68 |
+
bygroups(Whitespace, String, Text, Whitespace)),
|
| 69 |
+
(r'.*$', String, "#pop"),
|
| 70 |
+
],
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
def analyse_text(text):
|
| 74 |
+
npos = text.find('\n')
|
| 75 |
+
if npos < 3:
|
| 76 |
+
return False
|
| 77 |
+
if text[0] == '[' and text[npos-1] == ']':
|
| 78 |
+
return 0.8
|
| 79 |
+
return False
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
class DesktopLexer(RegexLexer):
|
| 83 |
+
"""
|
| 84 |
+
Lexer for .desktop files.
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
name = 'Desktop file'
|
| 88 |
+
url = "https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html"
|
| 89 |
+
aliases = ['desktop']
|
| 90 |
+
filenames = ['*.desktop']
|
| 91 |
+
mimetypes = ['application/x-desktop']
|
| 92 |
+
version_added = '2.16'
|
| 93 |
+
|
| 94 |
+
tokens = {
|
| 95 |
+
'root': [
|
| 96 |
+
(r'^[ \t]*\n', Whitespace),
|
| 97 |
+
(r'^(#.*)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 98 |
+
(r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)),
|
| 99 |
+
(r'([-A-Za-z0-9]+)(\[[^\] \t=]+\])?([ \t]*)(=)([ \t]*)([^\n]*)([ \t\n]*\n)',
|
| 100 |
+
bygroups(Name.Attribute, Name.Namespace, Whitespace, Operator, Whitespace, String, Whitespace)),
|
| 101 |
+
],
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
def analyse_text(text):
|
| 105 |
+
if text.startswith("[Desktop Entry]"):
|
| 106 |
+
return 1.0
|
| 107 |
+
if re.search(r"^\[Desktop Entry\][ \t]*$", text[:500], re.MULTILINE) is not None:
|
| 108 |
+
return 0.9
|
| 109 |
+
return 0.0
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class SystemdLexer(RegexLexer):
|
| 113 |
+
"""
|
| 114 |
+
Lexer for systemd unit files.
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
name = 'Systemd'
|
| 118 |
+
url = "https://www.freedesktop.org/software/systemd/man/systemd.syntax.html"
|
| 119 |
+
aliases = ['systemd']
|
| 120 |
+
filenames = [
|
| 121 |
+
'*.service', '*.socket', '*.device', '*.mount', '*.automount',
|
| 122 |
+
'*.swap', '*.target', '*.path', '*.timer', '*.slice', '*.scope',
|
| 123 |
+
]
|
| 124 |
+
version_added = '2.16'
|
| 125 |
+
|
| 126 |
+
tokens = {
|
| 127 |
+
'root': [
|
| 128 |
+
(r'^[ \t]*\n', Whitespace),
|
| 129 |
+
(r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 130 |
+
(r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)),
|
| 131 |
+
(r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\\)(\n)',
|
| 132 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String,
|
| 133 |
+
Text, Whitespace),
|
| 134 |
+
"value"),
|
| 135 |
+
(r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\n)',
|
| 136 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, Whitespace)),
|
| 137 |
+
],
|
| 138 |
+
'value': [
|
| 139 |
+
# line continuation
|
| 140 |
+
(r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 141 |
+
(r'([ \t]*)([^\n]*)(\\)(\n)',
|
| 142 |
+
bygroups(Whitespace, String, Text, Whitespace)),
|
| 143 |
+
(r'([ \t]*)([^\n]*)(\n)',
|
| 144 |
+
bygroups(Whitespace, String, Whitespace), "#pop"),
|
| 145 |
+
],
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
def analyse_text(text):
|
| 149 |
+
if text.startswith("[Unit]"):
|
| 150 |
+
return 1.0
|
| 151 |
+
if re.search(r"^\[Unit\][ \t]*$", text[:500], re.MULTILINE) is not None:
|
| 152 |
+
return 0.9
|
| 153 |
+
return 0.0
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
class RegeditLexer(RegexLexer):
|
| 157 |
+
"""
|
| 158 |
+
Lexer for Windows Registry files produced by regedit.
|
| 159 |
+
"""
|
| 160 |
+
|
| 161 |
+
name = 'reg'
|
| 162 |
+
url = 'http://en.wikipedia.org/wiki/Windows_Registry#.REG_files'
|
| 163 |
+
aliases = ['registry']
|
| 164 |
+
filenames = ['*.reg']
|
| 165 |
+
mimetypes = ['text/x-windows-registry']
|
| 166 |
+
version_added = '1.6'
|
| 167 |
+
|
| 168 |
+
tokens = {
|
| 169 |
+
'root': [
|
| 170 |
+
(r'Windows Registry Editor.*', Text),
|
| 171 |
+
(r'\s+', Whitespace),
|
| 172 |
+
(r'[;#].*', Comment.Single),
|
| 173 |
+
(r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$',
|
| 174 |
+
bygroups(Keyword, Operator, Name.Builtin, Keyword)),
|
| 175 |
+
# String keys, which obey somewhat normal escaping
|
| 176 |
+
(r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)',
|
| 177 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace),
|
| 178 |
+
'value'),
|
| 179 |
+
# Bare keys (includes @)
|
| 180 |
+
(r'(.*?)([ \t]*)(=)([ \t]*)',
|
| 181 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace),
|
| 182 |
+
'value'),
|
| 183 |
+
],
|
| 184 |
+
'value': [
|
| 185 |
+
(r'-', Operator, '#pop'), # delete value
|
| 186 |
+
(r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)',
|
| 187 |
+
bygroups(Name.Variable, Punctuation, Number), '#pop'),
|
| 188 |
+
# As far as I know, .reg files do not support line continuation.
|
| 189 |
+
(r'.+', String, '#pop'),
|
| 190 |
+
default('#pop'),
|
| 191 |
+
]
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
def analyse_text(text):
|
| 195 |
+
return text.startswith('Windows Registry Editor')
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class PropertiesLexer(RegexLexer):
|
| 199 |
+
"""
|
| 200 |
+
Lexer for configuration files in Java's properties format.
|
| 201 |
+
|
| 202 |
+
Note: trailing whitespace counts as part of the value as per spec
|
| 203 |
+
"""
|
| 204 |
+
|
| 205 |
+
name = 'Properties'
|
| 206 |
+
aliases = ['properties', 'jproperties']
|
| 207 |
+
filenames = ['*.properties']
|
| 208 |
+
mimetypes = ['text/x-java-properties']
|
| 209 |
+
url = 'https://en.wikipedia.org/wiki/.properties'
|
| 210 |
+
version_added = '1.4'
|
| 211 |
+
|
| 212 |
+
tokens = {
|
| 213 |
+
'root': [
|
| 214 |
+
# comments
|
| 215 |
+
(r'[!#].*|/{2}.*', Comment.Single),
|
| 216 |
+
# ending a comment or whitespace-only line
|
| 217 |
+
(r'\n', Whitespace),
|
| 218 |
+
# eat whitespace at the beginning of a line
|
| 219 |
+
(r'^[^\S\n]+', Whitespace),
|
| 220 |
+
# start lexing a key
|
| 221 |
+
default('key'),
|
| 222 |
+
],
|
| 223 |
+
'key': [
|
| 224 |
+
# non-escaped key characters
|
| 225 |
+
(r'[^\\:=\s]+', Name.Attribute),
|
| 226 |
+
# escapes
|
| 227 |
+
include('escapes'),
|
| 228 |
+
# separator is the first non-escaped whitespace or colon or '=' on the line;
|
| 229 |
+
# if it's whitespace, = and : are gobbled after it
|
| 230 |
+
(r'([^\S\n]*)([:=])([^\S\n]*)',
|
| 231 |
+
bygroups(Whitespace, Operator, Whitespace),
|
| 232 |
+
('#pop', 'value')),
|
| 233 |
+
(r'[^\S\n]+', Whitespace, ('#pop', 'value')),
|
| 234 |
+
# maybe we got no value after all
|
| 235 |
+
(r'\n', Whitespace, '#pop'),
|
| 236 |
+
],
|
| 237 |
+
'value': [
|
| 238 |
+
# non-escaped value characters
|
| 239 |
+
(r'[^\\\n]+', String),
|
| 240 |
+
# escapes
|
| 241 |
+
include('escapes'),
|
| 242 |
+
# end the value on an unescaped newline
|
| 243 |
+
(r'\n', Whitespace, '#pop'),
|
| 244 |
+
],
|
| 245 |
+
'escapes': [
|
| 246 |
+
# line continuations; these gobble whitespace at the beginning of the next line
|
| 247 |
+
(r'(\\\n)([^\S\n]*)', bygroups(String.Escape, Whitespace)),
|
| 248 |
+
# other escapes
|
| 249 |
+
(r'\\(.|\n)', String.Escape),
|
| 250 |
+
],
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
def _rx_indent(level):
|
| 255 |
+
# Kconfig *always* interprets a tab as 8 spaces, so this is the default.
|
| 256 |
+
# Edit this if you are in an environment where KconfigLexer gets expanded
|
| 257 |
+
# input (tabs expanded to spaces) and the expansion tab width is != 8,
|
| 258 |
+
# e.g. in connection with Trac (trac.ini, [mimeviewer], tab_width).
|
| 259 |
+
# Value range here is 2 <= {tab_width} <= 8.
|
| 260 |
+
tab_width = 8
|
| 261 |
+
# Regex matching a given indentation {level}, assuming that indentation is
|
| 262 |
+
# a multiple of {tab_width}. In other cases there might be problems.
|
| 263 |
+
if tab_width == 2:
|
| 264 |
+
space_repeat = '+'
|
| 265 |
+
else:
|
| 266 |
+
space_repeat = '{1,%d}' % (tab_width - 1)
|
| 267 |
+
if level == 1:
|
| 268 |
+
level_repeat = ''
|
| 269 |
+
else:
|
| 270 |
+
level_repeat = f'{{{level}}}'
|
| 271 |
+
return rf'(?:\t| {space_repeat}\t| {{{tab_width}}}){level_repeat}.*\n'
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
class KconfigLexer(RegexLexer):
|
| 275 |
+
"""
|
| 276 |
+
For Linux-style Kconfig files.
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
name = 'Kconfig'
|
| 280 |
+
aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config']
|
| 281 |
+
version_added = '1.6'
|
| 282 |
+
# Adjust this if new kconfig file names appear in your environment
|
| 283 |
+
filenames = ['Kconfig*', '*Config.in*', 'external.in*',
|
| 284 |
+
'standard-modules.in']
|
| 285 |
+
mimetypes = ['text/x-kconfig']
|
| 286 |
+
url = 'https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html'
|
| 287 |
+
|
| 288 |
+
# No re.MULTILINE, indentation-aware help text needs line-by-line handling
|
| 289 |
+
flags = 0
|
| 290 |
+
|
| 291 |
+
def call_indent(level):
|
| 292 |
+
# If indentation >= {level} is detected, enter state 'indent{level}'
|
| 293 |
+
return (_rx_indent(level), String.Doc, f'indent{level}')
|
| 294 |
+
|
| 295 |
+
def do_indent(level):
|
| 296 |
+
# Print paragraphs of indentation level >= {level} as String.Doc,
|
| 297 |
+
# ignoring blank lines. Then return to 'root' state.
|
| 298 |
+
return [
|
| 299 |
+
(_rx_indent(level), String.Doc),
|
| 300 |
+
(r'\s*\n', Text),
|
| 301 |
+
default('#pop:2')
|
| 302 |
+
]
|
| 303 |
+
|
| 304 |
+
tokens = {
|
| 305 |
+
'root': [
|
| 306 |
+
(r'\s+', Whitespace),
|
| 307 |
+
(r'#.*?\n', Comment.Single),
|
| 308 |
+
(words((
|
| 309 |
+
'mainmenu', 'config', 'menuconfig', 'choice', 'endchoice',
|
| 310 |
+
'comment', 'menu', 'endmenu', 'visible if', 'if', 'endif',
|
| 311 |
+
'source', 'prompt', 'select', 'depends on', 'default',
|
| 312 |
+
'range', 'option'), suffix=r'\b'),
|
| 313 |
+
Keyword),
|
| 314 |
+
(r'(---help---|help)[\t ]*\n', Keyword, 'help'),
|
| 315 |
+
(r'(bool|tristate|string|hex|int|defconfig_list|modules|env)\b',
|
| 316 |
+
Name.Builtin),
|
| 317 |
+
(r'[!=&|]', Operator),
|
| 318 |
+
(r'[()]', Punctuation),
|
| 319 |
+
(r'[0-9]+', Number.Integer),
|
| 320 |
+
(r"'(''|[^'])*'", String.Single),
|
| 321 |
+
(r'"(""|[^"])*"', String.Double),
|
| 322 |
+
(r'\S+', Text),
|
| 323 |
+
],
|
| 324 |
+
# Help text is indented, multi-line and ends when a lower indentation
|
| 325 |
+
# level is detected.
|
| 326 |
+
'help': [
|
| 327 |
+
# Skip blank lines after help token, if any
|
| 328 |
+
(r'\s*\n', Text),
|
| 329 |
+
# Determine the first help line's indentation level heuristically(!).
|
| 330 |
+
# Attention: this is not perfect, but works for 99% of "normal"
|
| 331 |
+
# indentation schemes up to a max. indentation level of 7.
|
| 332 |
+
call_indent(7),
|
| 333 |
+
call_indent(6),
|
| 334 |
+
call_indent(5),
|
| 335 |
+
call_indent(4),
|
| 336 |
+
call_indent(3),
|
| 337 |
+
call_indent(2),
|
| 338 |
+
call_indent(1),
|
| 339 |
+
default('#pop'), # for incomplete help sections without text
|
| 340 |
+
],
|
| 341 |
+
# Handle text for indentation levels 7 to 1
|
| 342 |
+
'indent7': do_indent(7),
|
| 343 |
+
'indent6': do_indent(6),
|
| 344 |
+
'indent5': do_indent(5),
|
| 345 |
+
'indent4': do_indent(4),
|
| 346 |
+
'indent3': do_indent(3),
|
| 347 |
+
'indent2': do_indent(2),
|
| 348 |
+
'indent1': do_indent(1),
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
class Cfengine3Lexer(RegexLexer):
|
| 353 |
+
"""
|
| 354 |
+
Lexer for CFEngine3 policy files.
|
| 355 |
+
"""
|
| 356 |
+
|
| 357 |
+
name = 'CFEngine3'
|
| 358 |
+
url = 'http://cfengine.org'
|
| 359 |
+
aliases = ['cfengine3', 'cf3']
|
| 360 |
+
filenames = ['*.cf']
|
| 361 |
+
mimetypes = []
|
| 362 |
+
version_added = '1.5'
|
| 363 |
+
|
| 364 |
+
tokens = {
|
| 365 |
+
'root': [
|
| 366 |
+
(r'#.*?\n', Comment),
|
| 367 |
+
(r'(body)(\s+)(\S+)(\s+)(control)',
|
| 368 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)),
|
| 369 |
+
(r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()',
|
| 370 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function, Punctuation),
|
| 371 |
+
'arglist'),
|
| 372 |
+
(r'(body|bundle)(\s+)(\S+)(\s+)(\w+)',
|
| 373 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function)),
|
| 374 |
+
(r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)',
|
| 375 |
+
bygroups(Punctuation, Name.Variable, Punctuation,
|
| 376 |
+
Whitespace, Keyword.Type, Whitespace, Operator, Whitespace)),
|
| 377 |
+
(r'(\S+)(\s*)(=>)(\s*)',
|
| 378 |
+
bygroups(Keyword.Reserved, Whitespace, Operator, Text)),
|
| 379 |
+
(r'"', String, 'string'),
|
| 380 |
+
(r'(\w+)(\()', bygroups(Name.Function, Punctuation)),
|
| 381 |
+
(r'([\w.!&|()]+)(::)', bygroups(Name.Class, Punctuation)),
|
| 382 |
+
(r'(\w+)(:)', bygroups(Keyword.Declaration, Punctuation)),
|
| 383 |
+
(r'@[{(][^)}]+[})]', Name.Variable),
|
| 384 |
+
(r'[(){},;]', Punctuation),
|
| 385 |
+
(r'=>', Operator),
|
| 386 |
+
(r'->', Operator),
|
| 387 |
+
(r'\d+\.\d+', Number.Float),
|
| 388 |
+
(r'\d+', Number.Integer),
|
| 389 |
+
(r'\w+', Name.Function),
|
| 390 |
+
(r'\s+', Whitespace),
|
| 391 |
+
],
|
| 392 |
+
'string': [
|
| 393 |
+
(r'\$[{(]', String.Interpol, 'interpol'),
|
| 394 |
+
(r'\\.', String.Escape),
|
| 395 |
+
(r'"', String, '#pop'),
|
| 396 |
+
(r'\n', String),
|
| 397 |
+
(r'.', String),
|
| 398 |
+
],
|
| 399 |
+
'interpol': [
|
| 400 |
+
(r'\$[{(]', String.Interpol, '#push'),
|
| 401 |
+
(r'[})]', String.Interpol, '#pop'),
|
| 402 |
+
(r'[^${()}]+', String.Interpol),
|
| 403 |
+
],
|
| 404 |
+
'arglist': [
|
| 405 |
+
(r'\)', Punctuation, '#pop'),
|
| 406 |
+
(r',', Punctuation),
|
| 407 |
+
(r'\w+', Name.Variable),
|
| 408 |
+
(r'\s+', Whitespace),
|
| 409 |
+
],
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
class ApacheConfLexer(RegexLexer):
|
| 414 |
+
"""
|
| 415 |
+
Lexer for configuration files following the Apache config file
|
| 416 |
+
format.
|
| 417 |
+
"""
|
| 418 |
+
|
| 419 |
+
name = 'ApacheConf'
|
| 420 |
+
aliases = ['apacheconf', 'aconf', 'apache']
|
| 421 |
+
filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
|
| 422 |
+
mimetypes = ['text/x-apacheconf']
|
| 423 |
+
url = 'https://httpd.apache.org/docs/current/configuring.html'
|
| 424 |
+
version_added = '0.6'
|
| 425 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 426 |
+
|
| 427 |
+
tokens = {
|
| 428 |
+
'root': [
|
| 429 |
+
(r'\s+', Whitespace),
|
| 430 |
+
(r'#(.*\\\n)+.*$|(#.*?)$', Comment),
|
| 431 |
+
(r'(<[^\s>/][^\s>]*)(?:(\s+)(.*))?(>)',
|
| 432 |
+
bygroups(Name.Tag, Whitespace, String, Name.Tag)),
|
| 433 |
+
(r'(</[^\s>]+)(>)',
|
| 434 |
+
bygroups(Name.Tag, Name.Tag)),
|
| 435 |
+
(r'[a-z]\w*', Name.Builtin, 'value'),
|
| 436 |
+
(r'\.+', Text),
|
| 437 |
+
],
|
| 438 |
+
'value': [
|
| 439 |
+
(r'\\\n', Text),
|
| 440 |
+
(r'\n+', Whitespace, '#pop'),
|
| 441 |
+
(r'\\', Text),
|
| 442 |
+
(r'[^\S\n]+', Whitespace),
|
| 443 |
+
(r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
|
| 444 |
+
(r'\d+', Number),
|
| 445 |
+
(r'/([*a-z0-9][*\w./-]+)', String.Other),
|
| 446 |
+
(r'(on|off|none|any|all|double|email|dns|min|minimal|'
|
| 447 |
+
r'os|productonly|full|emerg|alert|crit|error|warn|'
|
| 448 |
+
r'notice|info|debug|registry|script|inetd|standalone|'
|
| 449 |
+
r'user|group)\b', Keyword),
|
| 450 |
+
(r'"([^"\\]*(?:\\(.|\n)[^"\\]*)*)"', String.Double),
|
| 451 |
+
(r'[^\s"\\]+', Text)
|
| 452 |
+
],
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
|
| 456 |
+
class SquidConfLexer(RegexLexer):
|
| 457 |
+
"""
|
| 458 |
+
Lexer for squid configuration files.
|
| 459 |
+
"""
|
| 460 |
+
|
| 461 |
+
name = 'SquidConf'
|
| 462 |
+
url = 'http://www.squid-cache.org/'
|
| 463 |
+
aliases = ['squidconf', 'squid.conf', 'squid']
|
| 464 |
+
filenames = ['squid.conf']
|
| 465 |
+
mimetypes = ['text/x-squidconf']
|
| 466 |
+
version_added = '0.9'
|
| 467 |
+
flags = re.IGNORECASE
|
| 468 |
+
|
| 469 |
+
keywords = (
|
| 470 |
+
"access_log", "acl", "always_direct", "announce_host",
|
| 471 |
+
"announce_period", "announce_port", "announce_to", "anonymize_headers",
|
| 472 |
+
"append_domain", "as_whois_server", "auth_param_basic",
|
| 473 |
+
"authenticate_children", "authenticate_program", "authenticate_ttl",
|
| 474 |
+
"broken_posts", "buffered_logs", "cache_access_log", "cache_announce",
|
| 475 |
+
"cache_dir", "cache_dns_program", "cache_effective_group",
|
| 476 |
+
"cache_effective_user", "cache_host", "cache_host_acl",
|
| 477 |
+
"cache_host_domain", "cache_log", "cache_mem", "cache_mem_high",
|
| 478 |
+
"cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer",
|
| 479 |
+
"cache_peer_access", "cache_replacement_policy", "cache_stoplist",
|
| 480 |
+
"cache_stoplist_pattern", "cache_store_log", "cache_swap",
|
| 481 |
+
"cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db",
|
| 482 |
+
"client_lifetime", "client_netmask", "connect_timeout", "coredump_dir",
|
| 483 |
+
"dead_peer_timeout", "debug_options", "delay_access", "delay_class",
|
| 484 |
+
"delay_initial_bucket_level", "delay_parameters", "delay_pools",
|
| 485 |
+
"deny_info", "dns_children", "dns_defnames", "dns_nameservers",
|
| 486 |
+
"dns_testnames", "emulate_httpd_log", "err_html_text",
|
| 487 |
+
"fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port",
|
| 488 |
+
"fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width",
|
| 489 |
+
"ftp_passive", "ftp_user", "half_closed_clients", "header_access",
|
| 490 |
+
"header_replace", "hierarchy_stoplist", "high_response_time_warning",
|
| 491 |
+
"high_page_fault_warning", "hosts_file", "htcp_port", "http_access",
|
| 492 |
+
"http_anonymizer", "httpd_accel", "httpd_accel_host",
|
| 493 |
+
"httpd_accel_port", "httpd_accel_uses_host_header",
|
| 494 |
+
"httpd_accel_with_proxy", "http_port", "http_reply_access",
|
| 495 |
+
"icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout",
|
| 496 |
+
"ident_lookup", "ident_lookup_access", "ident_timeout",
|
| 497 |
+
"incoming_http_average", "incoming_icp_average", "inside_firewall",
|
| 498 |
+
"ipcache_high", "ipcache_low", "ipcache_size", "local_domain",
|
| 499 |
+
"local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries",
|
| 500 |
+
"log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries",
|
| 501 |
+
"mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr",
|
| 502 |
+
"mcast_miss_encode_key", "mcast_miss_port", "memory_pools",
|
| 503 |
+
"memory_pools_limit", "memory_replacement_policy", "mime_table",
|
| 504 |
+
"min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops",
|
| 505 |
+
"minimum_object_size", "minimum_retry_timeout", "miss_access",
|
| 506 |
+
"negative_dns_ttl", "negative_ttl", "neighbor_timeout",
|
| 507 |
+
"neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period",
|
| 508 |
+
"netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy",
|
| 509 |
+
"pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl",
|
| 510 |
+
"prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp",
|
| 511 |
+
"quick_abort", "quick_abort_max", "quick_abort_min",
|
| 512 |
+
"quick_abort_pct", "range_offset_limit", "read_timeout",
|
| 513 |
+
"redirect_children", "redirect_program",
|
| 514 |
+
"redirect_rewrites_host_header", "reference_age",
|
| 515 |
+
"refresh_pattern", "reload_into_ims", "request_body_max_size",
|
| 516 |
+
"request_size", "request_timeout", "shutdown_lifetime",
|
| 517 |
+
"single_parent_bypass", "siteselect_timeout", "snmp_access",
|
| 518 |
+
"snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy",
|
| 519 |
+
"store_avg_object_size", "store_objects_per_bucket",
|
| 520 |
+
"strip_query_terms", "swap_level1_dirs", "swap_level2_dirs",
|
| 521 |
+
"tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize",
|
| 522 |
+
"test_reachability", "udp_hit_obj", "udp_hit_obj_size",
|
| 523 |
+
"udp_incoming_address", "udp_outgoing_address", "unique_hostname",
|
| 524 |
+
"unlinkd_program", "uri_whitespace", "useragent_log",
|
| 525 |
+
"visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port",
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
opts = (
|
| 529 |
+
"proxy-only", "weight", "ttl", "no-query", "default", "round-robin",
|
| 530 |
+
"multicast-responder", "on", "off", "all", "deny", "allow", "via",
|
| 531 |
+
"parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2",
|
| 532 |
+
"credentialsttl", "none", "disable", "offline_toggle", "diskd",
|
| 533 |
+
)
|
| 534 |
+
|
| 535 |
+
actions = (
|
| 536 |
+
"shutdown", "info", "parameter", "server_list", "client_list",
|
| 537 |
+
r'squid.conf',
|
| 538 |
+
)
|
| 539 |
+
|
| 540 |
+
actions_stats = (
|
| 541 |
+
"objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns",
|
| 542 |
+
"redirector", "io", "reply_headers", "filedescriptors", "netdb",
|
| 543 |
+
)
|
| 544 |
+
|
| 545 |
+
actions_log = ("status", "enable", "disable", "clear")
|
| 546 |
+
|
| 547 |
+
acls = (
|
| 548 |
+
"url_regex", "urlpath_regex", "referer_regex", "port", "proto",
|
| 549 |
+
"req_mime_type", "rep_mime_type", "method", "browser", "user", "src",
|
| 550 |
+
"dst", "time", "dstdomain", "ident", "snmp_community",
|
| 551 |
+
)
|
| 552 |
+
|
| 553 |
+
ipv4_group = r'(\d+|0x[0-9a-f]+)'
|
| 554 |
+
ipv4 = rf'({ipv4_group}(\.{ipv4_group}){{3}})'
|
| 555 |
+
ipv6_group = r'([0-9a-f]{0,4})'
|
| 556 |
+
ipv6 = rf'({ipv6_group}(:{ipv6_group}){{1,7}})'
|
| 557 |
+
bare_ip = rf'({ipv4}|{ipv6})'
|
| 558 |
+
# XXX: /integer is a subnet mark, but what is /IP ?
|
| 559 |
+
# There is no test where it is used.
|
| 560 |
+
ip = rf'{bare_ip}(/({bare_ip}|\d+))?'
|
| 561 |
+
|
| 562 |
+
tokens = {
|
| 563 |
+
'root': [
|
| 564 |
+
(r'\s+', Whitespace),
|
| 565 |
+
(r'#', Comment, 'comment'),
|
| 566 |
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 567 |
+
(words(opts, prefix=r'\b', suffix=r'\b'), Name.Constant),
|
| 568 |
+
# Actions
|
| 569 |
+
(words(actions, prefix=r'\b', suffix=r'\b'), String),
|
| 570 |
+
(words(actions_stats, prefix=r'stats/', suffix=r'\b'), String),
|
| 571 |
+
(words(actions_log, prefix=r'log/', suffix=r'='), String),
|
| 572 |
+
(words(acls, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 573 |
+
(ip, Number.Float),
|
| 574 |
+
(r'(?:\b\d+\b(?:-\b\d+|%)?)', Number),
|
| 575 |
+
(r'\S+', Text),
|
| 576 |
+
],
|
| 577 |
+
'comment': [
|
| 578 |
+
(r'\s*TAG:.*', String.Escape, '#pop'),
|
| 579 |
+
(r'.+', Comment, '#pop'),
|
| 580 |
+
default('#pop'),
|
| 581 |
+
],
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
class NginxConfLexer(RegexLexer):
|
| 586 |
+
"""
|
| 587 |
+
Lexer for Nginx configuration files.
|
| 588 |
+
"""
|
| 589 |
+
name = 'Nginx configuration file'
|
| 590 |
+
url = 'http://nginx.net/'
|
| 591 |
+
aliases = ['nginx']
|
| 592 |
+
filenames = ['nginx.conf']
|
| 593 |
+
mimetypes = ['text/x-nginx-conf']
|
| 594 |
+
version_added = '0.11'
|
| 595 |
+
|
| 596 |
+
tokens = {
|
| 597 |
+
'root': [
|
| 598 |
+
(r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Whitespace, Name)),
|
| 599 |
+
(r'[^\s;#]+', Keyword, 'stmt'),
|
| 600 |
+
include('base'),
|
| 601 |
+
],
|
| 602 |
+
'block': [
|
| 603 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 604 |
+
(r'[^\s;#]+', Keyword.Namespace, 'stmt'),
|
| 605 |
+
include('base'),
|
| 606 |
+
],
|
| 607 |
+
'stmt': [
|
| 608 |
+
(r'\{', Punctuation, 'block'),
|
| 609 |
+
(r';', Punctuation, '#pop'),
|
| 610 |
+
include('base'),
|
| 611 |
+
],
|
| 612 |
+
'base': [
|
| 613 |
+
(r'#.*\n', Comment.Single),
|
| 614 |
+
(r'on|off', Name.Constant),
|
| 615 |
+
(r'\$[^\s;#()]+', Name.Variable),
|
| 616 |
+
(r'([a-z0-9.-]+)(:)([0-9]+)',
|
| 617 |
+
bygroups(Name, Punctuation, Number.Integer)),
|
| 618 |
+
(r'[a-z-]+/[a-z-+]+', String), # mimetype
|
| 619 |
+
# (r'[a-zA-Z._-]+', Keyword),
|
| 620 |
+
(r'[0-9]+[km]?\b', Number.Integer),
|
| 621 |
+
(r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Whitespace, String.Regex)),
|
| 622 |
+
(r'[:=~]', Punctuation),
|
| 623 |
+
(r'[^\s;#{}$]+', String), # catch all
|
| 624 |
+
(r'/[^\s;#]*', Name), # pathname
|
| 625 |
+
(r'\s+', Whitespace),
|
| 626 |
+
(r'[$;]', Text), # leftover characters
|
| 627 |
+
],
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
class LighttpdConfLexer(RegexLexer):
|
| 632 |
+
"""
|
| 633 |
+
Lexer for Lighttpd configuration files.
|
| 634 |
+
"""
|
| 635 |
+
name = 'Lighttpd configuration file'
|
| 636 |
+
url = 'http://lighttpd.net/'
|
| 637 |
+
aliases = ['lighttpd', 'lighty']
|
| 638 |
+
filenames = ['lighttpd.conf']
|
| 639 |
+
mimetypes = ['text/x-lighttpd-conf']
|
| 640 |
+
version_added = '0.11'
|
| 641 |
+
|
| 642 |
+
tokens = {
|
| 643 |
+
'root': [
|
| 644 |
+
(r'#.*\n', Comment.Single),
|
| 645 |
+
(r'/\S*', Name), # pathname
|
| 646 |
+
(r'[a-zA-Z._-]+', Keyword),
|
| 647 |
+
(r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
|
| 648 |
+
(r'[0-9]+', Number),
|
| 649 |
+
(r'=>|=~|\+=|==|=|\+', Operator),
|
| 650 |
+
(r'\$[A-Z]+', Name.Builtin),
|
| 651 |
+
(r'[(){}\[\],]', Punctuation),
|
| 652 |
+
(r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
|
| 653 |
+
(r'\s+', Whitespace),
|
| 654 |
+
],
|
| 655 |
+
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
class DockerLexer(RegexLexer):
|
| 660 |
+
"""
|
| 661 |
+
Lexer for Docker configuration files.
|
| 662 |
+
"""
|
| 663 |
+
name = 'Docker'
|
| 664 |
+
url = 'http://docker.io'
|
| 665 |
+
aliases = ['docker', 'dockerfile']
|
| 666 |
+
filenames = ['Dockerfile', '*.docker']
|
| 667 |
+
mimetypes = ['text/x-dockerfile-config']
|
| 668 |
+
version_added = '2.0'
|
| 669 |
+
|
| 670 |
+
_keywords = (r'(?:MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)')
|
| 671 |
+
_bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)')
|
| 672 |
+
_lb = r'(?:\s*\\?\s*)' # dockerfile line break regex
|
| 673 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 674 |
+
|
| 675 |
+
tokens = {
|
| 676 |
+
'root': [
|
| 677 |
+
(r'#.*', Comment),
|
| 678 |
+
(r'(FROM)([ \t]*)(\S*)([ \t]*)(?:(AS)([ \t]*)(\S*))?',
|
| 679 |
+
bygroups(Keyword, Whitespace, String, Whitespace, Keyword, Whitespace, String)),
|
| 680 |
+
(rf'(ONBUILD)(\s+)({_lb})', bygroups(Keyword, Whitespace, using(BashLexer))),
|
| 681 |
+
(rf'(HEALTHCHECK)(\s+)(({_lb}--\w+=\w+{_lb})*)',
|
| 682 |
+
bygroups(Keyword, Whitespace, using(BashLexer))),
|
| 683 |
+
(rf'(VOLUME|ENTRYPOINT|CMD|SHELL)(\s+)({_lb})(\[.*?\])',
|
| 684 |
+
bygroups(Keyword, Whitespace, using(BashLexer), using(JsonLexer))),
|
| 685 |
+
(rf'(LABEL|ENV|ARG)(\s+)(({_lb}\w+=\w+{_lb})*)',
|
| 686 |
+
bygroups(Keyword, Whitespace, using(BashLexer))),
|
| 687 |
+
(rf'({_keywords}|VOLUME)\b(\s+)(.*)', bygroups(Keyword, Whitespace, String)),
|
| 688 |
+
(rf'({_bash_keywords})(\s+)', bygroups(Keyword, Whitespace)),
|
| 689 |
+
(r'(.*\\\n)*.+', using(BashLexer)),
|
| 690 |
+
]
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
|
| 694 |
+
class TerraformLexer(ExtendedRegexLexer):
|
| 695 |
+
"""
|
| 696 |
+
Lexer for terraformi ``.tf`` files.
|
| 697 |
+
"""
|
| 698 |
+
|
| 699 |
+
name = 'Terraform'
|
| 700 |
+
url = 'https://www.terraform.io/'
|
| 701 |
+
aliases = ['terraform', 'tf', 'hcl']
|
| 702 |
+
filenames = ['*.tf', '*.hcl']
|
| 703 |
+
mimetypes = ['application/x-tf', 'application/x-terraform']
|
| 704 |
+
version_added = '2.1'
|
| 705 |
+
|
| 706 |
+
classes = ('backend', 'data', 'module', 'output', 'provider',
|
| 707 |
+
'provisioner', 'resource', 'variable')
|
| 708 |
+
classes_re = "({})".format(('|').join(classes))
|
| 709 |
+
|
| 710 |
+
types = ('string', 'number', 'bool', 'list', 'tuple', 'map', 'set', 'object', 'null')
|
| 711 |
+
|
| 712 |
+
numeric_functions = ('abs', 'ceil', 'floor', 'log', 'max',
|
| 713 |
+
'mix', 'parseint', 'pow', 'signum')
|
| 714 |
+
|
| 715 |
+
string_functions = ('chomp', 'format', 'formatlist', 'indent',
|
| 716 |
+
'join', 'lower', 'regex', 'regexall', 'replace',
|
| 717 |
+
'split', 'strrev', 'substr', 'title', 'trim',
|
| 718 |
+
'trimprefix', 'trimsuffix', 'trimspace', 'upper'
|
| 719 |
+
)
|
| 720 |
+
|
| 721 |
+
collection_functions = ('alltrue', 'anytrue', 'chunklist', 'coalesce',
|
| 722 |
+
'coalescelist', 'compact', 'concat', 'contains',
|
| 723 |
+
'distinct', 'element', 'flatten', 'index', 'keys',
|
| 724 |
+
'length', 'list', 'lookup', 'map', 'matchkeys',
|
| 725 |
+
'merge', 'range', 'reverse', 'setintersection',
|
| 726 |
+
'setproduct', 'setsubtract', 'setunion', 'slice',
|
| 727 |
+
'sort', 'sum', 'transpose', 'values', 'zipmap'
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
encoding_functions = ('base64decode', 'base64encode', 'base64gzip',
|
| 731 |
+
'csvdecode', 'jsondecode', 'jsonencode', 'textdecodebase64',
|
| 732 |
+
'textencodebase64', 'urlencode', 'yamldecode', 'yamlencode')
|
| 733 |
+
|
| 734 |
+
filesystem_functions = ('abspath', 'dirname', 'pathexpand', 'basename',
|
| 735 |
+
'file', 'fileexists', 'fileset', 'filebase64', 'templatefile')
|
| 736 |
+
|
| 737 |
+
date_time_functions = ('formatdate', 'timeadd', 'timestamp')
|
| 738 |
+
|
| 739 |
+
hash_crypto_functions = ('base64sha256', 'base64sha512', 'bcrypt', 'filebase64sha256',
|
| 740 |
+
'filebase64sha512', 'filemd5', 'filesha1', 'filesha256', 'filesha512',
|
| 741 |
+
'md5', 'rsadecrypt', 'sha1', 'sha256', 'sha512', 'uuid', 'uuidv5')
|
| 742 |
+
|
| 743 |
+
ip_network_functions = ('cidrhost', 'cidrnetmask', 'cidrsubnet', 'cidrsubnets')
|
| 744 |
+
|
| 745 |
+
type_conversion_functions = ('can', 'defaults', 'tobool', 'tolist', 'tomap',
|
| 746 |
+
'tonumber', 'toset', 'tostring', 'try')
|
| 747 |
+
|
| 748 |
+
builtins = numeric_functions + string_functions + collection_functions + encoding_functions +\
|
| 749 |
+
filesystem_functions + date_time_functions + hash_crypto_functions + ip_network_functions +\
|
| 750 |
+
type_conversion_functions
|
| 751 |
+
builtins_re = "({})".format(('|').join(builtins))
|
| 752 |
+
|
| 753 |
+
def heredoc_callback(self, match, ctx):
|
| 754 |
+
# Parse a terraform heredoc
|
| 755 |
+
# match: 1 = <<[-]?, 2 = name 3 = rest of line
|
| 756 |
+
|
| 757 |
+
start = match.start(1)
|
| 758 |
+
yield start, Operator, match.group(1) # <<[-]?
|
| 759 |
+
yield match.start(2), String.Delimiter, match.group(2) # heredoc name
|
| 760 |
+
|
| 761 |
+
ctx.pos = match.start(3)
|
| 762 |
+
ctx.end = match.end(3)
|
| 763 |
+
yield ctx.pos, String.Heredoc, match.group(3)
|
| 764 |
+
ctx.pos = match.end()
|
| 765 |
+
|
| 766 |
+
hdname = match.group(2)
|
| 767 |
+
tolerant = True # leading whitespace is always accepted
|
| 768 |
+
|
| 769 |
+
lines = []
|
| 770 |
+
|
| 771 |
+
for match in line_re.finditer(ctx.text, ctx.pos):
|
| 772 |
+
if tolerant:
|
| 773 |
+
check = match.group().strip()
|
| 774 |
+
else:
|
| 775 |
+
check = match.group().rstrip()
|
| 776 |
+
if check == hdname:
|
| 777 |
+
for amatch in lines:
|
| 778 |
+
yield amatch.start(), String.Heredoc, amatch.group()
|
| 779 |
+
yield match.start(), String.Delimiter, match.group()
|
| 780 |
+
ctx.pos = match.end()
|
| 781 |
+
break
|
| 782 |
+
else:
|
| 783 |
+
lines.append(match)
|
| 784 |
+
else:
|
| 785 |
+
# end of heredoc not found -- error!
|
| 786 |
+
for amatch in lines:
|
| 787 |
+
yield amatch.start(), Error, amatch.group()
|
| 788 |
+
ctx.end = len(ctx.text)
|
| 789 |
+
|
| 790 |
+
tokens = {
|
| 791 |
+
'root': [
|
| 792 |
+
include('basic'),
|
| 793 |
+
include('whitespace'),
|
| 794 |
+
|
| 795 |
+
# Strings
|
| 796 |
+
(r'(".*")', bygroups(String.Double)),
|
| 797 |
+
|
| 798 |
+
# Constants
|
| 799 |
+
(words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Name.Constant),
|
| 800 |
+
|
| 801 |
+
# Types
|
| 802 |
+
(words(types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 803 |
+
|
| 804 |
+
include('identifier'),
|
| 805 |
+
include('punctuation'),
|
| 806 |
+
(r'[0-9]+', Number),
|
| 807 |
+
],
|
| 808 |
+
'basic': [
|
| 809 |
+
(r'\s*/\*', Comment.Multiline, 'comment'),
|
| 810 |
+
(r'\s*(#|//).*\n', Comment.Single),
|
| 811 |
+
include('whitespace'),
|
| 812 |
+
|
| 813 |
+
# e.g. terraform {
|
| 814 |
+
# e.g. egress {
|
| 815 |
+
(r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=?)(\s*)(\{)',
|
| 816 |
+
bygroups(Whitespace, Name.Builtin, Whitespace, Operator, Whitespace, Punctuation)),
|
| 817 |
+
|
| 818 |
+
# Assignment with attributes, e.g. something = ...
|
| 819 |
+
(r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=)(\s*)',
|
| 820 |
+
bygroups(Whitespace, Name.Attribute, Whitespace, Operator, Whitespace)),
|
| 821 |
+
|
| 822 |
+
# Assignment with environment variables and similar, e.g. "something" = ...
|
| 823 |
+
# or key value assignment, e.g. "SlotName" : ...
|
| 824 |
+
(r'(\s*)("\S+")(\s*)([=:])(\s*)',
|
| 825 |
+
bygroups(Whitespace, Literal.String.Double, Whitespace, Operator, Whitespace)),
|
| 826 |
+
|
| 827 |
+
# Functions, e.g. jsonencode(element("value"))
|
| 828 |
+
(builtins_re + r'(\()', bygroups(Name.Function, Punctuation)),
|
| 829 |
+
|
| 830 |
+
# List of attributes, e.g. ignore_changes = [last_modified, filename]
|
| 831 |
+
(r'(\[)([a-z_,\s]+)(\])', bygroups(Punctuation, Name.Builtin, Punctuation)),
|
| 832 |
+
|
| 833 |
+
# e.g. resource "aws_security_group" "allow_tls" {
|
| 834 |
+
# e.g. backend "consul" {
|
| 835 |
+
(classes_re + r'(\s+)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)',
|
| 836 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation)),
|
| 837 |
+
|
| 838 |
+
# here-doc style delimited strings
|
| 839 |
+
(r'(<<-?)\s*([a-zA-Z_]\w*)(.*?\n)', heredoc_callback),
|
| 840 |
+
],
|
| 841 |
+
'identifier': [
|
| 842 |
+
(r'\b(var\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)),
|
| 843 |
+
(r'\b([0-9a-zA-Z-_\[\]]+\.[0-9a-zA-Z-_\.\[\]]+)\b',
|
| 844 |
+
bygroups(Name.Variable)),
|
| 845 |
+
],
|
| 846 |
+
'punctuation': [
|
| 847 |
+
(r'[\[\]()\{\},.?:!=]', Punctuation),
|
| 848 |
+
],
|
| 849 |
+
'comment': [
|
| 850 |
+
(r'[^*/]', Comment.Multiline),
|
| 851 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 852 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 853 |
+
(r'[*/]', Comment.Multiline)
|
| 854 |
+
],
|
| 855 |
+
'whitespace': [
|
| 856 |
+
(r'\n', Whitespace),
|
| 857 |
+
(r'\s+', Whitespace),
|
| 858 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)),
|
| 859 |
+
],
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
+
|
| 863 |
+
class TermcapLexer(RegexLexer):
|
| 864 |
+
"""
|
| 865 |
+
Lexer for termcap database source.
|
| 866 |
+
|
| 867 |
+
This is very simple and minimal.
|
| 868 |
+
"""
|
| 869 |
+
name = 'Termcap'
|
| 870 |
+
aliases = ['termcap']
|
| 871 |
+
filenames = ['termcap', 'termcap.src']
|
| 872 |
+
mimetypes = []
|
| 873 |
+
url = 'https://en.wikipedia.org/wiki/Termcap'
|
| 874 |
+
version_added = '2.1'
|
| 875 |
+
|
| 876 |
+
# NOTE:
|
| 877 |
+
# * multiline with trailing backslash
|
| 878 |
+
# * separator is ':'
|
| 879 |
+
# * to embed colon as data, we must use \072
|
| 880 |
+
# * space after separator is not allowed (mayve)
|
| 881 |
+
tokens = {
|
| 882 |
+
'root': [
|
| 883 |
+
(r'^#.*', Comment),
|
| 884 |
+
(r'^[^\s#:|]+', Name.Tag, 'names'),
|
| 885 |
+
(r'\s+', Whitespace),
|
| 886 |
+
],
|
| 887 |
+
'names': [
|
| 888 |
+
(r'\n', Whitespace, '#pop'),
|
| 889 |
+
(r':', Punctuation, 'defs'),
|
| 890 |
+
(r'\|', Punctuation),
|
| 891 |
+
(r'[^:|]+', Name.Attribute),
|
| 892 |
+
],
|
| 893 |
+
'defs': [
|
| 894 |
+
(r'(\\)(\n[ \t]*)', bygroups(Text, Whitespace)),
|
| 895 |
+
(r'\n[ \t]*', Whitespace, '#pop:2'),
|
| 896 |
+
(r'(#)([0-9]+)', bygroups(Operator, Number)),
|
| 897 |
+
(r'=', Operator, 'data'),
|
| 898 |
+
(r':', Punctuation),
|
| 899 |
+
(r'[^\s:=#]+', Name.Class),
|
| 900 |
+
],
|
| 901 |
+
'data': [
|
| 902 |
+
(r'\\072', Literal),
|
| 903 |
+
(r':', Punctuation, '#pop'),
|
| 904 |
+
(r'[^:\\]+', Literal), # for performance
|
| 905 |
+
(r'.', Literal),
|
| 906 |
+
],
|
| 907 |
+
}
|
| 908 |
+
|
| 909 |
+
|
| 910 |
+
class TerminfoLexer(RegexLexer):
|
| 911 |
+
"""
|
| 912 |
+
Lexer for terminfo database source.
|
| 913 |
+
|
| 914 |
+
This is very simple and minimal.
|
| 915 |
+
"""
|
| 916 |
+
name = 'Terminfo'
|
| 917 |
+
aliases = ['terminfo']
|
| 918 |
+
filenames = ['terminfo', 'terminfo.src']
|
| 919 |
+
mimetypes = []
|
| 920 |
+
url = 'https://en.wikipedia.org/wiki/Terminfo'
|
| 921 |
+
version_added = '2.1'
|
| 922 |
+
|
| 923 |
+
# NOTE:
|
| 924 |
+
# * multiline with leading whitespace
|
| 925 |
+
# * separator is ','
|
| 926 |
+
# * to embed comma as data, we can use \,
|
| 927 |
+
# * space after separator is allowed
|
| 928 |
+
tokens = {
|
| 929 |
+
'root': [
|
| 930 |
+
(r'^#.*$', Comment),
|
| 931 |
+
(r'^[^\s#,|]+', Name.Tag, 'names'),
|
| 932 |
+
(r'\s+', Whitespace),
|
| 933 |
+
],
|
| 934 |
+
'names': [
|
| 935 |
+
(r'\n', Whitespace, '#pop'),
|
| 936 |
+
(r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), 'defs'),
|
| 937 |
+
(r'\|', Punctuation),
|
| 938 |
+
(r'[^,|]+', Name.Attribute),
|
| 939 |
+
],
|
| 940 |
+
'defs': [
|
| 941 |
+
(r'\n[ \t]+', Whitespace),
|
| 942 |
+
(r'\n', Whitespace, '#pop:2'),
|
| 943 |
+
(r'(#)([0-9]+)', bygroups(Operator, Number)),
|
| 944 |
+
(r'=', Operator, 'data'),
|
| 945 |
+
(r'(,)([ \t]*)', bygroups(Punctuation, Whitespace)),
|
| 946 |
+
(r'[^\s,=#]+', Name.Class),
|
| 947 |
+
],
|
| 948 |
+
'data': [
|
| 949 |
+
(r'\\[,\\]', Literal),
|
| 950 |
+
(r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), '#pop'),
|
| 951 |
+
(r'[^\\,]+', Literal), # for performance
|
| 952 |
+
(r'.', Literal),
|
| 953 |
+
],
|
| 954 |
+
}
|
| 955 |
+
|
| 956 |
+
|
| 957 |
+
class PkgConfigLexer(RegexLexer):
|
| 958 |
+
"""
|
| 959 |
+
Lexer for pkg-config
|
| 960 |
+
(see also `manual page <http://linux.die.net/man/1/pkg-config>`_).
|
| 961 |
+
"""
|
| 962 |
+
|
| 963 |
+
name = 'PkgConfig'
|
| 964 |
+
url = 'http://www.freedesktop.org/wiki/Software/pkg-config/'
|
| 965 |
+
aliases = ['pkgconfig']
|
| 966 |
+
filenames = ['*.pc']
|
| 967 |
+
mimetypes = []
|
| 968 |
+
version_added = '2.1'
|
| 969 |
+
|
| 970 |
+
tokens = {
|
| 971 |
+
'root': [
|
| 972 |
+
(r'#.*$', Comment.Single),
|
| 973 |
+
|
| 974 |
+
# variable definitions
|
| 975 |
+
(r'^(\w+)(=)', bygroups(Name.Attribute, Operator)),
|
| 976 |
+
|
| 977 |
+
# keyword lines
|
| 978 |
+
(r'^([\w.]+)(:)',
|
| 979 |
+
bygroups(Name.Tag, Punctuation), 'spvalue'),
|
| 980 |
+
|
| 981 |
+
# variable references
|
| 982 |
+
include('interp'),
|
| 983 |
+
|
| 984 |
+
# fallback
|
| 985 |
+
(r'\s+', Whitespace),
|
| 986 |
+
(r'[^${}#=:\n.]+', Text),
|
| 987 |
+
(r'.', Text),
|
| 988 |
+
],
|
| 989 |
+
'interp': [
|
| 990 |
+
# you can escape literal "$" as "$$"
|
| 991 |
+
(r'\$\$', Text),
|
| 992 |
+
|
| 993 |
+
# variable references
|
| 994 |
+
(r'\$\{', String.Interpol, 'curly'),
|
| 995 |
+
],
|
| 996 |
+
'curly': [
|
| 997 |
+
(r'\}', String.Interpol, '#pop'),
|
| 998 |
+
(r'\w+', Name.Attribute),
|
| 999 |
+
],
|
| 1000 |
+
'spvalue': [
|
| 1001 |
+
include('interp'),
|
| 1002 |
+
|
| 1003 |
+
(r'#.*$', Comment.Single, '#pop'),
|
| 1004 |
+
(r'\n', Whitespace, '#pop'),
|
| 1005 |
+
|
| 1006 |
+
# fallback
|
| 1007 |
+
(r'\s+', Whitespace),
|
| 1008 |
+
(r'[^${}#\n\s]+', Text),
|
| 1009 |
+
(r'.', Text),
|
| 1010 |
+
],
|
| 1011 |
+
}
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
class PacmanConfLexer(RegexLexer):
|
| 1015 |
+
"""
|
| 1016 |
+
Lexer for pacman.conf.
|
| 1017 |
+
|
| 1018 |
+
Actually, IniLexer works almost fine for this format,
|
| 1019 |
+
but it yield error token. It is because pacman.conf has
|
| 1020 |
+
a form without assignment like:
|
| 1021 |
+
|
| 1022 |
+
UseSyslog
|
| 1023 |
+
Color
|
| 1024 |
+
TotalDownload
|
| 1025 |
+
CheckSpace
|
| 1026 |
+
VerbosePkgLists
|
| 1027 |
+
|
| 1028 |
+
These are flags to switch on.
|
| 1029 |
+
"""
|
| 1030 |
+
|
| 1031 |
+
name = 'PacmanConf'
|
| 1032 |
+
url = 'https://www.archlinux.org/pacman/pacman.conf.5.html'
|
| 1033 |
+
aliases = ['pacmanconf']
|
| 1034 |
+
filenames = ['pacman.conf']
|
| 1035 |
+
mimetypes = []
|
| 1036 |
+
version_added = '2.1'
|
| 1037 |
+
|
| 1038 |
+
tokens = {
|
| 1039 |
+
'root': [
|
| 1040 |
+
# comment
|
| 1041 |
+
(r'#.*$', Comment.Single),
|
| 1042 |
+
|
| 1043 |
+
# section header
|
| 1044 |
+
(r'^(\s*)(\[.*?\])(\s*)$', bygroups(Whitespace, Keyword, Whitespace)),
|
| 1045 |
+
|
| 1046 |
+
# variable definitions
|
| 1047 |
+
# (Leading space is allowed...)
|
| 1048 |
+
(r'(\w+)(\s*)(=)',
|
| 1049 |
+
bygroups(Name.Attribute, Whitespace, Operator)),
|
| 1050 |
+
|
| 1051 |
+
# flags to on
|
| 1052 |
+
(r'^(\s*)(\w+)(\s*)$',
|
| 1053 |
+
bygroups(Whitespace, Name.Attribute, Whitespace)),
|
| 1054 |
+
|
| 1055 |
+
# built-in special values
|
| 1056 |
+
(words((
|
| 1057 |
+
'$repo', # repository
|
| 1058 |
+
'$arch', # architecture
|
| 1059 |
+
'%o', # outfile
|
| 1060 |
+
'%u', # url
|
| 1061 |
+
), suffix=r'\b'),
|
| 1062 |
+
Name.Variable),
|
| 1063 |
+
|
| 1064 |
+
# fallback
|
| 1065 |
+
(r'\s+', Whitespace),
|
| 1066 |
+
(r'.', Text),
|
| 1067 |
+
],
|
| 1068 |
+
}
|
| 1069 |
+
|
| 1070 |
+
|
| 1071 |
+
class AugeasLexer(RegexLexer):
|
| 1072 |
+
"""
|
| 1073 |
+
Lexer for Augeas.
|
| 1074 |
+
"""
|
| 1075 |
+
name = 'Augeas'
|
| 1076 |
+
url = 'http://augeas.net'
|
| 1077 |
+
aliases = ['augeas']
|
| 1078 |
+
filenames = ['*.aug']
|
| 1079 |
+
version_added = '2.4'
|
| 1080 |
+
|
| 1081 |
+
tokens = {
|
| 1082 |
+
'root': [
|
| 1083 |
+
(r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)),
|
| 1084 |
+
(r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Whitespace, Name.Variable)),
|
| 1085 |
+
(r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Whitespace)),
|
| 1086 |
+
(r'(\()([^:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)),
|
| 1087 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 1088 |
+
(r'[*+\-.;=?|]', Operator),
|
| 1089 |
+
(r'[()\[\]{}]', Operator),
|
| 1090 |
+
(r'"', String.Double, 'string'),
|
| 1091 |
+
(r'\/', String.Regex, 'regex'),
|
| 1092 |
+
(r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)),
|
| 1093 |
+
(r'.', Name.Variable),
|
| 1094 |
+
(r'\s+', Whitespace),
|
| 1095 |
+
],
|
| 1096 |
+
'string': [
|
| 1097 |
+
(r'\\.', String.Escape),
|
| 1098 |
+
(r'[^"]', String.Double),
|
| 1099 |
+
(r'"', String.Double, '#pop'),
|
| 1100 |
+
],
|
| 1101 |
+
'regex': [
|
| 1102 |
+
(r'\\.', String.Escape),
|
| 1103 |
+
(r'[^/]', String.Regex),
|
| 1104 |
+
(r'\/', String.Regex, '#pop'),
|
| 1105 |
+
],
|
| 1106 |
+
'comment': [
|
| 1107 |
+
(r'[^*)]', Comment.Multiline),
|
| 1108 |
+
(r'\(\*', Comment.Multiline, '#push'),
|
| 1109 |
+
(r'\*\)', Comment.Multiline, '#pop'),
|
| 1110 |
+
(r'[)*]', Comment.Multiline)
|
| 1111 |
+
],
|
| 1112 |
+
}
|
| 1113 |
+
|
| 1114 |
+
|
| 1115 |
+
class TOMLLexer(RegexLexer):
|
| 1116 |
+
"""
|
| 1117 |
+
Lexer for TOML, a simple language for config files.
|
| 1118 |
+
"""
|
| 1119 |
+
|
| 1120 |
+
name = 'TOML'
|
| 1121 |
+
aliases = ['toml']
|
| 1122 |
+
filenames = ['*.toml', 'Pipfile', 'poetry.lock']
|
| 1123 |
+
mimetypes = ['application/toml']
|
| 1124 |
+
url = 'https://toml.io'
|
| 1125 |
+
version_added = '2.4'
|
| 1126 |
+
|
| 1127 |
+
# Based on the TOML spec: https://toml.io/en/v1.0.0
|
| 1128 |
+
|
| 1129 |
+
# The following is adapted from CPython's tomllib:
|
| 1130 |
+
_time = r"\d\d:\d\d(:\d\d(\.\d+)?)?"
|
| 1131 |
+
_datetime = rf"""(?x)
|
| 1132 |
+
\d\d\d\d-\d\d-\d\d # date, e.g., 1988-10-27
|
| 1133 |
+
(
|
| 1134 |
+
[Tt ] {_time} # optional time
|
| 1135 |
+
(
|
| 1136 |
+
[Zz]|[+-]\d\d:\d\d # optional time offset
|
| 1137 |
+
)?
|
| 1138 |
+
)?
|
| 1139 |
+
"""
|
| 1140 |
+
|
| 1141 |
+
tokens = {
|
| 1142 |
+
'root': [
|
| 1143 |
+
# Note that we make an effort in order to distinguish
|
| 1144 |
+
# moments at which we're parsing a key and moments at
|
| 1145 |
+
# which we're parsing a value. In the TOML code
|
| 1146 |
+
#
|
| 1147 |
+
# 1234 = 1234
|
| 1148 |
+
#
|
| 1149 |
+
# the first "1234" should be Name, the second Integer.
|
| 1150 |
+
|
| 1151 |
+
# Whitespace
|
| 1152 |
+
(r'\s+', Whitespace),
|
| 1153 |
+
|
| 1154 |
+
# Comment
|
| 1155 |
+
(r'#.*', Comment.Single),
|
| 1156 |
+
|
| 1157 |
+
# Assignment keys
|
| 1158 |
+
include('key'),
|
| 1159 |
+
|
| 1160 |
+
# After "=", find a value
|
| 1161 |
+
(r'(=)(\s*)', bygroups(Operator, Whitespace), 'value'),
|
| 1162 |
+
|
| 1163 |
+
# Table header
|
| 1164 |
+
(r'\[\[?', Keyword, 'table-key'),
|
| 1165 |
+
],
|
| 1166 |
+
'key': [
|
| 1167 |
+
# Start of bare key (only ASCII is allowed here).
|
| 1168 |
+
(r'[A-Za-z0-9_-]+', Name),
|
| 1169 |
+
# Quoted key
|
| 1170 |
+
(r'"', String.Double, 'basic-string'),
|
| 1171 |
+
(r"'", String.Single, 'literal-string'),
|
| 1172 |
+
# Dots act as separators in keys
|
| 1173 |
+
(r'\.', Punctuation),
|
| 1174 |
+
],
|
| 1175 |
+
'table-key': [
|
| 1176 |
+
# This is like 'key', but highlights the name components
|
| 1177 |
+
# and separating dots as Keyword because it looks better
|
| 1178 |
+
# when the whole table header is Keyword. We do highlight
|
| 1179 |
+
# strings as strings though.
|
| 1180 |
+
# Start of bare key (only ASCII is allowed here).
|
| 1181 |
+
(r'[A-Za-z0-9_-]+', Keyword),
|
| 1182 |
+
(r'"', String.Double, 'basic-string'),
|
| 1183 |
+
(r"'", String.Single, 'literal-string'),
|
| 1184 |
+
(r'\.', Keyword),
|
| 1185 |
+
(r'\]\]?', Keyword, '#pop'),
|
| 1186 |
+
|
| 1187 |
+
# Inline whitespace allowed
|
| 1188 |
+
(r'[ \t]+', Whitespace),
|
| 1189 |
+
],
|
| 1190 |
+
'value': [
|
| 1191 |
+
# Datetime, baretime
|
| 1192 |
+
(_datetime, Literal.Date, '#pop'),
|
| 1193 |
+
(_time, Literal.Date, '#pop'),
|
| 1194 |
+
|
| 1195 |
+
# Recognize as float if there is a fractional part
|
| 1196 |
+
# and/or an exponent.
|
| 1197 |
+
(r'[+-]?\d[0-9_]*[eE][+-]?\d[0-9_]*', Number.Float, '#pop'),
|
| 1198 |
+
(r'[+-]?\d[0-9_]*\.\d[0-9_]*([eE][+-]?\d[0-9_]*)?',
|
| 1199 |
+
Number.Float, '#pop'),
|
| 1200 |
+
|
| 1201 |
+
# Infinities and NaN
|
| 1202 |
+
(r'[+-]?(inf|nan)', Number.Float, '#pop'),
|
| 1203 |
+
|
| 1204 |
+
# Integers
|
| 1205 |
+
(r'-?0b[01_]+', Number.Bin, '#pop'),
|
| 1206 |
+
(r'-?0o[0-7_]+', Number.Oct, '#pop'),
|
| 1207 |
+
(r'-?0x[0-9a-fA-F_]+', Number.Hex, '#pop'),
|
| 1208 |
+
(r'[+-]?[0-9_]+', Number.Integer, '#pop'),
|
| 1209 |
+
|
| 1210 |
+
# Strings
|
| 1211 |
+
(r'"""', String.Double, ('#pop', 'multiline-basic-string')),
|
| 1212 |
+
(r'"', String.Double, ('#pop', 'basic-string')),
|
| 1213 |
+
(r"'''", String.Single, ('#pop', 'multiline-literal-string')),
|
| 1214 |
+
(r"'", String.Single, ('#pop', 'literal-string')),
|
| 1215 |
+
|
| 1216 |
+
# Booleans
|
| 1217 |
+
(r'true|false', Keyword.Constant, '#pop'),
|
| 1218 |
+
|
| 1219 |
+
# Start of array
|
| 1220 |
+
(r'\[', Punctuation, ('#pop', 'array')),
|
| 1221 |
+
|
| 1222 |
+
# Start of inline table
|
| 1223 |
+
(r'\{', Punctuation, ('#pop', 'inline-table')),
|
| 1224 |
+
],
|
| 1225 |
+
'array': [
|
| 1226 |
+
# Whitespace, including newlines, is ignored inside arrays,
|
| 1227 |
+
# and comments are allowed.
|
| 1228 |
+
(r'\s+', Whitespace),
|
| 1229 |
+
(r'#.*', Comment.Single),
|
| 1230 |
+
|
| 1231 |
+
# Delimiters
|
| 1232 |
+
(r',', Punctuation),
|
| 1233 |
+
|
| 1234 |
+
# End of array
|
| 1235 |
+
(r'\]', Punctuation, '#pop'),
|
| 1236 |
+
|
| 1237 |
+
# Parse a value and come back
|
| 1238 |
+
default('value'),
|
| 1239 |
+
],
|
| 1240 |
+
'inline-table': [
|
| 1241 |
+
# Whitespace (since TOML 1.1.0, same as in array)
|
| 1242 |
+
(r'\s+', Whitespace),
|
| 1243 |
+
(r'#.*', Comment.Single),
|
| 1244 |
+
|
| 1245 |
+
# Keys
|
| 1246 |
+
include('key'),
|
| 1247 |
+
|
| 1248 |
+
# Values
|
| 1249 |
+
(r'(=)(\s*)', bygroups(Punctuation, Whitespace), 'value'),
|
| 1250 |
+
|
| 1251 |
+
# Delimiters
|
| 1252 |
+
(r',', Punctuation),
|
| 1253 |
+
|
| 1254 |
+
# End of inline table
|
| 1255 |
+
(r'\}', Punctuation, '#pop'),
|
| 1256 |
+
],
|
| 1257 |
+
'basic-string': [
|
| 1258 |
+
(r'"', String.Double, '#pop'),
|
| 1259 |
+
include('escapes'),
|
| 1260 |
+
(r'[^"\\]+', String.Double),
|
| 1261 |
+
],
|
| 1262 |
+
'literal-string': [
|
| 1263 |
+
(r".*?'", String.Single, '#pop'),
|
| 1264 |
+
],
|
| 1265 |
+
'multiline-basic-string': [
|
| 1266 |
+
(r'"""', String.Double, '#pop'),
|
| 1267 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)),
|
| 1268 |
+
include('escapes'),
|
| 1269 |
+
(r'[^"\\]+', String.Double),
|
| 1270 |
+
(r'"', String.Double),
|
| 1271 |
+
],
|
| 1272 |
+
'multiline-literal-string': [
|
| 1273 |
+
(r"'''", String.Single, '#pop'),
|
| 1274 |
+
(r"[^']+", String.Single),
|
| 1275 |
+
(r"'", String.Single),
|
| 1276 |
+
],
|
| 1277 |
+
'escapes': [
|
| 1278 |
+
(r'\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}', String.Escape),
|
| 1279 |
+
(r'\\.', String.Escape),
|
| 1280 |
+
],
|
| 1281 |
+
}
|
| 1282 |
+
|
| 1283 |
+
class NestedTextLexer(RegexLexer):
|
| 1284 |
+
"""
|
| 1285 |
+
Lexer for *NextedText*, a human-friendly data format.
|
| 1286 |
+
|
| 1287 |
+
.. versionchanged:: 2.16
|
| 1288 |
+
Added support for *NextedText* v3.0.
|
| 1289 |
+
"""
|
| 1290 |
+
|
| 1291 |
+
name = 'NestedText'
|
| 1292 |
+
url = 'https://nestedtext.org'
|
| 1293 |
+
aliases = ['nestedtext', 'nt']
|
| 1294 |
+
filenames = ['*.nt']
|
| 1295 |
+
version_added = '2.9'
|
| 1296 |
+
|
| 1297 |
+
tokens = {
|
| 1298 |
+
'root': [
|
| 1299 |
+
# Comment: # ...
|
| 1300 |
+
(r'^([ ]*)(#.*)$', bygroups(Whitespace, Comment)),
|
| 1301 |
+
|
| 1302 |
+
# Inline dictionary: {...}
|
| 1303 |
+
(r'^([ ]*)(\{)', bygroups(Whitespace, Punctuation), 'inline_dict'),
|
| 1304 |
+
|
| 1305 |
+
# Inline list: [...]
|
| 1306 |
+
(r'^([ ]*)(\[)', bygroups(Whitespace, Punctuation), 'inline_list'),
|
| 1307 |
+
|
| 1308 |
+
# empty multiline string item: >
|
| 1309 |
+
(r'^([ ]*)(>)$', bygroups(Whitespace, Punctuation)),
|
| 1310 |
+
|
| 1311 |
+
# multiline string item: > ...
|
| 1312 |
+
(r'^([ ]*)(>)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)),
|
| 1313 |
+
|
| 1314 |
+
# empty list item: -
|
| 1315 |
+
(r'^([ ]*)(-)$', bygroups(Whitespace, Punctuation)),
|
| 1316 |
+
|
| 1317 |
+
# list item: - ...
|
| 1318 |
+
(r'^([ ]*)(-)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)),
|
| 1319 |
+
|
| 1320 |
+
# empty multiline key item: :
|
| 1321 |
+
(r'^([ ]*)(:)$', bygroups(Whitespace, Punctuation)),
|
| 1322 |
+
|
| 1323 |
+
# multiline key item: : ...
|
| 1324 |
+
(r'^([ ]*)(:)( )([^\n]*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Name.Tag, Whitespace)),
|
| 1325 |
+
|
| 1326 |
+
# empty dict key item: ...:
|
| 1327 |
+
(r'^([ ]*)([^\{\[\s].*?)(:)$', bygroups(Whitespace, Name.Tag, Punctuation)),
|
| 1328 |
+
|
| 1329 |
+
# dict key item: ...: ...
|
| 1330 |
+
(r'^([ ]*)([^\{\[\s].*?)(:)( )(.*?)([ \t]*)$', bygroups(Whitespace, Name.Tag, Punctuation, Whitespace, Text, Whitespace)),
|
| 1331 |
+
],
|
| 1332 |
+
'inline_list': [
|
| 1333 |
+
include('whitespace'),
|
| 1334 |
+
(r'[^\{\}\[\],\s]+', Text),
|
| 1335 |
+
include('inline_value'),
|
| 1336 |
+
(r',', Punctuation),
|
| 1337 |
+
(r'\]', Punctuation, '#pop'),
|
| 1338 |
+
(r'\n', Error, '#pop'),
|
| 1339 |
+
],
|
| 1340 |
+
'inline_dict': [
|
| 1341 |
+
include('whitespace'),
|
| 1342 |
+
(r'[^\{\}\[\],:\s]+', Name.Tag),
|
| 1343 |
+
(r':', Punctuation, 'inline_dict_value'),
|
| 1344 |
+
(r'\}', Punctuation, '#pop'),
|
| 1345 |
+
(r'\n', Error, '#pop'),
|
| 1346 |
+
],
|
| 1347 |
+
'inline_dict_value': [
|
| 1348 |
+
include('whitespace'),
|
| 1349 |
+
(r'[^\{\}\[\],:\s]+', Text),
|
| 1350 |
+
include('inline_value'),
|
| 1351 |
+
(r',', Punctuation, '#pop'),
|
| 1352 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 1353 |
+
],
|
| 1354 |
+
'inline_value': [
|
| 1355 |
+
include('whitespace'),
|
| 1356 |
+
(r'\{', Punctuation, 'inline_dict'),
|
| 1357 |
+
(r'\[', Punctuation, 'inline_list'),
|
| 1358 |
+
],
|
| 1359 |
+
'whitespace': [
|
| 1360 |
+
(r'[ \t]+', Whitespace),
|
| 1361 |
+
],
|
| 1362 |
+
}
|
| 1363 |
+
|
| 1364 |
+
|
| 1365 |
+
class SingularityLexer(RegexLexer):
|
| 1366 |
+
"""
|
| 1367 |
+
Lexer for Singularity definition files.
|
| 1368 |
+
"""
|
| 1369 |
+
|
| 1370 |
+
name = 'Singularity'
|
| 1371 |
+
url = 'https://www.sylabs.io/guides/3.0/user-guide/definition_files.html'
|
| 1372 |
+
aliases = ['singularity']
|
| 1373 |
+
filenames = ['*.def', 'Singularity']
|
| 1374 |
+
version_added = '2.6'
|
| 1375 |
+
flags = re.IGNORECASE | re.MULTILINE | re.DOTALL
|
| 1376 |
+
|
| 1377 |
+
_headers = r'^(\s*)(bootstrap|from|osversion|mirrorurl|include|registry|namespace|includecmd)(:)'
|
| 1378 |
+
_section = r'^(%(?:pre|post|setup|environment|help|labels|test|runscript|files|startscript))(\s*)'
|
| 1379 |
+
_appsect = r'^(%app(?:install|help|run|labels|env|test|files))(\s*)'
|
| 1380 |
+
|
| 1381 |
+
tokens = {
|
| 1382 |
+
'root': [
|
| 1383 |
+
(_section, bygroups(Generic.Heading, Whitespace), 'script'),
|
| 1384 |
+
(_appsect, bygroups(Generic.Heading, Whitespace), 'script'),
|
| 1385 |
+
(_headers, bygroups(Whitespace, Keyword, Text)),
|
| 1386 |
+
(r'\s*#.*?\n', Comment),
|
| 1387 |
+
(r'\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b', Number),
|
| 1388 |
+
(r'[ \t]+', Whitespace),
|
| 1389 |
+
(r'(?!^\s*%).', Text),
|
| 1390 |
+
],
|
| 1391 |
+
'script': [
|
| 1392 |
+
(r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'),
|
| 1393 |
+
],
|
| 1394 |
+
}
|
| 1395 |
+
|
| 1396 |
+
def analyse_text(text):
|
| 1397 |
+
"""This is a quite simple script file, but there are a few keywords
|
| 1398 |
+
which seem unique to this language."""
|
| 1399 |
+
result = 0
|
| 1400 |
+
if re.search(r'\b(?:osversion|includecmd|mirrorurl)\b', text, re.IGNORECASE):
|
| 1401 |
+
result += 0.5
|
| 1402 |
+
|
| 1403 |
+
if re.search(SingularityLexer._section[1:], text):
|
| 1404 |
+
result += 0.49
|
| 1405 |
+
|
| 1406 |
+
return result
|
| 1407 |
+
|
| 1408 |
+
|
| 1409 |
+
class UnixConfigLexer(RegexLexer):
|
| 1410 |
+
"""
|
| 1411 |
+
Lexer for Unix/Linux config files using colon-separated values, e.g.
|
| 1412 |
+
|
| 1413 |
+
* ``/etc/group``
|
| 1414 |
+
* ``/etc/passwd``
|
| 1415 |
+
* ``/etc/shadow``
|
| 1416 |
+
"""
|
| 1417 |
+
|
| 1418 |
+
name = 'Unix/Linux config files'
|
| 1419 |
+
aliases = ['unixconfig', 'linuxconfig']
|
| 1420 |
+
filenames = []
|
| 1421 |
+
url = 'https://en.wikipedia.org/wiki/Configuration_file#Unix_and_Unix-like_operating_systems'
|
| 1422 |
+
version_added = '2.12'
|
| 1423 |
+
|
| 1424 |
+
tokens = {
|
| 1425 |
+
'root': [
|
| 1426 |
+
(r'^#.*', Comment),
|
| 1427 |
+
(r'\n', Whitespace),
|
| 1428 |
+
(r':', Punctuation),
|
| 1429 |
+
(r'[0-9]+', Number),
|
| 1430 |
+
(r'((?!\n)[a-zA-Z0-9\_\-\s\(\),]){2,}', Text),
|
| 1431 |
+
(r'[^:\n]+', String),
|
| 1432 |
+
],
|
| 1433 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/console.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.console
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for misc console output.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, bygroups
|
| 12 |
+
from pygments.token import Generic, Comment, String, Text, Keyword, Name, \
|
| 13 |
+
Punctuation, Number, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['VCTreeStatusLexer', 'PyPyLogLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class VCTreeStatusLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For colorizing output of version control status commands, like "hg
|
| 21 |
+
status" or "svn status".
|
| 22 |
+
"""
|
| 23 |
+
name = 'VCTreeStatus'
|
| 24 |
+
aliases = ['vctreestatus']
|
| 25 |
+
filenames = []
|
| 26 |
+
mimetypes = []
|
| 27 |
+
url = ""
|
| 28 |
+
version_added = '2.0'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'^A \+ C\s+', Generic.Error),
|
| 33 |
+
(r'^A\s+\+?\s+', String),
|
| 34 |
+
(r'^M\s+', Generic.Inserted),
|
| 35 |
+
(r'^C\s+', Generic.Error),
|
| 36 |
+
(r'^D\s+', Generic.Deleted),
|
| 37 |
+
(r'^[?!]\s+', Comment.Preproc),
|
| 38 |
+
(r' >\s+.*\n', Comment.Preproc),
|
| 39 |
+
(r'\S+', Text),
|
| 40 |
+
(r'\s+', Whitespace),
|
| 41 |
+
]
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class PyPyLogLexer(RegexLexer):
|
| 46 |
+
"""
|
| 47 |
+
Lexer for PyPy log files.
|
| 48 |
+
"""
|
| 49 |
+
name = "PyPy Log"
|
| 50 |
+
aliases = ["pypylog", "pypy"]
|
| 51 |
+
filenames = ["*.pypylog"]
|
| 52 |
+
mimetypes = ['application/x-pypylog']
|
| 53 |
+
url = 'pypy.org'
|
| 54 |
+
version_added = '1.5'
|
| 55 |
+
|
| 56 |
+
tokens = {
|
| 57 |
+
"root": [
|
| 58 |
+
(r"\[\w+\] \{jit-log-.*?$", Keyword, "jit-log"),
|
| 59 |
+
(r"\[\w+\] \{jit-backend-counts$", Keyword, "jit-backend-counts"),
|
| 60 |
+
include("extra-stuff"),
|
| 61 |
+
],
|
| 62 |
+
"jit-log": [
|
| 63 |
+
(r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"),
|
| 64 |
+
(r"^\+\d+: ", Comment),
|
| 65 |
+
(r"--end of the loop--", Comment),
|
| 66 |
+
(r"[ifp]\d+", Name),
|
| 67 |
+
(r"ptr\d+", Name),
|
| 68 |
+
(r"(\()(\w+(?:\.\w+)?)(\))",
|
| 69 |
+
bygroups(Punctuation, Name.Builtin, Punctuation)),
|
| 70 |
+
(r"[\[\]=,()]", Punctuation),
|
| 71 |
+
(r"(\d+\.\d+|inf|-inf)", Number.Float),
|
| 72 |
+
(r"-?\d+", Number.Integer),
|
| 73 |
+
(r"'.*'", String),
|
| 74 |
+
(r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name),
|
| 75 |
+
(r"<.*?>+", Name.Builtin),
|
| 76 |
+
(r"(label|debug_merge_point|jump|finish)", Name.Class),
|
| 77 |
+
(r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|"
|
| 78 |
+
r"int_floordiv|int_mod|int_lshift|int_rshift|int_and|int_or|"
|
| 79 |
+
r"int_xor|int_eq|int_ne|int_ge|int_gt|int_le|int_lt|int_is_zero|"
|
| 80 |
+
r"int_is_true|"
|
| 81 |
+
r"uint_floordiv|uint_ge|uint_lt|"
|
| 82 |
+
r"float_add|float_sub|float_mul|float_truediv|float_neg|"
|
| 83 |
+
r"float_eq|float_ne|float_ge|float_gt|float_le|float_lt|float_abs|"
|
| 84 |
+
r"ptr_eq|ptr_ne|instance_ptr_eq|instance_ptr_ne|"
|
| 85 |
+
r"cast_int_to_float|cast_float_to_int|"
|
| 86 |
+
r"force_token|quasiimmut_field|same_as|virtual_ref_finish|"
|
| 87 |
+
r"virtual_ref|mark_opaque_ptr|"
|
| 88 |
+
r"call_may_force|call_assembler|call_loopinvariant|"
|
| 89 |
+
r"call_release_gil|call_pure|call|"
|
| 90 |
+
r"new_with_vtable|new_array|newstr|newunicode|new|"
|
| 91 |
+
r"arraylen_gc|"
|
| 92 |
+
r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|"
|
| 93 |
+
r"getarrayitem_raw|setarrayitem_raw|getfield_gc_pure|"
|
| 94 |
+
r"getfield_gc|getinteriorfield_gc|setinteriorfield_gc|"
|
| 95 |
+
r"getfield_raw|setfield_gc|setfield_raw|"
|
| 96 |
+
r"strgetitem|strsetitem|strlen|copystrcontent|"
|
| 97 |
+
r"unicodegetitem|unicodesetitem|unicodelen|"
|
| 98 |
+
r"guard_true|guard_false|guard_value|guard_isnull|"
|
| 99 |
+
r"guard_nonnull_class|guard_nonnull|guard_class|guard_no_overflow|"
|
| 100 |
+
r"guard_not_forced|guard_no_exception|guard_not_invalidated)",
|
| 101 |
+
Name.Builtin),
|
| 102 |
+
include("extra-stuff"),
|
| 103 |
+
],
|
| 104 |
+
"jit-backend-counts": [
|
| 105 |
+
(r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
|
| 106 |
+
(r":", Punctuation),
|
| 107 |
+
(r"\d+", Number),
|
| 108 |
+
include("extra-stuff"),
|
| 109 |
+
],
|
| 110 |
+
"extra-stuff": [
|
| 111 |
+
(r"\s+", Whitespace),
|
| 112 |
+
(r"#.*?$", Comment),
|
| 113 |
+
],
|
| 114 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/cplint.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.cplint
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the cplint language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import bygroups, inherit, words
|
| 12 |
+
from pygments.lexers import PrologLexer
|
| 13 |
+
from pygments.token import Operator, Keyword, Name, String, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['CplintLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class CplintLexer(PrologLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for cplint files, including CP-logic, Logic Programs with Annotated
|
| 21 |
+
Disjunctions, Distributional Clauses syntax, ProbLog, DTProbLog.
|
| 22 |
+
"""
|
| 23 |
+
name = 'cplint'
|
| 24 |
+
url = 'https://cplint.eu'
|
| 25 |
+
aliases = ['cplint']
|
| 26 |
+
filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl']
|
| 27 |
+
mimetypes = ['text/x-cplint']
|
| 28 |
+
version_added = '2.12'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'map_query', Keyword),
|
| 33 |
+
(words(('gaussian', 'uniform_dens', 'dirichlet', 'gamma', 'beta',
|
| 34 |
+
'poisson', 'binomial', 'geometric', 'exponential', 'pascal',
|
| 35 |
+
'multinomial', 'user', 'val', 'uniform', 'discrete',
|
| 36 |
+
'finite')), Name.Builtin),
|
| 37 |
+
# annotations of atoms
|
| 38 |
+
(r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)),
|
| 39 |
+
(r':(-|=)|::?|~=?|=>', Operator),
|
| 40 |
+
(r'\?', Name.Builtin),
|
| 41 |
+
inherit,
|
| 42 |
+
],
|
| 43 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/crystal.py
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.crystal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Crystal.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import ExtendedRegexLexer, include, bygroups, default, \
|
| 14 |
+
words, line_re
|
| 15 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, \
|
| 16 |
+
Punctuation, Error, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['CrystalLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
CRYSTAL_OPERATORS = [
|
| 22 |
+
'!=', '!~', '!', '%', '&&', '&', '**', '*', '+', '-', '/', '<=>', '<<', '<=', '<',
|
| 23 |
+
'===', '==', '=~', '=', '>=', '>>', '>', '[]=', '[]?', '[]', '^', '||', '|', '~'
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class CrystalLexer(ExtendedRegexLexer):
|
| 28 |
+
"""
|
| 29 |
+
For Crystal source code.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
name = 'Crystal'
|
| 33 |
+
url = 'https://crystal-lang.org'
|
| 34 |
+
aliases = ['cr', 'crystal']
|
| 35 |
+
filenames = ['*.cr']
|
| 36 |
+
mimetypes = ['text/x-crystal']
|
| 37 |
+
version_added = '2.2'
|
| 38 |
+
|
| 39 |
+
flags = re.DOTALL | re.MULTILINE
|
| 40 |
+
|
| 41 |
+
def heredoc_callback(self, match, ctx):
|
| 42 |
+
# okay, this is the hardest part of parsing Crystal...
|
| 43 |
+
# match: 1 = <<-?, 2 = quote? 3 = name 4 = quote? 5 = rest of line
|
| 44 |
+
|
| 45 |
+
start = match.start(1)
|
| 46 |
+
yield start, Operator, match.group(1) # <<-?
|
| 47 |
+
yield match.start(2), String.Heredoc, match.group(2) # quote ", ', `
|
| 48 |
+
yield match.start(3), String.Delimiter, match.group(3) # heredoc name
|
| 49 |
+
yield match.start(4), String.Heredoc, match.group(4) # quote again
|
| 50 |
+
|
| 51 |
+
heredocstack = ctx.__dict__.setdefault('heredocstack', [])
|
| 52 |
+
outermost = not bool(heredocstack)
|
| 53 |
+
heredocstack.append((match.group(1) == '<<-', match.group(3)))
|
| 54 |
+
|
| 55 |
+
ctx.pos = match.start(5)
|
| 56 |
+
ctx.end = match.end(5)
|
| 57 |
+
# this may find other heredocs, so limit the recursion depth
|
| 58 |
+
if len(heredocstack) < 100:
|
| 59 |
+
yield from self.get_tokens_unprocessed(context=ctx)
|
| 60 |
+
else:
|
| 61 |
+
yield ctx.pos, String.Heredoc, match.group(5)
|
| 62 |
+
ctx.pos = match.end()
|
| 63 |
+
|
| 64 |
+
if outermost:
|
| 65 |
+
# this is the outer heredoc again, now we can process them all
|
| 66 |
+
for tolerant, hdname in heredocstack:
|
| 67 |
+
lines = []
|
| 68 |
+
for match in line_re.finditer(ctx.text, ctx.pos):
|
| 69 |
+
if tolerant:
|
| 70 |
+
check = match.group().strip()
|
| 71 |
+
else:
|
| 72 |
+
check = match.group().rstrip()
|
| 73 |
+
if check == hdname:
|
| 74 |
+
for amatch in lines:
|
| 75 |
+
yield amatch.start(), String.Heredoc, amatch.group()
|
| 76 |
+
yield match.start(), String.Delimiter, match.group()
|
| 77 |
+
ctx.pos = match.end()
|
| 78 |
+
break
|
| 79 |
+
else:
|
| 80 |
+
lines.append(match)
|
| 81 |
+
else:
|
| 82 |
+
# end of heredoc not found -- error!
|
| 83 |
+
for amatch in lines:
|
| 84 |
+
yield amatch.start(), Error, amatch.group()
|
| 85 |
+
ctx.end = len(ctx.text)
|
| 86 |
+
del heredocstack[:]
|
| 87 |
+
|
| 88 |
+
def gen_crystalstrings_rules():
|
| 89 |
+
states = {}
|
| 90 |
+
states['strings'] = [
|
| 91 |
+
(r'\:\w+[!?]?', String.Symbol),
|
| 92 |
+
(words(CRYSTAL_OPERATORS, prefix=r'\:'), String.Symbol),
|
| 93 |
+
(r":'(\\\\|\\[^\\]|[^'\\])*'", String.Symbol),
|
| 94 |
+
# This allows arbitrary text after '\ for simplicity
|
| 95 |
+
(r"'(\\\\|\\'|[^']|\\[^'\\]+)'", String.Char),
|
| 96 |
+
(r':"', String.Symbol, 'simple-sym'),
|
| 97 |
+
# Crystal doesn't have "symbol:"s but this simplifies function args
|
| 98 |
+
(r'([a-zA-Z_]\w*)(:)(?!:)', bygroups(String.Symbol, Punctuation)),
|
| 99 |
+
(r'"', String.Double, 'simple-string'),
|
| 100 |
+
(r'(?<!\.)`', String.Backtick, 'simple-backtick'),
|
| 101 |
+
]
|
| 102 |
+
|
| 103 |
+
# double-quoted string and symbol
|
| 104 |
+
for name, ttype, end in ('string', String.Double, '"'), \
|
| 105 |
+
('sym', String.Symbol, '"'), \
|
| 106 |
+
('backtick', String.Backtick, '`'):
|
| 107 |
+
states['simple-'+name] = [
|
| 108 |
+
include('string-escaped' if name == 'sym' else 'string-intp-escaped'),
|
| 109 |
+
(rf'[^\\{end}#]+', ttype),
|
| 110 |
+
(r'[\\#]', ttype),
|
| 111 |
+
(end, ttype, '#pop'),
|
| 112 |
+
]
|
| 113 |
+
|
| 114 |
+
# https://crystal-lang.org/docs/syntax_and_semantics/literals/string.html#percent-string-literals
|
| 115 |
+
for lbrace, rbrace, bracecc, name in \
|
| 116 |
+
('\\{', '\\}', '{}', 'cb'), \
|
| 117 |
+
('\\[', '\\]', '\\[\\]', 'sb'), \
|
| 118 |
+
('\\(', '\\)', '()', 'pa'), \
|
| 119 |
+
('<', '>', '<>', 'ab'), \
|
| 120 |
+
('\\|', '\\|', '\\|', 'pi'):
|
| 121 |
+
states[name+'-intp-string'] = [
|
| 122 |
+
(r'\\' + lbrace, String.Other),
|
| 123 |
+
] + (lbrace != rbrace) * [
|
| 124 |
+
(lbrace, String.Other, '#push'),
|
| 125 |
+
] + [
|
| 126 |
+
(rbrace, String.Other, '#pop'),
|
| 127 |
+
include('string-intp-escaped'),
|
| 128 |
+
(r'[\\#' + bracecc + ']', String.Other),
|
| 129 |
+
(r'[^\\#' + bracecc + ']+', String.Other),
|
| 130 |
+
]
|
| 131 |
+
states['strings'].append((r'%Q?' + lbrace, String.Other,
|
| 132 |
+
name+'-intp-string'))
|
| 133 |
+
states[name+'-string'] = [
|
| 134 |
+
(r'\\[\\' + bracecc + ']', String.Other),
|
| 135 |
+
] + (lbrace != rbrace) * [
|
| 136 |
+
(lbrace, String.Other, '#push'),
|
| 137 |
+
] + [
|
| 138 |
+
(rbrace, String.Other, '#pop'),
|
| 139 |
+
(r'[\\#' + bracecc + ']', String.Other),
|
| 140 |
+
(r'[^\\#' + bracecc + ']+', String.Other),
|
| 141 |
+
]
|
| 142 |
+
# https://crystal-lang.org/docs/syntax_and_semantics/literals/array.html#percent-array-literals
|
| 143 |
+
states['strings'].append((r'%[qwi]' + lbrace, String.Other,
|
| 144 |
+
name+'-string'))
|
| 145 |
+
states[name+'-regex'] = [
|
| 146 |
+
(r'\\[\\' + bracecc + ']', String.Regex),
|
| 147 |
+
] + (lbrace != rbrace) * [
|
| 148 |
+
(lbrace, String.Regex, '#push'),
|
| 149 |
+
] + [
|
| 150 |
+
(rbrace + '[imsx]*', String.Regex, '#pop'),
|
| 151 |
+
include('string-intp'),
|
| 152 |
+
(r'[\\#' + bracecc + ']', String.Regex),
|
| 153 |
+
(r'[^\\#' + bracecc + ']+', String.Regex),
|
| 154 |
+
]
|
| 155 |
+
states['strings'].append((r'%r' + lbrace, String.Regex,
|
| 156 |
+
name+'-regex'))
|
| 157 |
+
|
| 158 |
+
return states
|
| 159 |
+
|
| 160 |
+
tokens = {
|
| 161 |
+
'root': [
|
| 162 |
+
(r'#.*?$', Comment.Single),
|
| 163 |
+
# keywords
|
| 164 |
+
(words('''
|
| 165 |
+
abstract asm begin break case do else elsif end ensure extend if in
|
| 166 |
+
include next of private protected require rescue return select self super
|
| 167 |
+
then unless until when while with yield
|
| 168 |
+
'''.split(), suffix=r'\b'), Keyword),
|
| 169 |
+
(words('''
|
| 170 |
+
previous_def forall out uninitialized __DIR__ __FILE__ __LINE__
|
| 171 |
+
__END_LINE__
|
| 172 |
+
'''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Keyword.Pseudo),
|
| 173 |
+
# https://crystal-lang.org/docs/syntax_and_semantics/is_a.html
|
| 174 |
+
(r'\.(is_a\?|nil\?|responds_to\?|as\?|as\b)', Keyword.Pseudo),
|
| 175 |
+
(words(['true', 'false', 'nil'], suffix=r'\b'), Keyword.Constant),
|
| 176 |
+
# start of function, class and module names
|
| 177 |
+
(r'(module|lib)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)',
|
| 178 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 179 |
+
(r'(def|fun|macro)(\s+)((?:[a-zA-Z_]\w*::)*)',
|
| 180 |
+
bygroups(Keyword, Whitespace, Name.Namespace), 'funcname'),
|
| 181 |
+
(r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'),
|
| 182 |
+
(r'(annotation|class|struct|union|type|alias|enum)(\s+)((?:[a-zA-Z_]\w*::)*)',
|
| 183 |
+
bygroups(Keyword, Whitespace, Name.Namespace), 'classname'),
|
| 184 |
+
# https://crystal-lang.org/api/toplevel.html
|
| 185 |
+
(words('''
|
| 186 |
+
instance_sizeof offsetof pointerof sizeof typeof
|
| 187 |
+
'''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Keyword.Pseudo),
|
| 188 |
+
# macros
|
| 189 |
+
(r'(?<!\.)(debugger\b|p!|pp!|record\b|spawn\b)', Name.Builtin.Pseudo),
|
| 190 |
+
# builtins
|
| 191 |
+
(words('''
|
| 192 |
+
abort at_exit caller exit gets loop main p pp print printf puts
|
| 193 |
+
raise rand read_line sleep spawn sprintf system
|
| 194 |
+
'''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin),
|
| 195 |
+
# https://crystal-lang.org/api/Object.html#macro-summary
|
| 196 |
+
(r'(?<!\.)(((class_)?((getter|property)\b[!?]?|setter\b))|'
|
| 197 |
+
r'(def_(clone|equals|equals_and_hash|hash)|delegate|forward_missing_to)\b)',
|
| 198 |
+
Name.Builtin.Pseudo),
|
| 199 |
+
# normal heredocs
|
| 200 |
+
(r'(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)',
|
| 201 |
+
heredoc_callback),
|
| 202 |
+
# empty string heredocs
|
| 203 |
+
(r'(<<-?)("|\')()(\2)(.*?\n)', heredoc_callback),
|
| 204 |
+
(r'__END__', Comment.Preproc, 'end-part'),
|
| 205 |
+
# multiline regex (after keywords or assignments)
|
| 206 |
+
(r'(?:^|(?<=[=<>~!:])|'
|
| 207 |
+
r'(?<=(?:\s|;)when\s)|'
|
| 208 |
+
r'(?<=(?:\s|;)or\s)|'
|
| 209 |
+
r'(?<=(?:\s|;)and\s)|'
|
| 210 |
+
r'(?<=\.index\s)|'
|
| 211 |
+
r'(?<=\.scan\s)|'
|
| 212 |
+
r'(?<=\.sub\s)|'
|
| 213 |
+
r'(?<=\.sub!\s)|'
|
| 214 |
+
r'(?<=\.gsub\s)|'
|
| 215 |
+
r'(?<=\.gsub!\s)|'
|
| 216 |
+
r'(?<=\.match\s)|'
|
| 217 |
+
r'(?<=(?:\s|;)if\s)|'
|
| 218 |
+
r'(?<=(?:\s|;)elsif\s)|'
|
| 219 |
+
r'(?<=^when\s)|'
|
| 220 |
+
r'(?<=^index\s)|'
|
| 221 |
+
r'(?<=^scan\s)|'
|
| 222 |
+
r'(?<=^sub\s)|'
|
| 223 |
+
r'(?<=^gsub\s)|'
|
| 224 |
+
r'(?<=^sub!\s)|'
|
| 225 |
+
r'(?<=^gsub!\s)|'
|
| 226 |
+
r'(?<=^match\s)|'
|
| 227 |
+
r'(?<=^if\s)|'
|
| 228 |
+
r'(?<=^elsif\s)'
|
| 229 |
+
r')(\s*)(/)', bygroups(Whitespace, String.Regex), 'multiline-regex'),
|
| 230 |
+
# multiline regex (in method calls or subscripts)
|
| 231 |
+
(r'(?<=\(|,|\[)/', String.Regex, 'multiline-regex'),
|
| 232 |
+
# multiline regex (this time the funny no whitespace rule)
|
| 233 |
+
(r'(\s+)(/)(?![\s=])', bygroups(Whitespace, String.Regex),
|
| 234 |
+
'multiline-regex'),
|
| 235 |
+
# lex numbers and ignore following regular expressions which
|
| 236 |
+
# are division operators in fact (grrrr. i hate that. any
|
| 237 |
+
# better ideas?)
|
| 238 |
+
# since pygments 0.7 we also eat a "?" operator after numbers
|
| 239 |
+
# so that the char operator does not work. Chars are not allowed
|
| 240 |
+
# there so that you can use the ternary operator.
|
| 241 |
+
# stupid example:
|
| 242 |
+
# x>=0?n[x]:""
|
| 243 |
+
(r'(0o[0-7]+(?:_[0-7]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?',
|
| 244 |
+
bygroups(Number.Oct, Whitespace, Operator)),
|
| 245 |
+
(r'(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?',
|
| 246 |
+
bygroups(Number.Hex, Whitespace, Operator)),
|
| 247 |
+
(r'(0b[01]+(?:_[01]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?',
|
| 248 |
+
bygroups(Number.Bin, Whitespace, Operator)),
|
| 249 |
+
# 3 separate expressions for floats because any of the 3 optional
|
| 250 |
+
# parts makes it a float
|
| 251 |
+
(r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)(?:e[+-]?[0-9]+)?'
|
| 252 |
+
r'(?:_?f[0-9]+)?)(\s*)([/?])?',
|
| 253 |
+
bygroups(Number.Float, Whitespace, Operator)),
|
| 254 |
+
(r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)'
|
| 255 |
+
r'(?:_?f[0-9]+)?)(\s*)([/?])?',
|
| 256 |
+
bygroups(Number.Float, Whitespace, Operator)),
|
| 257 |
+
(r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)?'
|
| 258 |
+
r'(?:_?f[0-9]+))(\s*)([/?])?',
|
| 259 |
+
bygroups(Number.Float, Whitespace, Operator)),
|
| 260 |
+
(r'(0\b|[1-9][\d]*(?:_\d+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?',
|
| 261 |
+
bygroups(Number.Integer, Whitespace, Operator)),
|
| 262 |
+
# Names
|
| 263 |
+
(r'@@[a-zA-Z_]\w*', Name.Variable.Class),
|
| 264 |
+
(r'@[a-zA-Z_]\w*', Name.Variable.Instance),
|
| 265 |
+
(r'\$\w+', Name.Variable.Global),
|
| 266 |
+
(r'\$[!@&`\'+~=/\\,;.<>_*$?:"^-]', Name.Variable.Global),
|
| 267 |
+
(r'\$-[0adFiIlpvw]', Name.Variable.Global),
|
| 268 |
+
(r'::', Operator),
|
| 269 |
+
include('strings'),
|
| 270 |
+
# https://crystal-lang.org/reference/syntax_and_semantics/literals/char.html
|
| 271 |
+
(r'\?(\\[MC]-)*' # modifiers
|
| 272 |
+
r'(\\([\\abefnrtv#"\']|[0-7]{1,3}|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|u\{[a-fA-F0-9 ]+\})|\S)'
|
| 273 |
+
r'(?!\w)',
|
| 274 |
+
String.Char),
|
| 275 |
+
(r'[A-Z][A-Z_]+\b(?!::|\.)', Name.Constant),
|
| 276 |
+
# macro expansion
|
| 277 |
+
(r'\{%', String.Interpol, 'in-macro-control'),
|
| 278 |
+
(r'\{\{', String.Interpol, 'in-macro-expr'),
|
| 279 |
+
# annotations
|
| 280 |
+
(r'(@\[)(\s*)([A-Z]\w*(::[A-Z]\w*)*)',
|
| 281 |
+
bygroups(Operator, Whitespace, Name.Decorator), 'in-annot'),
|
| 282 |
+
# this is needed because Crystal attributes can look
|
| 283 |
+
# like keywords (class) or like this: ` ?!?
|
| 284 |
+
(words(CRYSTAL_OPERATORS, prefix=r'(\.|::)'),
|
| 285 |
+
bygroups(Operator, Name.Operator)),
|
| 286 |
+
(r'(\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])',
|
| 287 |
+
bygroups(Operator, Name)),
|
| 288 |
+
# Names can end with [!?] unless it's "!="
|
| 289 |
+
(r'[a-zA-Z_]\w*(?:[!?](?!=))?', Name),
|
| 290 |
+
(r'(\[|\]\??|\*\*|<=>?|>=|<<?|>>?|=~|===|'
|
| 291 |
+
r'!~|&&?|\|\||\.{1,3})', Operator),
|
| 292 |
+
(r'[-+/*%=<>&!^|~]=?', Operator),
|
| 293 |
+
(r'[(){};,/?:\\]', Punctuation),
|
| 294 |
+
(r'\s+', Whitespace)
|
| 295 |
+
],
|
| 296 |
+
'funcname': [
|
| 297 |
+
(r'(?:([a-zA-Z_]\w*)(\.))?'
|
| 298 |
+
r'([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|'
|
| 299 |
+
r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)',
|
| 300 |
+
bygroups(Name.Class, Operator, Name.Function), '#pop'),
|
| 301 |
+
default('#pop')
|
| 302 |
+
],
|
| 303 |
+
'classname': [
|
| 304 |
+
(r'[A-Z_]\w*', Name.Class),
|
| 305 |
+
(r'(\()(\s*)([A-Z_]\w*)(\s*)(\))',
|
| 306 |
+
bygroups(Punctuation, Whitespace, Name.Class, Whitespace, Punctuation)),
|
| 307 |
+
default('#pop')
|
| 308 |
+
],
|
| 309 |
+
'in-intp': [
|
| 310 |
+
(r'\{', String.Interpol, '#push'),
|
| 311 |
+
(r'\}', String.Interpol, '#pop'),
|
| 312 |
+
include('root'),
|
| 313 |
+
],
|
| 314 |
+
'string-intp': [
|
| 315 |
+
(r'#\{', String.Interpol, 'in-intp'),
|
| 316 |
+
],
|
| 317 |
+
'string-escaped': [
|
| 318 |
+
# https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html
|
| 319 |
+
(r'\\([\\abefnrtv#"\']|[0-7]{1,3}|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|u\{[a-fA-F0-9 ]+\})',
|
| 320 |
+
String.Escape)
|
| 321 |
+
],
|
| 322 |
+
'string-intp-escaped': [
|
| 323 |
+
include('string-intp'),
|
| 324 |
+
include('string-escaped'),
|
| 325 |
+
],
|
| 326 |
+
'interpolated-regex': [
|
| 327 |
+
include('string-intp'),
|
| 328 |
+
(r'[\\#]', String.Regex),
|
| 329 |
+
(r'[^\\#]+', String.Regex),
|
| 330 |
+
],
|
| 331 |
+
'interpolated-string': [
|
| 332 |
+
include('string-intp'),
|
| 333 |
+
(r'[\\#]', String.Other),
|
| 334 |
+
(r'[^\\#]+', String.Other),
|
| 335 |
+
],
|
| 336 |
+
'multiline-regex': [
|
| 337 |
+
include('string-intp'),
|
| 338 |
+
(r'\\\\', String.Regex),
|
| 339 |
+
(r'\\/', String.Regex),
|
| 340 |
+
(r'[\\#]', String.Regex),
|
| 341 |
+
(r'[^\\/#]+', String.Regex),
|
| 342 |
+
(r'/[imsx]*', String.Regex, '#pop'),
|
| 343 |
+
],
|
| 344 |
+
'end-part': [
|
| 345 |
+
(r'.+', Comment.Preproc, '#pop')
|
| 346 |
+
],
|
| 347 |
+
'in-macro-control': [
|
| 348 |
+
(r'\{%', String.Interpol, '#push'),
|
| 349 |
+
(r'%\}', String.Interpol, '#pop'),
|
| 350 |
+
(r'(for|verbatim)\b', Keyword),
|
| 351 |
+
include('root'),
|
| 352 |
+
],
|
| 353 |
+
'in-macro-expr': [
|
| 354 |
+
(r'\{\{', String.Interpol, '#push'),
|
| 355 |
+
(r'\}\}', String.Interpol, '#pop'),
|
| 356 |
+
include('root'),
|
| 357 |
+
],
|
| 358 |
+
'in-annot': [
|
| 359 |
+
(r'\[', Operator, '#push'),
|
| 360 |
+
(r'\]', Operator, '#pop'),
|
| 361 |
+
include('root'),
|
| 362 |
+
],
|
| 363 |
+
}
|
| 364 |
+
tokens.update(gen_crystalstrings_rules())
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/csound.py
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.csound
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Csound languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, default, include, using, words
|
| 14 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, Punctuation, \
|
| 15 |
+
String, Text, Whitespace
|
| 16 |
+
from pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES, REMOVED_OPCODES
|
| 17 |
+
from pygments.lexers.html import HtmlLexer
|
| 18 |
+
from pygments.lexers.python import PythonLexer
|
| 19 |
+
from pygments.lexers.scripting import LuaLexer
|
| 20 |
+
|
| 21 |
+
__all__ = ['CsoundScoreLexer', 'CsoundOrchestraLexer', 'CsoundDocumentLexer']
|
| 22 |
+
|
| 23 |
+
newline = (r'((?:(?:;|//).*)*)(\n)', bygroups(Comment.Single, Text))
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class CsoundLexer(RegexLexer):
|
| 27 |
+
url = 'https://csound.com/'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'whitespace': [
|
| 31 |
+
(r'[ \t]+', Whitespace),
|
| 32 |
+
(r'/[*](?:.|\n)*?[*]/', Comment.Multiline),
|
| 33 |
+
(r'(?:;|//).*$', Comment.Single),
|
| 34 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace))
|
| 35 |
+
],
|
| 36 |
+
|
| 37 |
+
'preprocessor directives': [
|
| 38 |
+
(r'#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+', Comment.Preproc),
|
| 39 |
+
(r'#includestr', Comment.Preproc, 'includestr directive'),
|
| 40 |
+
(r'#include', Comment.Preproc, 'include directive'),
|
| 41 |
+
(r'#[ \t]*define', Comment.Preproc, 'define directive'),
|
| 42 |
+
(r'#(?:ifn?def|undef)\b', Comment.Preproc, 'macro directive')
|
| 43 |
+
],
|
| 44 |
+
|
| 45 |
+
'include directive': [
|
| 46 |
+
include('whitespace'),
|
| 47 |
+
(r'([^ \t]).*?\1', String, '#pop')
|
| 48 |
+
],
|
| 49 |
+
'includestr directive': [
|
| 50 |
+
include('whitespace'),
|
| 51 |
+
(r'"', String, ('#pop', 'quoted string'))
|
| 52 |
+
],
|
| 53 |
+
|
| 54 |
+
'define directive': [
|
| 55 |
+
(r'\n', Whitespace),
|
| 56 |
+
include('whitespace'),
|
| 57 |
+
(r'([A-Z_a-z]\w*)(\()', bygroups(Comment.Preproc, Punctuation),
|
| 58 |
+
('#pop', 'macro parameter name list')),
|
| 59 |
+
(r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'before macro body'))
|
| 60 |
+
],
|
| 61 |
+
'macro parameter name list': [
|
| 62 |
+
include('whitespace'),
|
| 63 |
+
(r'[A-Z_a-z]\w*', Comment.Preproc),
|
| 64 |
+
(r"['#]", Punctuation),
|
| 65 |
+
(r'\)', Punctuation, ('#pop', 'before macro body'))
|
| 66 |
+
],
|
| 67 |
+
'before macro body': [
|
| 68 |
+
(r'\n', Whitespace),
|
| 69 |
+
include('whitespace'),
|
| 70 |
+
(r'#', Punctuation, ('#pop', 'macro body'))
|
| 71 |
+
],
|
| 72 |
+
'macro body': [
|
| 73 |
+
(r'(?:\\(?!#)|[^#\\]|\n)+', Comment.Preproc),
|
| 74 |
+
(r'\\#', Comment.Preproc),
|
| 75 |
+
(r'(?<!\\)#', Punctuation, '#pop')
|
| 76 |
+
],
|
| 77 |
+
|
| 78 |
+
'macro directive': [
|
| 79 |
+
include('whitespace'),
|
| 80 |
+
(r'[A-Z_a-z]\w*', Comment.Preproc, '#pop')
|
| 81 |
+
],
|
| 82 |
+
|
| 83 |
+
'macro uses': [
|
| 84 |
+
(r'(\$[A-Z_a-z]\w*\.?)(\()', bygroups(Comment.Preproc, Punctuation),
|
| 85 |
+
'macro parameter value list'),
|
| 86 |
+
(r'\$[A-Z_a-z]\w*(?:\.|\b)', Comment.Preproc)
|
| 87 |
+
],
|
| 88 |
+
'macro parameter value list': [
|
| 89 |
+
(r'(?:[^\'#"{()]|\{(?!\{))+', Comment.Preproc),
|
| 90 |
+
(r"['#]", Punctuation),
|
| 91 |
+
(r'"', String, 'macro parameter value quoted string'),
|
| 92 |
+
(r'\{\{', String, 'macro parameter value braced string'),
|
| 93 |
+
(r'\(', Comment.Preproc, 'macro parameter value parenthetical'),
|
| 94 |
+
(r'\)', Punctuation, '#pop')
|
| 95 |
+
],
|
| 96 |
+
'macro parameter value quoted string': [
|
| 97 |
+
(r"\\[#'()]", Comment.Preproc),
|
| 98 |
+
(r"[#'()]", Error),
|
| 99 |
+
include('quoted string')
|
| 100 |
+
],
|
| 101 |
+
'macro parameter value braced string': [
|
| 102 |
+
(r"\\[#'()]", Comment.Preproc),
|
| 103 |
+
(r"[#'()]", Error),
|
| 104 |
+
include('braced string')
|
| 105 |
+
],
|
| 106 |
+
'macro parameter value parenthetical': [
|
| 107 |
+
(r'(?:[^\\()]|\\\))+', Comment.Preproc),
|
| 108 |
+
(r'\(', Comment.Preproc, '#push'),
|
| 109 |
+
(r'\)', Comment.Preproc, '#pop')
|
| 110 |
+
],
|
| 111 |
+
|
| 112 |
+
'whitespace and macro uses': [
|
| 113 |
+
include('whitespace'),
|
| 114 |
+
include('macro uses')
|
| 115 |
+
],
|
| 116 |
+
|
| 117 |
+
'numbers': [
|
| 118 |
+
(r'\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
|
| 119 |
+
(r'(0[Xx])([0-9A-Fa-f]+)', bygroups(Keyword.Type, Number.Hex)),
|
| 120 |
+
(r'\d+', Number.Integer)
|
| 121 |
+
],
|
| 122 |
+
|
| 123 |
+
'quoted string': [
|
| 124 |
+
(r'"', String, '#pop'),
|
| 125 |
+
(r'[^"$]+', String),
|
| 126 |
+
include('macro uses'),
|
| 127 |
+
(r'[$]', String)
|
| 128 |
+
],
|
| 129 |
+
|
| 130 |
+
'braced string': [
|
| 131 |
+
# Do nothing. This must be defined in subclasses.
|
| 132 |
+
]
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class CsoundScoreLexer(CsoundLexer):
|
| 137 |
+
"""
|
| 138 |
+
For `Csound <https://csound.com>`_ scores.
|
| 139 |
+
"""
|
| 140 |
+
|
| 141 |
+
name = 'Csound Score'
|
| 142 |
+
aliases = ['csound-score', 'csound-sco']
|
| 143 |
+
filenames = ['*.sco']
|
| 144 |
+
version_added = '2.1'
|
| 145 |
+
|
| 146 |
+
tokens = {
|
| 147 |
+
'root': [
|
| 148 |
+
(r'\n', Whitespace),
|
| 149 |
+
include('whitespace and macro uses'),
|
| 150 |
+
include('preprocessor directives'),
|
| 151 |
+
|
| 152 |
+
(r'[aBbCdefiqstvxy]', Keyword),
|
| 153 |
+
# There is also a w statement that is generated internally and should not be
|
| 154 |
+
# used; see https://github.com/csound/csound/issues/750.
|
| 155 |
+
|
| 156 |
+
(r'z', Keyword.Constant),
|
| 157 |
+
# z is a constant equal to 800,000,000,000. 800 billion seconds is about
|
| 158 |
+
# 25,367.8 years. See also
|
| 159 |
+
# https://csound.com/docs/manual/ScoreTop.html and
|
| 160 |
+
# https://github.com/csound/csound/search?q=stof+path%3AEngine+filename%3Asread.c.
|
| 161 |
+
|
| 162 |
+
(r'([nNpP][pP])(\d+)', bygroups(Keyword, Number.Integer)),
|
| 163 |
+
|
| 164 |
+
(r'[mn]', Keyword, 'mark statement'),
|
| 165 |
+
|
| 166 |
+
include('numbers'),
|
| 167 |
+
(r'[!+\-*/^%&|<>#~.]', Operator),
|
| 168 |
+
(r'[()\[\]]', Punctuation),
|
| 169 |
+
(r'"', String, 'quoted string'),
|
| 170 |
+
(r'\{', Comment.Preproc, 'loop after left brace'),
|
| 171 |
+
],
|
| 172 |
+
|
| 173 |
+
'mark statement': [
|
| 174 |
+
include('whitespace and macro uses'),
|
| 175 |
+
(r'[A-Z_a-z]\w*', Name.Label),
|
| 176 |
+
(r'\n', Whitespace, '#pop')
|
| 177 |
+
],
|
| 178 |
+
|
| 179 |
+
'loop after left brace': [
|
| 180 |
+
include('whitespace and macro uses'),
|
| 181 |
+
(r'\d+', Number.Integer, ('#pop', 'loop after repeat count')),
|
| 182 |
+
],
|
| 183 |
+
'loop after repeat count': [
|
| 184 |
+
include('whitespace and macro uses'),
|
| 185 |
+
(r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'loop'))
|
| 186 |
+
],
|
| 187 |
+
'loop': [
|
| 188 |
+
(r'\}', Comment.Preproc, '#pop'),
|
| 189 |
+
include('root')
|
| 190 |
+
],
|
| 191 |
+
|
| 192 |
+
# Braced strings are not allowed in Csound scores, but this is needed because the
|
| 193 |
+
# superclass includes it.
|
| 194 |
+
'braced string': [
|
| 195 |
+
(r'\}\}', String, '#pop'),
|
| 196 |
+
(r'[^}]|\}(?!\})', String)
|
| 197 |
+
]
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
class CsoundOrchestraLexer(CsoundLexer):
|
| 202 |
+
"""
|
| 203 |
+
For `Csound <https://csound.com>`_ orchestras.
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
name = 'Csound Orchestra'
|
| 207 |
+
aliases = ['csound', 'csound-orc']
|
| 208 |
+
filenames = ['*.orc', '*.udo']
|
| 209 |
+
version_added = '2.1'
|
| 210 |
+
|
| 211 |
+
user_defined_opcodes = set()
|
| 212 |
+
|
| 213 |
+
def opcode_name_callback(lexer, match):
|
| 214 |
+
opcode = match.group(0)
|
| 215 |
+
lexer.user_defined_opcodes.add(opcode)
|
| 216 |
+
yield match.start(), Name.Function, opcode
|
| 217 |
+
|
| 218 |
+
def name_callback(lexer, match):
|
| 219 |
+
type_annotation_token = Keyword.Type
|
| 220 |
+
|
| 221 |
+
name = match.group(1)
|
| 222 |
+
if name in OPCODES or name in DEPRECATED_OPCODES or name in REMOVED_OPCODES:
|
| 223 |
+
yield match.start(), Name.Builtin, name
|
| 224 |
+
elif name in lexer.user_defined_opcodes:
|
| 225 |
+
yield match.start(), Name.Function, name
|
| 226 |
+
else:
|
| 227 |
+
type_annotation_token = Name
|
| 228 |
+
name_match = re.search(r'^(g?[afikSw])(\w+)', name)
|
| 229 |
+
if name_match:
|
| 230 |
+
yield name_match.start(1), Keyword.Type, name_match.group(1)
|
| 231 |
+
yield name_match.start(2), Name, name_match.group(2)
|
| 232 |
+
else:
|
| 233 |
+
yield match.start(), Name, name
|
| 234 |
+
|
| 235 |
+
if match.group(2):
|
| 236 |
+
yield match.start(2), Punctuation, match.group(2)
|
| 237 |
+
yield match.start(3), type_annotation_token, match.group(3)
|
| 238 |
+
|
| 239 |
+
tokens = {
|
| 240 |
+
'root': [
|
| 241 |
+
(r'\n', Whitespace),
|
| 242 |
+
|
| 243 |
+
(r'^([ \t]*)(\w+)(:)([ \t]+|$)', bygroups(Whitespace, Name.Label, Punctuation, Whitespace)),
|
| 244 |
+
|
| 245 |
+
include('whitespace and macro uses'),
|
| 246 |
+
include('preprocessor directives'),
|
| 247 |
+
|
| 248 |
+
(r'\binstr\b', Keyword.Declaration, 'instrument numbers and identifiers'),
|
| 249 |
+
(r'\bopcode\b', Keyword.Declaration, 'after opcode keyword'),
|
| 250 |
+
(r'\b(?:end(?:in|op))\b', Keyword.Declaration),
|
| 251 |
+
|
| 252 |
+
include('partial statements')
|
| 253 |
+
],
|
| 254 |
+
|
| 255 |
+
'partial statements': [
|
| 256 |
+
(r'\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\b', Name.Variable.Global),
|
| 257 |
+
|
| 258 |
+
include('numbers'),
|
| 259 |
+
|
| 260 |
+
(r'\+=|-=|\*=|/=|<<|>>|<=|>=|==|!=|&&|\|\||[~¬]|[=!+\-*/^%&|<>#?:]', Operator),
|
| 261 |
+
(r'[(),\[\]]', Punctuation),
|
| 262 |
+
|
| 263 |
+
(r'"', String, 'quoted string'),
|
| 264 |
+
(r'\{\{', String, 'braced string'),
|
| 265 |
+
|
| 266 |
+
(words((
|
| 267 |
+
'do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen', 'kthen',
|
| 268 |
+
'od', 'then', 'until', 'while',
|
| 269 |
+
), prefix=r'\b', suffix=r'\b'), Keyword),
|
| 270 |
+
(words(('return', 'rireturn'), prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
|
| 271 |
+
|
| 272 |
+
(r'\b[ik]?goto\b', Keyword, 'goto label'),
|
| 273 |
+
(r'\b(r(?:einit|igoto)|tigoto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
|
| 274 |
+
'goto label'),
|
| 275 |
+
(r'\b(c(?:g|in?|k|nk?)goto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
|
| 276 |
+
('goto label', 'goto argument')),
|
| 277 |
+
(r'\b(timout)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
|
| 278 |
+
('goto label', 'goto argument', 'goto argument')),
|
| 279 |
+
(r'\b(loop_[gl][et])(\(|\b)', bygroups(Keyword.Pseudo, Punctuation),
|
| 280 |
+
('goto label', 'goto argument', 'goto argument', 'goto argument')),
|
| 281 |
+
|
| 282 |
+
(r'\bprintk?s\b', Name.Builtin, 'prints opcode'),
|
| 283 |
+
(r'\b(?:readscore|scoreline(?:_i)?)\b', Name.Builtin, 'Csound score opcode'),
|
| 284 |
+
(r'\bpyl?run[it]?\b', Name.Builtin, 'Python opcode'),
|
| 285 |
+
(r'\blua_(?:exec|opdef)\b', Name.Builtin, 'Lua opcode'),
|
| 286 |
+
(r'\bp\d+\b', Name.Variable.Instance),
|
| 287 |
+
(r'\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\b', name_callback)
|
| 288 |
+
],
|
| 289 |
+
|
| 290 |
+
'instrument numbers and identifiers': [
|
| 291 |
+
include('whitespace and macro uses'),
|
| 292 |
+
(r'\d+|[A-Z_a-z]\w*', Name.Function),
|
| 293 |
+
(r'[+,]', Punctuation),
|
| 294 |
+
(r'\n', Whitespace, '#pop')
|
| 295 |
+
],
|
| 296 |
+
|
| 297 |
+
'after opcode keyword': [
|
| 298 |
+
include('whitespace and macro uses'),
|
| 299 |
+
(r'[A-Z_a-z]\w*', opcode_name_callback, ('#pop', 'opcode type signatures')),
|
| 300 |
+
(r'\n', Whitespace, '#pop')
|
| 301 |
+
],
|
| 302 |
+
'opcode type signatures': [
|
| 303 |
+
include('whitespace and macro uses'),
|
| 304 |
+
|
| 305 |
+
# https://github.com/csound/csound/search?q=XIDENT+path%3AEngine+filename%3Acsound_orc.lex
|
| 306 |
+
(r'0|[afijkKoOpPStV\[\]]+', Keyword.Type),
|
| 307 |
+
|
| 308 |
+
(r',', Punctuation),
|
| 309 |
+
(r'\n', Whitespace, '#pop')
|
| 310 |
+
],
|
| 311 |
+
|
| 312 |
+
'quoted string': [
|
| 313 |
+
(r'"', String, '#pop'),
|
| 314 |
+
(r'[^\\"$%)]+', String),
|
| 315 |
+
include('macro uses'),
|
| 316 |
+
include('escape sequences'),
|
| 317 |
+
include('format specifiers'),
|
| 318 |
+
(r'[\\$%)]', String)
|
| 319 |
+
],
|
| 320 |
+
'braced string': [
|
| 321 |
+
(r'\}\}', String, '#pop'),
|
| 322 |
+
(r'(?:[^\\%)}]|\}(?!\}))+', String),
|
| 323 |
+
include('escape sequences'),
|
| 324 |
+
include('format specifiers'),
|
| 325 |
+
(r'[\\%)]', String)
|
| 326 |
+
],
|
| 327 |
+
'escape sequences': [
|
| 328 |
+
# https://github.com/csound/csound/search?q=unquote_string+path%3AEngine+filename%3Acsound_orc_compile.c
|
| 329 |
+
(r'\\(?:[\\abnrt"]|[0-7]{1,3})', String.Escape)
|
| 330 |
+
],
|
| 331 |
+
# Format specifiers are highlighted in all strings, even though only
|
| 332 |
+
# fprintks https://csound.com/docs/manual/fprintks.html
|
| 333 |
+
# fprints https://csound.com/docs/manual/fprints.html
|
| 334 |
+
# printf/printf_i https://csound.com/docs/manual/printf.html
|
| 335 |
+
# printks https://csound.com/docs/manual/printks.html
|
| 336 |
+
# prints https://csound.com/docs/manual/prints.html
|
| 337 |
+
# sprintf https://csound.com/docs/manual/sprintf.html
|
| 338 |
+
# sprintfk https://csound.com/docs/manual/sprintfk.html
|
| 339 |
+
# work with strings that contain format specifiers. In addition, these opcodes’
|
| 340 |
+
# handling of format specifiers is inconsistent:
|
| 341 |
+
# - fprintks and fprints accept %a and %A specifiers, and accept %s specifiers
|
| 342 |
+
# starting in Csound 6.15.0.
|
| 343 |
+
# - printks and prints accept %a and %A specifiers, but don’t accept %s
|
| 344 |
+
# specifiers.
|
| 345 |
+
# - printf, printf_i, sprintf, and sprintfk don’t accept %a and %A specifiers,
|
| 346 |
+
# but accept %s specifiers.
|
| 347 |
+
# See https://github.com/csound/csound/issues/747 for more information.
|
| 348 |
+
'format specifiers': [
|
| 349 |
+
(r'%[#0\- +]*\d*(?:\.\d+)?[AE-GXac-giosux]', String.Interpol),
|
| 350 |
+
(r'%%', String.Escape)
|
| 351 |
+
],
|
| 352 |
+
|
| 353 |
+
'goto argument': [
|
| 354 |
+
include('whitespace and macro uses'),
|
| 355 |
+
(r',', Punctuation, '#pop'),
|
| 356 |
+
include('partial statements')
|
| 357 |
+
],
|
| 358 |
+
'goto label': [
|
| 359 |
+
include('whitespace and macro uses'),
|
| 360 |
+
(r'\w+', Name.Label, '#pop'),
|
| 361 |
+
default('#pop')
|
| 362 |
+
],
|
| 363 |
+
|
| 364 |
+
'prints opcode': [
|
| 365 |
+
include('whitespace and macro uses'),
|
| 366 |
+
(r'"', String, 'prints quoted string'),
|
| 367 |
+
default('#pop')
|
| 368 |
+
],
|
| 369 |
+
'prints quoted string': [
|
| 370 |
+
(r'\\\\[aAbBnNrRtT]', String.Escape),
|
| 371 |
+
(r'%[!nNrRtT]|[~^]{1,2}', String.Escape),
|
| 372 |
+
include('quoted string')
|
| 373 |
+
],
|
| 374 |
+
|
| 375 |
+
'Csound score opcode': [
|
| 376 |
+
include('whitespace and macro uses'),
|
| 377 |
+
(r'"', String, 'quoted string'),
|
| 378 |
+
(r'\{\{', String, 'Csound score'),
|
| 379 |
+
(r'\n', Whitespace, '#pop')
|
| 380 |
+
],
|
| 381 |
+
'Csound score': [
|
| 382 |
+
(r'\}\}', String, '#pop'),
|
| 383 |
+
(r'([^}]+)|\}(?!\})', using(CsoundScoreLexer))
|
| 384 |
+
],
|
| 385 |
+
|
| 386 |
+
'Python opcode': [
|
| 387 |
+
include('whitespace and macro uses'),
|
| 388 |
+
(r'"', String, 'quoted string'),
|
| 389 |
+
(r'\{\{', String, 'Python'),
|
| 390 |
+
(r'\n', Whitespace, '#pop')
|
| 391 |
+
],
|
| 392 |
+
'Python': [
|
| 393 |
+
(r'\}\}', String, '#pop'),
|
| 394 |
+
(r'([^}]+)|\}(?!\})', using(PythonLexer))
|
| 395 |
+
],
|
| 396 |
+
|
| 397 |
+
'Lua opcode': [
|
| 398 |
+
include('whitespace and macro uses'),
|
| 399 |
+
(r'"', String, 'quoted string'),
|
| 400 |
+
(r'\{\{', String, 'Lua'),
|
| 401 |
+
(r'\n', Whitespace, '#pop')
|
| 402 |
+
],
|
| 403 |
+
'Lua': [
|
| 404 |
+
(r'\}\}', String, '#pop'),
|
| 405 |
+
(r'([^}]+)|\}(?!\})', using(LuaLexer))
|
| 406 |
+
]
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
class CsoundDocumentLexer(RegexLexer):
|
| 411 |
+
"""
|
| 412 |
+
For Csound documents.
|
| 413 |
+
"""
|
| 414 |
+
|
| 415 |
+
name = 'Csound Document'
|
| 416 |
+
aliases = ['csound-document', 'csound-csd']
|
| 417 |
+
filenames = ['*.csd']
|
| 418 |
+
url = 'https://csound.com'
|
| 419 |
+
version_added = '2.1'
|
| 420 |
+
|
| 421 |
+
# These tokens are based on those in XmlLexer in pygments/lexers/html.py. Making
|
| 422 |
+
# CsoundDocumentLexer a subclass of XmlLexer rather than RegexLexer may seem like a
|
| 423 |
+
# better idea, since Csound Document files look like XML files. However, Csound
|
| 424 |
+
# Documents can contain Csound comments (preceded by //, for example) before and
|
| 425 |
+
# after the root element, unescaped bitwise AND & and less than < operators, etc. In
|
| 426 |
+
# other words, while Csound Document files look like XML files, they may not actually
|
| 427 |
+
# be XML files.
|
| 428 |
+
tokens = {
|
| 429 |
+
'root': [
|
| 430 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 431 |
+
(r'(?:;|//).*$', Comment.Single),
|
| 432 |
+
(r'[^/;<]+|/(?!/)', Text),
|
| 433 |
+
|
| 434 |
+
(r'<\s*CsInstruments', Name.Tag, ('orchestra', 'tag')),
|
| 435 |
+
(r'<\s*CsScore', Name.Tag, ('score', 'tag')),
|
| 436 |
+
(r'<\s*[Hh][Tt][Mm][Ll]', Name.Tag, ('HTML', 'tag')),
|
| 437 |
+
|
| 438 |
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
|
| 439 |
+
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag)
|
| 440 |
+
],
|
| 441 |
+
|
| 442 |
+
'orchestra': [
|
| 443 |
+
(r'<\s*/\s*CsInstruments\s*>', Name.Tag, '#pop'),
|
| 444 |
+
(r'(.|\n)+?(?=<\s*/\s*CsInstruments\s*>)', using(CsoundOrchestraLexer))
|
| 445 |
+
],
|
| 446 |
+
'score': [
|
| 447 |
+
(r'<\s*/\s*CsScore\s*>', Name.Tag, '#pop'),
|
| 448 |
+
(r'(.|\n)+?(?=<\s*/\s*CsScore\s*>)', using(CsoundScoreLexer))
|
| 449 |
+
],
|
| 450 |
+
'HTML': [
|
| 451 |
+
(r'<\s*/\s*[Hh][Tt][Mm][Ll]\s*>', Name.Tag, '#pop'),
|
| 452 |
+
(r'(.|\n)+?(?=<\s*/\s*[Hh][Tt][Mm][Ll]\s*>)', using(HtmlLexer))
|
| 453 |
+
],
|
| 454 |
+
|
| 455 |
+
'tag': [
|
| 456 |
+
(r'\s+', Whitespace),
|
| 457 |
+
(r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
|
| 458 |
+
(r'/?\s*>', Name.Tag, '#pop')
|
| 459 |
+
],
|
| 460 |
+
'attr': [
|
| 461 |
+
(r'\s+', Whitespace),
|
| 462 |
+
(r'".*?"', String, '#pop'),
|
| 463 |
+
(r"'.*?'", String, '#pop'),
|
| 464 |
+
(r'[^\s>]+', String, '#pop')
|
| 465 |
+
]
|
| 466 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/css.py
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.css
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for CSS and related stylesheet formats.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
import copy
|
| 13 |
+
|
| 14 |
+
from pygments.lexer import ExtendedRegexLexer, RegexLexer, include, bygroups, \
|
| 15 |
+
default, words, inherit
|
| 16 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, \
|
| 17 |
+
Punctuation, Whitespace
|
| 18 |
+
from pygments.lexers._css_builtins import _css_properties
|
| 19 |
+
|
| 20 |
+
__all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# List of vendor prefixes obtained from:
|
| 24 |
+
# https://www.w3.org/TR/CSS21/syndata.html#vendor-keyword-history
|
| 25 |
+
_vendor_prefixes = (
|
| 26 |
+
'-ms-', 'mso-', '-moz-', '-o-', '-xv-', '-atsc-', '-wap-', '-khtml-',
|
| 27 |
+
'-webkit-', 'prince-', '-ah-', '-hp-', '-ro-', '-rim-', '-tc-',
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# List of extended color keywords obtained from:
|
| 31 |
+
# https://drafts.csswg.org/css-color/#named-colors
|
| 32 |
+
_color_keywords = (
|
| 33 |
+
'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige',
|
| 34 |
+
'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown',
|
| 35 |
+
'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral',
|
| 36 |
+
'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan',
|
| 37 |
+
'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki',
|
| 38 |
+
'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred',
|
| 39 |
+
'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray',
|
| 40 |
+
'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue',
|
| 41 |
+
'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite',
|
| 42 |
+
'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod',
|
| 43 |
+
'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred',
|
| 44 |
+
'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen',
|
| 45 |
+
'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan',
|
| 46 |
+
'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey',
|
| 47 |
+
'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue',
|
| 48 |
+
'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow',
|
| 49 |
+
'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine',
|
| 50 |
+
'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen',
|
| 51 |
+
'mediumslateblue', 'mediumspringgreen', 'mediumturquoise',
|
| 52 |
+
'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin',
|
| 53 |
+
'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange',
|
| 54 |
+
'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise',
|
| 55 |
+
'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum',
|
| 56 |
+
'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue',
|
| 57 |
+
'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna',
|
| 58 |
+
'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow',
|
| 59 |
+
'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise',
|
| 60 |
+
'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen',
|
| 61 |
+
) + ('transparent',)
|
| 62 |
+
|
| 63 |
+
# List of keyword values obtained from:
|
| 64 |
+
# http://cssvalues.com/
|
| 65 |
+
_keyword_values = (
|
| 66 |
+
'absolute', 'alias', 'all', 'all-petite-caps', 'all-scroll',
|
| 67 |
+
'all-small-caps', 'allow-end', 'alpha', 'alternate', 'alternate-reverse',
|
| 68 |
+
'always', 'armenian', 'auto', 'avoid', 'avoid-column', 'avoid-page',
|
| 69 |
+
'backwards', 'balance', 'baseline', 'below', 'blink', 'block', 'bold',
|
| 70 |
+
'bolder', 'border-box', 'both', 'bottom', 'box-decoration', 'break-word',
|
| 71 |
+
'capitalize', 'cell', 'center', 'circle', 'clip', 'clone', 'close-quote',
|
| 72 |
+
'col-resize', 'collapse', 'color', 'color-burn', 'color-dodge', 'column',
|
| 73 |
+
'column-reverse', 'compact', 'condensed', 'contain', 'container',
|
| 74 |
+
'content-box', 'context-menu', 'copy', 'cover', 'crisp-edges', 'crosshair',
|
| 75 |
+
'currentColor', 'cursive', 'darken', 'dashed', 'decimal',
|
| 76 |
+
'decimal-leading-zero', 'default', 'descendants', 'difference', 'digits',
|
| 77 |
+
'disc', 'distribute', 'dot', 'dotted', 'double', 'double-circle', 'e-resize',
|
| 78 |
+
'each-line', 'ease', 'ease-in', 'ease-in-out', 'ease-out', 'edges',
|
| 79 |
+
'ellipsis', 'end', 'ew-resize', 'exclusion', 'expanded', 'extra-condensed',
|
| 80 |
+
'extra-expanded', 'fantasy', 'fill', 'fill-box', 'filled', 'first', 'fixed',
|
| 81 |
+
'flat', 'flex', 'flex-end', 'flex-start', 'flip', 'force-end', 'forwards',
|
| 82 |
+
'from-image', 'full-width', 'geometricPrecision', 'georgian', 'groove',
|
| 83 |
+
'hanging', 'hard-light', 'help', 'hidden', 'hide', 'horizontal', 'hue',
|
| 84 |
+
'icon', 'infinite', 'inherit', 'initial', 'ink', 'inline', 'inline-block',
|
| 85 |
+
'inline-flex', 'inline-table', 'inset', 'inside', 'inter-word', 'invert',
|
| 86 |
+
'isolate', 'italic', 'justify', 'large', 'larger', 'last', 'left',
|
| 87 |
+
'lighten', 'lighter', 'line-through', 'linear', 'list-item', 'local',
|
| 88 |
+
'loose', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman',
|
| 89 |
+
'lowercase', 'ltr', 'luminance', 'luminosity', 'mandatory', 'manipulation',
|
| 90 |
+
'manual', 'margin-box', 'match-parent', 'medium', 'mixed', 'monospace',
|
| 91 |
+
'move', 'multiply', 'n-resize', 'ne-resize', 'nesw-resize',
|
| 92 |
+
'no-close-quote', 'no-drop', 'no-open-quote', 'no-repeat', 'none', 'normal',
|
| 93 |
+
'not-allowed', 'nowrap', 'ns-resize', 'nw-resize', 'nwse-resize', 'objects',
|
| 94 |
+
'oblique', 'off', 'on', 'open', 'open-quote', 'optimizeLegibility',
|
| 95 |
+
'optimizeSpeed', 'outset', 'outside', 'over', 'overlay', 'overline',
|
| 96 |
+
'padding-box', 'page', 'pan-down', 'pan-left', 'pan-right', 'pan-up',
|
| 97 |
+
'pan-x', 'pan-y', 'paused', 'petite-caps', 'pixelated', 'pointer',
|
| 98 |
+
'preserve-3d', 'progress', 'proximity', 'relative', 'repeat',
|
| 99 |
+
'repeat no-repeat', 'repeat-x', 'repeat-y', 'reverse', 'revert', 'ridge', 'right',
|
| 100 |
+
'round', 'row', 'row-resize', 'row-reverse', 'rtl', 'ruby', 'ruby-base',
|
| 101 |
+
'ruby-base-container', 'ruby-text', 'ruby-text-container', 'run-in',
|
| 102 |
+
'running', 's-resize', 'sans-serif', 'saturation', 'scale-down', 'screen',
|
| 103 |
+
'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate',
|
| 104 |
+
'serif', 'sesame', 'show', 'sideways', 'sideways-left', 'sideways-right',
|
| 105 |
+
'slice', 'small', 'small-caps', 'smaller', 'smooth', 'snap', 'soft-light',
|
| 106 |
+
'solid', 'space', 'space-around', 'space-between', 'spaces', 'square',
|
| 107 |
+
'start', 'static', 'step-end', 'step-start', 'sticky', 'stretch', 'strict',
|
| 108 |
+
'stroke-box', 'style', 'sw-resize', 'table', 'table-caption', 'table-cell',
|
| 109 |
+
'table-column', 'table-column-group', 'table-footer-group',
|
| 110 |
+
'table-header-group', 'table-row', 'table-row-group', 'text', 'thick',
|
| 111 |
+
'thin', 'titling-caps', 'to', 'top', 'triangle', 'ultra-condensed',
|
| 112 |
+
'ultra-expanded', 'under', 'underline', 'unicase', 'unset', 'upper-alpha',
|
| 113 |
+
'upper-latin', 'upper-roman', 'uppercase', 'upright', 'use-glyph-orientation',
|
| 114 |
+
'vertical', 'vertical-text', 'view-box', 'visible', 'w-resize', 'wait',
|
| 115 |
+
'wavy', 'weight', 'weight style', 'wrap', 'wrap-reverse', 'x-large',
|
| 116 |
+
'x-small', 'xx-large', 'xx-small', 'zoom-in', 'zoom-out',
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
# List of other keyword values from other sources:
|
| 120 |
+
_other_keyword_values = (
|
| 121 |
+
'above', 'aural', 'behind', 'bidi-override', 'center-left', 'center-right',
|
| 122 |
+
'cjk-ideographic', 'continuous', 'crop', 'cross', 'embed', 'far-left',
|
| 123 |
+
'far-right', 'fast', 'faster', 'hebrew', 'high', 'higher', 'hiragana',
|
| 124 |
+
'hiragana-iroha', 'katakana', 'katakana-iroha', 'landscape', 'left-side',
|
| 125 |
+
'leftwards', 'level', 'loud', 'low', 'lower', 'message-box', 'middle',
|
| 126 |
+
'mix', 'narrower', 'once', 'portrait', 'right-side', 'rightwards', 'silent',
|
| 127 |
+
'slow', 'slower', 'small-caption', 'soft', 'spell-out', 'status-bar',
|
| 128 |
+
'super', 'text-bottom', 'text-top', 'wider', 'x-fast', 'x-high', 'x-loud',
|
| 129 |
+
'x-low', 'x-soft', 'yes', 'pre', 'pre-wrap', 'pre-line',
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
# List of functional notation and function keyword values:
|
| 133 |
+
_functional_notation_keyword_values = (
|
| 134 |
+
'attr', 'blackness', 'blend', 'blenda', 'blur', 'brightness', 'calc',
|
| 135 |
+
'circle', 'color-mod', 'contrast', 'counter', 'cubic-bezier', 'device-cmyk',
|
| 136 |
+
'drop-shadow', 'ellipse', 'gray', 'grayscale', 'hsl', 'hsla', 'hue',
|
| 137 |
+
'hue-rotate', 'hwb', 'image', 'inset', 'invert', 'lightness',
|
| 138 |
+
'linear-gradient', 'matrix', 'matrix3d', 'opacity', 'perspective',
|
| 139 |
+
'polygon', 'radial-gradient', 'rect', 'repeating-linear-gradient',
|
| 140 |
+
'repeating-radial-gradient', 'rgb', 'rgba', 'rotate', 'rotate3d', 'rotateX',
|
| 141 |
+
'rotateY', 'rotateZ', 'saturate', 'saturation', 'scale', 'scale3d',
|
| 142 |
+
'scaleX', 'scaleY', 'scaleZ', 'sepia', 'shade', 'skewX', 'skewY', 'steps',
|
| 143 |
+
'tint', 'toggle', 'translate', 'translate3d', 'translateX', 'translateY',
|
| 144 |
+
'translateZ', 'whiteness',
|
| 145 |
+
)
|
| 146 |
+
# Note! Handle url(...) separately.
|
| 147 |
+
|
| 148 |
+
# List of units obtained from:
|
| 149 |
+
# https://www.w3.org/TR/css3-values/
|
| 150 |
+
_angle_units = (
|
| 151 |
+
'deg', 'grad', 'rad', 'turn',
|
| 152 |
+
)
|
| 153 |
+
_frequency_units = (
|
| 154 |
+
'Hz', 'kHz',
|
| 155 |
+
)
|
| 156 |
+
_length_units = (
|
| 157 |
+
'em', 'ex', 'ch', 'rem',
|
| 158 |
+
'vh', 'vw', 'vmin', 'vmax',
|
| 159 |
+
'px', 'mm', 'cm', 'in', 'pt', 'pc', 'q',
|
| 160 |
+
)
|
| 161 |
+
_resolution_units = (
|
| 162 |
+
'dpi', 'dpcm', 'dppx',
|
| 163 |
+
)
|
| 164 |
+
_time_units = (
|
| 165 |
+
's', 'ms',
|
| 166 |
+
)
|
| 167 |
+
_all_units = _angle_units + _frequency_units + _length_units + \
|
| 168 |
+
_resolution_units + _time_units
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class CssLexer(RegexLexer):
|
| 172 |
+
"""
|
| 173 |
+
For CSS (Cascading Style Sheets).
|
| 174 |
+
"""
|
| 175 |
+
|
| 176 |
+
name = 'CSS'
|
| 177 |
+
url = 'https://www.w3.org/TR/CSS/#css'
|
| 178 |
+
aliases = ['css']
|
| 179 |
+
filenames = ['*.css']
|
| 180 |
+
mimetypes = ['text/css']
|
| 181 |
+
version_added = ''
|
| 182 |
+
|
| 183 |
+
tokens = {
|
| 184 |
+
'root': [
|
| 185 |
+
include('basics'),
|
| 186 |
+
],
|
| 187 |
+
'basics': [
|
| 188 |
+
(r'\s+', Whitespace),
|
| 189 |
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
| 190 |
+
(r'\{', Punctuation, 'content'),
|
| 191 |
+
(r'(\:{1,2})([\w-]+)', bygroups(Punctuation, Name.Decorator)),
|
| 192 |
+
(r'(\.)([\w-]+)', bygroups(Punctuation, Name.Class)),
|
| 193 |
+
(r'(\#)([\w-]+)', bygroups(Punctuation, Name.Namespace)),
|
| 194 |
+
(r'(@)([\w-]+)', bygroups(Punctuation, Keyword), 'atrule'),
|
| 195 |
+
(r'[\w-]+', Name.Tag),
|
| 196 |
+
(r'[~^*!%&$\[\]()<>|+=@:;,./?-]', Operator),
|
| 197 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 198 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 199 |
+
],
|
| 200 |
+
'atrule': [
|
| 201 |
+
(r'\{', Punctuation, 'atcontent'),
|
| 202 |
+
(r';', Punctuation, '#pop'),
|
| 203 |
+
include('basics'),
|
| 204 |
+
],
|
| 205 |
+
'atcontent': [
|
| 206 |
+
include('basics'),
|
| 207 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 208 |
+
],
|
| 209 |
+
'content': [
|
| 210 |
+
(r'\s+', Whitespace),
|
| 211 |
+
(r'\}', Punctuation, '#pop'),
|
| 212 |
+
(r';', Punctuation),
|
| 213 |
+
(r'^@.*?$', Comment.Preproc),
|
| 214 |
+
|
| 215 |
+
(words(_vendor_prefixes,), Keyword.Pseudo),
|
| 216 |
+
(r'('+r'|'.join(_css_properties)+r')(\s*)(\:)',
|
| 217 |
+
bygroups(Keyword, Whitespace, Punctuation), 'value-start'),
|
| 218 |
+
(r'([-]+[a-zA-Z_][\w-]*)(\s*)(\:)', bygroups(Name.Variable, Whitespace, Punctuation),
|
| 219 |
+
'value-start'),
|
| 220 |
+
(r'([a-zA-Z_][\w-]*)(\s*)(\:)', bygroups(Name, Whitespace, Punctuation),
|
| 221 |
+
'value-start'),
|
| 222 |
+
|
| 223 |
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
| 224 |
+
],
|
| 225 |
+
'value-start': [
|
| 226 |
+
(r'\s+', Whitespace),
|
| 227 |
+
(words(_vendor_prefixes,), Name.Builtin.Pseudo),
|
| 228 |
+
include('urls'),
|
| 229 |
+
(r'('+r'|'.join(_functional_notation_keyword_values)+r')(\()',
|
| 230 |
+
bygroups(Name.Builtin, Punctuation), 'function-start'),
|
| 231 |
+
(r'([a-zA-Z_][\w-]+)(\()',
|
| 232 |
+
bygroups(Name.Function, Punctuation), 'function-start'),
|
| 233 |
+
(words(_keyword_values, suffix=r'\b'), Keyword.Constant),
|
| 234 |
+
(words(_other_keyword_values, suffix=r'\b'), Keyword.Constant),
|
| 235 |
+
(words(_color_keywords, suffix=r'\b'), Keyword.Constant),
|
| 236 |
+
# for transition-property etc.
|
| 237 |
+
(words(_css_properties, suffix=r'\b'), Keyword),
|
| 238 |
+
(r'\!important', Comment.Preproc),
|
| 239 |
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
| 240 |
+
|
| 241 |
+
include('numeric-values'),
|
| 242 |
+
|
| 243 |
+
(r'[~^*!%&<>|+=@:./?-]+', Operator),
|
| 244 |
+
(r'[\[\](),]+', Punctuation),
|
| 245 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 246 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 247 |
+
(r'[a-zA-Z_][\w-]*', Name),
|
| 248 |
+
(r';', Punctuation, '#pop'),
|
| 249 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 250 |
+
],
|
| 251 |
+
'function-start': [
|
| 252 |
+
(r'\s+', Whitespace),
|
| 253 |
+
(r'[-]+([A-Za-z][\w+]*[-]*)+', Name.Variable),
|
| 254 |
+
include('urls'),
|
| 255 |
+
(words(_vendor_prefixes,), Keyword.Pseudo),
|
| 256 |
+
(words(_keyword_values, suffix=r'\b'), Keyword.Constant),
|
| 257 |
+
(words(_other_keyword_values, suffix=r'\b'), Keyword.Constant),
|
| 258 |
+
(words(_color_keywords, suffix=r'\b'), Keyword.Constant),
|
| 259 |
+
|
| 260 |
+
# function-start may be entered recursively
|
| 261 |
+
(r'(' + r'|'.join(_functional_notation_keyword_values) + r')(\()',
|
| 262 |
+
bygroups(Name.Builtin, Punctuation), 'function-start'),
|
| 263 |
+
(r'([a-zA-Z_][\w-]+)(\()',
|
| 264 |
+
bygroups(Name.Function, Punctuation), 'function-start'),
|
| 265 |
+
|
| 266 |
+
(r'/\*(?:.|\n)*?\*/', Comment),
|
| 267 |
+
include('numeric-values'),
|
| 268 |
+
(r'[*+/-]', Operator),
|
| 269 |
+
(r',', Punctuation),
|
| 270 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 271 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 272 |
+
(r'[a-zA-Z_-]\w*', Name),
|
| 273 |
+
(r'\)', Punctuation, '#pop'),
|
| 274 |
+
],
|
| 275 |
+
'urls': [
|
| 276 |
+
(r'(url)(\()(".*?")(\))', bygroups(Name.Builtin, Punctuation,
|
| 277 |
+
String.Double, Punctuation)),
|
| 278 |
+
(r"(url)(\()('.*?')(\))", bygroups(Name.Builtin, Punctuation,
|
| 279 |
+
String.Single, Punctuation)),
|
| 280 |
+
(r'(url)(\()(.*?)(\))', bygroups(Name.Builtin, Punctuation,
|
| 281 |
+
String.Other, Punctuation)),
|
| 282 |
+
],
|
| 283 |
+
'numeric-values': [
|
| 284 |
+
(r'\#[a-zA-Z0-9]{1,6}', Number.Hex),
|
| 285 |
+
(r'[+\-]?[0-9]*[.][0-9]+', Number.Float, 'numeric-end'),
|
| 286 |
+
(r'[+\-]?[0-9]+', Number.Integer, 'numeric-end'),
|
| 287 |
+
],
|
| 288 |
+
'numeric-end': [
|
| 289 |
+
(words(_all_units, suffix=r'\b'), Keyword.Type),
|
| 290 |
+
(r'%', Keyword.Type),
|
| 291 |
+
default('#pop'),
|
| 292 |
+
],
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
common_sass_tokens = {
|
| 297 |
+
'value': [
|
| 298 |
+
(r'[ \t]+', Whitespace),
|
| 299 |
+
(r'[!$][\w-]+', Name.Variable),
|
| 300 |
+
(r'url\(', String.Other, 'string-url'),
|
| 301 |
+
(r'[a-z_-][\w-]*(?=\()', Name.Function),
|
| 302 |
+
(words(_css_properties + (
|
| 303 |
+
'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline',
|
| 304 |
+
'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both',
|
| 305 |
+
'capitalize', 'center-left', 'center-right', 'center', 'circle',
|
| 306 |
+
'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous',
|
| 307 |
+
'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero',
|
| 308 |
+
'decimal', 'default', 'digits', 'disc', 'dotted', 'double', 'e-resize', 'embed',
|
| 309 |
+
'extra-condensed', 'extra-expanded', 'expanded', 'fantasy', 'far-left',
|
| 310 |
+
'far-right', 'faster', 'fast', 'fixed', 'georgian', 'groove', 'hebrew', 'help',
|
| 311 |
+
'hidden', 'hide', 'higher', 'high', 'hiragana-iroha', 'hiragana', 'icon',
|
| 312 |
+
'inherit', 'inline-table', 'inline', 'inset', 'inside', 'invert', 'italic',
|
| 313 |
+
'justify', 'katakana-iroha', 'katakana', 'landscape', 'larger', 'large',
|
| 314 |
+
'left-side', 'leftwards', 'level', 'lighter', 'line-through', 'list-item',
|
| 315 |
+
'loud', 'lower-alpha', 'lower-greek', 'lower-roman', 'lowercase', 'ltr',
|
| 316 |
+
'lower', 'low', 'medium', 'message-box', 'middle', 'mix', 'monospace',
|
| 317 |
+
'n-resize', 'narrower', 'ne-resize', 'no-close-quote', 'no-open-quote',
|
| 318 |
+
'no-repeat', 'none', 'normal', 'nowrap', 'nw-resize', 'oblique', 'once',
|
| 319 |
+
'open-quote', 'outset', 'outside', 'overline', 'pointer', 'portrait', 'px',
|
| 320 |
+
'relative', 'repeat-x', 'repeat-y', 'repeat', 'rgb', 'ridge', 'right-side',
|
| 321 |
+
'rightwards', 's-resize', 'sans-serif', 'scroll', 'se-resize',
|
| 322 |
+
'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'silent',
|
| 323 |
+
'slow', 'slower', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid',
|
| 324 |
+
'spell-out', 'square', 'static', 'status-bar', 'super', 'sw-resize',
|
| 325 |
+
'table-caption', 'table-cell', 'table-column', 'table-column-group',
|
| 326 |
+
'table-footer-group', 'table-header-group', 'table-row',
|
| 327 |
+
'table-row-group', 'text', 'text-bottom', 'text-top', 'thick', 'thin',
|
| 328 |
+
'transparent', 'ultra-condensed', 'ultra-expanded', 'underline',
|
| 329 |
+
'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url',
|
| 330 |
+
'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud',
|
| 331 |
+
'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'),
|
| 332 |
+
Name.Constant),
|
| 333 |
+
(words(_color_keywords, suffix=r'\b'), Name.Entity),
|
| 334 |
+
(words((
|
| 335 |
+
'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green',
|
| 336 |
+
'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'), suffix=r'\b'),
|
| 337 |
+
Name.Builtin),
|
| 338 |
+
(r'\!(important|default)', Name.Exception),
|
| 339 |
+
(r'(true|false)', Name.Pseudo),
|
| 340 |
+
(r'(and|or|not)', Operator.Word),
|
| 341 |
+
(r'/\*', Comment.Multiline, 'inline-comment'),
|
| 342 |
+
(r'//[^\n]*', Comment.Single),
|
| 343 |
+
(r'\#[a-z0-9]{1,6}', Number.Hex),
|
| 344 |
+
(r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)),
|
| 345 |
+
(r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)),
|
| 346 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 347 |
+
(r'[~^*!&%<>|+=@:,./?-]+', Operator),
|
| 348 |
+
(r'[\[\]()]+', Punctuation),
|
| 349 |
+
(r'"', String.Double, 'string-double'),
|
| 350 |
+
(r"'", String.Single, 'string-single'),
|
| 351 |
+
(r'[a-z_-][\w-]*', Name),
|
| 352 |
+
],
|
| 353 |
+
|
| 354 |
+
'interpolation': [
|
| 355 |
+
(r'\}', String.Interpol, '#pop'),
|
| 356 |
+
include('value'),
|
| 357 |
+
],
|
| 358 |
+
|
| 359 |
+
'selector': [
|
| 360 |
+
(r'[ \t]+', Whitespace),
|
| 361 |
+
(r'\:', Name.Decorator, 'pseudo-class'),
|
| 362 |
+
(r'\.', Name.Class, 'class'),
|
| 363 |
+
(r'\#', Name.Namespace, 'id'),
|
| 364 |
+
(r'[\w-]+', Name.Tag),
|
| 365 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 366 |
+
(r'&', Keyword),
|
| 367 |
+
(r'[~^*!&\[\]()<>|+=@:;,./?-]', Operator),
|
| 368 |
+
(r'"', String.Double, 'string-double'),
|
| 369 |
+
(r"'", String.Single, 'string-single'),
|
| 370 |
+
],
|
| 371 |
+
|
| 372 |
+
'string-double': [
|
| 373 |
+
(r'(\\.|#(?=[^\n{])|[^\n"#])+', String.Double),
|
| 374 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 375 |
+
(r'"', String.Double, '#pop'),
|
| 376 |
+
],
|
| 377 |
+
|
| 378 |
+
'string-single': [
|
| 379 |
+
(r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Single),
|
| 380 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 381 |
+
(r"'", String.Single, '#pop'),
|
| 382 |
+
],
|
| 383 |
+
|
| 384 |
+
'string-url': [
|
| 385 |
+
(r'(\\#|#(?=[^\n{])|[^\n#)])+', String.Other),
|
| 386 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 387 |
+
(r'\)', String.Other, '#pop'),
|
| 388 |
+
],
|
| 389 |
+
|
| 390 |
+
'pseudo-class': [
|
| 391 |
+
(r'[\w-]+', Name.Decorator),
|
| 392 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 393 |
+
default('#pop'),
|
| 394 |
+
],
|
| 395 |
+
|
| 396 |
+
'class': [
|
| 397 |
+
(r'[\w-]+', Name.Class),
|
| 398 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 399 |
+
default('#pop'),
|
| 400 |
+
],
|
| 401 |
+
|
| 402 |
+
'id': [
|
| 403 |
+
(r'[\w-]+', Name.Namespace),
|
| 404 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 405 |
+
default('#pop'),
|
| 406 |
+
],
|
| 407 |
+
|
| 408 |
+
'for': [
|
| 409 |
+
(r'(from|to|through)', Operator.Word),
|
| 410 |
+
include('value'),
|
| 411 |
+
],
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
def _indentation(lexer, match, ctx):
|
| 416 |
+
indentation = match.group(0)
|
| 417 |
+
yield match.start(), Whitespace, indentation
|
| 418 |
+
ctx.last_indentation = indentation
|
| 419 |
+
ctx.pos = match.end()
|
| 420 |
+
|
| 421 |
+
if hasattr(ctx, 'block_state') and ctx.block_state and \
|
| 422 |
+
indentation.startswith(ctx.block_indentation) and \
|
| 423 |
+
indentation != ctx.block_indentation:
|
| 424 |
+
ctx.stack.append(ctx.block_state)
|
| 425 |
+
else:
|
| 426 |
+
ctx.block_state = None
|
| 427 |
+
ctx.block_indentation = None
|
| 428 |
+
ctx.stack.append('content')
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
def _starts_block(token, state):
|
| 432 |
+
def callback(lexer, match, ctx):
|
| 433 |
+
yield match.start(), token, match.group(0)
|
| 434 |
+
|
| 435 |
+
if hasattr(ctx, 'last_indentation'):
|
| 436 |
+
ctx.block_indentation = ctx.last_indentation
|
| 437 |
+
else:
|
| 438 |
+
ctx.block_indentation = ''
|
| 439 |
+
|
| 440 |
+
ctx.block_state = state
|
| 441 |
+
ctx.pos = match.end()
|
| 442 |
+
|
| 443 |
+
return callback
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
class SassLexer(ExtendedRegexLexer):
|
| 447 |
+
"""
|
| 448 |
+
For Sass stylesheets.
|
| 449 |
+
"""
|
| 450 |
+
|
| 451 |
+
name = 'Sass'
|
| 452 |
+
url = 'https://sass-lang.com/'
|
| 453 |
+
aliases = ['sass']
|
| 454 |
+
filenames = ['*.sass']
|
| 455 |
+
mimetypes = ['text/x-sass']
|
| 456 |
+
version_added = '1.3'
|
| 457 |
+
|
| 458 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 459 |
+
|
| 460 |
+
tokens = {
|
| 461 |
+
'root': [
|
| 462 |
+
(r'[ \t]*\n', Whitespace),
|
| 463 |
+
(r'[ \t]*', _indentation),
|
| 464 |
+
],
|
| 465 |
+
|
| 466 |
+
'content': [
|
| 467 |
+
(r'//[^\n]*', _starts_block(Comment.Single, 'single-comment'),
|
| 468 |
+
'root'),
|
| 469 |
+
(r'/\*[^\n]*', _starts_block(Comment.Multiline, 'multi-comment'),
|
| 470 |
+
'root'),
|
| 471 |
+
(r'@import', Keyword, 'import'),
|
| 472 |
+
(r'@for', Keyword, 'for'),
|
| 473 |
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
| 474 |
+
(r'(@mixin)( )([\w-]+)', bygroups(Keyword, Whitespace, Name.Function), 'value'),
|
| 475 |
+
(r'(@include)( )([\w-]+)', bygroups(Keyword, Whitespace, Name.Decorator), 'value'),
|
| 476 |
+
(r'@extend', Keyword, 'selector'),
|
| 477 |
+
(r'@[\w-]+', Keyword, 'selector'),
|
| 478 |
+
(r'=[\w-]+', Name.Function, 'value'),
|
| 479 |
+
(r'\+[\w-]+', Name.Decorator, 'value'),
|
| 480 |
+
(r'([!$][\w-]\w*)([ \t]*(?:(?:\|\|)?=|:))',
|
| 481 |
+
bygroups(Name.Variable, Operator), 'value'),
|
| 482 |
+
(r':', Name.Attribute, 'old-style-attr'),
|
| 483 |
+
(r'(?=.+?[=:]([^a-z]|$))', Name.Attribute, 'new-style-attr'),
|
| 484 |
+
default('selector'),
|
| 485 |
+
],
|
| 486 |
+
|
| 487 |
+
'single-comment': [
|
| 488 |
+
(r'.+', Comment.Single),
|
| 489 |
+
(r'\n', Whitespace, 'root'),
|
| 490 |
+
],
|
| 491 |
+
|
| 492 |
+
'multi-comment': [
|
| 493 |
+
(r'.+', Comment.Multiline),
|
| 494 |
+
(r'\n', Whitespace, 'root'),
|
| 495 |
+
],
|
| 496 |
+
|
| 497 |
+
'import': [
|
| 498 |
+
(r'[ \t]+', Whitespace),
|
| 499 |
+
(r'\S+', String),
|
| 500 |
+
(r'\n', Whitespace, 'root'),
|
| 501 |
+
],
|
| 502 |
+
|
| 503 |
+
'old-style-attr': [
|
| 504 |
+
(r'[^\s:="\[]+', Name.Attribute),
|
| 505 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 506 |
+
(r'([ \t]*)(=)', bygroups(Whitespace, Operator), 'value'),
|
| 507 |
+
default('value'),
|
| 508 |
+
],
|
| 509 |
+
|
| 510 |
+
'new-style-attr': [
|
| 511 |
+
(r'[^\s:="\[]+', Name.Attribute),
|
| 512 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 513 |
+
(r'([ \t]*)([=:])', bygroups(Whitespace, Operator), 'value'),
|
| 514 |
+
],
|
| 515 |
+
|
| 516 |
+
'inline-comment': [
|
| 517 |
+
(r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline),
|
| 518 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 519 |
+
(r"\*/", Comment, '#pop'),
|
| 520 |
+
],
|
| 521 |
+
}
|
| 522 |
+
for group, common in common_sass_tokens.items():
|
| 523 |
+
tokens[group] = copy.copy(common)
|
| 524 |
+
tokens['value'].append((r'\n', Whitespace, 'root'))
|
| 525 |
+
tokens['selector'].append((r'\n', Whitespace, 'root'))
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
class ScssLexer(RegexLexer):
|
| 529 |
+
"""
|
| 530 |
+
For SCSS stylesheets.
|
| 531 |
+
"""
|
| 532 |
+
|
| 533 |
+
name = 'SCSS'
|
| 534 |
+
url = 'https://sass-lang.com/'
|
| 535 |
+
aliases = ['scss']
|
| 536 |
+
filenames = ['*.scss']
|
| 537 |
+
mimetypes = ['text/x-scss']
|
| 538 |
+
version_added = ''
|
| 539 |
+
|
| 540 |
+
flags = re.IGNORECASE | re.DOTALL
|
| 541 |
+
tokens = {
|
| 542 |
+
'root': [
|
| 543 |
+
(r'\s+', Whitespace),
|
| 544 |
+
(r'//.*?\n', Comment.Single),
|
| 545 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 546 |
+
(r'@import', Keyword, 'value'),
|
| 547 |
+
(r'@for', Keyword, 'for'),
|
| 548 |
+
(r'@(debug|warn|if|while)', Keyword, 'value'),
|
| 549 |
+
(r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'),
|
| 550 |
+
(r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
|
| 551 |
+
(r'@extend', Keyword, 'selector'),
|
| 552 |
+
(r'(@media)(\s+)', bygroups(Keyword, Whitespace), 'value'),
|
| 553 |
+
(r'@[\w-]+', Keyword, 'selector'),
|
| 554 |
+
(r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
|
| 555 |
+
# TODO: broken, and prone to infinite loops.
|
| 556 |
+
# (r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
|
| 557 |
+
# (r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
|
| 558 |
+
default('selector'),
|
| 559 |
+
],
|
| 560 |
+
|
| 561 |
+
'attr': [
|
| 562 |
+
(r'[^\s:="\[]+', Name.Attribute),
|
| 563 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 564 |
+
(r'[ \t]*:', Operator, 'value'),
|
| 565 |
+
default('#pop'),
|
| 566 |
+
],
|
| 567 |
+
|
| 568 |
+
'inline-comment': [
|
| 569 |
+
(r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
|
| 570 |
+
(r'#\{', String.Interpol, 'interpolation'),
|
| 571 |
+
(r"\*/", Comment, '#pop'),
|
| 572 |
+
],
|
| 573 |
+
}
|
| 574 |
+
for group, common in common_sass_tokens.items():
|
| 575 |
+
tokens[group] = copy.copy(common)
|
| 576 |
+
tokens['value'].extend([(r'\n', Whitespace), (r'[;{}]', Punctuation, '#pop')])
|
| 577 |
+
tokens['selector'].extend([(r'\n', Whitespace), (r'[;{}]', Punctuation, '#pop')])
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
class LessCssLexer(CssLexer):
|
| 581 |
+
"""
|
| 582 |
+
For LESS styleshets.
|
| 583 |
+
"""
|
| 584 |
+
|
| 585 |
+
name = 'LessCss'
|
| 586 |
+
url = 'http://lesscss.org/'
|
| 587 |
+
aliases = ['less']
|
| 588 |
+
filenames = ['*.less']
|
| 589 |
+
mimetypes = ['text/x-less-css']
|
| 590 |
+
version_added = '2.1'
|
| 591 |
+
|
| 592 |
+
tokens = {
|
| 593 |
+
# FIXME: It's not currently possible to simply do the following,
|
| 594 |
+
# as `include('basics')` doesn't take overrides into account:
|
| 595 |
+
# 'basics': [
|
| 596 |
+
# (r'//.*\n', Comment.Single),
|
| 597 |
+
# (r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 598 |
+
# inherit,
|
| 599 |
+
# ],
|
| 600 |
+
'root': [
|
| 601 |
+
(r'@\w+', Name.Variable),
|
| 602 |
+
(r'//.*\n', Comment.Single),
|
| 603 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 604 |
+
inherit,
|
| 605 |
+
],
|
| 606 |
+
'atcontent': [
|
| 607 |
+
(r'//.*\n', Comment.Single),
|
| 608 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 609 |
+
inherit,
|
| 610 |
+
],
|
| 611 |
+
'atrule': [
|
| 612 |
+
(r'//.*\n', Comment.Single),
|
| 613 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 614 |
+
inherit,
|
| 615 |
+
],
|
| 616 |
+
'content': [
|
| 617 |
+
(r'\{', Punctuation, '#push'),
|
| 618 |
+
(r'//.*\n', Comment.Single),
|
| 619 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 620 |
+
inherit,
|
| 621 |
+
],
|
| 622 |
+
'value-start': [
|
| 623 |
+
(r'//.*\n', Comment.Single),
|
| 624 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 625 |
+
inherit,
|
| 626 |
+
],
|
| 627 |
+
'function-start': [
|
| 628 |
+
(r'//.*\n', Comment.Single),
|
| 629 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 630 |
+
inherit,
|
| 631 |
+
],
|
| 632 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/d.py
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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2 |
+
pygments.lexers.d
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for D languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, words, bygroups
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, String, Number, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['DLexer', 'CrocLexer', 'MiniDLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class DLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For D source.
|
| 21 |
+
"""
|
| 22 |
+
name = 'D'
|
| 23 |
+
url = 'https://dlang.org/'
|
| 24 |
+
filenames = ['*.d', '*.di']
|
| 25 |
+
aliases = ['d']
|
| 26 |
+
mimetypes = ['text/x-dsrc']
|
| 27 |
+
version_added = '1.2'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'\n', Whitespace),
|
| 32 |
+
(r'\s+', Whitespace),
|
| 33 |
+
# (r'\\\n', Text), # line continuations
|
| 34 |
+
# Comments
|
| 35 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 36 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 37 |
+
(r'/\+', Comment.Multiline, 'nested_comment'),
|
| 38 |
+
# Keywords
|
| 39 |
+
(words((
|
| 40 |
+
'abstract', 'alias', 'align', 'asm', 'assert', 'auto', 'body',
|
| 41 |
+
'break', 'case', 'cast', 'catch', 'class', 'const', 'continue',
|
| 42 |
+
'debug', 'default', 'delegate', 'delete', 'deprecated', 'do', 'else',
|
| 43 |
+
'enum', 'export', 'extern', 'finally', 'final', 'foreach_reverse',
|
| 44 |
+
'foreach', 'for', 'function', 'goto', 'if', 'immutable', 'import',
|
| 45 |
+
'interface', 'invariant', 'inout', 'in', 'is', 'lazy', 'mixin',
|
| 46 |
+
'module', 'new', 'nothrow', 'out', 'override', 'package', 'pragma',
|
| 47 |
+
'private', 'protected', 'public', 'pure', 'ref', 'return', 'scope',
|
| 48 |
+
'shared', 'static', 'struct', 'super', 'switch', 'synchronized',
|
| 49 |
+
'template', 'this', 'throw', 'try', 'typeid', 'typeof',
|
| 50 |
+
'union', 'unittest', 'version', 'volatile', 'while', 'with',
|
| 51 |
+
'__gshared', '__traits', '__vector', '__parameters'),
|
| 52 |
+
suffix=r'\b'),
|
| 53 |
+
Keyword),
|
| 54 |
+
(words((
|
| 55 |
+
# Removed in 2.072
|
| 56 |
+
'typedef', ),
|
| 57 |
+
suffix=r'\b'),
|
| 58 |
+
Keyword.Removed),
|
| 59 |
+
(words((
|
| 60 |
+
'bool', 'byte', 'cdouble', 'cent', 'cfloat', 'char', 'creal',
|
| 61 |
+
'dchar', 'double', 'float', 'idouble', 'ifloat', 'int', 'ireal',
|
| 62 |
+
'long', 'real', 'short', 'ubyte', 'ucent', 'uint', 'ulong',
|
| 63 |
+
'ushort', 'void', 'wchar'), suffix=r'\b'),
|
| 64 |
+
Keyword.Type),
|
| 65 |
+
(r'(false|true|null)\b', Keyword.Constant),
|
| 66 |
+
(words((
|
| 67 |
+
'__FILE__', '__FILE_FULL_PATH__', '__MODULE__', '__LINE__', '__FUNCTION__',
|
| 68 |
+
'__PRETTY_FUNCTION__', '__DATE__', '__EOF__', '__TIME__', '__TIMESTAMP__',
|
| 69 |
+
'__VENDOR__', '__VERSION__'), suffix=r'\b'),
|
| 70 |
+
Keyword.Pseudo),
|
| 71 |
+
(r'macro\b', Keyword.Reserved),
|
| 72 |
+
(r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
|
| 73 |
+
# FloatLiteral
|
| 74 |
+
# -- HexFloat
|
| 75 |
+
(r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
|
| 76 |
+
r'[pP][+\-]?[0-9_]+[fFL]?[i]?', Number.Float),
|
| 77 |
+
# -- DecimalFloat
|
| 78 |
+
(r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|'
|
| 79 |
+
r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?', Number.Float),
|
| 80 |
+
(r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float),
|
| 81 |
+
# IntegerLiteral
|
| 82 |
+
# -- Binary
|
| 83 |
+
(r'0[Bb][01_]+', Number.Bin),
|
| 84 |
+
# -- Octal
|
| 85 |
+
(r'0[0-7_]+', Number.Oct),
|
| 86 |
+
# -- Hexadecimal
|
| 87 |
+
(r'0[xX][0-9a-fA-F_]+', Number.Hex),
|
| 88 |
+
# -- Decimal
|
| 89 |
+
(r'(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?', Number.Integer),
|
| 90 |
+
# CharacterLiteral
|
| 91 |
+
(r"""'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
|
| 92 |
+
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'""",
|
| 93 |
+
String.Char),
|
| 94 |
+
# StringLiteral
|
| 95 |
+
# -- WysiwygString
|
| 96 |
+
(r'r"[^"]*"[cwd]?', String),
|
| 97 |
+
# -- AlternateWysiwygString
|
| 98 |
+
(r'`[^`]*`[cwd]?', String),
|
| 99 |
+
# -- DoubleQuotedString
|
| 100 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"[cwd]?', String),
|
| 101 |
+
# -- EscapeSequence
|
| 102 |
+
(r"\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}"
|
| 103 |
+
r"|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)",
|
| 104 |
+
String),
|
| 105 |
+
# -- HexString
|
| 106 |
+
(r'x"[0-9a-fA-F_\s]*"[cwd]?', String),
|
| 107 |
+
# -- DelimitedString
|
| 108 |
+
(r'q"\[', String, 'delimited_bracket'),
|
| 109 |
+
(r'q"\(', String, 'delimited_parenthesis'),
|
| 110 |
+
(r'q"<', String, 'delimited_angle'),
|
| 111 |
+
(r'q"\{', String, 'delimited_curly'),
|
| 112 |
+
(r'q"([a-zA-Z_]\w*)\n.*?\n\1"', String),
|
| 113 |
+
(r'q"(.).*?\1"', String),
|
| 114 |
+
# -- TokenString
|
| 115 |
+
(r'q\{', String, 'token_string'),
|
| 116 |
+
# Attributes
|
| 117 |
+
(r'@([a-zA-Z_]\w*)?', Name.Decorator),
|
| 118 |
+
# Tokens
|
| 119 |
+
(r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
|
| 120 |
+
r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
|
| 121 |
+
r'|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]', Punctuation),
|
| 122 |
+
# Identifier
|
| 123 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 124 |
+
# Line
|
| 125 |
+
(r'(#line)(\s)(.*)(\n)', bygroups(Comment.Special, Whitespace,
|
| 126 |
+
Comment.Special, Whitespace)),
|
| 127 |
+
],
|
| 128 |
+
'nested_comment': [
|
| 129 |
+
(r'[^+/]+', Comment.Multiline),
|
| 130 |
+
(r'/\+', Comment.Multiline, '#push'),
|
| 131 |
+
(r'\+/', Comment.Multiline, '#pop'),
|
| 132 |
+
(r'[+/]', Comment.Multiline),
|
| 133 |
+
],
|
| 134 |
+
'token_string': [
|
| 135 |
+
(r'\{', Punctuation, 'token_string_nest'),
|
| 136 |
+
(r'\}', String, '#pop'),
|
| 137 |
+
include('root'),
|
| 138 |
+
],
|
| 139 |
+
'token_string_nest': [
|
| 140 |
+
(r'\{', Punctuation, '#push'),
|
| 141 |
+
(r'\}', Punctuation, '#pop'),
|
| 142 |
+
include('root'),
|
| 143 |
+
],
|
| 144 |
+
'delimited_bracket': [
|
| 145 |
+
(r'[^\[\]]+', String),
|
| 146 |
+
(r'\[', String, 'delimited_inside_bracket'),
|
| 147 |
+
(r'\]"', String, '#pop'),
|
| 148 |
+
],
|
| 149 |
+
'delimited_inside_bracket': [
|
| 150 |
+
(r'[^\[\]]+', String),
|
| 151 |
+
(r'\[', String, '#push'),
|
| 152 |
+
(r'\]', String, '#pop'),
|
| 153 |
+
],
|
| 154 |
+
'delimited_parenthesis': [
|
| 155 |
+
(r'[^()]+', String),
|
| 156 |
+
(r'\(', String, 'delimited_inside_parenthesis'),
|
| 157 |
+
(r'\)"', String, '#pop'),
|
| 158 |
+
],
|
| 159 |
+
'delimited_inside_parenthesis': [
|
| 160 |
+
(r'[^()]+', String),
|
| 161 |
+
(r'\(', String, '#push'),
|
| 162 |
+
(r'\)', String, '#pop'),
|
| 163 |
+
],
|
| 164 |
+
'delimited_angle': [
|
| 165 |
+
(r'[^<>]+', String),
|
| 166 |
+
(r'<', String, 'delimited_inside_angle'),
|
| 167 |
+
(r'>"', String, '#pop'),
|
| 168 |
+
],
|
| 169 |
+
'delimited_inside_angle': [
|
| 170 |
+
(r'[^<>]+', String),
|
| 171 |
+
(r'<', String, '#push'),
|
| 172 |
+
(r'>', String, '#pop'),
|
| 173 |
+
],
|
| 174 |
+
'delimited_curly': [
|
| 175 |
+
(r'[^{}]+', String),
|
| 176 |
+
(r'\{', String, 'delimited_inside_curly'),
|
| 177 |
+
(r'\}"', String, '#pop'),
|
| 178 |
+
],
|
| 179 |
+
'delimited_inside_curly': [
|
| 180 |
+
(r'[^{}]+', String),
|
| 181 |
+
(r'\{', String, '#push'),
|
| 182 |
+
(r'\}', String, '#pop'),
|
| 183 |
+
],
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class CrocLexer(RegexLexer):
|
| 188 |
+
"""
|
| 189 |
+
For Croc source.
|
| 190 |
+
"""
|
| 191 |
+
name = 'Croc'
|
| 192 |
+
url = 'http://jfbillingsley.com/croc'
|
| 193 |
+
filenames = ['*.croc']
|
| 194 |
+
aliases = ['croc']
|
| 195 |
+
mimetypes = ['text/x-crocsrc']
|
| 196 |
+
version_added = ''
|
| 197 |
+
|
| 198 |
+
tokens = {
|
| 199 |
+
'root': [
|
| 200 |
+
(r'\n', Whitespace),
|
| 201 |
+
(r'\s+', Whitespace),
|
| 202 |
+
# Comments
|
| 203 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 204 |
+
(r'/\*', Comment.Multiline, 'nestedcomment'),
|
| 205 |
+
# Keywords
|
| 206 |
+
(words((
|
| 207 |
+
'as', 'assert', 'break', 'case', 'catch', 'class', 'continue',
|
| 208 |
+
'default', 'do', 'else', 'finally', 'for', 'foreach', 'function',
|
| 209 |
+
'global', 'namespace', 'if', 'import', 'in', 'is', 'local',
|
| 210 |
+
'module', 'return', 'scope', 'super', 'switch', 'this', 'throw',
|
| 211 |
+
'try', 'vararg', 'while', 'with', 'yield'), suffix=r'\b'),
|
| 212 |
+
Keyword),
|
| 213 |
+
(r'(false|true|null)\b', Keyword.Constant),
|
| 214 |
+
# FloatLiteral
|
| 215 |
+
(r'([0-9][0-9_]*)(?=[.eE])(\.[0-9][0-9_]*)?([eE][+\-]?[0-9_]+)?',
|
| 216 |
+
Number.Float),
|
| 217 |
+
# IntegerLiteral
|
| 218 |
+
# -- Binary
|
| 219 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 220 |
+
# -- Hexadecimal
|
| 221 |
+
(r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex),
|
| 222 |
+
# -- Decimal
|
| 223 |
+
(r'([0-9][0-9_]*)(?![.eE])', Number.Integer),
|
| 224 |
+
# CharacterLiteral
|
| 225 |
+
(r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-9]{1,3}"""
|
| 226 |
+
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
|
| 227 |
+
String.Char),
|
| 228 |
+
# StringLiteral
|
| 229 |
+
# -- WysiwygString
|
| 230 |
+
(r'@"(""|[^"])*"', String),
|
| 231 |
+
(r'@`(``|[^`])*`', String),
|
| 232 |
+
(r"@'(''|[^'])*'", String),
|
| 233 |
+
# -- DoubleQuotedString
|
| 234 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 235 |
+
# Tokens
|
| 236 |
+
(r'(~=|\^=|%=|\*=|==|!=|>>>=|>>>|>>=|>>|>=|<=>|\?=|-\>'
|
| 237 |
+
r'|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.|/=)'
|
| 238 |
+
r'|[-/.&$@|\+<>!()\[\]{}?,;:=*%^~#\\]', Punctuation),
|
| 239 |
+
# Identifier
|
| 240 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 241 |
+
],
|
| 242 |
+
'nestedcomment': [
|
| 243 |
+
(r'[^*/]+', Comment.Multiline),
|
| 244 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 245 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 246 |
+
(r'[*/]', Comment.Multiline),
|
| 247 |
+
],
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class MiniDLexer(CrocLexer):
|
| 252 |
+
"""
|
| 253 |
+
For MiniD source. MiniD is now known as Croc.
|
| 254 |
+
"""
|
| 255 |
+
name = 'MiniD'
|
| 256 |
+
filenames = [] # don't lex .md as MiniD, reserve for Markdown
|
| 257 |
+
aliases = ['minid']
|
| 258 |
+
mimetypes = ['text/x-minidsrc']
|
| 259 |
+
version_added = ''
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dalvik.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dalvik
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments lexers for Dalvik VM-related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups
|
| 14 |
+
from pygments.token import Keyword, Text, Comment, Name, String, Number, \
|
| 15 |
+
Punctuation, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['SmaliLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class SmaliLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Smali (Android/Dalvik) assembly
|
| 23 |
+
code.
|
| 24 |
+
"""
|
| 25 |
+
name = 'Smali'
|
| 26 |
+
url = 'http://code.google.com/p/smali/'
|
| 27 |
+
aliases = ['smali']
|
| 28 |
+
filenames = ['*.smali']
|
| 29 |
+
mimetypes = ['text/smali']
|
| 30 |
+
version_added = '1.6'
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
include('comment'),
|
| 35 |
+
include('label'),
|
| 36 |
+
include('field'),
|
| 37 |
+
include('method'),
|
| 38 |
+
include('class'),
|
| 39 |
+
include('directive'),
|
| 40 |
+
include('access-modifier'),
|
| 41 |
+
include('instruction'),
|
| 42 |
+
include('literal'),
|
| 43 |
+
include('punctuation'),
|
| 44 |
+
include('type'),
|
| 45 |
+
include('whitespace')
|
| 46 |
+
],
|
| 47 |
+
'directive': [
|
| 48 |
+
(r'^([ \t]*)(\.(?:class|super|implements|field|subannotation|annotation|'
|
| 49 |
+
r'enum|method|registers|locals|array-data|packed-switch|'
|
| 50 |
+
r'sparse-switch|catchall|catch|line|parameter|local|prologue|'
|
| 51 |
+
r'epilogue|source))', bygroups(Whitespace, Keyword)),
|
| 52 |
+
(r'^([ \t]*)(\.end)( )(field|subannotation|annotation|method|array-data|'
|
| 53 |
+
'packed-switch|sparse-switch|parameter|local)',
|
| 54 |
+
bygroups(Whitespace, Keyword, Whitespace, Keyword)),
|
| 55 |
+
(r'^([ \t]*)(\.restart)( )(local)',
|
| 56 |
+
bygroups(Whitespace, Keyword, Whitespace, Keyword)),
|
| 57 |
+
],
|
| 58 |
+
'access-modifier': [
|
| 59 |
+
(r'(public|private|protected|static|final|synchronized|bridge|'
|
| 60 |
+
r'varargs|native|abstract|strictfp|synthetic|constructor|'
|
| 61 |
+
r'declared-synchronized|interface|enum|annotation|volatile|'
|
| 62 |
+
r'transient)', Keyword),
|
| 63 |
+
],
|
| 64 |
+
'whitespace': [
|
| 65 |
+
(r'\n', Whitespace),
|
| 66 |
+
(r'\s+', Whitespace),
|
| 67 |
+
],
|
| 68 |
+
'instruction': [
|
| 69 |
+
(r'\b[vp]\d+\b', Name.Builtin), # registers
|
| 70 |
+
(r'(\b[a-z][A-Za-z0-9/-]+)(\s+)', bygroups(Text, Whitespace)), # instructions
|
| 71 |
+
],
|
| 72 |
+
'literal': [
|
| 73 |
+
(r'".*"', String),
|
| 74 |
+
(r'0x[0-9A-Fa-f]+t?', Number.Hex),
|
| 75 |
+
(r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 76 |
+
(r'[0-9]+L?', Number.Integer),
|
| 77 |
+
],
|
| 78 |
+
'field': [
|
| 79 |
+
(r'(\$?\b)([\w$]*)(:)',
|
| 80 |
+
bygroups(Punctuation, Name.Variable, Punctuation)),
|
| 81 |
+
],
|
| 82 |
+
'method': [
|
| 83 |
+
(r'<(?:cl)?init>', Name.Function), # constructor
|
| 84 |
+
(r'(\$?\b)([\w$]*)(\()',
|
| 85 |
+
bygroups(Punctuation, Name.Function, Punctuation)),
|
| 86 |
+
],
|
| 87 |
+
'label': [
|
| 88 |
+
(r':\w+', Name.Label),
|
| 89 |
+
],
|
| 90 |
+
'class': [
|
| 91 |
+
# class names in the form Lcom/namespace/ClassName;
|
| 92 |
+
# I only want to color the ClassName part, so the namespace part is
|
| 93 |
+
# treated as 'Text'
|
| 94 |
+
(r'(L)((?:[\w$]+/)*)([\w$]+)(;)',
|
| 95 |
+
bygroups(Keyword.Type, Text, Name.Class, Text)),
|
| 96 |
+
],
|
| 97 |
+
'punctuation': [
|
| 98 |
+
(r'->', Punctuation),
|
| 99 |
+
(r'[{},():=.-]', Punctuation),
|
| 100 |
+
],
|
| 101 |
+
'type': [
|
| 102 |
+
(r'[ZBSCIJFDV\[]+', Keyword.Type),
|
| 103 |
+
],
|
| 104 |
+
'comment': [
|
| 105 |
+
(r'#.*?\n', Comment),
|
| 106 |
+
],
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
def analyse_text(text):
|
| 110 |
+
score = 0
|
| 111 |
+
if re.search(r'^\s*\.class\s', text, re.MULTILINE):
|
| 112 |
+
score += 0.5
|
| 113 |
+
if re.search(r'\b((check-cast|instance-of|throw-verification-error'
|
| 114 |
+
r')\b|(-to|add|[ais]get|[ais]put|and|cmpl|const|div|'
|
| 115 |
+
r'if|invoke|move|mul|neg|not|or|rem|return|rsub|shl|'
|
| 116 |
+
r'shr|sub|ushr)[-/])|{|}', text, re.MULTILINE):
|
| 117 |
+
score += 0.3
|
| 118 |
+
if re.search(r'(\.(catchall|epilogue|restart local|prologue)|'
|
| 119 |
+
r'\b(array-data|class-change-error|declared-synchronized|'
|
| 120 |
+
r'(field|inline|vtable)@0x[0-9a-fA-F]|generic-error|'
|
| 121 |
+
r'illegal-class-access|illegal-field-access|'
|
| 122 |
+
r'illegal-method-access|instantiation-error|no-error|'
|
| 123 |
+
r'no-such-class|no-such-field|no-such-method|'
|
| 124 |
+
r'packed-switch|sparse-switch))\b', text, re.MULTILINE):
|
| 125 |
+
score += 0.6
|
| 126 |
+
return score
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/data.py
ADDED
|
@@ -0,0 +1,763 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.data
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for data file format.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import Lexer, ExtendedRegexLexer, LexerContext, \
|
| 12 |
+
include, bygroups
|
| 13 |
+
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \
|
| 14 |
+
Punctuation, String, Whitespace
|
| 15 |
+
|
| 16 |
+
__all__ = ['YamlLexer', 'JsonLexer', 'JsonBareObjectLexer', 'JsonLdLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class YamlLexerContext(LexerContext):
|
| 20 |
+
"""Indentation context for the YAML lexer."""
|
| 21 |
+
|
| 22 |
+
def __init__(self, *args, **kwds):
|
| 23 |
+
super().__init__(*args, **kwds)
|
| 24 |
+
self.indent_stack = []
|
| 25 |
+
self.indent = -1
|
| 26 |
+
self.next_indent = 0
|
| 27 |
+
self.block_scalar_indent = None
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class YamlLexer(ExtendedRegexLexer):
|
| 31 |
+
"""
|
| 32 |
+
Lexer for YAML, a human-friendly data serialization
|
| 33 |
+
language.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
name = 'YAML'
|
| 37 |
+
url = 'http://yaml.org/'
|
| 38 |
+
aliases = ['yaml']
|
| 39 |
+
filenames = ['*.yaml', '*.yml']
|
| 40 |
+
mimetypes = ['text/x-yaml']
|
| 41 |
+
version_added = '0.11'
|
| 42 |
+
|
| 43 |
+
def something(token_class):
|
| 44 |
+
"""Do not produce empty tokens."""
|
| 45 |
+
def callback(lexer, match, context):
|
| 46 |
+
text = match.group()
|
| 47 |
+
if not text:
|
| 48 |
+
return
|
| 49 |
+
yield match.start(), token_class, text
|
| 50 |
+
context.pos = match.end()
|
| 51 |
+
return callback
|
| 52 |
+
|
| 53 |
+
def reset_indent(token_class):
|
| 54 |
+
"""Reset the indentation levels."""
|
| 55 |
+
def callback(lexer, match, context):
|
| 56 |
+
text = match.group()
|
| 57 |
+
context.indent_stack = []
|
| 58 |
+
context.indent = -1
|
| 59 |
+
context.next_indent = 0
|
| 60 |
+
context.block_scalar_indent = None
|
| 61 |
+
yield match.start(), token_class, text
|
| 62 |
+
context.pos = match.end()
|
| 63 |
+
return callback
|
| 64 |
+
|
| 65 |
+
def save_indent(token_class, start=False):
|
| 66 |
+
"""Save a possible indentation level."""
|
| 67 |
+
def callback(lexer, match, context):
|
| 68 |
+
text = match.group()
|
| 69 |
+
extra = ''
|
| 70 |
+
if start:
|
| 71 |
+
context.next_indent = len(text)
|
| 72 |
+
if context.next_indent < context.indent:
|
| 73 |
+
while context.next_indent < context.indent:
|
| 74 |
+
context.indent = context.indent_stack.pop()
|
| 75 |
+
if context.next_indent > context.indent:
|
| 76 |
+
extra = text[context.indent:]
|
| 77 |
+
text = text[:context.indent]
|
| 78 |
+
else:
|
| 79 |
+
context.next_indent += len(text)
|
| 80 |
+
if text:
|
| 81 |
+
yield match.start(), token_class, text
|
| 82 |
+
if extra:
|
| 83 |
+
yield match.start()+len(text), token_class.Error, extra
|
| 84 |
+
context.pos = match.end()
|
| 85 |
+
return callback
|
| 86 |
+
|
| 87 |
+
def set_indent(token_class, implicit=False):
|
| 88 |
+
"""Set the previously saved indentation level."""
|
| 89 |
+
def callback(lexer, match, context):
|
| 90 |
+
text = match.group()
|
| 91 |
+
if context.indent < context.next_indent:
|
| 92 |
+
context.indent_stack.append(context.indent)
|
| 93 |
+
context.indent = context.next_indent
|
| 94 |
+
if not implicit:
|
| 95 |
+
context.next_indent += len(text)
|
| 96 |
+
yield match.start(), token_class, text
|
| 97 |
+
context.pos = match.end()
|
| 98 |
+
return callback
|
| 99 |
+
|
| 100 |
+
def set_block_scalar_indent(token_class):
|
| 101 |
+
"""Set an explicit indentation level for a block scalar."""
|
| 102 |
+
def callback(lexer, match, context):
|
| 103 |
+
text = match.group()
|
| 104 |
+
context.block_scalar_indent = None
|
| 105 |
+
if not text:
|
| 106 |
+
return
|
| 107 |
+
increment = match.group(1)
|
| 108 |
+
if increment:
|
| 109 |
+
current_indent = max(context.indent, 0)
|
| 110 |
+
increment = int(increment)
|
| 111 |
+
context.block_scalar_indent = current_indent + increment
|
| 112 |
+
if text:
|
| 113 |
+
yield match.start(), token_class, text
|
| 114 |
+
context.pos = match.end()
|
| 115 |
+
return callback
|
| 116 |
+
|
| 117 |
+
def parse_block_scalar_empty_line(indent_token_class, content_token_class):
|
| 118 |
+
"""Process an empty line in a block scalar."""
|
| 119 |
+
def callback(lexer, match, context):
|
| 120 |
+
text = match.group()
|
| 121 |
+
if (context.block_scalar_indent is None or
|
| 122 |
+
len(text) <= context.block_scalar_indent):
|
| 123 |
+
if text:
|
| 124 |
+
yield match.start(), indent_token_class, text
|
| 125 |
+
else:
|
| 126 |
+
indentation = text[:context.block_scalar_indent]
|
| 127 |
+
content = text[context.block_scalar_indent:]
|
| 128 |
+
yield match.start(), indent_token_class, indentation
|
| 129 |
+
yield (match.start()+context.block_scalar_indent,
|
| 130 |
+
content_token_class, content)
|
| 131 |
+
context.pos = match.end()
|
| 132 |
+
return callback
|
| 133 |
+
|
| 134 |
+
def parse_block_scalar_indent(token_class):
|
| 135 |
+
"""Process indentation spaces in a block scalar."""
|
| 136 |
+
def callback(lexer, match, context):
|
| 137 |
+
text = match.group()
|
| 138 |
+
if context.block_scalar_indent is None:
|
| 139 |
+
if len(text) <= max(context.indent, 0):
|
| 140 |
+
context.stack.pop()
|
| 141 |
+
context.stack.pop()
|
| 142 |
+
return
|
| 143 |
+
context.block_scalar_indent = len(text)
|
| 144 |
+
else:
|
| 145 |
+
if len(text) < context.block_scalar_indent:
|
| 146 |
+
context.stack.pop()
|
| 147 |
+
context.stack.pop()
|
| 148 |
+
return
|
| 149 |
+
if text:
|
| 150 |
+
yield match.start(), token_class, text
|
| 151 |
+
context.pos = match.end()
|
| 152 |
+
return callback
|
| 153 |
+
|
| 154 |
+
def parse_plain_scalar_indent(token_class):
|
| 155 |
+
"""Process indentation spaces in a plain scalar."""
|
| 156 |
+
def callback(lexer, match, context):
|
| 157 |
+
text = match.group()
|
| 158 |
+
if len(text) <= context.indent:
|
| 159 |
+
context.stack.pop()
|
| 160 |
+
context.stack.pop()
|
| 161 |
+
return
|
| 162 |
+
if text:
|
| 163 |
+
yield match.start(), token_class, text
|
| 164 |
+
context.pos = match.end()
|
| 165 |
+
return callback
|
| 166 |
+
|
| 167 |
+
tokens = {
|
| 168 |
+
# the root rules
|
| 169 |
+
'root': [
|
| 170 |
+
# ignored whitespaces
|
| 171 |
+
(r'[ ]+(?=#|$)', Whitespace),
|
| 172 |
+
# line breaks
|
| 173 |
+
(r'\n+', Whitespace),
|
| 174 |
+
# a comment
|
| 175 |
+
(r'#[^\n]*', Comment.Single),
|
| 176 |
+
# the '%YAML' directive
|
| 177 |
+
(r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'),
|
| 178 |
+
# the %TAG directive
|
| 179 |
+
(r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'),
|
| 180 |
+
# document start and document end indicators
|
| 181 |
+
(r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace),
|
| 182 |
+
'block-line'),
|
| 183 |
+
# indentation spaces
|
| 184 |
+
(r'[ ]*(?!\s|$)', save_indent(Whitespace, start=True),
|
| 185 |
+
('block-line', 'indentation')),
|
| 186 |
+
],
|
| 187 |
+
|
| 188 |
+
# trailing whitespaces after directives or a block scalar indicator
|
| 189 |
+
'ignored-line': [
|
| 190 |
+
# ignored whitespaces
|
| 191 |
+
(r'[ ]+(?=#|$)', Whitespace),
|
| 192 |
+
# a comment
|
| 193 |
+
(r'#[^\n]*', Comment.Single),
|
| 194 |
+
# line break
|
| 195 |
+
(r'\n', Whitespace, '#pop:2'),
|
| 196 |
+
],
|
| 197 |
+
|
| 198 |
+
# the %YAML directive
|
| 199 |
+
'yaml-directive': [
|
| 200 |
+
# the version number
|
| 201 |
+
(r'([ ]+)([0-9]+\.[0-9]+)',
|
| 202 |
+
bygroups(Whitespace, Number), 'ignored-line'),
|
| 203 |
+
],
|
| 204 |
+
|
| 205 |
+
# the %TAG directive
|
| 206 |
+
'tag-directive': [
|
| 207 |
+
# a tag handle and the corresponding prefix
|
| 208 |
+
(r'([ ]+)(!|![\w-]*!)'
|
| 209 |
+
r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)',
|
| 210 |
+
bygroups(Whitespace, Keyword.Type, Whitespace, Keyword.Type),
|
| 211 |
+
'ignored-line'),
|
| 212 |
+
],
|
| 213 |
+
|
| 214 |
+
# block scalar indicators and indentation spaces
|
| 215 |
+
'indentation': [
|
| 216 |
+
# trailing whitespaces are ignored
|
| 217 |
+
(r'[ ]*$', something(Whitespace), '#pop:2'),
|
| 218 |
+
# whitespaces preceding block collection indicators
|
| 219 |
+
(r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Whitespace)),
|
| 220 |
+
# block collection indicators
|
| 221 |
+
(r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)),
|
| 222 |
+
# the beginning a block line
|
| 223 |
+
(r'[ ]*', save_indent(Whitespace), '#pop'),
|
| 224 |
+
],
|
| 225 |
+
|
| 226 |
+
# an indented line in the block context
|
| 227 |
+
'block-line': [
|
| 228 |
+
# the line end
|
| 229 |
+
(r'[ ]*(?=#|$)', something(Whitespace), '#pop'),
|
| 230 |
+
# whitespaces separating tokens
|
| 231 |
+
(r'[ ]+', Whitespace),
|
| 232 |
+
# key with colon
|
| 233 |
+
(r'''([^#,?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
|
| 234 |
+
bygroups(Name.Tag, set_indent(Punctuation, implicit=True))),
|
| 235 |
+
# tags, anchors and aliases,
|
| 236 |
+
include('descriptors'),
|
| 237 |
+
# block collections and scalars
|
| 238 |
+
include('block-nodes'),
|
| 239 |
+
# flow collections and quoted scalars
|
| 240 |
+
include('flow-nodes'),
|
| 241 |
+
# a plain scalar
|
| 242 |
+
(r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)',
|
| 243 |
+
something(Name.Variable),
|
| 244 |
+
'plain-scalar-in-block-context'),
|
| 245 |
+
],
|
| 246 |
+
|
| 247 |
+
# tags, anchors, aliases
|
| 248 |
+
'descriptors': [
|
| 249 |
+
# a full-form tag
|
| 250 |
+
(r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type),
|
| 251 |
+
# a tag in the form '!', '!suffix' or '!handle!suffix'
|
| 252 |
+
(r'!(?:[\w-]+!)?'
|
| 253 |
+
r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]*', Keyword.Type),
|
| 254 |
+
# an anchor
|
| 255 |
+
(r'&[\w-]+', Name.Label),
|
| 256 |
+
# an alias
|
| 257 |
+
(r'\*[\w-]+', Name.Variable),
|
| 258 |
+
],
|
| 259 |
+
|
| 260 |
+
# block collections and scalars
|
| 261 |
+
'block-nodes': [
|
| 262 |
+
# implicit key
|
| 263 |
+
(r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)),
|
| 264 |
+
# literal and folded scalars
|
| 265 |
+
(r'[|>]', Punctuation.Indicator,
|
| 266 |
+
('block-scalar-content', 'block-scalar-header')),
|
| 267 |
+
],
|
| 268 |
+
|
| 269 |
+
# flow collections and quoted scalars
|
| 270 |
+
'flow-nodes': [
|
| 271 |
+
# a flow sequence
|
| 272 |
+
(r'\[', Punctuation.Indicator, 'flow-sequence'),
|
| 273 |
+
# a flow mapping
|
| 274 |
+
(r'\{', Punctuation.Indicator, 'flow-mapping'),
|
| 275 |
+
# a single-quoted scalar
|
| 276 |
+
(r'\'', String, 'single-quoted-scalar'),
|
| 277 |
+
# a double-quoted scalar
|
| 278 |
+
(r'\"', String, 'double-quoted-scalar'),
|
| 279 |
+
],
|
| 280 |
+
|
| 281 |
+
# the content of a flow collection
|
| 282 |
+
'flow-collection': [
|
| 283 |
+
# whitespaces
|
| 284 |
+
(r'[ ]+', Whitespace),
|
| 285 |
+
# line breaks
|
| 286 |
+
(r'\n+', Whitespace),
|
| 287 |
+
# a comment
|
| 288 |
+
(r'#[^\n]*', Comment.Single),
|
| 289 |
+
# simple indicators
|
| 290 |
+
(r'[?:,]', Punctuation.Indicator),
|
| 291 |
+
# tags, anchors and aliases
|
| 292 |
+
include('descriptors'),
|
| 293 |
+
# nested collections and quoted scalars
|
| 294 |
+
include('flow-nodes'),
|
| 295 |
+
# a plain scalar
|
| 296 |
+
(r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`])',
|
| 297 |
+
something(Name.Variable),
|
| 298 |
+
'plain-scalar-in-flow-context'),
|
| 299 |
+
],
|
| 300 |
+
|
| 301 |
+
# a flow sequence indicated by '[' and ']'
|
| 302 |
+
'flow-sequence': [
|
| 303 |
+
# include flow collection rules
|
| 304 |
+
include('flow-collection'),
|
| 305 |
+
# the closing indicator
|
| 306 |
+
(r'\]', Punctuation.Indicator, '#pop'),
|
| 307 |
+
],
|
| 308 |
+
|
| 309 |
+
# a flow mapping indicated by '{' and '}'
|
| 310 |
+
'flow-mapping': [
|
| 311 |
+
# key with colon
|
| 312 |
+
(r'''([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
|
| 313 |
+
bygroups(Name.Tag, Punctuation)),
|
| 314 |
+
# include flow collection rules
|
| 315 |
+
include('flow-collection'),
|
| 316 |
+
# the closing indicator
|
| 317 |
+
(r'\}', Punctuation.Indicator, '#pop'),
|
| 318 |
+
],
|
| 319 |
+
|
| 320 |
+
# block scalar lines
|
| 321 |
+
'block-scalar-content': [
|
| 322 |
+
# line break
|
| 323 |
+
(r'\n', Whitespace),
|
| 324 |
+
# empty line
|
| 325 |
+
(r'^[ ]+$',
|
| 326 |
+
parse_block_scalar_empty_line(Whitespace, Name.Constant)),
|
| 327 |
+
# indentation spaces (we may leave the state here)
|
| 328 |
+
(r'^[ ]*', parse_block_scalar_indent(Whitespace)),
|
| 329 |
+
# line content
|
| 330 |
+
(r'[\S\t ]+', Name.Constant),
|
| 331 |
+
],
|
| 332 |
+
|
| 333 |
+
# the content of a literal or folded scalar
|
| 334 |
+
'block-scalar-header': [
|
| 335 |
+
# indentation indicator followed by chomping flag
|
| 336 |
+
(r'([1-9])?[+-]?(?=[ ]|$)',
|
| 337 |
+
set_block_scalar_indent(Punctuation.Indicator),
|
| 338 |
+
'ignored-line'),
|
| 339 |
+
# chomping flag followed by indentation indicator
|
| 340 |
+
(r'[+-]?([1-9])?(?=[ ]|$)',
|
| 341 |
+
set_block_scalar_indent(Punctuation.Indicator),
|
| 342 |
+
'ignored-line'),
|
| 343 |
+
],
|
| 344 |
+
|
| 345 |
+
# ignored and regular whitespaces in quoted scalars
|
| 346 |
+
'quoted-scalar-whitespaces': [
|
| 347 |
+
# leading and trailing whitespaces are ignored
|
| 348 |
+
(r'^[ ]+', Whitespace),
|
| 349 |
+
(r'[ ]+$', Whitespace),
|
| 350 |
+
# line breaks are ignored
|
| 351 |
+
(r'\n+', Whitespace),
|
| 352 |
+
# other whitespaces are a part of the value
|
| 353 |
+
(r'[ ]+', Name.Variable),
|
| 354 |
+
],
|
| 355 |
+
|
| 356 |
+
# single-quoted scalars
|
| 357 |
+
'single-quoted-scalar': [
|
| 358 |
+
# include whitespace and line break rules
|
| 359 |
+
include('quoted-scalar-whitespaces'),
|
| 360 |
+
# escaping of the quote character
|
| 361 |
+
(r'\'\'', String.Escape),
|
| 362 |
+
# regular non-whitespace characters
|
| 363 |
+
(r'[^\s\']+', String),
|
| 364 |
+
# the closing quote
|
| 365 |
+
(r'\'', String, '#pop'),
|
| 366 |
+
],
|
| 367 |
+
|
| 368 |
+
# double-quoted scalars
|
| 369 |
+
'double-quoted-scalar': [
|
| 370 |
+
# include whitespace and line break rules
|
| 371 |
+
include('quoted-scalar-whitespaces'),
|
| 372 |
+
# escaping of special characters
|
| 373 |
+
(r'\\[0abt\tn\nvfre "\\N_LP]', String),
|
| 374 |
+
# escape codes
|
| 375 |
+
(r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})',
|
| 376 |
+
String.Escape),
|
| 377 |
+
# regular non-whitespace characters
|
| 378 |
+
(r'[^\s"\\]+', String),
|
| 379 |
+
# the closing quote
|
| 380 |
+
(r'"', String, '#pop'),
|
| 381 |
+
],
|
| 382 |
+
|
| 383 |
+
# the beginning of a new line while scanning a plain scalar
|
| 384 |
+
'plain-scalar-in-block-context-new-line': [
|
| 385 |
+
# empty lines
|
| 386 |
+
(r'^[ ]+$', Whitespace),
|
| 387 |
+
# line breaks
|
| 388 |
+
(r'\n+', Whitespace),
|
| 389 |
+
# document start and document end indicators
|
| 390 |
+
(r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'),
|
| 391 |
+
# indentation spaces (we may leave the block line state here)
|
| 392 |
+
(r'^[ ]*', parse_plain_scalar_indent(Whitespace), '#pop'),
|
| 393 |
+
],
|
| 394 |
+
|
| 395 |
+
# a plain scalar in the block context
|
| 396 |
+
'plain-scalar-in-block-context': [
|
| 397 |
+
# the scalar ends with the ':' indicator
|
| 398 |
+
(r'[ ]*(?=:[ ]|:$)', something(Whitespace), '#pop'),
|
| 399 |
+
# the scalar ends with whitespaces followed by a comment
|
| 400 |
+
(r'[ ]+(?=#)', Whitespace, '#pop'),
|
| 401 |
+
# trailing whitespaces are ignored
|
| 402 |
+
(r'[ ]+$', Whitespace),
|
| 403 |
+
# line breaks are ignored
|
| 404 |
+
(r'\n+', Whitespace, 'plain-scalar-in-block-context-new-line'),
|
| 405 |
+
# other whitespaces are a part of the value
|
| 406 |
+
(r'[ ]+', Literal.Scalar.Plain),
|
| 407 |
+
# regular non-whitespace characters
|
| 408 |
+
(r'(?::(?!\s)|[^\s:])+', Literal.Scalar.Plain),
|
| 409 |
+
],
|
| 410 |
+
|
| 411 |
+
# a plain scalar is the flow context
|
| 412 |
+
'plain-scalar-in-flow-context': [
|
| 413 |
+
# the scalar ends with an indicator character
|
| 414 |
+
(r'[ ]*(?=[,:?\[\]{}])', something(Whitespace), '#pop'),
|
| 415 |
+
# the scalar ends with a comment
|
| 416 |
+
(r'[ ]+(?=#)', Whitespace, '#pop'),
|
| 417 |
+
# leading and trailing whitespaces are ignored
|
| 418 |
+
(r'^[ ]+', Whitespace),
|
| 419 |
+
(r'[ ]+$', Whitespace),
|
| 420 |
+
# line breaks are ignored
|
| 421 |
+
(r'\n+', Whitespace),
|
| 422 |
+
# other whitespaces are a part of the value
|
| 423 |
+
(r'[ ]+', Name.Variable),
|
| 424 |
+
# regular non-whitespace characters
|
| 425 |
+
(r'[^\s,:?\[\]{}]+', Name.Variable),
|
| 426 |
+
],
|
| 427 |
+
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
def get_tokens_unprocessed(self, text=None, context=None):
|
| 431 |
+
if context is None:
|
| 432 |
+
context = YamlLexerContext(text, 0)
|
| 433 |
+
return super().get_tokens_unprocessed(text, context)
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
class JsonLexer(Lexer):
|
| 437 |
+
"""
|
| 438 |
+
For JSON data structures.
|
| 439 |
+
|
| 440 |
+
Javascript-style comments are supported (like ``/* */`` and ``//``),
|
| 441 |
+
though comments are not part of the JSON specification.
|
| 442 |
+
This allows users to highlight JSON as it is used in the wild.
|
| 443 |
+
|
| 444 |
+
No validation is performed on the input JSON document.
|
| 445 |
+
"""
|
| 446 |
+
|
| 447 |
+
name = 'JSON'
|
| 448 |
+
url = 'https://www.json.org'
|
| 449 |
+
aliases = ['json', 'json-object']
|
| 450 |
+
filenames = ['*.json', '*.jsonl', '*.ndjson', 'Pipfile.lock', '*.module', '*.xc']
|
| 451 |
+
mimetypes = ['application/json', 'application/json-object', 'application/x-ndjson', 'application/jsonl', 'application/json-seq']
|
| 452 |
+
version_added = '1.5'
|
| 453 |
+
|
| 454 |
+
# No validation of integers, floats, or constants is done.
|
| 455 |
+
# As long as the characters are members of the following
|
| 456 |
+
# sets, the token will be considered valid. For example,
|
| 457 |
+
#
|
| 458 |
+
# "--1--" is parsed as an integer
|
| 459 |
+
# "1...eee" is parsed as a float
|
| 460 |
+
# "trustful" is parsed as a constant
|
| 461 |
+
#
|
| 462 |
+
integers = set('-0123456789')
|
| 463 |
+
floats = set('.eE+')
|
| 464 |
+
constants = set('truefalsenull') # true|false|null
|
| 465 |
+
hexadecimals = set('0123456789abcdefABCDEF')
|
| 466 |
+
punctuations = set('{}[],')
|
| 467 |
+
whitespaces = {'\u0020', '\u000a', '\u000d', '\u0009'}
|
| 468 |
+
|
| 469 |
+
def get_tokens_unprocessed(self, text):
|
| 470 |
+
"""Parse JSON data."""
|
| 471 |
+
|
| 472 |
+
in_string = False
|
| 473 |
+
in_escape = False
|
| 474 |
+
in_unicode_escape = 0
|
| 475 |
+
in_whitespace = False
|
| 476 |
+
in_constant = False
|
| 477 |
+
in_number = False
|
| 478 |
+
in_float = False
|
| 479 |
+
in_punctuation = False
|
| 480 |
+
in_comment_single = False
|
| 481 |
+
in_comment_multiline = False
|
| 482 |
+
expecting_second_comment_opener = False # // or /*
|
| 483 |
+
expecting_second_comment_closer = False # */
|
| 484 |
+
|
| 485 |
+
start = 0
|
| 486 |
+
|
| 487 |
+
# The queue is used to store data that may need to be tokenized
|
| 488 |
+
# differently based on what follows. In particular, JSON object
|
| 489 |
+
# keys are tokenized differently than string values, but cannot
|
| 490 |
+
# be distinguished until punctuation is encountered outside the
|
| 491 |
+
# string.
|
| 492 |
+
#
|
| 493 |
+
# A ":" character after the string indicates that the string is
|
| 494 |
+
# an object key; any other character indicates the string is a
|
| 495 |
+
# regular string value.
|
| 496 |
+
#
|
| 497 |
+
# The queue holds tuples that contain the following data:
|
| 498 |
+
#
|
| 499 |
+
# (start_index, token_type, text)
|
| 500 |
+
#
|
| 501 |
+
# By default the token type of text in double quotes is
|
| 502 |
+
# String.Double. The token type will be replaced if a colon
|
| 503 |
+
# is encountered after the string closes.
|
| 504 |
+
#
|
| 505 |
+
queue = []
|
| 506 |
+
|
| 507 |
+
for stop, character in enumerate(text):
|
| 508 |
+
if in_string:
|
| 509 |
+
if in_unicode_escape:
|
| 510 |
+
if character in self.hexadecimals:
|
| 511 |
+
in_unicode_escape -= 1
|
| 512 |
+
if not in_unicode_escape:
|
| 513 |
+
in_escape = False
|
| 514 |
+
else:
|
| 515 |
+
in_unicode_escape = 0
|
| 516 |
+
in_escape = False
|
| 517 |
+
|
| 518 |
+
elif in_escape:
|
| 519 |
+
if character == 'u':
|
| 520 |
+
in_unicode_escape = 4
|
| 521 |
+
else:
|
| 522 |
+
in_escape = False
|
| 523 |
+
|
| 524 |
+
elif character == '\\':
|
| 525 |
+
in_escape = True
|
| 526 |
+
|
| 527 |
+
elif character == '"':
|
| 528 |
+
queue.append((start, String.Double, text[start:stop + 1]))
|
| 529 |
+
in_string = False
|
| 530 |
+
in_escape = False
|
| 531 |
+
in_unicode_escape = 0
|
| 532 |
+
|
| 533 |
+
continue
|
| 534 |
+
|
| 535 |
+
elif in_whitespace:
|
| 536 |
+
if character in self.whitespaces:
|
| 537 |
+
continue
|
| 538 |
+
|
| 539 |
+
if queue:
|
| 540 |
+
queue.append((start, Whitespace, text[start:stop]))
|
| 541 |
+
else:
|
| 542 |
+
yield start, Whitespace, text[start:stop]
|
| 543 |
+
in_whitespace = False
|
| 544 |
+
# Fall through so the new character can be evaluated.
|
| 545 |
+
|
| 546 |
+
elif in_constant:
|
| 547 |
+
if character in self.constants:
|
| 548 |
+
continue
|
| 549 |
+
|
| 550 |
+
yield start, Keyword.Constant, text[start:stop]
|
| 551 |
+
in_constant = False
|
| 552 |
+
# Fall through so the new character can be evaluated.
|
| 553 |
+
|
| 554 |
+
elif in_number:
|
| 555 |
+
if character in self.integers:
|
| 556 |
+
continue
|
| 557 |
+
elif character in self.floats:
|
| 558 |
+
in_float = True
|
| 559 |
+
continue
|
| 560 |
+
|
| 561 |
+
if in_float:
|
| 562 |
+
yield start, Number.Float, text[start:stop]
|
| 563 |
+
else:
|
| 564 |
+
yield start, Number.Integer, text[start:stop]
|
| 565 |
+
in_number = False
|
| 566 |
+
in_float = False
|
| 567 |
+
# Fall through so the new character can be evaluated.
|
| 568 |
+
|
| 569 |
+
elif in_punctuation:
|
| 570 |
+
if character in self.punctuations:
|
| 571 |
+
continue
|
| 572 |
+
|
| 573 |
+
yield start, Punctuation, text[start:stop]
|
| 574 |
+
in_punctuation = False
|
| 575 |
+
# Fall through so the new character can be evaluated.
|
| 576 |
+
|
| 577 |
+
elif in_comment_single:
|
| 578 |
+
if character != '\n':
|
| 579 |
+
continue
|
| 580 |
+
|
| 581 |
+
if queue:
|
| 582 |
+
queue.append((start, Comment.Single, text[start:stop]))
|
| 583 |
+
else:
|
| 584 |
+
yield start, Comment.Single, text[start:stop]
|
| 585 |
+
|
| 586 |
+
in_comment_single = False
|
| 587 |
+
# Fall through so the new character can be evaluated.
|
| 588 |
+
|
| 589 |
+
elif in_comment_multiline:
|
| 590 |
+
if character == '*':
|
| 591 |
+
expecting_second_comment_closer = True
|
| 592 |
+
elif expecting_second_comment_closer:
|
| 593 |
+
expecting_second_comment_closer = False
|
| 594 |
+
if character == '/':
|
| 595 |
+
if queue:
|
| 596 |
+
queue.append((start, Comment.Multiline, text[start:stop + 1]))
|
| 597 |
+
else:
|
| 598 |
+
yield start, Comment.Multiline, text[start:stop + 1]
|
| 599 |
+
|
| 600 |
+
in_comment_multiline = False
|
| 601 |
+
|
| 602 |
+
continue
|
| 603 |
+
|
| 604 |
+
elif expecting_second_comment_opener:
|
| 605 |
+
expecting_second_comment_opener = False
|
| 606 |
+
if character == '/':
|
| 607 |
+
in_comment_single = True
|
| 608 |
+
continue
|
| 609 |
+
elif character == '*':
|
| 610 |
+
in_comment_multiline = True
|
| 611 |
+
continue
|
| 612 |
+
|
| 613 |
+
# Exhaust the queue. Accept the existing token types.
|
| 614 |
+
yield from queue
|
| 615 |
+
queue.clear()
|
| 616 |
+
|
| 617 |
+
yield start, Error, text[start:stop]
|
| 618 |
+
# Fall through so the new character can be evaluated.
|
| 619 |
+
|
| 620 |
+
start = stop
|
| 621 |
+
|
| 622 |
+
if character == '"':
|
| 623 |
+
in_string = True
|
| 624 |
+
|
| 625 |
+
elif character in self.whitespaces:
|
| 626 |
+
in_whitespace = True
|
| 627 |
+
|
| 628 |
+
elif character in {'f', 'n', 't'}: # The first letters of true|false|null
|
| 629 |
+
# Exhaust the queue. Accept the existing token types.
|
| 630 |
+
yield from queue
|
| 631 |
+
queue.clear()
|
| 632 |
+
|
| 633 |
+
in_constant = True
|
| 634 |
+
|
| 635 |
+
elif character in self.integers:
|
| 636 |
+
# Exhaust the queue. Accept the existing token types.
|
| 637 |
+
yield from queue
|
| 638 |
+
queue.clear()
|
| 639 |
+
|
| 640 |
+
in_number = True
|
| 641 |
+
|
| 642 |
+
elif character == ':':
|
| 643 |
+
# Yield from the queue. Replace string token types.
|
| 644 |
+
for _start, _token, _text in queue:
|
| 645 |
+
# There can be only three types of tokens before a ':':
|
| 646 |
+
# Whitespace, Comment, or a quoted string.
|
| 647 |
+
#
|
| 648 |
+
# If it's a quoted string we emit Name.Tag.
|
| 649 |
+
# Otherwise, we yield the original token.
|
| 650 |
+
#
|
| 651 |
+
# In all other cases this would be invalid JSON,
|
| 652 |
+
# but this is not a validating JSON lexer, so it's OK.
|
| 653 |
+
if _token is String.Double:
|
| 654 |
+
yield _start, Name.Tag, _text
|
| 655 |
+
else:
|
| 656 |
+
yield _start, _token, _text
|
| 657 |
+
queue.clear()
|
| 658 |
+
|
| 659 |
+
in_punctuation = True
|
| 660 |
+
|
| 661 |
+
elif character in self.punctuations:
|
| 662 |
+
# Exhaust the queue. Accept the existing token types.
|
| 663 |
+
yield from queue
|
| 664 |
+
queue.clear()
|
| 665 |
+
|
| 666 |
+
in_punctuation = True
|
| 667 |
+
|
| 668 |
+
elif character == '/':
|
| 669 |
+
# This is the beginning of a comment.
|
| 670 |
+
expecting_second_comment_opener = True
|
| 671 |
+
|
| 672 |
+
else:
|
| 673 |
+
# Exhaust the queue. Accept the existing token types.
|
| 674 |
+
yield from queue
|
| 675 |
+
queue.clear()
|
| 676 |
+
|
| 677 |
+
yield start, Error, character
|
| 678 |
+
|
| 679 |
+
# Yield any remaining text.
|
| 680 |
+
yield from queue
|
| 681 |
+
if in_string:
|
| 682 |
+
yield start, Error, text[start:]
|
| 683 |
+
elif in_float:
|
| 684 |
+
yield start, Number.Float, text[start:]
|
| 685 |
+
elif in_number:
|
| 686 |
+
yield start, Number.Integer, text[start:]
|
| 687 |
+
elif in_constant:
|
| 688 |
+
yield start, Keyword.Constant, text[start:]
|
| 689 |
+
elif in_whitespace:
|
| 690 |
+
yield start, Whitespace, text[start:]
|
| 691 |
+
elif in_punctuation:
|
| 692 |
+
yield start, Punctuation, text[start:]
|
| 693 |
+
elif in_comment_single:
|
| 694 |
+
yield start, Comment.Single, text[start:]
|
| 695 |
+
elif in_comment_multiline:
|
| 696 |
+
yield start, Error, text[start:]
|
| 697 |
+
elif expecting_second_comment_opener:
|
| 698 |
+
yield start, Error, text[start:]
|
| 699 |
+
|
| 700 |
+
|
| 701 |
+
class JsonBareObjectLexer(JsonLexer):
|
| 702 |
+
"""
|
| 703 |
+
For JSON data structures (with missing object curly braces).
|
| 704 |
+
|
| 705 |
+
.. deprecated:: 2.8.0
|
| 706 |
+
|
| 707 |
+
Behaves the same as `JsonLexer` now.
|
| 708 |
+
"""
|
| 709 |
+
|
| 710 |
+
name = 'JSONBareObject'
|
| 711 |
+
aliases = []
|
| 712 |
+
filenames = []
|
| 713 |
+
mimetypes = []
|
| 714 |
+
version_added = '2.2'
|
| 715 |
+
|
| 716 |
+
|
| 717 |
+
class JsonLdLexer(JsonLexer):
|
| 718 |
+
"""
|
| 719 |
+
For JSON-LD linked data.
|
| 720 |
+
"""
|
| 721 |
+
|
| 722 |
+
name = 'JSON-LD'
|
| 723 |
+
url = 'https://json-ld.org/'
|
| 724 |
+
aliases = ['jsonld', 'json-ld']
|
| 725 |
+
filenames = ['*.jsonld']
|
| 726 |
+
mimetypes = ['application/ld+json']
|
| 727 |
+
version_added = '2.0'
|
| 728 |
+
|
| 729 |
+
json_ld_keywords = {
|
| 730 |
+
f'"@{keyword}"'
|
| 731 |
+
for keyword in (
|
| 732 |
+
'base',
|
| 733 |
+
'container',
|
| 734 |
+
'context',
|
| 735 |
+
'direction',
|
| 736 |
+
'graph',
|
| 737 |
+
'id',
|
| 738 |
+
'import',
|
| 739 |
+
'included',
|
| 740 |
+
'index',
|
| 741 |
+
'json',
|
| 742 |
+
'language',
|
| 743 |
+
'list',
|
| 744 |
+
'nest',
|
| 745 |
+
'none',
|
| 746 |
+
'prefix',
|
| 747 |
+
'propagate',
|
| 748 |
+
'protected',
|
| 749 |
+
'reverse',
|
| 750 |
+
'set',
|
| 751 |
+
'type',
|
| 752 |
+
'value',
|
| 753 |
+
'version',
|
| 754 |
+
'vocab',
|
| 755 |
+
)
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
def get_tokens_unprocessed(self, text):
|
| 759 |
+
for start, token, value in super().get_tokens_unprocessed(text):
|
| 760 |
+
if token is Name.Tag and value in self.json_ld_keywords:
|
| 761 |
+
yield start, Name.Decorator, value
|
| 762 |
+
else:
|
| 763 |
+
yield start, token, value
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dax.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dax
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for LilyPond.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import Comment, Punctuation, Whitespace,\
|
| 13 |
+
Name, Operator, String, Number, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['DaxLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class DaxLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for Power BI DAX
|
| 21 |
+
Referenced from: https://github.com/sql-bi/SyntaxHighlighterBrushDax
|
| 22 |
+
"""
|
| 23 |
+
name = 'Dax'
|
| 24 |
+
aliases = ['dax']
|
| 25 |
+
filenames = ['*.dax']
|
| 26 |
+
url = 'https://learn.microsoft.com/en-us/dax/dax-function-reference'
|
| 27 |
+
mimetypes = []
|
| 28 |
+
version_added = '2.15'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'\s+', Whitespace),
|
| 33 |
+
(r"--.*\n?", Comment.Single), # Comment: Double dash comment
|
| 34 |
+
(r"//.*\n?", Comment.Single), # Comment: Double backslash comment
|
| 35 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 36 |
+
(words(('abs', 'accrint', 'accrintm', 'acos', 'acosh', 'acot', 'acoth',
|
| 37 |
+
'addcolumns', 'addmissingitems', 'all', 'allcrossfiltered',
|
| 38 |
+
'allexcept', 'allnoblankrow', 'allselected', 'amordegrc', 'amorlinc',
|
| 39 |
+
'and','approximatedistinctcount', 'asin', 'asinh', 'atan', 'atanh',
|
| 40 |
+
'average', 'averagea', 'averagex', 'beta.dist', 'beta.inv',
|
| 41 |
+
'bitand', 'bitlshift', 'bitor', 'bitrshift', 'bitxor', 'blank',
|
| 42 |
+
'calculate', 'calculatetable', 'calendar', 'calendarauto', 'ceiling',
|
| 43 |
+
'chisq.dist', 'chisq.dist.rt', 'chisq.inv', 'chisq.inv.rt',
|
| 44 |
+
'closingbalancemonth', 'closingbalancequarter', 'closingbalanceyear',
|
| 45 |
+
'coalesce', 'columnstatistics', 'combin', 'combina', 'combinevalues',
|
| 46 |
+
'concatenate', 'concatenatex', 'confidence.norm', 'confidence.t',
|
| 47 |
+
'contains', 'containsrow', 'containsstring', 'containsstringexact',
|
| 48 |
+
'convert', 'cos', 'cosh', 'cot', 'coth', 'count', 'counta', 'countax',
|
| 49 |
+
'countblank', 'countrows', 'countx', 'coupdaybs', 'coupdays',
|
| 50 |
+
'coupdaysnc', 'coupncd', 'coupnum', 'couppcd', 'crossfilter',
|
| 51 |
+
'crossjoin', 'cumipmt', 'cumprinc', 'currency', 'currentgroup',
|
| 52 |
+
'customdata', 'datatable', 'date', 'dateadd', 'datediff',
|
| 53 |
+
'datesbetween', 'datesinperiod', 'datesmtd', 'datesqtd',
|
| 54 |
+
'datesytd', 'datevalue', 'day', 'db', 'ddb', 'degrees', 'detailrows',
|
| 55 |
+
'disc', 'distinct', 'distinctcount', 'distinctcountnoblank',
|
| 56 |
+
'divide', 'dollarde', 'dollarfr', 'duration', 'earlier', 'earliest',
|
| 57 |
+
'edate', 'effect', 'endofmonth', 'endofquarter', 'endofyear',
|
| 58 |
+
'eomonth', 'error', 'evaluateandlog', 'even', 'exact', 'except',
|
| 59 |
+
'exp', 'expon.dist', 'fact', 'false', 'filter', 'filters', 'find',
|
| 60 |
+
'firstdate', 'firstnonblank', 'firstnonblankvalue', 'fixed', 'floor',
|
| 61 |
+
'format', 'fv', 'gcd', 'generate', 'generateall', 'generateseries',
|
| 62 |
+
'geomean', 'geomeanx', 'groupby', 'hash', 'hasonefilter',
|
| 63 |
+
'hasonevalue', 'hour', 'if', 'if.eager', 'iferror', 'ignore', 'index',
|
| 64 |
+
'int', 'intersect', 'intrate', 'ipmt', 'isafter', 'isblank',
|
| 65 |
+
'iscrossfiltered', 'isempty', 'iserror', 'iseven', 'isfiltered',
|
| 66 |
+
'isinscope', 'islogical', 'isnontext', 'isnumber', 'iso.ceiling',
|
| 67 |
+
'isodd', 'isonorafter', 'ispmt', 'isselectedmeasure', 'issubtotal',
|
| 68 |
+
'istext', 'keepfilters', 'keywordmatch', 'lastdate', 'lastnonblank',
|
| 69 |
+
'lastnonblankvalue', 'lcm', 'left', 'len', 'linest', 'linestx', 'ln',
|
| 70 |
+
'log', 'log10', 'lookupvalue', 'lower', 'max', 'maxa', 'maxx',
|
| 71 |
+
'mduration', 'median', 'medianx', 'mid', 'min', 'mina', 'minute',
|
| 72 |
+
'minx', 'mod', 'month', 'mround', 'nameof', 'naturalinnerjoin',
|
| 73 |
+
'naturalleftouterjoin', 'networkdays', 'nextday', 'nextmonth',
|
| 74 |
+
'nextquarter', 'nextyear', 'nominal', 'nonvisual', 'norm.dist',
|
| 75 |
+
'norm.inv', 'norm.s.dist', 'norm.s.inv', 'not', 'now', 'nper', 'odd',
|
| 76 |
+
'oddfprice', 'oddfyield', 'oddlprice', 'oddlyield', 'offset',
|
| 77 |
+
'openingbalancemonth', 'openingbalancequarter', 'openingbalanceyear',
|
| 78 |
+
'or', 'orderby', 'parallelperiod', 'partitionby', 'path',
|
| 79 |
+
'pathcontains', 'pathitem', 'pathitemreverse', 'pathlength',
|
| 80 |
+
'pduration', 'percentile.exc', 'percentile.inc', 'percentilex.exc',
|
| 81 |
+
'percentilex.inc', 'permut', 'pi', 'pmt', 'poisson.dist', 'power',
|
| 82 |
+
'ppmt', 'previousday', 'previousmonth', 'previousquarter',
|
| 83 |
+
'previousyear', 'price', 'pricedisc', 'pricemat', 'product',
|
| 84 |
+
'productx', 'pv', 'quarter', 'quotient', 'radians', 'rand',
|
| 85 |
+
'randbetween', 'rank.eq', 'rankx', 'rate', 'received', 'related',
|
| 86 |
+
'relatedtable', 'removefilters', 'replace', 'rept', 'right',
|
| 87 |
+
'rollup', 'rollupaddissubtotal', 'rollupgroup', 'rollupissubtotal',
|
| 88 |
+
'round', 'rounddown', 'roundup', 'row', 'rri', 'sameperiodlastyear',
|
| 89 |
+
'sample', 'sampleaxiswithlocalminmax', 'search', 'second',
|
| 90 |
+
'selectcolumns', 'selectedmeasure', 'selectedmeasureformatstring',
|
| 91 |
+
'selectedmeasurename', 'selectedvalue', 'sign', 'sin', 'sinh', 'sln',
|
| 92 |
+
'sqrt', 'sqrtpi', 'startofmonth', 'startofquarter', 'startofyear',
|
| 93 |
+
'stdev.p', 'stdev.s', 'stdevx.p', 'stdevx.s', 'substitute',
|
| 94 |
+
'substitutewithindex', 'sum', 'summarize', 'summarizecolumns', 'sumx',
|
| 95 |
+
'switch', 'syd', 't.dist', 't.dist.2t', 't.dist.rt', 't.inv',
|
| 96 |
+
't.inv.2t', 'tan', 'tanh', 'tbilleq', 'tbillprice', 'tbillyield',
|
| 97 |
+
'time', 'timevalue', 'tocsv', 'today', 'tojson', 'topn',
|
| 98 |
+
'topnperlevel', 'topnskip', 'totalmtd', 'totalqtd', 'totalytd',
|
| 99 |
+
'treatas', 'trim', 'true', 'trunc', 'unichar', 'unicode', 'union',
|
| 100 |
+
'upper', 'userculture', 'userelationship', 'username', 'userobjectid',
|
| 101 |
+
'userprincipalname', 'utcnow', 'utctoday', 'value', 'values', 'var.p',
|
| 102 |
+
'var.s', 'varx.p', 'varx.s', 'vdb', 'weekday', 'weeknum', 'window',
|
| 103 |
+
'xirr', 'xnpv', 'year', 'yearfrac', 'yield', 'yielddisc', 'yieldmat'),
|
| 104 |
+
prefix=r'(?i)', suffix=r'\b'), Name.Function), #Functions
|
| 105 |
+
|
| 106 |
+
(words(('at','asc','boolean','both','by','create','currency',
|
| 107 |
+
'datetime','day','define','desc','double',
|
| 108 |
+
'evaluate','false','integer','measure',
|
| 109 |
+
'month','none','order','return','single','start','string',
|
| 110 |
+
'table','true','var','year'),
|
| 111 |
+
prefix=r'(?i)', suffix=r'\b'), Name.Builtin), # Keyword
|
| 112 |
+
|
| 113 |
+
(r':=|[-+*\/=^]', Operator),
|
| 114 |
+
(r'\b(IN|NOT)\b', Operator.Word),
|
| 115 |
+
(r'"', String, 'string'), #StringLiteral
|
| 116 |
+
(r"'(?:[^']|'')*'(?!')(?:\[[ \w]+\])?|\w+\[[ \w]+\]",
|
| 117 |
+
Name.Attribute), # Column reference
|
| 118 |
+
(r"\[[ \w]+\]", Name.Attribute), #Measure reference
|
| 119 |
+
(r'(?<!\w)(\d+\.?\d*|\.\d+\b)', Number),# Number
|
| 120 |
+
(r'[\[\](){}`,.]', Punctuation), #Parenthesis
|
| 121 |
+
(r'.*\n', Text),
|
| 122 |
+
|
| 123 |
+
],
|
| 124 |
+
'multiline-comments': [
|
| 125 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 126 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 127 |
+
(r'[^/*]+', Comment.Multiline),
|
| 128 |
+
(r'[/*]', Comment.Multiline)
|
| 129 |
+
],
|
| 130 |
+
'string': [
|
| 131 |
+
(r'""', String.Escape),
|
| 132 |
+
(r'"', String, '#pop'),
|
| 133 |
+
(r'[^"]+', String),
|
| 134 |
+
]
|
| 135 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/devicetree.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.devicetree
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Devicetree language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, include, default, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Text, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['DevicetreeLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class DevicetreeLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for Devicetree files.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Devicetree'
|
| 24 |
+
url = 'https://www.devicetree.org/'
|
| 25 |
+
aliases = ['devicetree', 'dts']
|
| 26 |
+
filenames = ['*.dts', '*.dtsi']
|
| 27 |
+
mimetypes = ['text/x-c']
|
| 28 |
+
version_added = '2.7'
|
| 29 |
+
|
| 30 |
+
#: optional Whitespace or /*...*/ style comment
|
| 31 |
+
_ws = r'\s*(?:/[*][^*/]*?[*]/\s*)*'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'macro': [
|
| 35 |
+
# Include preprocessor directives (C style):
|
| 36 |
+
(r'(#include)(' + _ws + r')([^\n]+)',
|
| 37 |
+
bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)),
|
| 38 |
+
# Define preprocessor directives (C style):
|
| 39 |
+
(r'(#define)(' + _ws + r')([^\n]+)',
|
| 40 |
+
bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc)),
|
| 41 |
+
# devicetree style with file:
|
| 42 |
+
(r'(/[^*/{]+/)(' + _ws + r')("[^\n{]+")',
|
| 43 |
+
bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)),
|
| 44 |
+
# devicetree style with property:
|
| 45 |
+
(r'(/[^*/{]+/)(' + _ws + r')([^\n;{]*)([;]?)',
|
| 46 |
+
bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc, Punctuation)),
|
| 47 |
+
],
|
| 48 |
+
'whitespace': [
|
| 49 |
+
(r'\n', Whitespace),
|
| 50 |
+
(r'\s+', Whitespace),
|
| 51 |
+
(r'\\\n', Text), # line continuation
|
| 52 |
+
(r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),
|
| 53 |
+
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
|
| 54 |
+
# Open until EOF, so no ending delimiter
|
| 55 |
+
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline),
|
| 56 |
+
],
|
| 57 |
+
'statements': [
|
| 58 |
+
(r'(L?)(")', bygroups(String.Affix, String), 'string'),
|
| 59 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 60 |
+
(r'\d+', Number.Integer),
|
| 61 |
+
(r'([^\s{}/*]*)(\s*)(:)', bygroups(Name.Label, Text, Punctuation), '#pop'),
|
| 62 |
+
(words(('compatible', 'model', 'phandle', 'status', '#address-cells',
|
| 63 |
+
'#size-cells', 'reg', 'virtual-reg', 'ranges', 'dma-ranges',
|
| 64 |
+
'device_type', 'name'), suffix=r'\b'), Keyword.Reserved),
|
| 65 |
+
(r'([~!%^&*+=|?:<>/#-])', Operator),
|
| 66 |
+
(r'[(){},.\]]', Punctuation),
|
| 67 |
+
(r'\[', Punctuation, 'bytestring'),
|
| 68 |
+
(r'[a-zA-Z_][\w-]*(?=(?:\s*,' + _ws + r'[a-zA-Z_][\w-]*)*' + _ws + r'[=;])',
|
| 69 |
+
Name),
|
| 70 |
+
(r'[a-zA-Z_]\w*', Name.Attribute),
|
| 71 |
+
],
|
| 72 |
+
'root': [
|
| 73 |
+
include('whitespace'),
|
| 74 |
+
include('macro'),
|
| 75 |
+
# Overlay/fragment: &label { ... } or &{/path/to/node} { ... }
|
| 76 |
+
(r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)',
|
| 77 |
+
bygroups(Operator, Name.Function, Punctuation, Name.Namespace,
|
| 78 |
+
Punctuation, Comment.Multiline, Punctuation), 'node'),
|
| 79 |
+
# Nodes
|
| 80 |
+
(r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)',
|
| 81 |
+
bygroups(Name.Function, Operator, Number.Integer,
|
| 82 |
+
Comment.Multiline, Punctuation), 'node'),
|
| 83 |
+
|
| 84 |
+
default('statement'),
|
| 85 |
+
],
|
| 86 |
+
'statement': [
|
| 87 |
+
include('whitespace'),
|
| 88 |
+
include('statements'),
|
| 89 |
+
(';', Punctuation, '#pop'),
|
| 90 |
+
],
|
| 91 |
+
'node': [
|
| 92 |
+
include('whitespace'),
|
| 93 |
+
include('macro'),
|
| 94 |
+
# Overlay/fragment: &label { ... } or &{/path/to/node} { ... }
|
| 95 |
+
(r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)',
|
| 96 |
+
bygroups(Operator, Name.Function, Punctuation, Name.Namespace,
|
| 97 |
+
Punctuation, Comment.Multiline, Punctuation), '#push'),
|
| 98 |
+
(r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)',
|
| 99 |
+
bygroups(Name.Function, Operator, Number.Integer,
|
| 100 |
+
Comment.Multiline, Punctuation), '#push'),
|
| 101 |
+
|
| 102 |
+
include('statements'),
|
| 103 |
+
|
| 104 |
+
(r'\};', Punctuation, '#pop'),
|
| 105 |
+
(';', Punctuation),
|
| 106 |
+
],
|
| 107 |
+
'string': [
|
| 108 |
+
(r'"', String, '#pop'),
|
| 109 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
| 110 |
+
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
| 111 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 112 |
+
(r'\\\n', String), # line continuation
|
| 113 |
+
(r'\\', String), # stray backslash
|
| 114 |
+
],
|
| 115 |
+
'bytestring': [
|
| 116 |
+
(r'\]', Punctuation, '#pop'),
|
| 117 |
+
(r'[0-9a-fA-F]{2}', Number.Hex),
|
| 118 |
+
(r'\s+', Whitespace),
|
| 119 |
+
],
|
| 120 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/diff.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.diff
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for diff/patch formats.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, Generic, \
|
| 15 |
+
Literal, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['DiffLexer', 'DarcsPatchLexer', 'WDiffLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class DiffLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for unified or context-style diffs or patches.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Diff'
|
| 26 |
+
aliases = ['diff', 'udiff']
|
| 27 |
+
filenames = ['*.diff', '*.patch']
|
| 28 |
+
mimetypes = ['text/x-diff', 'text/x-patch']
|
| 29 |
+
url = 'https://en.wikipedia.org/wiki/Diff'
|
| 30 |
+
version_added = ''
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
(r'( )(.*)(\n)', bygroups(Whitespace, Text, Whitespace)),
|
| 35 |
+
(r'(!.*|---)(\n)', bygroups(Generic.Strong, Whitespace)),
|
| 36 |
+
(r'((?:< |-).*)(\n)', bygroups(Generic.Deleted, Whitespace)),
|
| 37 |
+
(r'((?:> |\+).*)(\n)', bygroups(Generic.Inserted, Whitespace)),
|
| 38 |
+
(
|
| 39 |
+
r'(@.*|\d(?:,\d+)?(?:a|c|d)\d+(?:,\d+)?)(\n)',
|
| 40 |
+
bygroups(Generic.Subheading, Whitespace),
|
| 41 |
+
),
|
| 42 |
+
(r'((?:[Ii]ndex|diff).*)(\n)', bygroups(Generic.Heading, Whitespace)),
|
| 43 |
+
(r'(=.*)(\n)', bygroups(Generic.Heading, Whitespace)),
|
| 44 |
+
(r'(.*)(\n)', bygroups(Text, Whitespace)),
|
| 45 |
+
]
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
def analyse_text(text):
|
| 49 |
+
if text[:7] == 'Index: ':
|
| 50 |
+
return True
|
| 51 |
+
if text[:5] == 'diff ':
|
| 52 |
+
return True
|
| 53 |
+
if text[:4] == '--- ':
|
| 54 |
+
return 0.9
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class DarcsPatchLexer(RegexLexer):
|
| 58 |
+
"""
|
| 59 |
+
DarcsPatchLexer is a lexer for the various versions of the darcs patch
|
| 60 |
+
format. Examples of this format are derived by commands such as
|
| 61 |
+
``darcs annotate --patch`` and ``darcs send``.
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
name = 'Darcs Patch'
|
| 65 |
+
aliases = ['dpatch']
|
| 66 |
+
filenames = ['*.dpatch', '*.darcspatch']
|
| 67 |
+
url = 'https://darcs.net'
|
| 68 |
+
version_added = '0.10'
|
| 69 |
+
|
| 70 |
+
DPATCH_KEYWORDS = ('hunk', 'addfile', 'adddir', 'rmfile', 'rmdir', 'move',
|
| 71 |
+
'replace')
|
| 72 |
+
|
| 73 |
+
tokens = {
|
| 74 |
+
'root': [
|
| 75 |
+
(r'<', Operator),
|
| 76 |
+
(r'>', Operator),
|
| 77 |
+
(r'\{', Operator),
|
| 78 |
+
(r'\}', Operator),
|
| 79 |
+
(r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)(\])',
|
| 80 |
+
bygroups(Operator, Keyword, Name, Whitespace, Name, Operator,
|
| 81 |
+
Literal.Date, Whitespace, Operator)),
|
| 82 |
+
(r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)',
|
| 83 |
+
bygroups(Operator, Keyword, Name, Whitespace, Name, Operator,
|
| 84 |
+
Literal.Date, Whitespace), 'comment'),
|
| 85 |
+
(r'New patches:', Generic.Heading),
|
| 86 |
+
(r'Context:', Generic.Heading),
|
| 87 |
+
(r'Patch bundle hash:', Generic.Heading),
|
| 88 |
+
(r'(\s*)({})(.*)(\n)'.format('|'.join(DPATCH_KEYWORDS)),
|
| 89 |
+
bygroups(Whitespace, Keyword, Text, Whitespace)),
|
| 90 |
+
(r'\+', Generic.Inserted, "insert"),
|
| 91 |
+
(r'-', Generic.Deleted, "delete"),
|
| 92 |
+
(r'(.*)(\n)', bygroups(Text, Whitespace)),
|
| 93 |
+
],
|
| 94 |
+
'comment': [
|
| 95 |
+
(r'[^\]].*\n', Comment),
|
| 96 |
+
(r'\]', Operator, "#pop"),
|
| 97 |
+
],
|
| 98 |
+
'specialText': [ # darcs add [_CODE_] special operators for clarity
|
| 99 |
+
(r'\n', Whitespace, "#pop"), # line-based
|
| 100 |
+
(r'\[_[^_]*_]', Operator),
|
| 101 |
+
],
|
| 102 |
+
'insert': [
|
| 103 |
+
include('specialText'),
|
| 104 |
+
(r'\[', Generic.Inserted),
|
| 105 |
+
(r'[^\n\[]+', Generic.Inserted),
|
| 106 |
+
],
|
| 107 |
+
'delete': [
|
| 108 |
+
include('specialText'),
|
| 109 |
+
(r'\[', Generic.Deleted),
|
| 110 |
+
(r'[^\n\[]+', Generic.Deleted),
|
| 111 |
+
],
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class WDiffLexer(RegexLexer):
|
| 116 |
+
"""
|
| 117 |
+
A wdiff lexer.
|
| 118 |
+
|
| 119 |
+
Note that:
|
| 120 |
+
|
| 121 |
+
* It only works with normal output (without options like ``-l``).
|
| 122 |
+
* If the target files contain "[-", "-]", "{+", or "+}",
|
| 123 |
+
especially they are unbalanced, the lexer will get confused.
|
| 124 |
+
"""
|
| 125 |
+
|
| 126 |
+
name = 'WDiff'
|
| 127 |
+
url = 'https://www.gnu.org/software/wdiff/'
|
| 128 |
+
aliases = ['wdiff']
|
| 129 |
+
filenames = ['*.wdiff']
|
| 130 |
+
mimetypes = []
|
| 131 |
+
version_added = '2.2'
|
| 132 |
+
|
| 133 |
+
flags = re.MULTILINE | re.DOTALL
|
| 134 |
+
|
| 135 |
+
# We can only assume "[-" after "[-" before "-]" is `nested`,
|
| 136 |
+
# for instance wdiff to wdiff outputs. We have no way to
|
| 137 |
+
# distinct these marker is of wdiff output from original text.
|
| 138 |
+
|
| 139 |
+
ins_op = r"\{\+"
|
| 140 |
+
ins_cl = r"\+\}"
|
| 141 |
+
del_op = r"\[\-"
|
| 142 |
+
del_cl = r"\-\]"
|
| 143 |
+
normal = r'[^{}[\]+-]+' # for performance
|
| 144 |
+
tokens = {
|
| 145 |
+
'root': [
|
| 146 |
+
(ins_op, Generic.Inserted, 'inserted'),
|
| 147 |
+
(del_op, Generic.Deleted, 'deleted'),
|
| 148 |
+
(normal, Text),
|
| 149 |
+
(r'.', Text),
|
| 150 |
+
],
|
| 151 |
+
'inserted': [
|
| 152 |
+
(ins_op, Generic.Inserted, '#push'),
|
| 153 |
+
(del_op, Generic.Inserted, '#push'),
|
| 154 |
+
(del_cl, Generic.Inserted, '#pop'),
|
| 155 |
+
|
| 156 |
+
(ins_cl, Generic.Inserted, '#pop'),
|
| 157 |
+
(normal, Generic.Inserted),
|
| 158 |
+
(r'.', Generic.Inserted),
|
| 159 |
+
],
|
| 160 |
+
'deleted': [
|
| 161 |
+
(del_op, Generic.Deleted, '#push'),
|
| 162 |
+
(ins_op, Generic.Deleted, '#push'),
|
| 163 |
+
(ins_cl, Generic.Deleted, '#pop'),
|
| 164 |
+
|
| 165 |
+
(del_cl, Generic.Deleted, '#pop'),
|
| 166 |
+
(normal, Generic.Deleted),
|
| 167 |
+
(r'.', Generic.Deleted),
|
| 168 |
+
],
|
| 169 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dns.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dns
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments lexers for DNS
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation, Whitespace, Literal
|
| 15 |
+
from pygments.lexer import RegexLexer, bygroups, include
|
| 16 |
+
|
| 17 |
+
__all__ = ['DnsZoneLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
CLASSES = [
|
| 21 |
+
"IN",
|
| 22 |
+
"CS",
|
| 23 |
+
"CH",
|
| 24 |
+
"HS",
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
CLASSES_RE = "(" + "|".join(CLASSES) + ')'
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class DnsZoneLexer(RegexLexer):
|
| 31 |
+
|
| 32 |
+
"""
|
| 33 |
+
Lexer for DNS zone file
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
flags = re.MULTILINE
|
| 37 |
+
|
| 38 |
+
name = 'Zone'
|
| 39 |
+
aliases = ['zone']
|
| 40 |
+
filenames = [ "*.zone" ]
|
| 41 |
+
url = "https://datatracker.ietf.org/doc/html/rfc1035"
|
| 42 |
+
mimetypes = ['text/dns']
|
| 43 |
+
version_added = '2.16'
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
'root': [
|
| 47 |
+
# Empty/comment line:
|
| 48 |
+
(r'([ \t]*)(;.*)(\n)', bygroups(Whitespace, Comment.Single, Whitespace)),
|
| 49 |
+
# Special directives:
|
| 50 |
+
(r'^\$ORIGIN\b', Keyword, 'values'),
|
| 51 |
+
(r'^\$TTL\b', Keyword, 'values'),
|
| 52 |
+
(r'^\$INCLUDE\b', Comment.Preproc, 'include'),
|
| 53 |
+
# TODO, $GENERATE https://bind9.readthedocs.io/en/v9.18.14/chapter3.html#soa-rr
|
| 54 |
+
(r'^\$[A-Z]+\b', Keyword, 'values'),
|
| 55 |
+
# Records:
|
| 56 |
+
# <domain-name> [<TTL>] [<class>] <type> <RDATA> [<comment>]
|
| 57 |
+
(r'^(@)([ \t]+)(?:([0-9]+[smhdw]?)([ \t]+))?(?:' + CLASSES_RE + "([ \t]+))?([A-Z]+)([ \t]+)",
|
| 58 |
+
bygroups(Operator, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace),
|
| 59 |
+
"values"),
|
| 60 |
+
(r'^([^ \t\n]*)([ \t]+)(?:([0-9]+[smhdw]?)([ \t]+))?(?:' + CLASSES_RE + "([ \t]+))?([A-Z]+)([ \t]+)",
|
| 61 |
+
bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace),
|
| 62 |
+
"values"),
|
| 63 |
+
# <domain-name> [<class>] [<TTL>] <type> <RDATA> [<comment>]
|
| 64 |
+
(r'^(Operator)([ \t]+)(?:' + CLASSES_RE + "([ \t]+))?(?:([0-9]+[smhdw]?)([ \t]+))?([A-Z]+)([ \t]+)",
|
| 65 |
+
bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace),
|
| 66 |
+
"values"),
|
| 67 |
+
(r'^([^ \t\n]*)([ \t]+)(?:' + CLASSES_RE + "([ \t]+))?(?:([0-9]+[smhdw]?)([ \t]+))?([A-Z]+)([ \t]+)",
|
| 68 |
+
bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace),
|
| 69 |
+
"values"),
|
| 70 |
+
],
|
| 71 |
+
# Parsing values:
|
| 72 |
+
'values': [
|
| 73 |
+
(r'\n', Whitespace, "#pop"),
|
| 74 |
+
(r'\(', Punctuation, 'nested'),
|
| 75 |
+
include('simple-value'),
|
| 76 |
+
],
|
| 77 |
+
# Parsing nested values (...):
|
| 78 |
+
'nested': [
|
| 79 |
+
(r'\)', Punctuation, "#pop"),
|
| 80 |
+
include('multiple-simple-values'),
|
| 81 |
+
],
|
| 82 |
+
# Parsing values:
|
| 83 |
+
'simple-value': [
|
| 84 |
+
(r'(;.*)', bygroups(Comment.Single)),
|
| 85 |
+
(r'[ \t]+', Whitespace),
|
| 86 |
+
(r"@\b", Operator),
|
| 87 |
+
('"', String, 'string'),
|
| 88 |
+
(r'[0-9]+[smhdw]?$', Number.Integer),
|
| 89 |
+
(r'([0-9]+[smhdw]?)([ \t]+)', bygroups(Number.Integer, Whitespace)),
|
| 90 |
+
(r'\S+', Literal),
|
| 91 |
+
],
|
| 92 |
+
'multiple-simple-values': [
|
| 93 |
+
include('simple-value'),
|
| 94 |
+
(r'[\n]+', Whitespace),
|
| 95 |
+
],
|
| 96 |
+
'include': [
|
| 97 |
+
(r'([ \t]+)([^ \t\n]+)([ \t]+)([-\._a-zA-Z]+)([ \t]+)(;.*)?$',
|
| 98 |
+
bygroups(Whitespace, Comment.PreprocFile, Whitespace, Name, Whitespace, Comment.Single), '#pop'),
|
| 99 |
+
(r'([ \t]+)([^ \t\n]+)([ \t\n]+)$', bygroups(Whitespace, Comment.PreprocFile, Whitespace), '#pop'),
|
| 100 |
+
],
|
| 101 |
+
"string": [
|
| 102 |
+
(r'\\"', String),
|
| 103 |
+
(r'"', String, "#pop"),
|
| 104 |
+
(r'[^"]+', String),
|
| 105 |
+
]
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
def analyse_text(text):
|
| 109 |
+
return text.startswith("$ORIGIN")
|
.cache/uv/archive-v0/-Qec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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dotnet
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for .net languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
import re
|
| 11 |
+
|
| 12 |
+
from pygments.lexer import RegexLexer, DelegatingLexer, bygroups, include, \
|
| 13 |
+
using, this, default, words
|
| 14 |
+
from pygments.token import Punctuation, Text, Comment, Operator, Keyword, \
|
| 15 |
+
Name, String, Number, Literal, Other, Whitespace
|
| 16 |
+
from pygments.util import get_choice_opt
|
| 17 |
+
from pygments import unistring as uni
|
| 18 |
+
|
| 19 |
+
from pygments.lexers.html import XmlLexer
|
| 20 |
+
|
| 21 |
+
__all__ = ['CSharpLexer', 'NemerleLexer', 'BooLexer', 'VbNetLexer',
|
| 22 |
+
'CSharpAspxLexer', 'VbNetAspxLexer', 'FSharpLexer', 'XppLexer']
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class CSharpLexer(RegexLexer):
|
| 26 |
+
"""
|
| 27 |
+
For C# source code.
|
| 28 |
+
|
| 29 |
+
Additional options accepted:
|
| 30 |
+
|
| 31 |
+
`unicodelevel`
|
| 32 |
+
Determines which Unicode characters this lexer allows for identifiers.
|
| 33 |
+
The possible values are:
|
| 34 |
+
|
| 35 |
+
* ``none`` -- only the ASCII letters and numbers are allowed. This
|
| 36 |
+
is the fastest selection.
|
| 37 |
+
* ``basic`` -- all Unicode characters from the specification except
|
| 38 |
+
category ``Lo`` are allowed.
|
| 39 |
+
* ``full`` -- all Unicode characters as specified in the C# specs
|
| 40 |
+
are allowed. Note that this means a considerable slowdown since the
|
| 41 |
+
``Lo`` category has more than 40,000 characters in it!
|
| 42 |
+
|
| 43 |
+
The default value is ``basic``.
|
| 44 |
+
|
| 45 |
+
.. versionadded:: 0.8
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
name = 'C#'
|
| 49 |
+
url = 'https://docs.microsoft.com/en-us/dotnet/csharp/'
|
| 50 |
+
aliases = ['csharp', 'c#', 'cs']
|
| 51 |
+
filenames = ['*.cs']
|
| 52 |
+
mimetypes = ['text/x-csharp'] # inferred
|
| 53 |
+
version_added = ''
|
| 54 |
+
|
| 55 |
+
flags = re.MULTILINE | re.DOTALL
|
| 56 |
+
|
| 57 |
+
# for the range of allowed unicode characters in identifiers, see
|
| 58 |
+
# http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
|
| 59 |
+
|
| 60 |
+
levels = {
|
| 61 |
+
'none': r'@?[_a-zA-Z]\w*',
|
| 62 |
+
'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
|
| 63 |
+
'[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
|
| 64 |
+
'Cf', 'Mn', 'Mc') + ']*'),
|
| 65 |
+
'full': ('@?(?:_|[^' +
|
| 66 |
+
uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
|
| 67 |
+
'[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
|
| 68 |
+
'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
tokens = {}
|
| 72 |
+
token_variants = True
|
| 73 |
+
|
| 74 |
+
for levelname, cs_ident in levels.items():
|
| 75 |
+
tokens[levelname] = {
|
| 76 |
+
'root': [
|
| 77 |
+
include('numbers'),
|
| 78 |
+
# method names
|
| 79 |
+
(r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
|
| 80 |
+
r'(' + cs_ident + ')' # method name
|
| 81 |
+
r'(\s*)(\()', # signature start
|
| 82 |
+
bygroups(Whitespace, using(this), Name.Function, Whitespace,
|
| 83 |
+
Punctuation)),
|
| 84 |
+
(r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)),
|
| 85 |
+
(r'[^\S\n]+', Whitespace),
|
| 86 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
|
| 87 |
+
(r'//.*?\n', Comment.Single),
|
| 88 |
+
(r'/[*].*?[*]/', Comment.Multiline),
|
| 89 |
+
(r'\n', Whitespace),
|
| 90 |
+
(words((
|
| 91 |
+
'>>>=', '>>=', '<<=', '<=', '>=', '+=', '-=', '*=', '/=',
|
| 92 |
+
'%=', '&=', '|=', '^=', '??=', '=>', '??', '?.', '!=', '==',
|
| 93 |
+
'&&', '||', '>>>', '>>', '<<', '++', '--', '+', '-', '*',
|
| 94 |
+
'/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=',
|
| 95 |
+
)), Operator),
|
| 96 |
+
(r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
|
| 97 |
+
(r'[()\[\];:,.]', Punctuation),
|
| 98 |
+
(r'[{}]', Punctuation),
|
| 99 |
+
(r'@"(""|[^"])*"', String),
|
| 100 |
+
(r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
|
| 101 |
+
(r"'\\.'|'[^\\]'", String.Char),
|
| 102 |
+
(r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?"
|
| 103 |
+
r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 104 |
+
(r'(#)([ \t]*)(if|endif|else|elif|define|undef|'
|
| 105 |
+
r'line|error|warning|region|endregion|pragma)\b(.*?)(\n)',
|
| 106 |
+
bygroups(Comment.Preproc, Whitespace, Comment.Preproc,
|
| 107 |
+
Comment.Preproc, Whitespace)),
|
| 108 |
+
(r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace,
|
| 109 |
+
Keyword)),
|
| 110 |
+
(words((
|
| 111 |
+
'abstract', 'as', 'async', 'await', 'base', 'break', 'by',
|
| 112 |
+
'case', 'catch', 'checked', 'const', 'continue', 'default',
|
| 113 |
+
'delegate', 'do', 'else', 'enum', 'event', 'explicit',
|
| 114 |
+
'extern', 'false', 'finally', 'fixed', 'for', 'foreach',
|
| 115 |
+
'goto', 'if', 'implicit', 'in', 'interface', 'internal',
|
| 116 |
+
'is', 'let', 'lock', 'new', 'null', 'on', 'operator',
|
| 117 |
+
'out', 'override', 'params', 'private', 'protected',
|
| 118 |
+
'public', 'readonly', 'ref', 'return', 'sealed', 'sizeof',
|
| 119 |
+
'stackalloc', 'static', 'switch', 'this', 'throw', 'true',
|
| 120 |
+
'try', 'typeof', 'unchecked', 'unsafe', 'virtual', 'void',
|
| 121 |
+
'while', 'get', 'set', 'new', 'partial', 'yield', 'add',
|
| 122 |
+
'remove', 'value', 'alias', 'ascending', 'descending',
|
| 123 |
+
'from', 'group', 'into', 'orderby', 'select', 'thenby',
|
| 124 |
+
'where', 'join', 'equals', 'record', 'allows',
|
| 125 |
+
'and', 'init', 'managed', 'nameof', 'nint', 'not',
|
| 126 |
+
'notnull', 'nuint', 'or', 'scoped', 'unmanaged', 'when',
|
| 127 |
+
'with'
|
| 128 |
+
), suffix=r'\b'), Keyword),
|
| 129 |
+
# version 1: assumes that 'file' is the only contextual keyword
|
| 130 |
+
# that is a class modifier
|
| 131 |
+
(r'(file)(\s+)(record|class|abstract|enum|new|sealed|static)\b',
|
| 132 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 133 |
+
(r'(global)(::)', bygroups(Keyword, Punctuation)),
|
| 134 |
+
(r'(bool|byte|char|decimal|double|dynamic|float|int|long|object|'
|
| 135 |
+
r'sbyte|short|string|uint|ulong|ushort|var)\b\??', Keyword.Type),
|
| 136 |
+
(r'(class|struct)(\s+)', bygroups(Keyword, Whitespace), 'class'),
|
| 137 |
+
(r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace), 'namespace'),
|
| 138 |
+
(cs_ident, Name),
|
| 139 |
+
],
|
| 140 |
+
'numbers_int': [
|
| 141 |
+
(r"0[xX][0-9a-fA-F]+(([uU][lL]?)|[lL][uU]?)?", Number.Hex),
|
| 142 |
+
(r"0[bB][01]+(([uU][lL]?)|[lL][uU]?)?", Number.Bin),
|
| 143 |
+
(r"[0-9]+(([uU][lL]?)|[lL][uU]?)?", Number.Integer),
|
| 144 |
+
],
|
| 145 |
+
'numbers_float': [
|
| 146 |
+
(r"([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|"
|
| 147 |
+
r"(\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|"
|
| 148 |
+
r"([0-9]+([eE][+-]?[0-9]+)[fFdDmM]?)|"
|
| 149 |
+
r"([0-9]+[fFdDmM])", Number.Float),
|
| 150 |
+
],
|
| 151 |
+
'numbers': [
|
| 152 |
+
include('numbers_float'),
|
| 153 |
+
include('numbers_int'),
|
| 154 |
+
],
|
| 155 |
+
'class': [
|
| 156 |
+
(cs_ident, Name.Class, '#pop'),
|
| 157 |
+
default('#pop'),
|
| 158 |
+
],
|
| 159 |
+
'namespace': [
|
| 160 |
+
(r'(?=\()', Text, '#pop'), # using (resource)
|
| 161 |
+
('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop'),
|
| 162 |
+
]
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
def __init__(self, **options):
|
| 166 |
+
level = get_choice_opt(options, 'unicodelevel', list(self.tokens), 'basic')
|
| 167 |
+
if level not in self._all_tokens:
|
| 168 |
+
# compile the regexes now
|
| 169 |
+
self._tokens = self.__class__.process_tokendef(level)
|
| 170 |
+
else:
|
| 171 |
+
self._tokens = self._all_tokens[level]
|
| 172 |
+
|
| 173 |
+
RegexLexer.__init__(self, **options)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
class NemerleLexer(RegexLexer):
|
| 177 |
+
"""
|
| 178 |
+
For Nemerle source code.
|
| 179 |
+
|
| 180 |
+
Additional options accepted:
|
| 181 |
+
|
| 182 |
+
`unicodelevel`
|
| 183 |
+
Determines which Unicode characters this lexer allows for identifiers.
|
| 184 |
+
The possible values are:
|
| 185 |
+
|
| 186 |
+
* ``none`` -- only the ASCII letters and numbers are allowed. This
|
| 187 |
+
is the fastest selection.
|
| 188 |
+
* ``basic`` -- all Unicode characters from the specification except
|
| 189 |
+
category ``Lo`` are allowed.
|
| 190 |
+
* ``full`` -- all Unicode characters as specified in the C# specs
|
| 191 |
+
are allowed. Note that this means a considerable slowdown since the
|
| 192 |
+
``Lo`` category has more than 40,000 characters in it!
|
| 193 |
+
|
| 194 |
+
The default value is ``basic``.
|
| 195 |
+
"""
|
| 196 |
+
|
| 197 |
+
name = 'Nemerle'
|
| 198 |
+
url = 'http://nemerle.org'
|
| 199 |
+
aliases = ['nemerle']
|
| 200 |
+
filenames = ['*.n']
|
| 201 |
+
mimetypes = ['text/x-nemerle'] # inferred
|
| 202 |
+
version_added = '1.5'
|
| 203 |
+
|
| 204 |
+
flags = re.MULTILINE | re.DOTALL
|
| 205 |
+
|
| 206 |
+
# for the range of allowed unicode characters in identifiers, see
|
| 207 |
+
# http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
|
| 208 |
+
|
| 209 |
+
levels = {
|
| 210 |
+
'none': r'@?[_a-zA-Z]\w*',
|
| 211 |
+
'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
|
| 212 |
+
'[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
|
| 213 |
+
'Cf', 'Mn', 'Mc') + ']*'),
|
| 214 |
+
'full': ('@?(?:_|[^' +
|
| 215 |
+
uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
|
| 216 |
+
'[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
|
| 217 |
+
'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
tokens = {}
|
| 221 |
+
token_variants = True
|
| 222 |
+
|
| 223 |
+
for levelname, cs_ident in levels.items():
|
| 224 |
+
tokens[levelname] = {
|
| 225 |
+
'root': [
|
| 226 |
+
# method names
|
| 227 |
+
(r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
|
| 228 |
+
r'(' + cs_ident + ')' # method name
|
| 229 |
+
r'(\s*)(\()', # signature start
|
| 230 |
+
bygroups(Whitespace, using(this), Name.Function, Whitespace, \
|
| 231 |
+
Punctuation)),
|
| 232 |
+
(r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)),
|
| 233 |
+
(r'[^\S\n]+', Whitespace),
|
| 234 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
|
| 235 |
+
(r'//.*?\n', Comment.Single),
|
| 236 |
+
(r'/[*].*?[*]/', Comment.Multiline),
|
| 237 |
+
(r'\n', Whitespace),
|
| 238 |
+
(r'(\$)(\s*)(")', bygroups(String, Whitespace, String),
|
| 239 |
+
'splice-string'),
|
| 240 |
+
(r'(\$)(\s*)(<#)', bygroups(String, Whitespace, String),
|
| 241 |
+
'splice-string2'),
|
| 242 |
+
(r'<#', String, 'recursive-string'),
|
| 243 |
+
|
| 244 |
+
(r'(<\[)(\s*)(' + cs_ident + ':)?',
|
| 245 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 246 |
+
(r'\]\>', Keyword),
|
| 247 |
+
|
| 248 |
+
# quasiquotation only
|
| 249 |
+
(r'\$' + cs_ident, Name),
|
| 250 |
+
(r'(\$)(\()', bygroups(Name, Punctuation),
|
| 251 |
+
'splice-string-content'),
|
| 252 |
+
|
| 253 |
+
(r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
|
| 254 |
+
(r'[{}]', Punctuation),
|
| 255 |
+
(r'@"(""|[^"])*"', String),
|
| 256 |
+
(r'"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
|
| 257 |
+
(r"'\\.'|'[^\\]'", String.Char),
|
| 258 |
+
(r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 259 |
+
(r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFLdD]?", Number),
|
| 260 |
+
(r'(#)([ \t]*)(if|endif|else|elif|define|undef|'
|
| 261 |
+
r'line|error|warning|region|endregion|pragma)\b',
|
| 262 |
+
bygroups(Comment.Preproc, Whitespace, Comment.Preproc), 'preproc'),
|
| 263 |
+
(r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace, Keyword)),
|
| 264 |
+
(r'(abstract|and|as|base|catch|def|delegate|'
|
| 265 |
+
r'enum|event|extern|false|finally|'
|
| 266 |
+
r'fun|implements|interface|internal|'
|
| 267 |
+
r'is|macro|match|matches|module|mutable|new|'
|
| 268 |
+
r'null|out|override|params|partial|private|'
|
| 269 |
+
r'protected|public|ref|sealed|static|'
|
| 270 |
+
r'syntax|this|throw|true|try|type|typeof|'
|
| 271 |
+
r'virtual|volatile|when|where|with|'
|
| 272 |
+
r'assert|assert2|async|break|checked|continue|do|else|'
|
| 273 |
+
r'ensures|for|foreach|if|late|lock|new|nolate|'
|
| 274 |
+
r'otherwise|regexp|repeat|requires|return|surroundwith|'
|
| 275 |
+
r'unchecked|unless|using|while|yield)\b', Keyword),
|
| 276 |
+
(r'(global)(::)', bygroups(Keyword, Punctuation)),
|
| 277 |
+
(r'(bool|byte|char|decimal|double|float|int|long|object|sbyte|'
|
| 278 |
+
r'short|string|uint|ulong|ushort|void|array|list)\b\??',
|
| 279 |
+
Keyword.Type),
|
| 280 |
+
(r'(:>?)(\s*)(' + cs_ident + r'\??)',
|
| 281 |
+
bygroups(Punctuation, Whitespace, Keyword.Type)),
|
| 282 |
+
(r'(class|struct|variant|module)(\s+)',
|
| 283 |
+
bygroups(Keyword, Whitespace), 'class'),
|
| 284 |
+
(r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace),
|
| 285 |
+
'namespace'),
|
| 286 |
+
(cs_ident, Name),
|
| 287 |
+
],
|
| 288 |
+
'class': [
|
| 289 |
+
(cs_ident, Name.Class, '#pop')
|
| 290 |
+
],
|
| 291 |
+
'preproc': [
|
| 292 |
+
(r'\w+', Comment.Preproc),
|
| 293 |
+
(r'[ \t]+', Whitespace),
|
| 294 |
+
(r'\n', Whitespace, '#pop')
|
| 295 |
+
],
|
| 296 |
+
'namespace': [
|
| 297 |
+
(r'(?=\()', Text, '#pop'), # using (resource)
|
| 298 |
+
('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop')
|
| 299 |
+
],
|
| 300 |
+
'splice-string': [
|
| 301 |
+
(r'[^"$]', String),
|
| 302 |
+
(r'\$' + cs_ident, Name),
|
| 303 |
+
(r'(\$)(\()', bygroups(Name, Punctuation),
|
| 304 |
+
'splice-string-content'),
|
| 305 |
+
(r'\\"', String),
|
| 306 |
+
(r'"', String, '#pop')
|
| 307 |
+
],
|
| 308 |
+
'splice-string2': [
|
| 309 |
+
(r'[^#<>$]', String),
|
| 310 |
+
(r'\$' + cs_ident, Name),
|
| 311 |
+
(r'(\$)(\()', bygroups(Name, Punctuation),
|
| 312 |
+
'splice-string-content'),
|
| 313 |
+
(r'<#', String, '#push'),
|
| 314 |
+
(r'#>', String, '#pop')
|
| 315 |
+
],
|
| 316 |
+
'recursive-string': [
|
| 317 |
+
(r'[^#<>]', String),
|
| 318 |
+
(r'<#', String, '#push'),
|
| 319 |
+
(r'#>', String, '#pop')
|
| 320 |
+
],
|
| 321 |
+
'splice-string-content': [
|
| 322 |
+
(r'if|match', Keyword),
|
| 323 |
+
(r'[~!%^&*+=|\[\]:;,.<>/?-\\"$ ]', Punctuation),
|
| 324 |
+
(cs_ident, Name),
|
| 325 |
+
(r'\d+', Number),
|
| 326 |
+
(r'\(', Punctuation, '#push'),
|
| 327 |
+
(r'\)', Punctuation, '#pop')
|
| 328 |
+
]
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
def __init__(self, **options):
|
| 332 |
+
level = get_choice_opt(options, 'unicodelevel', list(self.tokens),
|
| 333 |
+
'basic')
|
| 334 |
+
if level not in self._all_tokens:
|
| 335 |
+
# compile the regexes now
|
| 336 |
+
self._tokens = self.__class__.process_tokendef(level)
|
| 337 |
+
else:
|
| 338 |
+
self._tokens = self._all_tokens[level]
|
| 339 |
+
|
| 340 |
+
RegexLexer.__init__(self, **options)
|
| 341 |
+
|
| 342 |
+
def analyse_text(text):
|
| 343 |
+
"""Nemerle is quite similar to Python, but @if is relatively uncommon
|
| 344 |
+
elsewhere."""
|
| 345 |
+
result = 0
|
| 346 |
+
|
| 347 |
+
if '@if' in text:
|
| 348 |
+
result += 0.1
|
| 349 |
+
|
| 350 |
+
return result
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
class BooLexer(RegexLexer):
|
| 354 |
+
"""
|
| 355 |
+
For Boo source code.
|
| 356 |
+
"""
|
| 357 |
+
|
| 358 |
+
name = 'Boo'
|
| 359 |
+
url = 'https://github.com/boo-lang/boo'
|
| 360 |
+
aliases = ['boo']
|
| 361 |
+
filenames = ['*.boo']
|
| 362 |
+
mimetypes = ['text/x-boo']
|
| 363 |
+
version_added = ''
|
| 364 |
+
|
| 365 |
+
tokens = {
|
| 366 |
+
'root': [
|
| 367 |
+
(r'\s+', Whitespace),
|
| 368 |
+
(r'(#|//).*$', Comment.Single),
|
| 369 |
+
(r'/[*]', Comment.Multiline, 'comment'),
|
| 370 |
+
(r'[]{}:(),.;[]', Punctuation),
|
| 371 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)),
|
| 372 |
+
(r'\\', Text),
|
| 373 |
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
| 374 |
+
(r'/(\\\\|\\[^\\]|[^/\\\s])/', String.Regex),
|
| 375 |
+
(r'@/(\\\\|\\[^\\]|[^/\\])*/', String.Regex),
|
| 376 |
+
(r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
|
| 377 |
+
(r'(as|abstract|callable|constructor|destructor|do|import|'
|
| 378 |
+
r'enum|event|final|get|interface|internal|of|override|'
|
| 379 |
+
r'partial|private|protected|public|return|set|static|'
|
| 380 |
+
r'struct|transient|virtual|yield|super|and|break|cast|'
|
| 381 |
+
r'continue|elif|else|ensure|except|for|given|goto|if|in|'
|
| 382 |
+
r'is|isa|not|or|otherwise|pass|raise|ref|try|unless|when|'
|
| 383 |
+
r'while|from|as)\b', Keyword),
|
| 384 |
+
(r'def(?=\s+\(.*?\))', Keyword),
|
| 385 |
+
(r'(def)(\s+)', bygroups(Keyword, Whitespace), 'funcname'),
|
| 386 |
+
(r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 387 |
+
(r'(namespace)(\s+)', bygroups(Keyword, Whitespace), 'namespace'),
|
| 388 |
+
(r'(?<!\.)(true|false|null|self|__eval__|__switch__|array|'
|
| 389 |
+
r'assert|checked|enumerate|filter|getter|len|lock|map|'
|
| 390 |
+
r'matrix|max|min|normalArrayIndexing|print|property|range|'
|
| 391 |
+
r'rawArrayIndexing|required|typeof|unchecked|using|'
|
| 392 |
+
r'yieldAll|zip)\b', Name.Builtin),
|
| 393 |
+
(r'"""(\\\\|\\"|.*?)"""', String.Double),
|
| 394 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 395 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 396 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 397 |
+
(r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float),
|
| 398 |
+
(r'[0-9][0-9.]*(ms?|d|h|s)', Number),
|
| 399 |
+
(r'0\d+', Number.Oct),
|
| 400 |
+
(r'0x[a-fA-F0-9]+', Number.Hex),
|
| 401 |
+
(r'\d+L', Number.Integer.Long),
|
| 402 |
+
(r'\d+', Number.Integer),
|
| 403 |
+
],
|
| 404 |
+
'comment': [
|
| 405 |
+
('/[*]', Comment.Multiline, '#push'),
|
| 406 |
+
('[*]/', Comment.Multiline, '#pop'),
|
| 407 |
+
('[^/*]', Comment.Multiline),
|
| 408 |
+
('[*/]', Comment.Multiline)
|
| 409 |
+
],
|
| 410 |
+
'funcname': [
|
| 411 |
+
(r'[a-zA-Z_]\w*', Name.Function, '#pop')
|
| 412 |
+
],
|
| 413 |
+
'classname': [
|
| 414 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
| 415 |
+
],
|
| 416 |
+
'namespace': [
|
| 417 |
+
(r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop')
|
| 418 |
+
]
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
class VbNetLexer(RegexLexer):
|
| 423 |
+
"""
|
| 424 |
+
For Visual Basic.NET source code.
|
| 425 |
+
Also LibreOffice Basic, OpenOffice Basic, and StarOffice Basic.
|
| 426 |
+
"""
|
| 427 |
+
|
| 428 |
+
name = 'VB.net'
|
| 429 |
+
url = 'https://docs.microsoft.com/en-us/dotnet/visual-basic/'
|
| 430 |
+
aliases = ['vb.net', 'vbnet', 'lobas', 'oobas', 'sobas', 'visual-basic', 'visualbasic']
|
| 431 |
+
filenames = ['*.vb', '*.bas']
|
| 432 |
+
mimetypes = ['text/x-vbnet', 'text/x-vba'] # (?)
|
| 433 |
+
version_added = ''
|
| 434 |
+
|
| 435 |
+
uni_name = '[_' + uni.combine('Ll', 'Lt', 'Lm', 'Nl') + ']' + \
|
| 436 |
+
'[' + uni.combine('Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
|
| 437 |
+
'Cf', 'Mn', 'Mc') + ']*'
|
| 438 |
+
|
| 439 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 440 |
+
tokens = {
|
| 441 |
+
'root': [
|
| 442 |
+
(r'^\s*<.*?>', Name.Attribute),
|
| 443 |
+
(r'\s+', Whitespace),
|
| 444 |
+
(r'\n', Whitespace),
|
| 445 |
+
(r'(rem\b.*?)(\n)', bygroups(Comment, Whitespace)),
|
| 446 |
+
(r"('.*?)(\n)", bygroups(Comment, Whitespace)),
|
| 447 |
+
(r'#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|'
|
| 448 |
+
r'#ExternalSource.*?\n|#End\s+ExternalSource|'
|
| 449 |
+
r'#Region.*?\n|#End\s+Region|#ExternalChecksum',
|
| 450 |
+
Comment.Preproc),
|
| 451 |
+
(r'[(){}!#,.:]', Punctuation),
|
| 452 |
+
(r'(Option)(\s+)(Strict|Explicit|Compare)(\s+)'
|
| 453 |
+
r'(On|Off|Binary|Text)',
|
| 454 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration,
|
| 455 |
+
Whitespace, Keyword.Declaration)),
|
| 456 |
+
(words((
|
| 457 |
+
'AddHandler', 'Alias', 'ByRef', 'ByVal', 'Call', 'Case',
|
| 458 |
+
'Catch', 'CBool', 'CByte', 'CChar', 'CDate', 'CDec', 'CDbl',
|
| 459 |
+
'CInt', 'CLng', 'CObj', 'Continue', 'CSByte', 'CShort', 'CSng',
|
| 460 |
+
'CStr', 'CType', 'CUInt', 'CULng', 'CUShort', 'Declare',
|
| 461 |
+
'Default', 'Delegate', 'DirectCast', 'Do', 'Each', 'Else',
|
| 462 |
+
'ElseIf', 'EndIf', 'Erase', 'Error', 'Event', 'Exit', 'False',
|
| 463 |
+
'Finally', 'For', 'Friend', 'Get', 'Global', 'GoSub', 'GoTo',
|
| 464 |
+
'Handles', 'If', 'Implements', 'Inherits', 'Interface', 'Let',
|
| 465 |
+
'Lib', 'Loop', 'Me', 'MustInherit', 'MustOverride', 'MyBase',
|
| 466 |
+
'MyClass', 'Narrowing', 'New', 'Next', 'Not', 'Nothing',
|
| 467 |
+
'NotInheritable', 'NotOverridable', 'Of', 'On', 'Operator',
|
| 468 |
+
'Option', 'Optional', 'Overloads', 'Overridable', 'Overrides',
|
| 469 |
+
'ParamArray', 'Partial', 'Private', 'Protected', 'Public',
|
| 470 |
+
'RaiseEvent', 'ReadOnly', 'ReDim', 'RemoveHandler', 'Resume',
|
| 471 |
+
'Return', 'Select', 'Set', 'Shadows', 'Shared', 'Single',
|
| 472 |
+
'Static', 'Step', 'Stop', 'SyncLock', 'Then', 'Throw', 'To',
|
| 473 |
+
'True', 'Try', 'TryCast', 'Wend', 'Using', 'When', 'While',
|
| 474 |
+
'Widening', 'With', 'WithEvents', 'WriteOnly'),
|
| 475 |
+
prefix=r'(?<!\.)', suffix=r'\b'), Keyword),
|
| 476 |
+
(r'(?<!\.)End\b', Keyword, 'end'),
|
| 477 |
+
(r'(?<!\.)(Dim|Const)\b', Keyword, 'dim'),
|
| 478 |
+
(r'(?<!\.)(Function|Sub|Property)(\s+)',
|
| 479 |
+
bygroups(Keyword, Whitespace), 'funcname'),
|
| 480 |
+
(r'(?<!\.)(Class|Structure|Enum)(\s+)',
|
| 481 |
+
bygroups(Keyword, Whitespace), 'classname'),
|
| 482 |
+
(r'(?<!\.)(Module|Namespace|Imports)(\s+)',
|
| 483 |
+
bygroups(Keyword, Whitespace), 'namespace'),
|
| 484 |
+
(r'(?<!\.)(Boolean|Byte|Char|Date|Decimal|Double|Integer|Long|'
|
| 485 |
+
r'Object|SByte|Short|Single|String|Variant|UInteger|ULong|'
|
| 486 |
+
r'UShort)\b', Keyword.Type),
|
| 487 |
+
(r'(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|'
|
| 488 |
+
r'Or|OrElse|TypeOf|Xor)\b', Operator.Word),
|
| 489 |
+
(r'&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|'
|
| 490 |
+
r'<=|>=|<>|[-&*/\\^+=<>\[\]]',
|
| 491 |
+
Operator),
|
| 492 |
+
('"', String, 'string'),
|
| 493 |
+
(r'(_)(\n)', bygroups(Text, Whitespace)), # Line continuation (must be before Name)
|
| 494 |
+
(uni_name + '[%&@!#$]?', Name),
|
| 495 |
+
('#.*?#', Literal.Date),
|
| 496 |
+
(r'(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?', Number.Float),
|
| 497 |
+
(r'\d+([SILDFR]|US|UI|UL)?', Number.Integer),
|
| 498 |
+
(r'&H[0-9a-f]+([SILDFR]|US|UI|UL)?', Number.Integer),
|
| 499 |
+
(r'&O[0-7]+([SILDFR]|US|UI|UL)?', Number.Integer),
|
| 500 |
+
],
|
| 501 |
+
'string': [
|
| 502 |
+
(r'""', String),
|
| 503 |
+
(r'"C?', String, '#pop'),
|
| 504 |
+
(r'[^"]+', String),
|
| 505 |
+
],
|
| 506 |
+
'dim': [
|
| 507 |
+
(uni_name, Name.Variable, '#pop'),
|
| 508 |
+
default('#pop'), # any other syntax
|
| 509 |
+
],
|
| 510 |
+
'funcname': [
|
| 511 |
+
(uni_name, Name.Function, '#pop'),
|
| 512 |
+
],
|
| 513 |
+
'classname': [
|
| 514 |
+
(uni_name, Name.Class, '#pop'),
|
| 515 |
+
],
|
| 516 |
+
'namespace': [
|
| 517 |
+
(uni_name, Name.Namespace),
|
| 518 |
+
(r'\.', Name.Namespace),
|
| 519 |
+
default('#pop'),
|
| 520 |
+
],
|
| 521 |
+
'end': [
|
| 522 |
+
(r'\s+', Whitespace),
|
| 523 |
+
(r'(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b',
|
| 524 |
+
Keyword, '#pop'),
|
| 525 |
+
default('#pop'),
|
| 526 |
+
]
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
def analyse_text(text):
|
| 530 |
+
if re.search(r'^\s*(#If|Module|Namespace)', text, re.MULTILINE):
|
| 531 |
+
return 0.5
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
class GenericAspxLexer(RegexLexer):
|
| 535 |
+
"""
|
| 536 |
+
Lexer for ASP.NET pages.
|
| 537 |
+
"""
|
| 538 |
+
|
| 539 |
+
name = 'aspx-gen'
|
| 540 |
+
filenames = []
|
| 541 |
+
mimetypes = []
|
| 542 |
+
url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
|
| 543 |
+
|
| 544 |
+
flags = re.DOTALL
|
| 545 |
+
|
| 546 |
+
tokens = {
|
| 547 |
+
'root': [
|
| 548 |
+
(r'(<%[@=#]?)(.*?)(%>)', bygroups(Name.Tag, Other, Name.Tag)),
|
| 549 |
+
(r'(<script.*?>)(.*?)(</script>)', bygroups(using(XmlLexer),
|
| 550 |
+
Other,
|
| 551 |
+
using(XmlLexer))),
|
| 552 |
+
(r'(.+?)(?=<)', using(XmlLexer)),
|
| 553 |
+
(r'.+', using(XmlLexer)),
|
| 554 |
+
],
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
# TODO support multiple languages within the same source file
|
| 559 |
+
class CSharpAspxLexer(DelegatingLexer):
|
| 560 |
+
"""
|
| 561 |
+
Lexer for highlighting C# within ASP.NET pages.
|
| 562 |
+
"""
|
| 563 |
+
|
| 564 |
+
name = 'aspx-cs'
|
| 565 |
+
aliases = ['aspx-cs']
|
| 566 |
+
filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd']
|
| 567 |
+
mimetypes = []
|
| 568 |
+
url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
|
| 569 |
+
version_added = ''
|
| 570 |
+
|
| 571 |
+
def __init__(self, **options):
|
| 572 |
+
super().__init__(CSharpLexer, GenericAspxLexer, **options)
|
| 573 |
+
|
| 574 |
+
def analyse_text(text):
|
| 575 |
+
if re.search(r'Page\s*Language="C#"', text, re.I) is not None:
|
| 576 |
+
return 0.2
|
| 577 |
+
elif re.search(r'script[^>]+language=["\']C#', text, re.I) is not None:
|
| 578 |
+
return 0.15
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
class VbNetAspxLexer(DelegatingLexer):
|
| 582 |
+
"""
|
| 583 |
+
Lexer for highlighting Visual Basic.net within ASP.NET pages.
|
| 584 |
+
"""
|
| 585 |
+
|
| 586 |
+
name = 'aspx-vb'
|
| 587 |
+
aliases = ['aspx-vb']
|
| 588 |
+
filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd']
|
| 589 |
+
mimetypes = []
|
| 590 |
+
url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
|
| 591 |
+
version_added = ''
|
| 592 |
+
|
| 593 |
+
def __init__(self, **options):
|
| 594 |
+
super().__init__(VbNetLexer, GenericAspxLexer, **options)
|
| 595 |
+
|
| 596 |
+
def analyse_text(text):
|
| 597 |
+
if re.search(r'Page\s*Language="Vb"', text, re.I) is not None:
|
| 598 |
+
return 0.2
|
| 599 |
+
elif re.search(r'script[^>]+language=["\']vb', text, re.I) is not None:
|
| 600 |
+
return 0.15
|
| 601 |
+
|
| 602 |
+
|
| 603 |
+
# Very close to functional.OcamlLexer
|
| 604 |
+
class FSharpLexer(RegexLexer):
|
| 605 |
+
"""
|
| 606 |
+
For the F# language (version 3.0).
|
| 607 |
+
"""
|
| 608 |
+
|
| 609 |
+
name = 'F#'
|
| 610 |
+
url = 'https://fsharp.org/'
|
| 611 |
+
aliases = ['fsharp', 'f#']
|
| 612 |
+
filenames = ['*.fs', '*.fsi', '*.fsx']
|
| 613 |
+
mimetypes = ['text/x-fsharp']
|
| 614 |
+
version_added = '1.5'
|
| 615 |
+
|
| 616 |
+
keywords = [
|
| 617 |
+
'abstract', 'as', 'assert', 'base', 'begin', 'class', 'default',
|
| 618 |
+
'delegate', 'do!', 'do', 'done', 'downcast', 'downto', 'elif', 'else',
|
| 619 |
+
'end', 'exception', 'extern', 'false', 'finally', 'for', 'function',
|
| 620 |
+
'fun', 'global', 'if', 'inherit', 'inline', 'interface', 'internal',
|
| 621 |
+
'in', 'lazy', 'let!', 'let', 'match', 'member', 'module', 'mutable',
|
| 622 |
+
'namespace', 'new', 'null', 'of', 'open', 'override', 'private', 'public',
|
| 623 |
+
'rec', 'return!', 'return', 'select', 'static', 'struct', 'then', 'to',
|
| 624 |
+
'true', 'try', 'type', 'upcast', 'use!', 'use', 'val', 'void', 'when',
|
| 625 |
+
'while', 'with', 'yield!', 'yield',
|
| 626 |
+
]
|
| 627 |
+
# Reserved words; cannot hurt to color them as keywords too.
|
| 628 |
+
keywords += [
|
| 629 |
+
'atomic', 'break', 'checked', 'component', 'const', 'constraint',
|
| 630 |
+
'constructor', 'continue', 'eager', 'event', 'external', 'fixed',
|
| 631 |
+
'functor', 'include', 'method', 'mixin', 'object', 'parallel',
|
| 632 |
+
'process', 'protected', 'pure', 'sealed', 'tailcall', 'trait',
|
| 633 |
+
'virtual', 'volatile',
|
| 634 |
+
]
|
| 635 |
+
keyopts = [
|
| 636 |
+
'!=', '#', '&&', '&', r'\(', r'\)', r'\*', r'\+', ',', r'-\.',
|
| 637 |
+
'->', '-', r'\.\.', r'\.', '::', ':=', ':>', ':', ';;', ';', '<-',
|
| 638 |
+
r'<\]', '<', r'>\]', '>', r'\?\?', r'\?', r'\[<', r'\[\|', r'\[', r'\]',
|
| 639 |
+
'_', '`', r'\{', r'\|\]', r'\|', r'\}', '~', '<@@', '<@', '=', '@>', '@@>',
|
| 640 |
+
]
|
| 641 |
+
|
| 642 |
+
operators = r'[!$%&*+\./:<=>?@^|~-]'
|
| 643 |
+
word_operators = ['and', 'or', 'not']
|
| 644 |
+
prefix_syms = r'[!?~]'
|
| 645 |
+
infix_syms = r'[=<>@^|&+\*/$%-]'
|
| 646 |
+
primitives = [
|
| 647 |
+
'sbyte', 'byte', 'char', 'nativeint', 'unativeint', 'float32', 'single',
|
| 648 |
+
'float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32',
|
| 649 |
+
'uint32', 'int64', 'uint64', 'decimal', 'unit', 'bool', 'string',
|
| 650 |
+
'list', 'exn', 'obj', 'enum',
|
| 651 |
+
]
|
| 652 |
+
|
| 653 |
+
# See http://msdn.microsoft.com/en-us/library/dd233181.aspx and/or
|
| 654 |
+
# http://fsharp.org/about/files/spec.pdf for reference. Good luck.
|
| 655 |
+
|
| 656 |
+
tokens = {
|
| 657 |
+
'escape-sequence': [
|
| 658 |
+
(r'\\[\\"\'ntbrafv]', String.Escape),
|
| 659 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 660 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 661 |
+
(r'\\U[0-9a-fA-F]{8}', String.Escape),
|
| 662 |
+
],
|
| 663 |
+
'root': [
|
| 664 |
+
(r'\s+', Whitespace),
|
| 665 |
+
(r'\(\)|\[\]', Name.Builtin.Pseudo),
|
| 666 |
+
(r'\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)',
|
| 667 |
+
Name.Namespace, 'dotted'),
|
| 668 |
+
(r'\b([A-Z][\w\']*)', Name),
|
| 669 |
+
(r'(///.*?)(\n)', bygroups(String.Doc, Whitespace)),
|
| 670 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 671 |
+
(r'\(\*(?!\))', Comment, 'comment'),
|
| 672 |
+
|
| 673 |
+
(r'@"', String, 'lstring'),
|
| 674 |
+
(r'"""', String, 'tqs'),
|
| 675 |
+
(r'"', String, 'string'),
|
| 676 |
+
|
| 677 |
+
(r'\b(open|module)(\s+)([\w.]+)',
|
| 678 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 679 |
+
(r'\b(let!?)(\s+)(\w+)',
|
| 680 |
+
bygroups(Keyword, Whitespace, Name.Variable)),
|
| 681 |
+
(r'\b(type)(\s+)(\w+)',
|
| 682 |
+
bygroups(Keyword, Whitespace, Name.Class)),
|
| 683 |
+
(r'\b(member|override)(\s+)(\w+)(\.)(\w+)',
|
| 684 |
+
bygroups(Keyword, Whitespace, Name, Punctuation, Name.Function)),
|
| 685 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 686 |
+
(r'``([^`\n\r\t]|`[^`\n\r\t])+``', Name),
|
| 687 |
+
(r'({})'.format('|'.join(keyopts)), Operator),
|
| 688 |
+
(rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
|
| 689 |
+
(r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
|
| 690 |
+
(r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
|
| 691 |
+
(r'(#)([ \t]*)(if|endif|else|line|nowarn|light|\d+)\b(.*?)(\n)',
|
| 692 |
+
bygroups(Comment.Preproc, Whitespace, Comment.Preproc,
|
| 693 |
+
Comment.Preproc, Whitespace)),
|
| 694 |
+
|
| 695 |
+
(r"[^\W\d][\w']*", Name),
|
| 696 |
+
|
| 697 |
+
(r'\d[\d_]*[uU]?[yslLnQRZINGmM]?', Number.Integer),
|
| 698 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?', Number.Hex),
|
| 699 |
+
(r'0[oO][0-7][0-7_]*[uU]?[yslLn]?', Number.Oct),
|
| 700 |
+
(r'0[bB][01][01_]*[uU]?[yslLn]?', Number.Bin),
|
| 701 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?',
|
| 702 |
+
Number.Float),
|
| 703 |
+
|
| 704 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?",
|
| 705 |
+
String.Char),
|
| 706 |
+
(r"'.'", String.Char),
|
| 707 |
+
(r"'", Keyword), # a stray quote is another syntax element
|
| 708 |
+
|
| 709 |
+
(r'@?"', String.Double, 'string'),
|
| 710 |
+
|
| 711 |
+
(r'[~?][a-z][\w\']*:', Name.Variable),
|
| 712 |
+
],
|
| 713 |
+
'dotted': [
|
| 714 |
+
(r'\s+', Whitespace),
|
| 715 |
+
(r'\.', Punctuation),
|
| 716 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
|
| 717 |
+
(r'[A-Z][\w\']*', Name, '#pop'),
|
| 718 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 719 |
+
# e.g. dictionary index access
|
| 720 |
+
default('#pop'),
|
| 721 |
+
],
|
| 722 |
+
'comment': [
|
| 723 |
+
(r'[^(*)@"]+', Comment),
|
| 724 |
+
(r'\(\*', Comment, '#push'),
|
| 725 |
+
(r'\*\)', Comment, '#pop'),
|
| 726 |
+
# comments cannot be closed within strings in comments
|
| 727 |
+
(r'@"', String, 'lstring'),
|
| 728 |
+
(r'"""', String, 'tqs'),
|
| 729 |
+
(r'"', String, 'string'),
|
| 730 |
+
(r'[(*)@]', Comment),
|
| 731 |
+
],
|
| 732 |
+
'string': [
|
| 733 |
+
(r'[^\\"]+', String),
|
| 734 |
+
include('escape-sequence'),
|
| 735 |
+
(r'\\\n', String),
|
| 736 |
+
(r'\n', String), # newlines are allowed in any string
|
| 737 |
+
(r'"B?', String, '#pop'),
|
| 738 |
+
],
|
| 739 |
+
'lstring': [
|
| 740 |
+
(r'[^"]+', String),
|
| 741 |
+
(r'\n', String),
|
| 742 |
+
(r'""', String),
|
| 743 |
+
(r'"B?', String, '#pop'),
|
| 744 |
+
],
|
| 745 |
+
'tqs': [
|
| 746 |
+
(r'[^"]+', String),
|
| 747 |
+
(r'\n', String),
|
| 748 |
+
(r'"""B?', String, '#pop'),
|
| 749 |
+
(r'"', String),
|
| 750 |
+
],
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
def analyse_text(text):
|
| 754 |
+
"""F# doesn't have that many unique features -- |> and <| are weak
|
| 755 |
+
indicators."""
|
| 756 |
+
result = 0
|
| 757 |
+
if '|>' in text:
|
| 758 |
+
result += 0.05
|
| 759 |
+
if '<|' in text:
|
| 760 |
+
result += 0.05
|
| 761 |
+
|
| 762 |
+
return result
|
| 763 |
+
|
| 764 |
+
|
| 765 |
+
class XppLexer(RegexLexer):
|
| 766 |
+
|
| 767 |
+
"""
|
| 768 |
+
For X++ source code. This is based loosely on the CSharpLexer
|
| 769 |
+
"""
|
| 770 |
+
|
| 771 |
+
name = 'X++'
|
| 772 |
+
url = 'https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-language-reference'
|
| 773 |
+
aliases = ['xpp', 'x++']
|
| 774 |
+
filenames = ['*.xpp']
|
| 775 |
+
version_added = '2.15'
|
| 776 |
+
|
| 777 |
+
flags = re.MULTILINE
|
| 778 |
+
|
| 779 |
+
XPP_CHARS = ('@?(?:_|[^' +
|
| 780 |
+
uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
|
| 781 |
+
'[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
|
| 782 |
+
'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*')
|
| 783 |
+
# Temporary, see
|
| 784 |
+
# https://github.com/thatch/regexlint/pull/49
|
| 785 |
+
XPP_CHARS = XPP_CHARS.replace('\x00', '\x01')
|
| 786 |
+
|
| 787 |
+
OPERATORS = (
|
| 788 |
+
'<=', '>=', '+=', '-=', '*=', '/=', '!=', '==',
|
| 789 |
+
'&&', '||', '>>', '<<', '++', '--', '+', '-', '*',
|
| 790 |
+
'/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=',
|
| 791 |
+
)
|
| 792 |
+
KEYWORDS = ('abstract','anytype','as','async','asc','at','avg','break','breakpoint','by','byref','case','catch',
|
| 793 |
+
'changecompany','client','container','continue','count','crosscompany','default','delegate',
|
| 794 |
+
'delete_from','desc','display','div','do','edit','else','element','eventhandler','exists','false','final',
|
| 795 |
+
'firstfast','firstonly','firstonly10','firstonly100','firstonly1000','flush','for','forceliterals',
|
| 796 |
+
'forcenestedloop','forceplaceholders','forceselectorder','forupdate','from','group','if','insert_recordset',
|
| 797 |
+
'interface','is','join','like','maxof','minof','mod','new','next','nofetch','notexists','null','optimisticlock','order',
|
| 798 |
+
'outer','pause','pessimisticlock','print','private','protected','public','repeatableread','retry','return',
|
| 799 |
+
'reverse','select','server','setting','static','sum','super','switch','tablelock','this','throw','true','try','ttsabort','ttsbegin',
|
| 800 |
+
'ttscommit','update_recordset','validtimestate','void','where','while','window')
|
| 801 |
+
RUNTIME_FUNCTIONS = ('_duration','abs','acos','any2Date','any2Enum','any2Guid','any2Int','any2Int64','any2Real','any2Str','anytodate',
|
| 802 |
+
'anytoenum','anytoguid','anytoint','anytoint64','anytoreal','anytostr','asin','atan','beep','cTerm','char2Num','classIdGet',
|
| 803 |
+
'corrFlagGet','corrFlagSet','cos','cosh','curExt','curUserId','date2Num','date2Str','datetime2Str','dayName','dayOfMth',
|
| 804 |
+
'dayOfWk','dayOfYr','ddb','decRound','dg','dimOf','endMth','enum2str','exp','exp10','fV','fieldId2Name','fieldId2PName',
|
| 805 |
+
'fieldName2Id','frac','funcName','getCurrentPartition','getCurrentPartitionRecId','getPrefix','guid2Str','idg','indexId2Name',
|
| 806 |
+
'indexName2Id','int2Str','int642Str','intvMax','intvName','intvNo','intvNorm','log10','logN','match','max','min','mkDate','mthName',
|
| 807 |
+
'mthOfYr','newGuid','nextMth','nextQtr','nextYr','num2Char','num2Date','num2Str','pmt','power','prevMth','prevQtr','prevYr',
|
| 808 |
+
'prmIsDefault','pt','pv','rate','refPrintAll','round','runAs','sessionId','setPrefix','sin','sinh','sleep','sln','str2Date',
|
| 809 |
+
'str2Datetime','str2Enum','str2Guid','str2Int','str2Int64','str2Num','str2Time','strAlpha','strCmp','strColSeq','strDel',
|
| 810 |
+
'strFind','strFmt','strIns','strKeep','strLTrim','strLen','strLine','strLwr','strNFind','strPoke','strPrompt','strRTrim',
|
| 811 |
+
'strRem','strRep','strScan','strUpr','subStr','syd','systemDateGet','systemDateSet','tableId2Name',
|
| 812 |
+
'tableId2PName','tableName2Id','tan','tanh','term','time2Str','timeNow','today','trunc','typeOf','uint2Str','wkOfYr','year')
|
| 813 |
+
COMPILE_FUNCTIONS = ('attributeStr','classNum','classStr','configurationKeyNum','configurationKeyStr','dataEntityDataSourceStr','delegateStr',
|
| 814 |
+
'dimensionHierarchyLevelStr','dimensionHierarchyStr','dimensionReferenceStr','dutyStr','enumCnt','enumLiteralStr','enumNum','enumStr',
|
| 815 |
+
'extendedTypeNum','extendedTypeStr','fieldNum','fieldPName','fieldStr','formControlStr','formDataFieldStr','formDataSourceStr',
|
| 816 |
+
'formMethodStr','formStr','identifierStr','indexNum','indexStr','licenseCodeNum','licenseCodeStr','literalStr','maxDate','maxInt',
|
| 817 |
+
'measureStr','measurementStr','menuItemActionStr','menuItemDisplayStr','menuItemOutputStr','menuStr','methodStr','minInt','privilegeStr',
|
| 818 |
+
'queryDatasourceStr','queryMethodStr','queryStr','reportStr','resourceStr','roleStr','ssrsReportStr','staticDelegateStr','staticMethodStr',
|
| 819 |
+
'tableCollectionStr','tableFieldGroupStr','tableMethodStr','tableNum','tablePName','tableStaticMethodStr','tableStr','tileStr','varStr',
|
| 820 |
+
'webActionItemStr','webDisplayContentItemStr','webFormStr','webMenuStr','webOutputContentItemStr','webReportStr','webSiteTempStr',
|
| 821 |
+
'webStaticFileStr','webUrlItemStr','webWebPartStr','webletItemStr','webpageDefStr','websiteDefStr','workflowApprovalStr',
|
| 822 |
+
'workflowCategoryStr','workflowTaskStr','workflowTypeStr')
|
| 823 |
+
|
| 824 |
+
tokens = {}
|
| 825 |
+
|
| 826 |
+
tokens = {
|
| 827 |
+
'root': [
|
| 828 |
+
# method names
|
| 829 |
+
(r'(\s*)\b(else|if)\b([^\n])', bygroups(Whitespace, Keyword, using(this))), # ensure that if is not treated like a function
|
| 830 |
+
(r'^([ \t]*)((?:' + XPP_CHARS + r'(?:\[\])?\s+)+?)' # return type
|
| 831 |
+
r'(' + XPP_CHARS + ')' # method name
|
| 832 |
+
r'(\s*)(\()', # signature start
|
| 833 |
+
bygroups(Whitespace, using(this), Name.Function, Whitespace,
|
| 834 |
+
Punctuation)),
|
| 835 |
+
(r'^(\s*)(\[)([^\n]*?)(\])', bygroups(Whitespace, Name.Attribute, Name.Variable.Class, Name.Attribute)),
|
| 836 |
+
(r'[^\S\n]+', Whitespace),
|
| 837 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
|
| 838 |
+
(r'//[^\n]*?\n', Comment.Single),
|
| 839 |
+
(r'/[*][^\n]*?[*]/', Comment.Multiline),
|
| 840 |
+
(r'\n', Whitespace),
|
| 841 |
+
(words(OPERATORS), Operator),
|
| 842 |
+
(r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
|
| 843 |
+
(r'[()\[\];:,.#@]', Punctuation),
|
| 844 |
+
(r'[{}]', Punctuation),
|
| 845 |
+
(r'@"(""|[^"])*"', String),
|
| 846 |
+
(r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
|
| 847 |
+
(r"'\\.'|'[^\\]'", String.Char),
|
| 848 |
+
(r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?"
|
| 849 |
+
r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 850 |
+
(words(KEYWORDS, suffix=r'\b'), Keyword),
|
| 851 |
+
(r'(boolean|int|int64|str|real|guid|date)\b\??', Keyword.Type),
|
| 852 |
+
(r'(class|struct|extends|implements)(\s+)', bygroups(Keyword, Whitespace), 'class'),
|
| 853 |
+
(r'('+XPP_CHARS+')(::)', bygroups(Name.Variable.Class, Punctuation)),
|
| 854 |
+
(r'(\s*)(\w+)(\s+\w+(,|=)?[^\n]*;)', bygroups(Whitespace, Name.Variable.Class, using(this))), # declaration
|
| 855 |
+
# x++ specific function to get field should highlight the classname
|
| 856 |
+
(r'(fieldNum\()('+XPP_CHARS+r')(\s*,\s*)('+XPP_CHARS+r')(\s*\))',
|
| 857 |
+
bygroups(using(this), Name.Variable.Class, using(this), Name.Property, using(this))),
|
| 858 |
+
# x++ specific function to get table should highlight the classname
|
| 859 |
+
(r'(tableNum\()('+XPP_CHARS+r')(\s*\))',
|
| 860 |
+
bygroups(using(this), Name.Variable.Class, using(this))),
|
| 861 |
+
(words(RUNTIME_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic),
|
| 862 |
+
(words(COMPILE_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic),
|
| 863 |
+
(XPP_CHARS, Name),
|
| 864 |
+
],
|
| 865 |
+
'class': [
|
| 866 |
+
(XPP_CHARS, Name.Class, '#pop'),
|
| 867 |
+
default('#pop'),
|
| 868 |
+
],
|
| 869 |
+
'namespace': [
|
| 870 |
+
(r'(?=\()', Text, '#pop'), # using (resource)
|
| 871 |
+
('(' + XPP_CHARS + r'|\.)+', Name.Namespace, '#pop'),
|
| 872 |
+
]
|
| 873 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dsls.py
ADDED
|
@@ -0,0 +1,970 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dsls
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for various domain-specific languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import ExtendedRegexLexer, RegexLexer, bygroups, words, \
|
| 14 |
+
include, default, this, using, combined
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['ProtoBufLexer', 'ZeekLexer', 'PuppetLexer', 'RslLexer',
|
| 19 |
+
'MscgenLexer', 'VGLLexer', 'AlloyLexer', 'PanLexer',
|
| 20 |
+
'CrmshLexer', 'ThriftLexer', 'FlatlineLexer', 'SnowballLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class ProtoBufLexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
Lexer for Protocol Buffer definition files.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
name = 'Protocol Buffer'
|
| 29 |
+
url = 'https://developers.google.com/protocol-buffers/'
|
| 30 |
+
aliases = ['protobuf', 'proto']
|
| 31 |
+
filenames = ['*.proto']
|
| 32 |
+
version_added = '1.4'
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
(r'[ \t]+', Whitespace),
|
| 37 |
+
(r'[,;{}\[\]()<>]', Punctuation),
|
| 38 |
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 39 |
+
(r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
|
| 40 |
+
(words((
|
| 41 |
+
'import', 'option', 'optional', 'required', 'repeated',
|
| 42 |
+
'reserved', 'default', 'packed', 'ctype', 'extensions', 'to',
|
| 43 |
+
'max', 'rpc', 'returns', 'oneof', 'syntax'), prefix=r'\b', suffix=r'\b'),
|
| 44 |
+
Keyword),
|
| 45 |
+
(words((
|
| 46 |
+
'int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64',
|
| 47 |
+
'fixed32', 'fixed64', 'sfixed32', 'sfixed64',
|
| 48 |
+
'float', 'double', 'bool', 'string', 'bytes'), suffix=r'\b'),
|
| 49 |
+
Keyword.Type),
|
| 50 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 51 |
+
(r'(package)(\s+)', bygroups(Keyword.Namespace, Whitespace), 'package'),
|
| 52 |
+
(r'(message|extend)(\s+)',
|
| 53 |
+
bygroups(Keyword.Declaration, Whitespace), 'message'),
|
| 54 |
+
(r'(enum|group|service)(\s+)',
|
| 55 |
+
bygroups(Keyword.Declaration, Whitespace), 'type'),
|
| 56 |
+
(r'\".*?\"', String),
|
| 57 |
+
(r'\'.*?\'', String),
|
| 58 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
| 59 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 60 |
+
(r'(\-?(inf|nan))\b', Number.Float),
|
| 61 |
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 62 |
+
(r'0[0-7]+[LlUu]*', Number.Oct),
|
| 63 |
+
(r'\d+[LlUu]*', Number.Integer),
|
| 64 |
+
(r'[+-=]', Operator),
|
| 65 |
+
(r'([a-zA-Z_][\w.]*)([ \t]*)(=)',
|
| 66 |
+
bygroups(Name.Attribute, Whitespace, Operator)),
|
| 67 |
+
(r'[a-zA-Z_][\w.]*', Name),
|
| 68 |
+
],
|
| 69 |
+
'package': [
|
| 70 |
+
(r'[a-zA-Z_][\w\.]*', Name.Namespace, '#pop'),
|
| 71 |
+
default('#pop'),
|
| 72 |
+
],
|
| 73 |
+
'message': [
|
| 74 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop'),
|
| 75 |
+
default('#pop'),
|
| 76 |
+
],
|
| 77 |
+
'type': [
|
| 78 |
+
(r'[a-zA-Z_]\w*', Name, '#pop'),
|
| 79 |
+
default('#pop'),
|
| 80 |
+
],
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class ThriftLexer(RegexLexer):
|
| 85 |
+
"""
|
| 86 |
+
For Thrift interface definitions.
|
| 87 |
+
"""
|
| 88 |
+
name = 'Thrift'
|
| 89 |
+
url = 'https://thrift.apache.org/'
|
| 90 |
+
aliases = ['thrift']
|
| 91 |
+
filenames = ['*.thrift']
|
| 92 |
+
mimetypes = ['application/x-thrift']
|
| 93 |
+
version_added = '2.1'
|
| 94 |
+
|
| 95 |
+
tokens = {
|
| 96 |
+
'root': [
|
| 97 |
+
include('whitespace'),
|
| 98 |
+
include('comments'),
|
| 99 |
+
(r'"', String.Double, combined('stringescape', 'dqs')),
|
| 100 |
+
(r'\'', String.Single, combined('stringescape', 'sqs')),
|
| 101 |
+
(r'(namespace)(\s+)',
|
| 102 |
+
bygroups(Keyword.Namespace, Whitespace), 'namespace'),
|
| 103 |
+
(r'(enum|union|struct|service|exception)(\s+)',
|
| 104 |
+
bygroups(Keyword.Declaration, Whitespace), 'class'),
|
| 105 |
+
(r'((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)' # return arguments
|
| 106 |
+
r'((?:[^\W\d]|\$)[\w$]*)' # method name
|
| 107 |
+
r'(\s*)(\()', # signature start
|
| 108 |
+
bygroups(using(this), Name.Function, Whitespace, Operator)),
|
| 109 |
+
include('keywords'),
|
| 110 |
+
include('numbers'),
|
| 111 |
+
(r'[&=]', Operator),
|
| 112 |
+
(r'[:;,{}()<>\[\]]', Punctuation),
|
| 113 |
+
(r'[a-zA-Z_](\.\w|\w)*', Name),
|
| 114 |
+
],
|
| 115 |
+
'whitespace': [
|
| 116 |
+
(r'\n', Whitespace),
|
| 117 |
+
(r'\s+', Whitespace),
|
| 118 |
+
],
|
| 119 |
+
'comments': [
|
| 120 |
+
(r'#.*$', Comment),
|
| 121 |
+
(r'//.*?\n', Comment),
|
| 122 |
+
(r'/\*[\w\W]*?\*/', Comment.Multiline),
|
| 123 |
+
],
|
| 124 |
+
'stringescape': [
|
| 125 |
+
(r'\\([\\nrt"\'])', String.Escape),
|
| 126 |
+
],
|
| 127 |
+
'dqs': [
|
| 128 |
+
(r'"', String.Double, '#pop'),
|
| 129 |
+
(r'[^\\"\n]+', String.Double),
|
| 130 |
+
],
|
| 131 |
+
'sqs': [
|
| 132 |
+
(r"'", String.Single, '#pop'),
|
| 133 |
+
(r'[^\\\'\n]+', String.Single),
|
| 134 |
+
],
|
| 135 |
+
'namespace': [
|
| 136 |
+
(r'[a-z*](\.\w|\w)*', Name.Namespace, '#pop'),
|
| 137 |
+
default('#pop'),
|
| 138 |
+
],
|
| 139 |
+
'class': [
|
| 140 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop'),
|
| 141 |
+
default('#pop'),
|
| 142 |
+
],
|
| 143 |
+
'keywords': [
|
| 144 |
+
(r'(async|oneway|extends|throws|required|optional)\b', Keyword),
|
| 145 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 146 |
+
(r'(const|typedef)\b', Keyword.Declaration),
|
| 147 |
+
(words((
|
| 148 |
+
'cpp_namespace', 'cpp_include', 'cpp_type', 'java_package',
|
| 149 |
+
'cocoa_prefix', 'csharp_namespace', 'delphi_namespace',
|
| 150 |
+
'php_namespace', 'py_module', 'perl_package',
|
| 151 |
+
'ruby_namespace', 'smalltalk_category', 'smalltalk_prefix',
|
| 152 |
+
'xsd_all', 'xsd_optional', 'xsd_nillable', 'xsd_namespace',
|
| 153 |
+
'xsd_attrs', 'include'), suffix=r'\b'),
|
| 154 |
+
Keyword.Namespace),
|
| 155 |
+
(words((
|
| 156 |
+
'void', 'bool', 'byte', 'i16', 'i32', 'i64', 'double',
|
| 157 |
+
'string', 'binary', 'map', 'list', 'set', 'slist',
|
| 158 |
+
'senum'), suffix=r'\b'),
|
| 159 |
+
Keyword.Type),
|
| 160 |
+
(words((
|
| 161 |
+
'BEGIN', 'END', '__CLASS__', '__DIR__', '__FILE__',
|
| 162 |
+
'__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__',
|
| 163 |
+
'abstract', 'alias', 'and', 'args', 'as', 'assert', 'begin',
|
| 164 |
+
'break', 'case', 'catch', 'class', 'clone', 'continue',
|
| 165 |
+
'declare', 'def', 'default', 'del', 'delete', 'do', 'dynamic',
|
| 166 |
+
'elif', 'else', 'elseif', 'elsif', 'end', 'enddeclare',
|
| 167 |
+
'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile',
|
| 168 |
+
'ensure', 'except', 'exec', 'finally', 'float', 'for',
|
| 169 |
+
'foreach', 'function', 'global', 'goto', 'if', 'implements',
|
| 170 |
+
'import', 'in', 'inline', 'instanceof', 'interface', 'is',
|
| 171 |
+
'lambda', 'module', 'native', 'new', 'next', 'nil', 'not',
|
| 172 |
+
'or', 'pass', 'public', 'print', 'private', 'protected',
|
| 173 |
+
'raise', 'redo', 'rescue', 'retry', 'register', 'return',
|
| 174 |
+
'self', 'sizeof', 'static', 'super', 'switch', 'synchronized',
|
| 175 |
+
'then', 'this', 'throw', 'transient', 'try', 'undef',
|
| 176 |
+
'unless', 'unsigned', 'until', 'use', 'var', 'virtual',
|
| 177 |
+
'volatile', 'when', 'while', 'with', 'xor', 'yield'),
|
| 178 |
+
prefix=r'\b', suffix=r'\b'),
|
| 179 |
+
Keyword.Reserved),
|
| 180 |
+
],
|
| 181 |
+
'numbers': [
|
| 182 |
+
(r'[+-]?(\d+\.\d+([eE][+-]?\d+)?|\.?\d+[eE][+-]?\d+)', Number.Float),
|
| 183 |
+
(r'[+-]?0x[0-9A-Fa-f]+', Number.Hex),
|
| 184 |
+
(r'[+-]?[0-9]+', Number.Integer),
|
| 185 |
+
],
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
class ZeekLexer(RegexLexer):
|
| 190 |
+
"""
|
| 191 |
+
For Zeek scripts.
|
| 192 |
+
"""
|
| 193 |
+
name = 'Zeek'
|
| 194 |
+
url = 'https://www.zeek.org/'
|
| 195 |
+
aliases = ['zeek', 'bro']
|
| 196 |
+
filenames = ['*.zeek', '*.bro']
|
| 197 |
+
version_added = '2.5'
|
| 198 |
+
|
| 199 |
+
_hex = r'[0-9a-fA-F]'
|
| 200 |
+
_float = r'((\d*\.?\d+)|(\d+\.?\d*))([eE][-+]?\d+)?'
|
| 201 |
+
_h = r'[A-Za-z0-9][-A-Za-z0-9]*'
|
| 202 |
+
|
| 203 |
+
tokens = {
|
| 204 |
+
'root': [
|
| 205 |
+
include('whitespace'),
|
| 206 |
+
include('comments'),
|
| 207 |
+
include('directives'),
|
| 208 |
+
include('attributes'),
|
| 209 |
+
include('types'),
|
| 210 |
+
include('keywords'),
|
| 211 |
+
include('literals'),
|
| 212 |
+
include('operators'),
|
| 213 |
+
include('punctuation'),
|
| 214 |
+
(r'((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(?=\s*\()',
|
| 215 |
+
Name.Function),
|
| 216 |
+
include('identifiers'),
|
| 217 |
+
],
|
| 218 |
+
|
| 219 |
+
'whitespace': [
|
| 220 |
+
(r'\n', Whitespace),
|
| 221 |
+
(r'\s+', Whitespace),
|
| 222 |
+
(r'(\\)(\n)', bygroups(Text, Whitespace)),
|
| 223 |
+
],
|
| 224 |
+
|
| 225 |
+
'comments': [
|
| 226 |
+
(r'#.*$', Comment),
|
| 227 |
+
],
|
| 228 |
+
|
| 229 |
+
'directives': [
|
| 230 |
+
(r'@(load-plugin|load-sigs|load|unload)\b.*$', Comment.Preproc),
|
| 231 |
+
(r'@(DEBUG|DIR|FILENAME|deprecated|if|ifdef|ifndef|else|endif)\b', Comment.Preproc),
|
| 232 |
+
(r'(@prefixes)(\s*)((\+?=).*)$', bygroups(Comment.Preproc,
|
| 233 |
+
Whitespace, Comment.Preproc)),
|
| 234 |
+
],
|
| 235 |
+
|
| 236 |
+
'attributes': [
|
| 237 |
+
(words(('redef', 'priority', 'log', 'optional', 'default', 'add_func',
|
| 238 |
+
'delete_func', 'expire_func', 'read_expire', 'write_expire',
|
| 239 |
+
'create_expire', 'synchronized', 'persistent', 'rotate_interval',
|
| 240 |
+
'rotate_size', 'encrypt', 'raw_output', 'mergeable', 'error_handler',
|
| 241 |
+
'type_column', 'deprecated'),
|
| 242 |
+
prefix=r'&', suffix=r'\b'),
|
| 243 |
+
Keyword.Pseudo),
|
| 244 |
+
],
|
| 245 |
+
|
| 246 |
+
'types': [
|
| 247 |
+
(words(('any',
|
| 248 |
+
'enum', 'record', 'set', 'table', 'vector',
|
| 249 |
+
'function', 'hook', 'event',
|
| 250 |
+
'addr', 'bool', 'count', 'double', 'file', 'int', 'interval',
|
| 251 |
+
'pattern', 'port', 'string', 'subnet', 'time'),
|
| 252 |
+
suffix=r'\b'),
|
| 253 |
+
Keyword.Type),
|
| 254 |
+
|
| 255 |
+
(r'(opaque)(\s+)(of)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)\b',
|
| 256 |
+
bygroups(Keyword.Type, Whitespace, Operator.Word, Whitespace, Keyword.Type)),
|
| 257 |
+
|
| 258 |
+
(r'(type)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(\s*)(:)(\s*)\b(record|enum)\b',
|
| 259 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Operator, Whitespace, Keyword.Type)),
|
| 260 |
+
|
| 261 |
+
(r'(type)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(\s*)(:)',
|
| 262 |
+
bygroups(Keyword, Whitespace, Name, Whitespace, Operator)),
|
| 263 |
+
|
| 264 |
+
(r'(redef)(\s+)(record|enum)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)\b',
|
| 265 |
+
bygroups(Keyword, Whitespace, Keyword.Type, Whitespace, Name.Class)),
|
| 266 |
+
],
|
| 267 |
+
|
| 268 |
+
'keywords': [
|
| 269 |
+
(words(('redef', 'export', 'if', 'else', 'for', 'while',
|
| 270 |
+
'return', 'break', 'next', 'continue', 'fallthrough',
|
| 271 |
+
'switch', 'default', 'case',
|
| 272 |
+
'add', 'delete',
|
| 273 |
+
'when', 'timeout', 'schedule'),
|
| 274 |
+
suffix=r'\b'),
|
| 275 |
+
Keyword),
|
| 276 |
+
(r'(print)\b', Keyword),
|
| 277 |
+
(r'(global|local|const|option)\b', Keyword.Declaration),
|
| 278 |
+
(r'(module)(\s+)(([A-Za-z_]\w*)(?:::([A-Za-z_]\w*))*)\b',
|
| 279 |
+
bygroups(Keyword.Namespace, Whitespace, Name.Namespace)),
|
| 280 |
+
],
|
| 281 |
+
|
| 282 |
+
'literals': [
|
| 283 |
+
(r'"', String, 'string'),
|
| 284 |
+
|
| 285 |
+
# Not the greatest match for patterns, but generally helps
|
| 286 |
+
# disambiguate between start of a pattern and just a division
|
| 287 |
+
# operator.
|
| 288 |
+
(r'/(?=.*/)', String.Regex, 'regex'),
|
| 289 |
+
|
| 290 |
+
(r'(T|F)\b', Keyword.Constant),
|
| 291 |
+
|
| 292 |
+
# Port
|
| 293 |
+
(r'\d{1,5}/(udp|tcp|icmp|unknown)\b', Number),
|
| 294 |
+
|
| 295 |
+
# IPv4 Address
|
| 296 |
+
(r'(\d{1,3}.){3}(\d{1,3})\b', Number),
|
| 297 |
+
|
| 298 |
+
# IPv6 Address
|
| 299 |
+
(r'\[([0-9a-fA-F]{0,4}:){2,7}([0-9a-fA-F]{0,4})?((\d{1,3}.){3}(\d{1,3}))?\]', Number),
|
| 300 |
+
|
| 301 |
+
# Numeric
|
| 302 |
+
(r'0[xX]' + _hex + r'+\b', Number.Hex),
|
| 303 |
+
(_float + r'\s*(day|hr|min|sec|msec|usec)s?\b', Number.Float),
|
| 304 |
+
(_float + r'\b', Number.Float),
|
| 305 |
+
(r'(\d+)\b', Number.Integer),
|
| 306 |
+
|
| 307 |
+
# Hostnames
|
| 308 |
+
(_h + r'(\.' + _h + r')+', String),
|
| 309 |
+
],
|
| 310 |
+
|
| 311 |
+
'operators': [
|
| 312 |
+
(r'[!%*/+<=>~|&^-]', Operator),
|
| 313 |
+
(r'([-+=&|]{2}|[+=!><-]=)', Operator),
|
| 314 |
+
(r'(in|as|is|of)\b', Operator.Word),
|
| 315 |
+
(r'\??\$', Operator),
|
| 316 |
+
],
|
| 317 |
+
|
| 318 |
+
'punctuation': [
|
| 319 |
+
(r'[{}()\[\],;.]', Punctuation),
|
| 320 |
+
# The "ternary if", which uses '?' and ':', could instead be
|
| 321 |
+
# treated as an Operator, but colons are more frequently used to
|
| 322 |
+
# separate field/identifier names from their types, so the (often)
|
| 323 |
+
# less-prominent Punctuation is used even with '?' for consistency.
|
| 324 |
+
(r'[?:]', Punctuation),
|
| 325 |
+
],
|
| 326 |
+
|
| 327 |
+
'identifiers': [
|
| 328 |
+
(r'([a-zA-Z_]\w*)(::)', bygroups(Name, Punctuation)),
|
| 329 |
+
(r'[a-zA-Z_]\w*', Name)
|
| 330 |
+
],
|
| 331 |
+
|
| 332 |
+
'string': [
|
| 333 |
+
(r'\\.', String.Escape),
|
| 334 |
+
(r'%-?[0-9]*(\.[0-9]+)?[DTd-gsx]', String.Escape),
|
| 335 |
+
(r'"', String, '#pop'),
|
| 336 |
+
(r'.', String),
|
| 337 |
+
],
|
| 338 |
+
|
| 339 |
+
'regex': [
|
| 340 |
+
(r'\\.', String.Escape),
|
| 341 |
+
(r'/', String.Regex, '#pop'),
|
| 342 |
+
(r'.', String.Regex),
|
| 343 |
+
],
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
BroLexer = ZeekLexer
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
class PuppetLexer(RegexLexer):
|
| 351 |
+
"""
|
| 352 |
+
For Puppet configuration DSL.
|
| 353 |
+
"""
|
| 354 |
+
name = 'Puppet'
|
| 355 |
+
url = 'https://puppet.com/'
|
| 356 |
+
aliases = ['puppet']
|
| 357 |
+
filenames = ['*.pp']
|
| 358 |
+
version_added = '1.6'
|
| 359 |
+
|
| 360 |
+
tokens = {
|
| 361 |
+
'root': [
|
| 362 |
+
include('comments'),
|
| 363 |
+
include('keywords'),
|
| 364 |
+
include('names'),
|
| 365 |
+
include('numbers'),
|
| 366 |
+
include('operators'),
|
| 367 |
+
include('strings'),
|
| 368 |
+
|
| 369 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 370 |
+
(r'\s+', Whitespace),
|
| 371 |
+
],
|
| 372 |
+
|
| 373 |
+
'comments': [
|
| 374 |
+
(r'(\s*)(#.*)$', bygroups(Whitespace, Comment)),
|
| 375 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 376 |
+
],
|
| 377 |
+
|
| 378 |
+
'operators': [
|
| 379 |
+
(r'(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)', Operator),
|
| 380 |
+
(r'(in|and|or|not)\b', Operator.Word),
|
| 381 |
+
],
|
| 382 |
+
|
| 383 |
+
'names': [
|
| 384 |
+
(r'[a-zA-Z_]\w*', Name.Attribute),
|
| 385 |
+
(r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
|
| 386 |
+
String, Punctuation)),
|
| 387 |
+
(r'\$\S+', Name.Variable),
|
| 388 |
+
],
|
| 389 |
+
|
| 390 |
+
'numbers': [
|
| 391 |
+
# Copypasta from the Python lexer
|
| 392 |
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
|
| 393 |
+
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
|
| 394 |
+
(r'0[0-7]+j?', Number.Oct),
|
| 395 |
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
| 396 |
+
(r'\d+L', Number.Integer.Long),
|
| 397 |
+
(r'\d+j?', Number.Integer)
|
| 398 |
+
],
|
| 399 |
+
|
| 400 |
+
'keywords': [
|
| 401 |
+
# Left out 'group' and 'require'
|
| 402 |
+
# Since they're often used as attributes
|
| 403 |
+
(words((
|
| 404 |
+
'absent', 'alert', 'alias', 'audit', 'augeas', 'before', 'case',
|
| 405 |
+
'check', 'class', 'computer', 'configured', 'contained',
|
| 406 |
+
'create_resources', 'crit', 'cron', 'debug', 'default',
|
| 407 |
+
'define', 'defined', 'directory', 'else', 'elsif', 'emerg',
|
| 408 |
+
'err', 'exec', 'extlookup', 'fail', 'false', 'file',
|
| 409 |
+
'filebucket', 'fqdn_rand', 'generate', 'host', 'if', 'import',
|
| 410 |
+
'include', 'info', 'inherits', 'inline_template', 'installed',
|
| 411 |
+
'interface', 'k5login', 'latest', 'link', 'loglevel',
|
| 412 |
+
'macauthorization', 'mailalias', 'maillist', 'mcx', 'md5',
|
| 413 |
+
'mount', 'mounted', 'nagios_command', 'nagios_contact',
|
| 414 |
+
'nagios_contactgroup', 'nagios_host', 'nagios_hostdependency',
|
| 415 |
+
'nagios_hostescalation', 'nagios_hostextinfo', 'nagios_hostgroup',
|
| 416 |
+
'nagios_service', 'nagios_servicedependency', 'nagios_serviceescalation',
|
| 417 |
+
'nagios_serviceextinfo', 'nagios_servicegroup', 'nagios_timeperiod',
|
| 418 |
+
'node', 'noop', 'notice', 'notify', 'package', 'present', 'purged',
|
| 419 |
+
'realize', 'regsubst', 'resources', 'role', 'router', 'running',
|
| 420 |
+
'schedule', 'scheduled_task', 'search', 'selboolean', 'selmodule',
|
| 421 |
+
'service', 'sha1', 'shellquote', 'split', 'sprintf',
|
| 422 |
+
'ssh_authorized_key', 'sshkey', 'stage', 'stopped', 'subscribe',
|
| 423 |
+
'tag', 'tagged', 'template', 'tidy', 'true', 'undef', 'unmounted',
|
| 424 |
+
'user', 'versioncmp', 'vlan', 'warning', 'yumrepo', 'zfs', 'zone',
|
| 425 |
+
'zpool'), prefix='(?i)', suffix=r'\b'),
|
| 426 |
+
Keyword),
|
| 427 |
+
],
|
| 428 |
+
|
| 429 |
+
'strings': [
|
| 430 |
+
(r'"([^"])*"', String),
|
| 431 |
+
(r"'(\\'|[^'])*'", String),
|
| 432 |
+
],
|
| 433 |
+
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
class RslLexer(RegexLexer):
|
| 438 |
+
"""
|
| 439 |
+
RSL is the formal specification
|
| 440 |
+
language used in RAISE (Rigorous Approach to Industrial Software Engineering)
|
| 441 |
+
method.
|
| 442 |
+
"""
|
| 443 |
+
name = 'RSL'
|
| 444 |
+
url = 'http://en.wikipedia.org/wiki/RAISE'
|
| 445 |
+
aliases = ['rsl']
|
| 446 |
+
filenames = ['*.rsl']
|
| 447 |
+
mimetypes = ['text/rsl']
|
| 448 |
+
version_added = '2.0'
|
| 449 |
+
|
| 450 |
+
flags = re.MULTILINE | re.DOTALL
|
| 451 |
+
|
| 452 |
+
tokens = {
|
| 453 |
+
'root': [
|
| 454 |
+
(words((
|
| 455 |
+
'Bool', 'Char', 'Int', 'Nat', 'Real', 'Text', 'Unit', 'abs',
|
| 456 |
+
'all', 'always', 'any', 'as', 'axiom', 'card', 'case', 'channel',
|
| 457 |
+
'chaos', 'class', 'devt_relation', 'dom', 'elems', 'else', 'elif',
|
| 458 |
+
'end', 'exists', 'extend', 'false', 'for', 'hd', 'hide', 'if',
|
| 459 |
+
'in', 'is', 'inds', 'initialise', 'int', 'inter', 'isin', 'len',
|
| 460 |
+
'let', 'local', 'ltl_assertion', 'object', 'of', 'out', 'post',
|
| 461 |
+
'pre', 'read', 'real', 'rng', 'scheme', 'skip', 'stop', 'swap',
|
| 462 |
+
'then', 'theory', 'test_case', 'tl', 'transition_system', 'true',
|
| 463 |
+
'type', 'union', 'until', 'use', 'value', 'variable', 'while',
|
| 464 |
+
'with', 'write', '~isin', '-inflist', '-infset', '-list',
|
| 465 |
+
'-set'), prefix=r'\b', suffix=r'\b'),
|
| 466 |
+
Keyword),
|
| 467 |
+
(r'(variable|value)\b', Keyword.Declaration),
|
| 468 |
+
(r'--.*?\n', Comment),
|
| 469 |
+
(r'<:.*?:>', Comment),
|
| 470 |
+
(r'\{!.*?!\}', Comment),
|
| 471 |
+
(r'/\*.*?\*/', Comment),
|
| 472 |
+
(r'^([ \t]*)([\w]+)([ \t]*)(:[^:])', bygroups(Whitespace,
|
| 473 |
+
Name.Function, Whitespace, Name.Function)),
|
| 474 |
+
(r'(^[ \t]*)([\w]+)([ \t]*)(\([\w\s,]*\))([ \t]*)(is|as)',
|
| 475 |
+
bygroups(Whitespace, Name.Function, Whitespace, Text,
|
| 476 |
+
Whitespace, Keyword)),
|
| 477 |
+
(r'\b[A-Z]\w*\b', Keyword.Type),
|
| 478 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 479 |
+
(r'".*"', String),
|
| 480 |
+
(r'\'.\'', String.Char),
|
| 481 |
+
(r'(><|->|-m->|/\\|<=|<<=|<\.|\|\||\|\^\||-~->|-~m->|\\/|>=|>>|'
|
| 482 |
+
r'\.>|\+\+|-\\|<->|=>|:-|~=|\*\*|<<|>>=|\+>|!!|\|=\||#)',
|
| 483 |
+
Operator),
|
| 484 |
+
(r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 485 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 486 |
+
(r'[0-9]+', Number.Integer),
|
| 487 |
+
(r'\s+', Whitespace),
|
| 488 |
+
(r'.', Text),
|
| 489 |
+
],
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
def analyse_text(text):
|
| 493 |
+
"""
|
| 494 |
+
Check for the most common text in the beginning of a RSL file.
|
| 495 |
+
"""
|
| 496 |
+
if re.search(r'scheme\s*.*?=\s*class\s*type', text, re.I) is not None:
|
| 497 |
+
return 1.0
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
class MscgenLexer(RegexLexer):
|
| 501 |
+
"""
|
| 502 |
+
For Mscgen files.
|
| 503 |
+
"""
|
| 504 |
+
name = 'Mscgen'
|
| 505 |
+
url = 'http://www.mcternan.me.uk/mscgen/'
|
| 506 |
+
aliases = ['mscgen', 'msc']
|
| 507 |
+
filenames = ['*.msc']
|
| 508 |
+
version_added = '1.6'
|
| 509 |
+
|
| 510 |
+
_var = r'(\w+|"(?:\\"|[^"])*")'
|
| 511 |
+
|
| 512 |
+
tokens = {
|
| 513 |
+
'root': [
|
| 514 |
+
(r'msc\b', Keyword.Type),
|
| 515 |
+
# Options
|
| 516 |
+
(r'(hscale|HSCALE|width|WIDTH|wordwraparcs|WORDWRAPARCS'
|
| 517 |
+
r'|arcgradient|ARCGRADIENT)\b', Name.Property),
|
| 518 |
+
# Operators
|
| 519 |
+
(r'(abox|ABOX|rbox|RBOX|box|BOX|note|NOTE)\b', Operator.Word),
|
| 520 |
+
(r'(\.|-|\|){3}', Keyword),
|
| 521 |
+
(r'(?:-|=|\.|:){2}'
|
| 522 |
+
r'|<<=>>|<->|<=>|<<>>|<:>'
|
| 523 |
+
r'|->|=>>|>>|=>|:>|-x|-X'
|
| 524 |
+
r'|<-|<<=|<<|<=|<:|x-|X-|=', Operator),
|
| 525 |
+
# Names
|
| 526 |
+
(r'\*', Name.Builtin),
|
| 527 |
+
(_var, Name.Variable),
|
| 528 |
+
# Other
|
| 529 |
+
(r'\[', Punctuation, 'attrs'),
|
| 530 |
+
(r'\{|\}|,|;', Punctuation),
|
| 531 |
+
include('comments')
|
| 532 |
+
],
|
| 533 |
+
'attrs': [
|
| 534 |
+
(r'\]', Punctuation, '#pop'),
|
| 535 |
+
(_var + r'(\s*)(=)(\s*)' + _var,
|
| 536 |
+
bygroups(Name.Attribute, Whitespace, Operator, Whitespace,
|
| 537 |
+
String)),
|
| 538 |
+
(r',', Punctuation),
|
| 539 |
+
include('comments')
|
| 540 |
+
],
|
| 541 |
+
'comments': [
|
| 542 |
+
(r'(?://|#).*?\n', Comment.Single),
|
| 543 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 544 |
+
(r'[ \t\r\n]+', Whitespace)
|
| 545 |
+
]
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
class VGLLexer(RegexLexer):
|
| 550 |
+
"""
|
| 551 |
+
For SampleManager VGL source code.
|
| 552 |
+
"""
|
| 553 |
+
name = 'VGL'
|
| 554 |
+
url = 'http://www.thermoscientific.com/samplemanager'
|
| 555 |
+
aliases = ['vgl']
|
| 556 |
+
filenames = ['*.rpf']
|
| 557 |
+
version_added = '1.6'
|
| 558 |
+
|
| 559 |
+
flags = re.MULTILINE | re.DOTALL | re.IGNORECASE
|
| 560 |
+
|
| 561 |
+
tokens = {
|
| 562 |
+
'root': [
|
| 563 |
+
(r'\{[^}]*\}', Comment.Multiline),
|
| 564 |
+
(r'declare', Keyword.Constant),
|
| 565 |
+
(r'(if|then|else|endif|while|do|endwhile|and|or|prompt|object'
|
| 566 |
+
r'|create|on|line|with|global|routine|value|endroutine|constant'
|
| 567 |
+
r'|global|set|join|library|compile_option|file|exists|create|copy'
|
| 568 |
+
r'|delete|enable|windows|name|notprotected)(?! *[=<>.,()])',
|
| 569 |
+
Keyword),
|
| 570 |
+
(r'(true|false|null|empty|error|locked)', Keyword.Constant),
|
| 571 |
+
(r'[~^*#!%&\[\]()<>|+=:;,./?-]', Operator),
|
| 572 |
+
(r'"[^"]*"', String),
|
| 573 |
+
(r'(\.)([a-z_$][\w$]*)', bygroups(Operator, Name.Attribute)),
|
| 574 |
+
(r'[0-9][0-9]*(\.[0-9]+(e[+\-]?[0-9]+)?)?', Number),
|
| 575 |
+
(r'[a-z_$][\w$]*', Name),
|
| 576 |
+
(r'[\r\n]+', Whitespace),
|
| 577 |
+
(r'\s+', Whitespace)
|
| 578 |
+
]
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
class AlloyLexer(RegexLexer):
|
| 583 |
+
"""
|
| 584 |
+
For Alloy source code.
|
| 585 |
+
"""
|
| 586 |
+
|
| 587 |
+
name = 'Alloy'
|
| 588 |
+
url = 'http://alloy.mit.edu'
|
| 589 |
+
aliases = ['alloy']
|
| 590 |
+
filenames = ['*.als']
|
| 591 |
+
mimetypes = ['text/x-alloy']
|
| 592 |
+
version_added = '2.0'
|
| 593 |
+
|
| 594 |
+
flags = re.MULTILINE | re.DOTALL
|
| 595 |
+
|
| 596 |
+
iden_rex = r'[a-zA-Z_][\w]*"*'
|
| 597 |
+
string_rex = r'"\b(\\\\|\\[^\\]|[^"\\])*"'
|
| 598 |
+
text_tuple = (r'[^\S\n]+', Whitespace)
|
| 599 |
+
|
| 600 |
+
tokens = {
|
| 601 |
+
'sig': [
|
| 602 |
+
(r'(extends)\b', Keyword, '#pop'),
|
| 603 |
+
(iden_rex, Name),
|
| 604 |
+
text_tuple,
|
| 605 |
+
(r',', Punctuation),
|
| 606 |
+
(r'\{', Operator, '#pop'),
|
| 607 |
+
],
|
| 608 |
+
'module': [
|
| 609 |
+
text_tuple,
|
| 610 |
+
(iden_rex, Name, '#pop'),
|
| 611 |
+
],
|
| 612 |
+
'fun': [
|
| 613 |
+
text_tuple,
|
| 614 |
+
(r'\{', Operator, '#pop'),
|
| 615 |
+
(iden_rex, Name, '#pop'),
|
| 616 |
+
],
|
| 617 |
+
'fact': [
|
| 618 |
+
include('fun'),
|
| 619 |
+
(string_rex, String, '#pop'),
|
| 620 |
+
],
|
| 621 |
+
'root': [
|
| 622 |
+
(r'--.*?$', Comment.Single),
|
| 623 |
+
(r'//.*?$', Comment.Single),
|
| 624 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 625 |
+
text_tuple,
|
| 626 |
+
(r'(module|open)(\s+)', bygroups(Keyword.Namespace, Whitespace),
|
| 627 |
+
'module'),
|
| 628 |
+
(r'(sig|enum)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'sig'),
|
| 629 |
+
(r'(iden|univ|none)\b', Keyword.Constant),
|
| 630 |
+
(r'(int|Int)\b', Keyword.Type),
|
| 631 |
+
(r'(var|this|abstract|extends|set|seq|one|lone|let)\b', Keyword),
|
| 632 |
+
(r'(all|some|no|sum|disj|when|else)\b', Keyword),
|
| 633 |
+
(r'(run|check|for|but|exactly|expect|as|steps)\b', Keyword),
|
| 634 |
+
(r'(always|after|eventually|until|release)\b', Keyword), # future time operators
|
| 635 |
+
(r'(historically|before|once|since|triggered)\b', Keyword), # past time operators
|
| 636 |
+
(r'(and|or|implies|iff|in)\b', Operator.Word),
|
| 637 |
+
(r'(fun|pred|assert)(\s+)', bygroups(Keyword, Whitespace), 'fun'),
|
| 638 |
+
(r'(fact)(\s+)', bygroups(Keyword, Whitespace), 'fact'),
|
| 639 |
+
(r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.\.|\.|->', Operator),
|
| 640 |
+
(r'[-+/*%=<>&!^|~{}\[\]().\';]', Operator),
|
| 641 |
+
(iden_rex, Name),
|
| 642 |
+
(r'[:,]', Punctuation),
|
| 643 |
+
(r'[0-9]+', Number.Integer),
|
| 644 |
+
(string_rex, String),
|
| 645 |
+
(r'\n', Whitespace),
|
| 646 |
+
]
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
class PanLexer(RegexLexer):
|
| 651 |
+
"""
|
| 652 |
+
Lexer for pan source files.
|
| 653 |
+
|
| 654 |
+
Based on tcsh lexer.
|
| 655 |
+
"""
|
| 656 |
+
|
| 657 |
+
name = 'Pan'
|
| 658 |
+
url = 'https://github.com/quattor/pan/'
|
| 659 |
+
aliases = ['pan']
|
| 660 |
+
filenames = ['*.pan']
|
| 661 |
+
version_added = '2.0'
|
| 662 |
+
|
| 663 |
+
tokens = {
|
| 664 |
+
'root': [
|
| 665 |
+
include('basic'),
|
| 666 |
+
(r'\(', Keyword, 'paren'),
|
| 667 |
+
(r'\{', Keyword, 'curly'),
|
| 668 |
+
include('data'),
|
| 669 |
+
],
|
| 670 |
+
'basic': [
|
| 671 |
+
(words((
|
| 672 |
+
'if', 'for', 'with', 'else', 'type', 'bind', 'while', 'valid', 'final',
|
| 673 |
+
'prefix', 'unique', 'object', 'foreach', 'include', 'template',
|
| 674 |
+
'function', 'variable', 'structure', 'extensible', 'declaration'),
|
| 675 |
+
prefix=r'\b', suffix=r'\b'),
|
| 676 |
+
Keyword),
|
| 677 |
+
(words((
|
| 678 |
+
'file_contents', 'format', 'index', 'length', 'match', 'matches',
|
| 679 |
+
'replace', 'splice', 'split', 'substr', 'to_lowercase', 'to_uppercase',
|
| 680 |
+
'debug', 'error', 'traceback', 'deprecated', 'base64_decode',
|
| 681 |
+
'base64_encode', 'digest', 'escape', 'unescape', 'append', 'create',
|
| 682 |
+
'first', 'nlist', 'key', 'list', 'merge', 'next', 'prepend', 'is_boolean',
|
| 683 |
+
'is_defined', 'is_double', 'is_list', 'is_long', 'is_nlist', 'is_null',
|
| 684 |
+
'is_number', 'is_property', 'is_resource', 'is_string', 'to_boolean',
|
| 685 |
+
'to_double', 'to_long', 'to_string', 'clone', 'delete', 'exists',
|
| 686 |
+
'path_exists', 'if_exists', 'return', 'value'),
|
| 687 |
+
prefix=r'\b', suffix=r'\b'),
|
| 688 |
+
Name.Builtin),
|
| 689 |
+
(r'#.*', Comment),
|
| 690 |
+
(r'\\[\w\W]', String.Escape),
|
| 691 |
+
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Whitespace, Operator)),
|
| 692 |
+
(r'[\[\]{}()=]+', Operator),
|
| 693 |
+
(r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
| 694 |
+
(r';', Punctuation),
|
| 695 |
+
],
|
| 696 |
+
'data': [
|
| 697 |
+
(r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
|
| 698 |
+
(r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
| 699 |
+
(r'\s+', Whitespace),
|
| 700 |
+
(r'[^=\s\[\]{}()$"\'`\\;#]+', Text),
|
| 701 |
+
(r'\d+(?= |\Z)', Number),
|
| 702 |
+
],
|
| 703 |
+
'curly': [
|
| 704 |
+
(r'\}', Keyword, '#pop'),
|
| 705 |
+
(r':-', Keyword),
|
| 706 |
+
(r'\w+', Name.Variable),
|
| 707 |
+
(r'[^}:"\'`$]+', Punctuation),
|
| 708 |
+
(r':', Punctuation),
|
| 709 |
+
include('root'),
|
| 710 |
+
],
|
| 711 |
+
'paren': [
|
| 712 |
+
(r'\)', Keyword, '#pop'),
|
| 713 |
+
include('root'),
|
| 714 |
+
],
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
class CrmshLexer(RegexLexer):
|
| 719 |
+
"""
|
| 720 |
+
Lexer for crmsh configuration files for Pacemaker clusters.
|
| 721 |
+
"""
|
| 722 |
+
name = 'Crmsh'
|
| 723 |
+
url = 'http://crmsh.github.io/'
|
| 724 |
+
aliases = ['crmsh', 'pcmk']
|
| 725 |
+
filenames = ['*.crmsh', '*.pcmk']
|
| 726 |
+
mimetypes = []
|
| 727 |
+
version_added = '2.1'
|
| 728 |
+
|
| 729 |
+
elem = words((
|
| 730 |
+
'node', 'primitive', 'group', 'clone', 'ms', 'location',
|
| 731 |
+
'colocation', 'order', 'fencing_topology', 'rsc_ticket',
|
| 732 |
+
'rsc_template', 'property', 'rsc_defaults',
|
| 733 |
+
'op_defaults', 'acl_target', 'acl_group', 'user', 'role',
|
| 734 |
+
'tag'), suffix=r'(?![\w#$-])')
|
| 735 |
+
sub = words((
|
| 736 |
+
'params', 'meta', 'operations', 'op', 'rule',
|
| 737 |
+
'attributes', 'utilization'), suffix=r'(?![\w#$-])')
|
| 738 |
+
acl = words(('read', 'write', 'deny'), suffix=r'(?![\w#$-])')
|
| 739 |
+
bin_rel = words(('and', 'or'), suffix=r'(?![\w#$-])')
|
| 740 |
+
un_ops = words(('defined', 'not_defined'), suffix=r'(?![\w#$-])')
|
| 741 |
+
date_exp = words(('in_range', 'date', 'spec', 'in'), suffix=r'(?![\w#$-])')
|
| 742 |
+
acl_mod = (r'(?:tag|ref|reference|attribute|type|xpath)')
|
| 743 |
+
bin_ops = (r'(?:lt|gt|lte|gte|eq|ne)')
|
| 744 |
+
val_qual = (r'(?:string|version|number)')
|
| 745 |
+
rsc_role_action = (r'(?:Master|Started|Slave|Stopped|'
|
| 746 |
+
r'start|promote|demote|stop)')
|
| 747 |
+
|
| 748 |
+
tokens = {
|
| 749 |
+
'root': [
|
| 750 |
+
(r'^(#.*)(\n)?', bygroups(Comment, Whitespace)),
|
| 751 |
+
# attr=value (nvpair)
|
| 752 |
+
(r'([\w#$-]+)(=)("(?:""|[^"])*"|\S+)',
|
| 753 |
+
bygroups(Name.Attribute, Punctuation, String)),
|
| 754 |
+
# need this construct, otherwise numeric node ids
|
| 755 |
+
# are matched as scores
|
| 756 |
+
# elem id:
|
| 757 |
+
(r'(node)(\s+)([\w#$-]+)(:)',
|
| 758 |
+
bygroups(Keyword, Whitespace, Name, Punctuation)),
|
| 759 |
+
# scores
|
| 760 |
+
(r'([+-]?([0-9]+|inf)):', Number),
|
| 761 |
+
# keywords (elements and other)
|
| 762 |
+
(elem, Keyword),
|
| 763 |
+
(sub, Keyword),
|
| 764 |
+
(acl, Keyword),
|
| 765 |
+
# binary operators
|
| 766 |
+
(rf'(?:{val_qual}:)?({bin_ops})(?![\w#$-])', Operator.Word),
|
| 767 |
+
# other operators
|
| 768 |
+
(bin_rel, Operator.Word),
|
| 769 |
+
(un_ops, Operator.Word),
|
| 770 |
+
(date_exp, Operator.Word),
|
| 771 |
+
# builtin attributes (e.g. #uname)
|
| 772 |
+
(r'#[a-z]+(?![\w#$-])', Name.Builtin),
|
| 773 |
+
# acl_mod:blah
|
| 774 |
+
(rf'({acl_mod})(:)("(?:""|[^"])*"|\S+)',
|
| 775 |
+
bygroups(Keyword, Punctuation, Name)),
|
| 776 |
+
# rsc_id[:(role|action)]
|
| 777 |
+
# NB: this matches all other identifiers
|
| 778 |
+
(rf'([\w#$-]+)(?:(:)({rsc_role_action}))?(?![\w#$-])',
|
| 779 |
+
bygroups(Name, Punctuation, Operator.Word)),
|
| 780 |
+
# punctuation
|
| 781 |
+
(r'(\\(?=\n)|[\[\](){}/:@])', Punctuation),
|
| 782 |
+
(r'\s+|\n', Whitespace),
|
| 783 |
+
],
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
|
| 787 |
+
class FlatlineLexer(RegexLexer):
|
| 788 |
+
"""
|
| 789 |
+
Lexer for Flatline expressions.
|
| 790 |
+
"""
|
| 791 |
+
name = 'Flatline'
|
| 792 |
+
url = 'https://github.com/bigmlcom/flatline'
|
| 793 |
+
aliases = ['flatline']
|
| 794 |
+
filenames = []
|
| 795 |
+
mimetypes = ['text/x-flatline']
|
| 796 |
+
version_added = '2.2'
|
| 797 |
+
|
| 798 |
+
special_forms = ('let',)
|
| 799 |
+
|
| 800 |
+
builtins = (
|
| 801 |
+
"!=", "*", "+", "-", "<", "<=", "=", ">", ">=", "abs", "acos", "all",
|
| 802 |
+
"all-but", "all-with-defaults", "all-with-numeric-default", "and",
|
| 803 |
+
"asin", "atan", "avg", "avg-window", "bin-center", "bin-count", "call",
|
| 804 |
+
"category-count", "ceil", "cond", "cond-window", "cons", "cos", "cosh",
|
| 805 |
+
"count", "diff-window", "div", "ensure-value", "ensure-weighted-value",
|
| 806 |
+
"epoch", "epoch-day", "epoch-fields", "epoch-hour", "epoch-millisecond",
|
| 807 |
+
"epoch-minute", "epoch-month", "epoch-second", "epoch-weekday",
|
| 808 |
+
"epoch-year", "exp", "f", "field", "field-prop", "fields", "filter",
|
| 809 |
+
"first", "floor", "head", "if", "in", "integer", "language", "length",
|
| 810 |
+
"levenshtein", "linear-regression", "list", "ln", "log", "log10", "map",
|
| 811 |
+
"matches", "matches?", "max", "maximum", "md5", "mean", "median", "min",
|
| 812 |
+
"minimum", "missing", "missing-count", "missing?", "missing_count",
|
| 813 |
+
"mod", "mode", "normalize", "not", "nth", "occurrences", "or",
|
| 814 |
+
"percentile", "percentile-label", "population", "population-fraction",
|
| 815 |
+
"pow", "preferred", "preferred?", "quantile-label", "rand", "rand-int",
|
| 816 |
+
"random-value", "re-quote", "real", "replace", "replace-first", "rest",
|
| 817 |
+
"round", "row-number", "segment-label", "sha1", "sha256", "sin", "sinh",
|
| 818 |
+
"sqrt", "square", "standard-deviation", "standard_deviation", "str",
|
| 819 |
+
"subs", "sum", "sum-squares", "sum-window", "sum_squares", "summary",
|
| 820 |
+
"summary-no", "summary-str", "tail", "tan", "tanh", "to-degrees",
|
| 821 |
+
"to-radians", "variance", "vectorize", "weighted-random-value", "window",
|
| 822 |
+
"winnow", "within-percentiles?", "z-score",
|
| 823 |
+
)
|
| 824 |
+
|
| 825 |
+
valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+'
|
| 826 |
+
|
| 827 |
+
tokens = {
|
| 828 |
+
'root': [
|
| 829 |
+
# whitespaces - usually not relevant
|
| 830 |
+
(r'[,]+', Text),
|
| 831 |
+
(r'\s+', Whitespace),
|
| 832 |
+
|
| 833 |
+
# numbers
|
| 834 |
+
(r'-?\d+\.\d+', Number.Float),
|
| 835 |
+
(r'-?\d+', Number.Integer),
|
| 836 |
+
(r'0x-?[a-f\d]+', Number.Hex),
|
| 837 |
+
|
| 838 |
+
# strings, symbols and characters
|
| 839 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 840 |
+
(r"\\(.|[a-z]+)", String.Char),
|
| 841 |
+
|
| 842 |
+
# expression template placeholder
|
| 843 |
+
(r'_', String.Symbol),
|
| 844 |
+
|
| 845 |
+
# highlight the special forms
|
| 846 |
+
(words(special_forms, suffix=' '), Keyword),
|
| 847 |
+
|
| 848 |
+
# highlight the builtins
|
| 849 |
+
(words(builtins, suffix=' '), Name.Builtin),
|
| 850 |
+
|
| 851 |
+
# the remaining functions
|
| 852 |
+
(r'(?<=\()' + valid_name, Name.Function),
|
| 853 |
+
|
| 854 |
+
# find the remaining variables
|
| 855 |
+
(valid_name, Name.Variable),
|
| 856 |
+
|
| 857 |
+
# parentheses
|
| 858 |
+
(r'(\(|\))', Punctuation),
|
| 859 |
+
],
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
+
|
| 863 |
+
class SnowballLexer(ExtendedRegexLexer):
|
| 864 |
+
"""
|
| 865 |
+
Lexer for Snowball source code.
|
| 866 |
+
"""
|
| 867 |
+
|
| 868 |
+
name = 'Snowball'
|
| 869 |
+
url = 'https://snowballstem.org/'
|
| 870 |
+
aliases = ['snowball']
|
| 871 |
+
filenames = ['*.sbl']
|
| 872 |
+
version_added = '2.2'
|
| 873 |
+
|
| 874 |
+
_ws = r'\n\r\t '
|
| 875 |
+
|
| 876 |
+
def __init__(self, **options):
|
| 877 |
+
self._reset_stringescapes()
|
| 878 |
+
ExtendedRegexLexer.__init__(self, **options)
|
| 879 |
+
|
| 880 |
+
def _reset_stringescapes(self):
|
| 881 |
+
self._start = "'"
|
| 882 |
+
self._end = "'"
|
| 883 |
+
|
| 884 |
+
def _string(do_string_first):
|
| 885 |
+
def callback(lexer, match, ctx):
|
| 886 |
+
s = match.start()
|
| 887 |
+
text = match.group()
|
| 888 |
+
string = re.compile(rf'([^{re.escape(lexer._start)}]*)(.)').match
|
| 889 |
+
escape = re.compile(rf'([^{re.escape(lexer._end)}]*)(.)').match
|
| 890 |
+
pos = 0
|
| 891 |
+
do_string = do_string_first
|
| 892 |
+
while pos < len(text):
|
| 893 |
+
if do_string:
|
| 894 |
+
match = string(text, pos)
|
| 895 |
+
yield s + match.start(1), String.Single, match.group(1)
|
| 896 |
+
if match.group(2) == "'":
|
| 897 |
+
yield s + match.start(2), String.Single, match.group(2)
|
| 898 |
+
ctx.stack.pop()
|
| 899 |
+
break
|
| 900 |
+
yield s + match.start(2), String.Escape, match.group(2)
|
| 901 |
+
pos = match.end()
|
| 902 |
+
match = escape(text, pos)
|
| 903 |
+
yield s + match.start(), String.Escape, match.group()
|
| 904 |
+
if match.group(2) != lexer._end:
|
| 905 |
+
ctx.stack[-1] = 'escape'
|
| 906 |
+
break
|
| 907 |
+
pos = match.end()
|
| 908 |
+
do_string = True
|
| 909 |
+
ctx.pos = s + match.end()
|
| 910 |
+
return callback
|
| 911 |
+
|
| 912 |
+
def _stringescapes(lexer, match, ctx):
|
| 913 |
+
lexer._start = match.group(3)
|
| 914 |
+
lexer._end = match.group(5)
|
| 915 |
+
return bygroups(Keyword.Reserved, Whitespace, String.Escape, Whitespace,
|
| 916 |
+
String.Escape)(lexer, match, ctx)
|
| 917 |
+
|
| 918 |
+
tokens = {
|
| 919 |
+
'root': [
|
| 920 |
+
(r'len\b', Name.Builtin),
|
| 921 |
+
(r'lenof\b', Operator.Word),
|
| 922 |
+
include('root1'),
|
| 923 |
+
],
|
| 924 |
+
'root1': [
|
| 925 |
+
(rf'[{_ws}]+', Whitespace),
|
| 926 |
+
(r'\d+', Number.Integer),
|
| 927 |
+
(r"'", String.Single, 'string'),
|
| 928 |
+
(r'[()]', Punctuation),
|
| 929 |
+
(r'/\*[\w\W]*?\*/', Comment.Multiline),
|
| 930 |
+
(r'//.*', Comment.Single),
|
| 931 |
+
(r'[!*+\-/<=>]=|[-=]>|<[+-]|[$*+\-/<=>?\[\]]', Operator),
|
| 932 |
+
(words(('as', 'get', 'hex', 'among', 'define', 'decimal',
|
| 933 |
+
'backwardmode'), suffix=r'\b'),
|
| 934 |
+
Keyword.Reserved),
|
| 935 |
+
(words(('strings', 'booleans', 'integers', 'routines', 'externals',
|
| 936 |
+
'groupings'), suffix=r'\b'),
|
| 937 |
+
Keyword.Reserved, 'declaration'),
|
| 938 |
+
(words(('do', 'or', 'and', 'for', 'hop', 'non', 'not', 'set', 'try',
|
| 939 |
+
'fail', 'goto', 'loop', 'next', 'test', 'true',
|
| 940 |
+
'false', 'unset', 'atmark', 'attach', 'delete', 'gopast',
|
| 941 |
+
'insert', 'repeat', 'sizeof', 'tomark', 'atleast',
|
| 942 |
+
'atlimit', 'reverse', 'setmark', 'tolimit', 'setlimit',
|
| 943 |
+
'backwards', 'substring'), suffix=r'\b'),
|
| 944 |
+
Operator.Word),
|
| 945 |
+
(words(('size', 'limit', 'cursor', 'maxint', 'minint'),
|
| 946 |
+
suffix=r'\b'),
|
| 947 |
+
Name.Builtin),
|
| 948 |
+
(rf'(stringdef\b)([{_ws}]*)([^{_ws}]+)',
|
| 949 |
+
bygroups(Keyword.Reserved, Whitespace, String.Escape)),
|
| 950 |
+
(rf'(stringescapes\b)([{_ws}]*)(.)([{_ws}]*)(.)',
|
| 951 |
+
_stringescapes),
|
| 952 |
+
(r'[A-Za-z]\w*', Name),
|
| 953 |
+
],
|
| 954 |
+
'declaration': [
|
| 955 |
+
(r'\)', Punctuation, '#pop'),
|
| 956 |
+
(words(('len', 'lenof'), suffix=r'\b'), Name,
|
| 957 |
+
('root1', 'declaration')),
|
| 958 |
+
include('root1'),
|
| 959 |
+
],
|
| 960 |
+
'string': [
|
| 961 |
+
(r"[^']*'", _string(True)),
|
| 962 |
+
],
|
| 963 |
+
'escape': [
|
| 964 |
+
(r"[^']*'", _string(False)),
|
| 965 |
+
],
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
def get_tokens_unprocessed(self, text=None, context=None):
|
| 969 |
+
self._reset_stringescapes()
|
| 970 |
+
return ExtendedRegexLexer.get_tokens_unprocessed(self, text, context)
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/dylan.py
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.dylan
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Dylan language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \
|
| 14 |
+
default, line_re
|
| 15 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Generic, Literal, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['DylanLexer', 'DylanConsoleLexer', 'DylanLidLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DylanLexer(RegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
For the Dylan language.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'Dylan'
|
| 27 |
+
url = 'http://www.opendylan.org/'
|
| 28 |
+
aliases = ['dylan']
|
| 29 |
+
filenames = ['*.dylan', '*.dyl', '*.intr']
|
| 30 |
+
mimetypes = ['text/x-dylan']
|
| 31 |
+
version_added = '0.7'
|
| 32 |
+
|
| 33 |
+
flags = re.IGNORECASE
|
| 34 |
+
|
| 35 |
+
builtins = {
|
| 36 |
+
'subclass', 'abstract', 'block', 'concrete', 'constant', 'class',
|
| 37 |
+
'compiler-open', 'compiler-sideways', 'domain', 'dynamic',
|
| 38 |
+
'each-subclass', 'exception', 'exclude', 'function', 'generic',
|
| 39 |
+
'handler', 'inherited', 'inline', 'inline-only', 'instance',
|
| 40 |
+
'interface', 'import', 'keyword', 'library', 'macro', 'method',
|
| 41 |
+
'module', 'open', 'primary', 'required', 'sealed', 'sideways',
|
| 42 |
+
'singleton', 'slot', 'thread', 'variable', 'virtual'}
|
| 43 |
+
|
| 44 |
+
keywords = {
|
| 45 |
+
'above', 'afterwards', 'begin', 'below', 'by', 'case', 'cleanup',
|
| 46 |
+
'create', 'define', 'else', 'elseif', 'end', 'export', 'finally',
|
| 47 |
+
'for', 'from', 'if', 'in', 'let', 'local', 'otherwise', 'rename',
|
| 48 |
+
'select', 'signal', 'then', 'to', 'unless', 'until', 'use', 'when',
|
| 49 |
+
'while'}
|
| 50 |
+
|
| 51 |
+
operators = {
|
| 52 |
+
'~', '+', '-', '*', '|', '^', '=', '==', '~=', '~==', '<', '<=',
|
| 53 |
+
'>', '>=', '&', '|'}
|
| 54 |
+
|
| 55 |
+
functions = {
|
| 56 |
+
'abort', 'abs', 'add', 'add!', 'add-method', 'add-new', 'add-new!',
|
| 57 |
+
'all-superclasses', 'always', 'any?', 'applicable-method?', 'apply',
|
| 58 |
+
'aref', 'aref-setter', 'as', 'as-lowercase', 'as-lowercase!',
|
| 59 |
+
'as-uppercase', 'as-uppercase!', 'ash', 'backward-iteration-protocol',
|
| 60 |
+
'break', 'ceiling', 'ceiling/', 'cerror', 'check-type', 'choose',
|
| 61 |
+
'choose-by', 'complement', 'compose', 'concatenate', 'concatenate-as',
|
| 62 |
+
'condition-format-arguments', 'condition-format-string', 'conjoin',
|
| 63 |
+
'copy-sequence', 'curry', 'default-handler', 'dimension', 'dimensions',
|
| 64 |
+
'direct-subclasses', 'direct-superclasses', 'disjoin', 'do',
|
| 65 |
+
'do-handlers', 'element', 'element-setter', 'empty?', 'error', 'even?',
|
| 66 |
+
'every?', 'false-or', 'fill!', 'find-key', 'find-method', 'first',
|
| 67 |
+
'first-setter', 'floor', 'floor/', 'forward-iteration-protocol',
|
| 68 |
+
'function-arguments', 'function-return-values',
|
| 69 |
+
'function-specializers', 'gcd', 'generic-function-mandatory-keywords',
|
| 70 |
+
'generic-function-methods', 'head', 'head-setter', 'identity',
|
| 71 |
+
'initialize', 'instance?', 'integral?', 'intersection',
|
| 72 |
+
'key-sequence', 'key-test', 'last', 'last-setter', 'lcm', 'limited',
|
| 73 |
+
'list', 'logand', 'logbit?', 'logior', 'lognot', 'logxor', 'make',
|
| 74 |
+
'map', 'map-as', 'map-into', 'max', 'member?', 'merge-hash-codes',
|
| 75 |
+
'min', 'modulo', 'negative', 'negative?', 'next-method',
|
| 76 |
+
'object-class', 'object-hash', 'odd?', 'one-of', 'pair', 'pop',
|
| 77 |
+
'pop-last', 'positive?', 'push', 'push-last', 'range', 'rank',
|
| 78 |
+
'rcurry', 'reduce', 'reduce1', 'remainder', 'remove', 'remove!',
|
| 79 |
+
'remove-duplicates', 'remove-duplicates!', 'remove-key!',
|
| 80 |
+
'remove-method', 'replace-elements!', 'replace-subsequence!',
|
| 81 |
+
'restart-query', 'return-allowed?', 'return-description',
|
| 82 |
+
'return-query', 'reverse', 'reverse!', 'round', 'round/',
|
| 83 |
+
'row-major-index', 'second', 'second-setter', 'shallow-copy',
|
| 84 |
+
'signal', 'singleton', 'size', 'size-setter', 'slot-initialized?',
|
| 85 |
+
'sort', 'sort!', 'sorted-applicable-methods', 'subsequence-position',
|
| 86 |
+
'subtype?', 'table-protocol', 'tail', 'tail-setter', 'third',
|
| 87 |
+
'third-setter', 'truncate', 'truncate/', 'type-error-expected-type',
|
| 88 |
+
'type-error-value', 'type-for-copy', 'type-union', 'union', 'values',
|
| 89 |
+
'vector', 'zero?'}
|
| 90 |
+
|
| 91 |
+
valid_name = '\\\\?[\\w!&*<>|^$%@\\-+~?/=]+'
|
| 92 |
+
|
| 93 |
+
def get_tokens_unprocessed(self, text):
|
| 94 |
+
for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
|
| 95 |
+
if token is Name:
|
| 96 |
+
lowercase_value = value.lower()
|
| 97 |
+
if lowercase_value in self.builtins:
|
| 98 |
+
yield index, Name.Builtin, value
|
| 99 |
+
continue
|
| 100 |
+
if lowercase_value in self.keywords:
|
| 101 |
+
yield index, Keyword, value
|
| 102 |
+
continue
|
| 103 |
+
if lowercase_value in self.functions:
|
| 104 |
+
yield index, Name.Builtin, value
|
| 105 |
+
continue
|
| 106 |
+
if lowercase_value in self.operators:
|
| 107 |
+
yield index, Operator, value
|
| 108 |
+
continue
|
| 109 |
+
yield index, token, value
|
| 110 |
+
|
| 111 |
+
tokens = {
|
| 112 |
+
'root': [
|
| 113 |
+
# Whitespace
|
| 114 |
+
(r'\s+', Whitespace),
|
| 115 |
+
|
| 116 |
+
# single line comment
|
| 117 |
+
(r'//.*?\n', Comment.Single),
|
| 118 |
+
|
| 119 |
+
# lid header
|
| 120 |
+
(r'([a-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
|
| 121 |
+
bygroups(Name.Attribute, Operator, Whitespace, String)),
|
| 122 |
+
|
| 123 |
+
default('code') # no header match, switch to code
|
| 124 |
+
],
|
| 125 |
+
'code': [
|
| 126 |
+
# Whitespace
|
| 127 |
+
(r'\s+', Whitespace),
|
| 128 |
+
|
| 129 |
+
# single line comment
|
| 130 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 131 |
+
|
| 132 |
+
# multi-line comment
|
| 133 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 134 |
+
|
| 135 |
+
# strings and characters
|
| 136 |
+
(r'"', String, 'string'),
|
| 137 |
+
(r"'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 138 |
+
|
| 139 |
+
# binary integer
|
| 140 |
+
(r'#b[01]+', Number.Bin),
|
| 141 |
+
|
| 142 |
+
# octal integer
|
| 143 |
+
(r'#o[0-7]+', Number.Oct),
|
| 144 |
+
|
| 145 |
+
# floating point
|
| 146 |
+
(r'[-+]?(\d*\.\d+(e[-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)', Number.Float),
|
| 147 |
+
|
| 148 |
+
# decimal integer
|
| 149 |
+
(r'[-+]?\d+', Number.Integer),
|
| 150 |
+
|
| 151 |
+
# hex integer
|
| 152 |
+
(r'#x[0-9a-f]+', Number.Hex),
|
| 153 |
+
|
| 154 |
+
# Macro parameters
|
| 155 |
+
(r'(\?' + valid_name + ')(:)'
|
| 156 |
+
r'(token|name|variable|expression|body|case-body|\*)',
|
| 157 |
+
bygroups(Name.Tag, Operator, Name.Builtin)),
|
| 158 |
+
(r'(\?)(:)(token|name|variable|expression|body|case-body|\*)',
|
| 159 |
+
bygroups(Name.Tag, Operator, Name.Builtin)),
|
| 160 |
+
(r'\?' + valid_name, Name.Tag),
|
| 161 |
+
|
| 162 |
+
# Punctuation
|
| 163 |
+
(r'(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])', Punctuation),
|
| 164 |
+
|
| 165 |
+
# Most operators are picked up as names and then re-flagged.
|
| 166 |
+
# This one isn't valid in a name though, so we pick it up now.
|
| 167 |
+
(r':=', Operator),
|
| 168 |
+
|
| 169 |
+
# Pick up #t / #f before we match other stuff with #.
|
| 170 |
+
(r'#[tf]', Literal),
|
| 171 |
+
|
| 172 |
+
# #"foo" style keywords
|
| 173 |
+
(r'#"', String.Symbol, 'keyword'),
|
| 174 |
+
|
| 175 |
+
# #rest, #key, #all-keys, etc.
|
| 176 |
+
(r'#[a-z0-9-]+', Keyword),
|
| 177 |
+
|
| 178 |
+
# required-init-keyword: style keywords.
|
| 179 |
+
(valid_name + ':', Keyword),
|
| 180 |
+
|
| 181 |
+
# class names
|
| 182 |
+
('<' + valid_name + '>', Name.Class),
|
| 183 |
+
|
| 184 |
+
# define variable forms.
|
| 185 |
+
(r'\*' + valid_name + r'\*', Name.Variable.Global),
|
| 186 |
+
|
| 187 |
+
# define constant forms.
|
| 188 |
+
(r'\$' + valid_name, Name.Constant),
|
| 189 |
+
|
| 190 |
+
# everything else. We re-flag some of these in the method above.
|
| 191 |
+
(valid_name, Name),
|
| 192 |
+
],
|
| 193 |
+
'comment': [
|
| 194 |
+
(r'[^*/]+', Comment.Multiline),
|
| 195 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 196 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 197 |
+
(r'[*/]', Comment.Multiline)
|
| 198 |
+
],
|
| 199 |
+
'keyword': [
|
| 200 |
+
(r'"', String.Symbol, '#pop'),
|
| 201 |
+
(r'[^\\"]+', String.Symbol), # all other characters
|
| 202 |
+
],
|
| 203 |
+
'string': [
|
| 204 |
+
(r'"', String, '#pop'),
|
| 205 |
+
(r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 206 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 207 |
+
(r'\\\n', String), # line continuation
|
| 208 |
+
(r'\\', String), # stray backslash
|
| 209 |
+
]
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
class DylanLidLexer(RegexLexer):
|
| 214 |
+
"""
|
| 215 |
+
For Dylan LID (Library Interchange Definition) files.
|
| 216 |
+
"""
|
| 217 |
+
|
| 218 |
+
name = 'DylanLID'
|
| 219 |
+
aliases = ['dylan-lid', 'lid']
|
| 220 |
+
filenames = ['*.lid', '*.hdp']
|
| 221 |
+
mimetypes = ['text/x-dylan-lid']
|
| 222 |
+
url = 'http://www.opendylan.org/'
|
| 223 |
+
version_added = '1.6'
|
| 224 |
+
flags = re.IGNORECASE
|
| 225 |
+
|
| 226 |
+
tokens = {
|
| 227 |
+
'root': [
|
| 228 |
+
# Whitespace
|
| 229 |
+
(r'\s+', Whitespace),
|
| 230 |
+
|
| 231 |
+
# single line comment
|
| 232 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 233 |
+
|
| 234 |
+
# lid header
|
| 235 |
+
(r'(.*?)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
|
| 236 |
+
bygroups(Name.Attribute, Operator, Whitespace, String)),
|
| 237 |
+
]
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class DylanConsoleLexer(Lexer):
|
| 242 |
+
"""
|
| 243 |
+
For Dylan interactive console output.
|
| 244 |
+
|
| 245 |
+
This is based on a copy of the ``RubyConsoleLexer``.
|
| 246 |
+
"""
|
| 247 |
+
name = 'Dylan session'
|
| 248 |
+
aliases = ['dylan-console', 'dylan-repl']
|
| 249 |
+
filenames = ['*.dylan-console']
|
| 250 |
+
mimetypes = ['text/x-dylan-console']
|
| 251 |
+
url = 'http://www.opendylan.org/'
|
| 252 |
+
version_added = '1.6'
|
| 253 |
+
_example = 'dylan-console/console.dylan-console'
|
| 254 |
+
|
| 255 |
+
_prompt_re = re.compile(r'\?| ')
|
| 256 |
+
|
| 257 |
+
def get_tokens_unprocessed(self, text):
|
| 258 |
+
dylexer = DylanLexer(**self.options)
|
| 259 |
+
|
| 260 |
+
curcode = ''
|
| 261 |
+
insertions = []
|
| 262 |
+
for match in line_re.finditer(text):
|
| 263 |
+
line = match.group()
|
| 264 |
+
m = self._prompt_re.match(line)
|
| 265 |
+
if m is not None:
|
| 266 |
+
end = m.end()
|
| 267 |
+
insertions.append((len(curcode),
|
| 268 |
+
[(0, Generic.Prompt, line[:end])]))
|
| 269 |
+
curcode += line[end:]
|
| 270 |
+
else:
|
| 271 |
+
if curcode:
|
| 272 |
+
yield from do_insertions(insertions,
|
| 273 |
+
dylexer.get_tokens_unprocessed(curcode))
|
| 274 |
+
curcode = ''
|
| 275 |
+
insertions = []
|
| 276 |
+
yield match.start(), Generic.Output, line
|
| 277 |
+
if curcode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ygments.lexers.ecl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the ECL language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, words
|
| 14 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['ECLLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class ECLLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for the declarative big-data ECL language.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'ECL'
|
| 26 |
+
url = 'https://hpccsystems.com/training/documentation/ecl-language-reference/html'
|
| 27 |
+
aliases = ['ecl']
|
| 28 |
+
filenames = ['*.ecl']
|
| 29 |
+
mimetypes = ['application/x-ecl']
|
| 30 |
+
version_added = '1.5'
|
| 31 |
+
|
| 32 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
include('whitespace'),
|
| 37 |
+
include('statements'),
|
| 38 |
+
],
|
| 39 |
+
'whitespace': [
|
| 40 |
+
(r'\s+', Whitespace),
|
| 41 |
+
(r'\/\/.*', Comment.Single),
|
| 42 |
+
(r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
|
| 43 |
+
],
|
| 44 |
+
'statements': [
|
| 45 |
+
include('types'),
|
| 46 |
+
include('keywords'),
|
| 47 |
+
include('functions'),
|
| 48 |
+
include('hash'),
|
| 49 |
+
(r'"', String, 'string'),
|
| 50 |
+
(r'\'', String, 'string'),
|
| 51 |
+
(r'(\d+\.\d*|\.\d+|\d+)e[+-]?\d+[lu]*', Number.Float),
|
| 52 |
+
(r'(\d+\.\d*|\.\d+|\d+f)f?', Number.Float),
|
| 53 |
+
(r'0x[0-9a-f]+[lu]*', Number.Hex),
|
| 54 |
+
(r'0[0-7]+[lu]*', Number.Oct),
|
| 55 |
+
(r'\d+[lu]*', Number.Integer),
|
| 56 |
+
(r'[~!%^&*+=|?:<>/-]+', Operator),
|
| 57 |
+
(r'[{}()\[\],.;]', Punctuation),
|
| 58 |
+
(r'[a-z_]\w*', Name),
|
| 59 |
+
],
|
| 60 |
+
'hash': [
|
| 61 |
+
(r'^#.*$', Comment.Preproc),
|
| 62 |
+
],
|
| 63 |
+
'types': [
|
| 64 |
+
(r'(RECORD|END)\D', Keyword.Declaration),
|
| 65 |
+
(r'((?:ASCII|BIG_ENDIAN|BOOLEAN|DATA|DECIMAL|EBCDIC|INTEGER|PATTERN|'
|
| 66 |
+
r'QSTRING|REAL|RECORD|RULE|SET OF|STRING|TOKEN|UDECIMAL|UNICODE|'
|
| 67 |
+
r'UNSIGNED|VARSTRING|VARUNICODE)\d*)(\s+)',
|
| 68 |
+
bygroups(Keyword.Type, Whitespace)),
|
| 69 |
+
],
|
| 70 |
+
'keywords': [
|
| 71 |
+
(words((
|
| 72 |
+
'APPLY', 'ASSERT', 'BUILD', 'BUILDINDEX', 'EVALUATE', 'FAIL',
|
| 73 |
+
'KEYDIFF', 'KEYPATCH', 'LOADXML', 'NOTHOR', 'NOTIFY', 'OUTPUT',
|
| 74 |
+
'PARALLEL', 'SEQUENTIAL', 'SOAPCALL', 'CHECKPOINT', 'DEPRECATED',
|
| 75 |
+
'FAILCODE', 'FAILMESSAGE', 'FAILURE', 'GLOBAL', 'INDEPENDENT',
|
| 76 |
+
'ONWARNING', 'PERSIST', 'PRIORITY', 'RECOVERY', 'STORED', 'SUCCESS',
|
| 77 |
+
'WAIT', 'WHEN'), suffix=r'\b'),
|
| 78 |
+
Keyword.Reserved),
|
| 79 |
+
# These are classed differently, check later
|
| 80 |
+
(words((
|
| 81 |
+
'ALL', 'AND', 'ANY', 'AS', 'ATMOST', 'BEFORE', 'BEGINC++', 'BEST',
|
| 82 |
+
'BETWEEN', 'CASE', 'CONST', 'COUNTER', 'CSV', 'DESCEND', 'ENCRYPT',
|
| 83 |
+
'ENDC++', 'ENDMACRO', 'EXCEPT', 'EXCLUSIVE', 'EXPIRE', 'EXPORT',
|
| 84 |
+
'EXTEND', 'FALSE', 'FEW', 'FIRST', 'FLAT', 'FULL', 'FUNCTION',
|
| 85 |
+
'GROUP', 'HEADER', 'HEADING', 'HOLE', 'IFBLOCK', 'IMPORT', 'IN',
|
| 86 |
+
'JOINED', 'KEEP', 'KEYED', 'LAST', 'LEFT', 'LIMIT', 'LOAD', 'LOCAL',
|
| 87 |
+
'LOCALE', 'LOOKUP', 'MACRO', 'MANY', 'MAXCOUNT', 'MAXLENGTH',
|
| 88 |
+
'MIN SKEW', 'MODULE', 'INTERFACE', 'NAMED', 'NOCASE', 'NOROOT',
|
| 89 |
+
'NOSCAN', 'NOSORT', 'NOT', 'OF', 'ONLY', 'OPT', 'OR', 'OUTER',
|
| 90 |
+
'OVERWRITE', 'PACKED', 'PARTITION', 'PENALTY', 'PHYSICALLENGTH',
|
| 91 |
+
'PIPE', 'QUOTE', 'RELATIONSHIP', 'REPEAT', 'RETURN', 'RIGHT',
|
| 92 |
+
'SCAN', 'SELF', 'SEPARATOR', 'SERVICE', 'SHARED', 'SKEW', 'SKIP',
|
| 93 |
+
'SQL', 'STORE', 'TERMINATOR', 'THOR', 'THRESHOLD', 'TOKEN',
|
| 94 |
+
'TRANSFORM', 'TRIM', 'TRUE', 'TYPE', 'UNICODEORDER', 'UNSORTED',
|
| 95 |
+
'VALIDATE', 'VIRTUAL', 'WHOLE', 'WILD', 'WITHIN', 'XML', 'XPATH',
|
| 96 |
+
'__COMPRESSED__'), suffix=r'\b'),
|
| 97 |
+
Keyword.Reserved),
|
| 98 |
+
],
|
| 99 |
+
'functions': [
|
| 100 |
+
(words((
|
| 101 |
+
'ABS', 'ACOS', 'ALLNODES', 'ASCII', 'ASIN', 'ASSTRING', 'ATAN',
|
| 102 |
+
'ATAN2', 'AVE', 'CASE', 'CHOOSE', 'CHOOSEN', 'CHOOSESETS',
|
| 103 |
+
'CLUSTERSIZE', 'COMBINE', 'CORRELATION', 'COS', 'COSH', 'COUNT',
|
| 104 |
+
'COVARIANCE', 'CRON', 'DATASET', 'DEDUP', 'DEFINE', 'DENORMALIZE',
|
| 105 |
+
'DISTRIBUTE', 'DISTRIBUTED', 'DISTRIBUTION', 'EBCDIC', 'ENTH',
|
| 106 |
+
'ERROR', 'EVALUATE', 'EVENT', 'EVENTEXTRA', 'EVENTNAME', 'EXISTS',
|
| 107 |
+
'EXP', 'FAILCODE', 'FAILMESSAGE', 'FETCH', 'FROMUNICODE',
|
| 108 |
+
'GETISVALID', 'GLOBAL', 'GRAPH', 'GROUP', 'HASH', 'HASH32',
|
| 109 |
+
'HASH64', 'HASHCRC', 'HASHMD5', 'HAVING', 'IF', 'INDEX',
|
| 110 |
+
'INTFORMAT', 'ISVALID', 'ITERATE', 'JOIN', 'KEYUNICODE', 'LENGTH',
|
| 111 |
+
'LIBRARY', 'LIMIT', 'LN', 'LOCAL', 'LOG', 'LOOP', 'MAP', 'MATCHED',
|
| 112 |
+
'MATCHLENGTH', 'MATCHPOSITION', 'MATCHTEXT', 'MATCHUNICODE', 'MAX',
|
| 113 |
+
'MERGE', 'MERGEJOIN', 'MIN', 'NOLOCAL', 'NONEMPTY', 'NORMALIZE',
|
| 114 |
+
'PARSE', 'PIPE', 'POWER', 'PRELOAD', 'PROCESS', 'PROJECT', 'PULL',
|
| 115 |
+
'RANDOM', 'RANGE', 'RANK', 'RANKED', 'REALFORMAT', 'RECORDOF',
|
| 116 |
+
'REGEXFIND', 'REGEXREPLACE', 'REGROUP', 'REJECTED', 'ROLLUP',
|
| 117 |
+
'ROUND', 'ROUNDUP', 'ROW', 'ROWDIFF', 'SAMPLE', 'SET', 'SIN',
|
| 118 |
+
'SINH', 'SIZEOF', 'SOAPCALL', 'SORT', 'SORTED', 'SQRT', 'STEPPED',
|
| 119 |
+
'STORED', 'SUM', 'TABLE', 'TAN', 'TANH', 'THISNODE', 'TOPN',
|
| 120 |
+
'TOUNICODE', 'TRANSFER', 'TRIM', 'TRUNCATE', 'TYPEOF', 'UNGROUP',
|
| 121 |
+
'UNICODEORDER', 'VARIANCE', 'WHICH', 'WORKUNIT', 'XMLDECODE',
|
| 122 |
+
'XMLENCODE', 'XMLTEXT', 'XMLUNICODE'), suffix=r'\b'),
|
| 123 |
+
Name.Function),
|
| 124 |
+
],
|
| 125 |
+
'string': [
|
| 126 |
+
(r'"', String, '#pop'),
|
| 127 |
+
(r'\'', String, '#pop'),
|
| 128 |
+
(r'[^"\']+', String),
|
| 129 |
+
],
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
def analyse_text(text):
|
| 133 |
+
"""This is very difficult to guess relative to other business languages.
|
| 134 |
+
-> in conjunction with BEGIN/END seems relatively rare though."""
|
| 135 |
+
result = 0
|
| 136 |
+
|
| 137 |
+
if '->' in text:
|
| 138 |
+
result += 0.01
|
| 139 |
+
if 'BEGIN' in text:
|
| 140 |
+
result += 0.01
|
| 141 |
+
if 'END' in text:
|
| 142 |
+
result += 0.01
|
| 143 |
+
|
| 144 |
+
return result
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/eiffel.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.eiffel
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Eiffel language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, words, bygroups
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['EiffelLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class EiffelLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Eiffel source code.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Eiffel'
|
| 23 |
+
url = 'https://www.eiffel.com'
|
| 24 |
+
aliases = ['eiffel']
|
| 25 |
+
filenames = ['*.e']
|
| 26 |
+
mimetypes = ['text/x-eiffel']
|
| 27 |
+
version_added = '2.0'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'[^\S\n]+', Whitespace),
|
| 32 |
+
(r'--.*?$', Comment.Single),
|
| 33 |
+
(r'[^\S\n]+', Whitespace),
|
| 34 |
+
# Please note that keyword and operator are case insensitive.
|
| 35 |
+
(r'(?i)(true|false|void|current|result|precursor)\b', Keyword.Constant),
|
| 36 |
+
(r'(?i)(not|xor|implies|or)\b', Operator.Word),
|
| 37 |
+
(r'(?i)(and)(?:(\s+)(then))?\b',
|
| 38 |
+
bygroups(Operator.Word, Whitespace, Operator.Word)),
|
| 39 |
+
(r'(?i)(or)(?:(\s+)(else))?\b',
|
| 40 |
+
bygroups(Operator.Word, Whitespace, Operator.Word)),
|
| 41 |
+
(words((
|
| 42 |
+
'across', 'agent', 'alias', 'all', 'as', 'assign', 'attached',
|
| 43 |
+
'attribute', 'check', 'class', 'convert', 'create', 'debug',
|
| 44 |
+
'deferred', 'detachable', 'do', 'else', 'elseif', 'end', 'ensure',
|
| 45 |
+
'expanded', 'export', 'external', 'feature', 'from', 'frozen', 'if',
|
| 46 |
+
'inherit', 'inspect', 'invariant', 'like', 'local', 'loop', 'none',
|
| 47 |
+
'note', 'obsolete', 'old', 'once', 'only', 'redefine', 'rename',
|
| 48 |
+
'require', 'rescue', 'retry', 'select', 'separate', 'then',
|
| 49 |
+
'undefine', 'until', 'variant', 'when'), prefix=r'(?i)\b', suffix=r'\b'),
|
| 50 |
+
Keyword.Reserved),
|
| 51 |
+
(r'"\[([^\]%]|%(.|\n)|\][^"])*?\]"', String),
|
| 52 |
+
(r'"([^"%\n]|%.)*?"', String),
|
| 53 |
+
include('numbers'),
|
| 54 |
+
(r"'([^'%]|%'|%%)'", String.Char),
|
| 55 |
+
(r"(//|\\\\|>=|<=|:=|/=|~|/~|[\\?!#%&@|+/\-=>*$<^\[\]])", Operator),
|
| 56 |
+
(r"([{}():;,.])", Punctuation),
|
| 57 |
+
(r'([a-z]\w*)|([A-Z][A-Z0-9_]*[a-z]\w*)', Name),
|
| 58 |
+
(r'([A-Z][A-Z0-9_]*)', Name.Class),
|
| 59 |
+
(r'\n+', Whitespace),
|
| 60 |
+
],
|
| 61 |
+
'numbers': [
|
| 62 |
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
| 63 |
+
(r'0[bB][01]+', Number.Bin),
|
| 64 |
+
(r'0[cC][0-7]+', Number.Oct),
|
| 65 |
+
(r'([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)', Number.Float),
|
| 66 |
+
(r'[0-9]+', Number.Integer),
|
| 67 |
+
],
|
| 68 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/elm.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.elm
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Elm programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, include, bygroups
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Punctuation, \
|
| 13 |
+
String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['ElmLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ElmLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Elm source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Elm'
|
| 24 |
+
url = 'https://elm-lang.org/'
|
| 25 |
+
aliases = ['elm']
|
| 26 |
+
filenames = ['*.elm']
|
| 27 |
+
mimetypes = ['text/x-elm']
|
| 28 |
+
version_added = '2.1'
|
| 29 |
+
|
| 30 |
+
validName = r'[a-z_][a-zA-Z0-9_\']*'
|
| 31 |
+
|
| 32 |
+
specialName = r'^main '
|
| 33 |
+
|
| 34 |
+
builtinOps = (
|
| 35 |
+
'~', '||', '|>', '|', '`', '^', '\\', '\'', '>>', '>=', '>', '==',
|
| 36 |
+
'=', '<~', '<|', '<=', '<<', '<-', '<', '::', ':', '/=', '//', '/',
|
| 37 |
+
'..', '.', '->', '-', '++', '+', '*', '&&', '%',
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
reservedWords = words((
|
| 41 |
+
'alias', 'as', 'case', 'else', 'if', 'import', 'in',
|
| 42 |
+
'let', 'module', 'of', 'port', 'then', 'type', 'where',
|
| 43 |
+
), suffix=r'\b')
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
'root': [
|
| 47 |
+
|
| 48 |
+
# Comments
|
| 49 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 50 |
+
(r'--.*', Comment.Single),
|
| 51 |
+
|
| 52 |
+
# Whitespace
|
| 53 |
+
(r'\s+', Whitespace),
|
| 54 |
+
|
| 55 |
+
# Strings
|
| 56 |
+
(r'"', String, 'doublequote'),
|
| 57 |
+
|
| 58 |
+
# Modules
|
| 59 |
+
(r'^(\s*)(module)(\s*)', bygroups(Whitespace, Keyword.Namespace,
|
| 60 |
+
Whitespace), 'imports'),
|
| 61 |
+
|
| 62 |
+
# Imports
|
| 63 |
+
(r'^(\s*)(import)(\s*)', bygroups(Whitespace, Keyword.Namespace,
|
| 64 |
+
Whitespace), 'imports'),
|
| 65 |
+
|
| 66 |
+
# Shaders
|
| 67 |
+
(r'\[glsl\|.*', Name.Entity, 'shader'),
|
| 68 |
+
|
| 69 |
+
# Keywords
|
| 70 |
+
(reservedWords, Keyword.Reserved),
|
| 71 |
+
|
| 72 |
+
# Types
|
| 73 |
+
(r'[A-Z][a-zA-Z0-9_]*', Keyword.Type),
|
| 74 |
+
|
| 75 |
+
# Main
|
| 76 |
+
(specialName, Keyword.Reserved),
|
| 77 |
+
|
| 78 |
+
# Prefix Operators
|
| 79 |
+
(words((builtinOps), prefix=r'\(', suffix=r'\)'), Name.Function),
|
| 80 |
+
|
| 81 |
+
# Infix Operators
|
| 82 |
+
(words(builtinOps), Name.Function),
|
| 83 |
+
|
| 84 |
+
# Numbers
|
| 85 |
+
include('numbers'),
|
| 86 |
+
|
| 87 |
+
# Variable Names
|
| 88 |
+
(validName, Name.Variable),
|
| 89 |
+
|
| 90 |
+
# Parens
|
| 91 |
+
(r'[,()\[\]{}]', Punctuation),
|
| 92 |
+
|
| 93 |
+
],
|
| 94 |
+
|
| 95 |
+
'comment': [
|
| 96 |
+
(r'-(?!\})', Comment.Multiline),
|
| 97 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 98 |
+
(r'[^-}]', Comment.Multiline),
|
| 99 |
+
(r'-\}', Comment.Multiline, '#pop'),
|
| 100 |
+
],
|
| 101 |
+
|
| 102 |
+
'doublequote': [
|
| 103 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 104 |
+
(r'\\[nrfvb\\"]', String.Escape),
|
| 105 |
+
(r'[^"]', String),
|
| 106 |
+
(r'"', String, '#pop'),
|
| 107 |
+
],
|
| 108 |
+
|
| 109 |
+
'imports': [
|
| 110 |
+
(r'\w+(\.\w+)*', Name.Class, '#pop'),
|
| 111 |
+
],
|
| 112 |
+
|
| 113 |
+
'numbers': [
|
| 114 |
+
(r'_?\d+\.(?=\d+)', Number.Float),
|
| 115 |
+
(r'_?\d+', Number.Integer),
|
| 116 |
+
],
|
| 117 |
+
|
| 118 |
+
'shader': [
|
| 119 |
+
(r'\|(?!\])', Name.Entity),
|
| 120 |
+
(r'\|\]', Name.Entity, '#pop'),
|
| 121 |
+
(r'(.*)(\n)', bygroups(Name.Entity, Whitespace)),
|
| 122 |
+
],
|
| 123 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/elpi.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.elpi
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the `Elpi <http://github.com/LPCIC/elpi>`_ programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, include, using
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['ElpiLexer']
|
| 16 |
+
|
| 17 |
+
from pygments.lexers.theorem import RocqLexer
|
| 18 |
+
|
| 19 |
+
class ElpiLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
Lexer for the Elpi programming language.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
name = 'Elpi'
|
| 25 |
+
url = 'http://github.com/LPCIC/elpi'
|
| 26 |
+
aliases = ['elpi']
|
| 27 |
+
filenames = ['*.elpi']
|
| 28 |
+
mimetypes = ['text/x-elpi']
|
| 29 |
+
version_added = '2.11'
|
| 30 |
+
|
| 31 |
+
lcase_re = r"[a-z]"
|
| 32 |
+
ucase_re = r"[A-Z]"
|
| 33 |
+
digit_re = r"[0-9]"
|
| 34 |
+
schar2_re = r"([+*^?/<>`'@#~=&!])"
|
| 35 |
+
schar_re = rf"({schar2_re}|-|\$|_)"
|
| 36 |
+
idchar_re = rf"({lcase_re}|{ucase_re}|{digit_re}|{schar_re})"
|
| 37 |
+
idcharstarns_re = rf"({idchar_re}*(\.({lcase_re}|{ucase_re}){idchar_re}*)*)"
|
| 38 |
+
symbchar_re = rf"({lcase_re}|{ucase_re}|{digit_re}|{schar_re}|:)"
|
| 39 |
+
constant_re = rf"({ucase_re}{idchar_re}*|{lcase_re}{idcharstarns_re}|{schar2_re}{symbchar_re}*|_{idchar_re}+)"
|
| 40 |
+
symbol_re = r"(,|<=>|->|:-|;|\?-|->|&|=>|\bas\b|\buvar\b|<|=<|=|==|>=|>|\bi<|\bi=<|\bi>=|\bi>|\bis\b|\br<|\br=<|\br>=|\br>|\bs<|\bs=<|\bs>=|\bs>|@|::|\[\]|`->|`:|`:=|\^|-|\+|\bi-|\bi\+|r-|r\+|/|\*|\bdiv\b|\bi\*|\bmod\b|\br\*|~|\bi~|\br~)"
|
| 41 |
+
escape_re = rf"\(({constant_re}|{symbol_re})\)"
|
| 42 |
+
const_sym_re = rf"({constant_re}|{symbol_re}|{escape_re})"
|
| 43 |
+
|
| 44 |
+
tokens = {
|
| 45 |
+
'root': [
|
| 46 |
+
include('elpi')
|
| 47 |
+
],
|
| 48 |
+
|
| 49 |
+
'elpi': [
|
| 50 |
+
include('_elpi-comment'),
|
| 51 |
+
|
| 52 |
+
(r"(:before|:after|:if|:name)(\s*)(\")",
|
| 53 |
+
bygroups(Keyword.Mode, Text.Whitespace, String.Double),
|
| 54 |
+
'elpi-string'),
|
| 55 |
+
(r"(:index)(\s*)(\()", bygroups(Keyword.Mode, Text.Whitespace, Punctuation),
|
| 56 |
+
'elpi-indexing-expr'),
|
| 57 |
+
(rf"\b(external pred|pred)(\s+)({const_sym_re})",
|
| 58 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 59 |
+
'elpi-pred-item'),
|
| 60 |
+
(rf"\b(func)(\s+)({const_sym_re})",
|
| 61 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 62 |
+
'elpi-func-item'),
|
| 63 |
+
(rf"\b(external type|type)(\s+)(({const_sym_re}(,\s*)?)+)",
|
| 64 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 65 |
+
'elpi-type'),
|
| 66 |
+
(rf"\b(kind)(\s+)(({const_sym_re}|,)+)",
|
| 67 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 68 |
+
'elpi-type'),
|
| 69 |
+
(rf"\b(typeabbrev)(\s+)({const_sym_re})",
|
| 70 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 71 |
+
'elpi-type'),
|
| 72 |
+
(r"\b(typeabbrev)(\s+)(\([^)]+\))",
|
| 73 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 74 |
+
'elpi-type'),
|
| 75 |
+
(r"\b(accumulate)(\s+)(\")",
|
| 76 |
+
bygroups(Keyword.Declaration, Text.Whitespace, String.Double),
|
| 77 |
+
'elpi-string'),
|
| 78 |
+
(rf"\b(accumulate|namespace|local)(\s+)({constant_re})",
|
| 79 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Text)),
|
| 80 |
+
(rf"\b(shorten)(\s+)({constant_re}\.)",
|
| 81 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Text)),
|
| 82 |
+
(r"\b(pi|sigma)(\s+)([a-zA-Z][A-Za-z0-9_ ]*)(\\)",
|
| 83 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable, Text)),
|
| 84 |
+
(rf"\b(constraint)(\s+)(({const_sym_re}(\s+)?)+)",
|
| 85 |
+
bygroups(Keyword.Declaration, Text.Whitespace, Name.Function),
|
| 86 |
+
'elpi-chr-rule-start'),
|
| 87 |
+
|
| 88 |
+
(rf"(?=[A-Z_]){constant_re}", Name.Variable),
|
| 89 |
+
(rf"(?=[a-z_])({constant_re}|_)\\", Name.Variable),
|
| 90 |
+
(r"_", Name.Variable),
|
| 91 |
+
(rf"({symbol_re}|!|=>|;)", Keyword.Declaration),
|
| 92 |
+
(constant_re, Text),
|
| 93 |
+
(r"\[|\]|\||=>", Keyword.Declaration),
|
| 94 |
+
(r'"', String.Double, 'elpi-string'),
|
| 95 |
+
(r'`', String.Double, 'elpi-btick'),
|
| 96 |
+
(r'\'', String.Double, 'elpi-tick'),
|
| 97 |
+
(r'\{\{', Punctuation, 'elpi-quote'),
|
| 98 |
+
(r'\{[^\{]', Text, 'elpi-spill'),
|
| 99 |
+
(r"\(", Punctuation, 'elpi-in-parens'),
|
| 100 |
+
(r'\d[\d_]*', Number.Integer),
|
| 101 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
|
| 102 |
+
(r"[\+\*\-/\^\.]", Operator),
|
| 103 |
+
],
|
| 104 |
+
'_elpi-comment': [
|
| 105 |
+
(r'%[^\n]*\n', Comment),
|
| 106 |
+
(r'/(?:\\\n)?[*](?:[^*]|[*](?!(?:\\\n)?/))*[*](?:\\\n)?/', Comment),
|
| 107 |
+
(r"\s+", Text.Whitespace),
|
| 108 |
+
],
|
| 109 |
+
'elpi-indexing-expr':[
|
| 110 |
+
(r'[0-9 _]+', Number.Integer),
|
| 111 |
+
(r'\)', Punctuation, '#pop'),
|
| 112 |
+
],
|
| 113 |
+
'elpi-type': [
|
| 114 |
+
(r"(ctype\s+)(\")", bygroups(Keyword.Type, String.Double), 'elpi-string'),
|
| 115 |
+
(r'->', Keyword.Type),
|
| 116 |
+
(r'prop', Keyword.Mode),
|
| 117 |
+
(constant_re, Keyword.Type),
|
| 118 |
+
(r"\(|\)", Keyword.Type),
|
| 119 |
+
(r"\.", Text, '#pop'),
|
| 120 |
+
include('_elpi-comment'),
|
| 121 |
+
],
|
| 122 |
+
'elpi-chr-rule-start': [
|
| 123 |
+
(r"\{", Punctuation, 'elpi-chr-rule'),
|
| 124 |
+
include('_elpi-comment'),
|
| 125 |
+
],
|
| 126 |
+
'elpi-chr-rule': [
|
| 127 |
+
(r"\brule\b", Keyword.Declaration),
|
| 128 |
+
(r"\\", Keyword.Declaration),
|
| 129 |
+
(r"\}", Punctuation, '#pop:2'),
|
| 130 |
+
include('elpi'),
|
| 131 |
+
],
|
| 132 |
+
'elpi-pred-item': [
|
| 133 |
+
(r"[io]:", Keyword.Mode),
|
| 134 |
+
(r"\.", Text, '#pop'),
|
| 135 |
+
(r",", Keyword.Mode),
|
| 136 |
+
include('_elpi-inner-pred-fun'),
|
| 137 |
+
(r"\)", Keyword.Mode, '#pop'),
|
| 138 |
+
(r"\(", Keyword.Type, '_elpi-type-item'),
|
| 139 |
+
include('_elpi-comment'),
|
| 140 |
+
include('_elpi-type-item'),
|
| 141 |
+
],
|
| 142 |
+
'elpi-func-item': [
|
| 143 |
+
(constant_re, Keyword.Type),
|
| 144 |
+
(r"\.", Text, '#pop'),
|
| 145 |
+
(r",", Keyword.Mode),
|
| 146 |
+
(r'->', Keyword.Mode),
|
| 147 |
+
include('_elpi-inner-pred-fun'),
|
| 148 |
+
(r"\)", Keyword.Mode, '#pop'),
|
| 149 |
+
(r"\(", Keyword.Type, '_elpi-type-item'),
|
| 150 |
+
include('_elpi-comment'),
|
| 151 |
+
include('_elpi-type-item'),
|
| 152 |
+
],
|
| 153 |
+
'_elpi-inner-pred-fun': [
|
| 154 |
+
(r"(\()(\s*)(pred)", bygroups(Keyword.Mode,Text.Whitespace,Keyword.Declaration), 'elpi-pred-item'),
|
| 155 |
+
(r"(\()(\s*)(func)", bygroups(Keyword.Mode,Text.Whitespace,Keyword.Declaration), 'elpi-func-item'),
|
| 156 |
+
],
|
| 157 |
+
'_elpi-type-item': [
|
| 158 |
+
(r'->', Keyword.Type),
|
| 159 |
+
(constant_re, Keyword.Type),
|
| 160 |
+
include('_elpi-inner-pred-fun'),
|
| 161 |
+
(r"\(", Keyword.Type, '#push'),
|
| 162 |
+
(r"\)", Keyword.Type, '#pop'),
|
| 163 |
+
include('_elpi-comment'),
|
| 164 |
+
],
|
| 165 |
+
|
| 166 |
+
''
|
| 167 |
+
|
| 168 |
+
'elpi-btick': [
|
| 169 |
+
(r'[^` ]+', String.Double),
|
| 170 |
+
(r'`', String.Double, '#pop'),
|
| 171 |
+
],
|
| 172 |
+
'elpi-tick': [
|
| 173 |
+
(r'[^\' ]+', String.Double),
|
| 174 |
+
(r'\'', String.Double, '#pop'),
|
| 175 |
+
],
|
| 176 |
+
'elpi-string': [
|
| 177 |
+
(r'[^\"]+', String.Double),
|
| 178 |
+
(r'"', String.Double, '#pop'),
|
| 179 |
+
],
|
| 180 |
+
'elpi-quote': [
|
| 181 |
+
(r'\}\}', Punctuation, '#pop'),
|
| 182 |
+
(r"\s+", Text.Whitespace),
|
| 183 |
+
(r"(lp:)(\{\{)", bygroups(Number, Punctuation), 'elpi-quote-exit'),
|
| 184 |
+
(rf"(lp:)((?=[A-Z_]){constant_re})", bygroups(Number, Name.Variable)),
|
| 185 |
+
(r"((?!lp:|\}\}).)+", using(RocqLexer)),
|
| 186 |
+
],
|
| 187 |
+
'elpi-quote-exit': [
|
| 188 |
+
include('elpi'),
|
| 189 |
+
(r'\}\}', Punctuation, '#pop'),
|
| 190 |
+
],
|
| 191 |
+
'elpi-spill': [
|
| 192 |
+
(r'\{[^\{]', Text, '#push'),
|
| 193 |
+
(r'\}[^\}]', Text, '#pop'),
|
| 194 |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
|
| 2 |
+
pygments.lexers.email
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the raw E-mail.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, DelegatingLexer, bygroups
|
| 12 |
+
from pygments.lexers.mime import MIMELexer
|
| 13 |
+
from pygments.token import Text, Keyword, Name, String, Number, Comment
|
| 14 |
+
from pygments.util import get_bool_opt
|
| 15 |
+
|
| 16 |
+
__all__ = ["EmailLexer"]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class EmailHeaderLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
Sub-lexer for raw E-mail. This lexer only process header part of e-mail.
|
| 22 |
+
|
| 23 |
+
.. versionadded:: 2.5
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
def __init__(self, **options):
|
| 27 |
+
super().__init__(**options)
|
| 28 |
+
self.highlight_x = get_bool_opt(options, "highlight-X-header", False)
|
| 29 |
+
|
| 30 |
+
def get_x_header_tokens(self, match):
|
| 31 |
+
if self.highlight_x:
|
| 32 |
+
# field
|
| 33 |
+
yield match.start(1), Name.Tag, match.group(1)
|
| 34 |
+
|
| 35 |
+
# content
|
| 36 |
+
default_actions = self.get_tokens_unprocessed(
|
| 37 |
+
match.group(2), stack=("root", "header"))
|
| 38 |
+
yield from default_actions
|
| 39 |
+
else:
|
| 40 |
+
# lowlight
|
| 41 |
+
yield match.start(1), Comment.Special, match.group(1)
|
| 42 |
+
yield match.start(2), Comment.Multiline, match.group(2)
|
| 43 |
+
|
| 44 |
+
tokens = {
|
| 45 |
+
"root": [
|
| 46 |
+
(r"^(?:[A-WYZ]|X400)[\w\-]*:", Name.Tag, "header"),
|
| 47 |
+
(r"^(X-(?:\w[\w\-]*:))([\s\S]*?\n)(?![ \t])", get_x_header_tokens),
|
| 48 |
+
],
|
| 49 |
+
"header": [
|
| 50 |
+
# folding
|
| 51 |
+
(r"\n[ \t]", Text.Whitespace),
|
| 52 |
+
(r"\n(?![ \t])", Text.Whitespace, "#pop"),
|
| 53 |
+
|
| 54 |
+
# keywords
|
| 55 |
+
(r"\bE?SMTPS?\b", Keyword),
|
| 56 |
+
(r"\b(?:HE|EH)LO\b", Keyword),
|
| 57 |
+
|
| 58 |
+
# mailbox
|
| 59 |
+
(r"[\w\.\-\+=]+@[\w\.\-]+", Name.Label),
|
| 60 |
+
(r"<[\w\.\-\+=]+@[\w\.\-]+>", Name.Label),
|
| 61 |
+
|
| 62 |
+
# domain
|
| 63 |
+
(r"\b(\w[\w\.-]*\.[\w\.-]*\w[a-zA-Z]+)\b", Name.Function),
|
| 64 |
+
|
| 65 |
+
# IPv4
|
| 66 |
+
(r"(?<=\b)(?:(?:25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.){3}(?:25[0"
|
| 67 |
+
r"-5]|2[0-4][0-9]|1?[0-9][0-9]?)(?=\b)",
|
| 68 |
+
Number.Integer),
|
| 69 |
+
|
| 70 |
+
# IPv6
|
| 71 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,7}:(?!\b)", Number.Hex),
|
| 72 |
+
(r"(?<=\b):((:[0-9a-fA-F]{1,4}){1,7}|:)(?=\b)", Number.Hex),
|
| 73 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}(?=\b)", Number.Hex),
|
| 74 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}(?=\b)", Number.Hex),
|
| 75 |
+
(r"(?<=\b)[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})(?=\b)", Number.Hex),
|
| 76 |
+
(r"(?<=\b)fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}(?=\b)", Number.Hex),
|
| 77 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}(?=\b)", Number.Hex),
|
| 78 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}(?=\b)",
|
| 79 |
+
Number.Hex),
|
| 80 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}(?=\b)",
|
| 81 |
+
Number.Hex),
|
| 82 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}(?=\b)",
|
| 83 |
+
Number.Hex),
|
| 84 |
+
(r"(?<=\b)::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}"
|
| 85 |
+
r"[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}"
|
| 86 |
+
r"[0-9])(?=\b)",
|
| 87 |
+
Number.Hex),
|
| 88 |
+
(r"(?<=\b)([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9])"
|
| 89 |
+
r"{0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])(?=\b)",
|
| 90 |
+
Number.Hex),
|
| 91 |
+
|
| 92 |
+
# Date time
|
| 93 |
+
(r"(?:(Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?(0[1-9]|[1-2]?[0-9]|3["
|
| 94 |
+
r"01])\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+("
|
| 95 |
+
r"19[0-9]{2}|[2-9][0-9]{3})\s+(2[0-3]|[0-1][0-9]):([0-5][0-9])"
|
| 96 |
+
r"(?::(60|[0-5][0-9]))?(?:\.\d{1,5})?\s+([-\+][0-9]{2}[0-5][0-"
|
| 97 |
+
r"9]|\(?(?:UTC?|GMT|(?:E|C|M|P)(?:ST|ET|DT)|[A-IK-Z])\)?)",
|
| 98 |
+
Name.Decorator),
|
| 99 |
+
|
| 100 |
+
# RFC-2047 encoded string
|
| 101 |
+
(r"(=\?)([\w-]+)(\?)([BbQq])(\?)([\[\w!\"#$%&\'()*+,-./:;<=>@[\\"
|
| 102 |
+
r"\]^_`{|}~]+)(\?=)",
|
| 103 |
+
bygroups(String.Affix, Name.Constant, String.Affix, Keyword.Constant,
|
| 104 |
+
String.Affix, Number.Hex, String.Affix)),
|
| 105 |
+
|
| 106 |
+
# others
|
| 107 |
+
(r'[\s]+', Text.Whitespace),
|
| 108 |
+
(r'[\S]', Text),
|
| 109 |
+
],
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class EmailLexer(DelegatingLexer):
|
| 114 |
+
"""
|
| 115 |
+
Lexer for raw E-mail.
|
| 116 |
+
|
| 117 |
+
Additional options accepted:
|
| 118 |
+
|
| 119 |
+
`highlight-X-header`
|
| 120 |
+
Highlight the fields of ``X-`` user-defined email header. (default:
|
| 121 |
+
``False``).
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
name = "E-mail"
|
| 125 |
+
aliases = ["email", "eml"]
|
| 126 |
+
filenames = ["*.eml"]
|
| 127 |
+
mimetypes = ["message/rfc822"]
|
| 128 |
+
url = "https://en.wikipedia.org/wiki/Email#Message_format"
|
| 129 |
+
version_added = '2.5'
|
| 130 |
+
|
| 131 |
+
def __init__(self, **options):
|
| 132 |
+
super().__init__(EmailHeaderLexer, MIMELexer, Comment, **options)
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/erlang.py
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Erlang.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, bygroups, words, do_insertions, \
|
| 14 |
+
include, default, line_re
|
| 15 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Generic, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['ErlangLexer', 'ErlangShellLexer', 'ElixirConsoleLexer',
|
| 19 |
+
'ElixirLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class ErlangLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For the Erlang functional programming language.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Erlang'
|
| 28 |
+
url = 'https://www.erlang.org/'
|
| 29 |
+
aliases = ['erlang']
|
| 30 |
+
filenames = ['*.erl', '*.hrl', '*.es', '*.escript']
|
| 31 |
+
mimetypes = ['text/x-erlang']
|
| 32 |
+
version_added = '0.9'
|
| 33 |
+
|
| 34 |
+
keywords = (
|
| 35 |
+
'after', 'begin', 'case', 'catch', 'cond', 'end', 'fun', 'if',
|
| 36 |
+
'let', 'of', 'query', 'receive', 'try', 'when',
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
builtins = ( # See erlang(3) man page
|
| 40 |
+
'abs', 'append_element', 'apply', 'atom_to_list', 'binary_to_list',
|
| 41 |
+
'bitstring_to_list', 'binary_to_term', 'bit_size', 'bump_reductions',
|
| 42 |
+
'byte_size', 'cancel_timer', 'check_process_code', 'delete_module',
|
| 43 |
+
'demonitor', 'disconnect_node', 'display', 'element', 'erase', 'exit',
|
| 44 |
+
'float', 'float_to_list', 'fun_info', 'fun_to_list',
|
| 45 |
+
'function_exported', 'garbage_collect', 'get', 'get_keys',
|
| 46 |
+
'group_leader', 'hash', 'hd', 'integer_to_list', 'iolist_to_binary',
|
| 47 |
+
'iolist_size', 'is_atom', 'is_binary', 'is_bitstring', 'is_boolean',
|
| 48 |
+
'is_builtin', 'is_float', 'is_function', 'is_integer', 'is_list',
|
| 49 |
+
'is_number', 'is_pid', 'is_port', 'is_process_alive', 'is_record',
|
| 50 |
+
'is_reference', 'is_tuple', 'length', 'link', 'list_to_atom',
|
| 51 |
+
'list_to_binary', 'list_to_bitstring', 'list_to_existing_atom',
|
| 52 |
+
'list_to_float', 'list_to_integer', 'list_to_pid', 'list_to_tuple',
|
| 53 |
+
'load_module', 'localtime_to_universaltime', 'make_tuple', 'md5',
|
| 54 |
+
'md5_final', 'md5_update', 'memory', 'module_loaded', 'monitor',
|
| 55 |
+
'monitor_node', 'node', 'nodes', 'open_port', 'phash', 'phash2',
|
| 56 |
+
'pid_to_list', 'port_close', 'port_command', 'port_connect',
|
| 57 |
+
'port_control', 'port_call', 'port_info', 'port_to_list',
|
| 58 |
+
'process_display', 'process_flag', 'process_info', 'purge_module',
|
| 59 |
+
'put', 'read_timer', 'ref_to_list', 'register', 'resume_process',
|
| 60 |
+
'round', 'send', 'send_after', 'send_nosuspend', 'set_cookie',
|
| 61 |
+
'setelement', 'size', 'spawn', 'spawn_link', 'spawn_monitor',
|
| 62 |
+
'spawn_opt', 'split_binary', 'start_timer', 'statistics',
|
| 63 |
+
'suspend_process', 'system_flag', 'system_info', 'system_monitor',
|
| 64 |
+
'system_profile', 'term_to_binary', 'tl', 'trace', 'trace_delivered',
|
| 65 |
+
'trace_info', 'trace_pattern', 'trunc', 'tuple_size', 'tuple_to_list',
|
| 66 |
+
'universaltime_to_localtime', 'unlink', 'unregister', 'whereis'
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
operators = r'(\+\+?|--?|\*|/|<|>|/=|=:=|=/=|=<|>=|==?|<-|!|\?)'
|
| 70 |
+
word_operators = (
|
| 71 |
+
'and', 'andalso', 'band', 'bnot', 'bor', 'bsl', 'bsr', 'bxor',
|
| 72 |
+
'div', 'not', 'or', 'orelse', 'rem', 'xor'
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
atom_re = r"(?:[a-z]\w*|'[^\n']*[^\\]')"
|
| 76 |
+
|
| 77 |
+
variable_re = r'(?:[A-Z_]\w*)'
|
| 78 |
+
|
| 79 |
+
esc_char_re = r'[bdefnrstv\'"\\]'
|
| 80 |
+
esc_octal_re = r'[0-7][0-7]?[0-7]?'
|
| 81 |
+
esc_hex_re = r'(?:x[0-9a-fA-F]{2}|x\{[0-9a-fA-F]+\})'
|
| 82 |
+
esc_ctrl_re = r'\^[a-zA-Z]'
|
| 83 |
+
escape_re = r'(?:\\(?:'+esc_char_re+r'|'+esc_octal_re+r'|'+esc_hex_re+r'|'+esc_ctrl_re+r'))'
|
| 84 |
+
|
| 85 |
+
macro_re = r'(?:'+variable_re+r'|'+atom_re+r')'
|
| 86 |
+
|
| 87 |
+
base_re = r'(?:[2-9]|[12][0-9]|3[0-6])'
|
| 88 |
+
|
| 89 |
+
tokens = {
|
| 90 |
+
'root': [
|
| 91 |
+
(r'\s+', Whitespace),
|
| 92 |
+
(r'(%.*)(\n)', bygroups(Comment, Whitespace)),
|
| 93 |
+
(words(keywords, suffix=r'\b'), Keyword),
|
| 94 |
+
(words(builtins, suffix=r'\b'), Name.Builtin),
|
| 95 |
+
(words(word_operators, suffix=r'\b'), Operator.Word),
|
| 96 |
+
(r'^-', Punctuation, 'directive'),
|
| 97 |
+
(operators, Operator),
|
| 98 |
+
(r'"', String, 'string'),
|
| 99 |
+
(r'<<', Name.Label),
|
| 100 |
+
(r'>>', Name.Label),
|
| 101 |
+
('(' + atom_re + ')(:)', bygroups(Name.Namespace, Punctuation)),
|
| 102 |
+
('(?:^|(?<=:))(' + atom_re + r')(\s*)(\()',
|
| 103 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 104 |
+
(r'[+-]?' + base_re + r'#[0-9a-zA-Z]+', Number.Integer),
|
| 105 |
+
(r'[+-]?\d+', Number.Integer),
|
| 106 |
+
(r'[+-]?\d+.\d+', Number.Float),
|
| 107 |
+
(r'[]\[:_@\".{}()|;,]', Punctuation),
|
| 108 |
+
(variable_re, Name.Variable),
|
| 109 |
+
(atom_re, Name),
|
| 110 |
+
(r'\?'+macro_re, Name.Constant),
|
| 111 |
+
(r'\$(?:'+escape_re+r'|\\[ %]|[^\\])', String.Char),
|
| 112 |
+
(r'#'+atom_re+r'(:?\.'+atom_re+r')?', Name.Label),
|
| 113 |
+
|
| 114 |
+
# Erlang script shebang
|
| 115 |
+
(r'\A#!.+\n', Comment.Hashbang),
|
| 116 |
+
|
| 117 |
+
# EEP 43: Maps
|
| 118 |
+
# http://www.erlang.org/eeps/eep-0043.html
|
| 119 |
+
(r'#\{', Punctuation, 'map_key'),
|
| 120 |
+
],
|
| 121 |
+
'string': [
|
| 122 |
+
(escape_re, String.Escape),
|
| 123 |
+
(r'"', String, '#pop'),
|
| 124 |
+
(r'~[0-9.*]*[~#+BPWXb-ginpswx]', String.Interpol),
|
| 125 |
+
(r'[^"\\~]+', String),
|
| 126 |
+
(r'~', String),
|
| 127 |
+
],
|
| 128 |
+
'directive': [
|
| 129 |
+
(r'(define)(\s*)(\()('+macro_re+r')',
|
| 130 |
+
bygroups(Name.Entity, Whitespace, Punctuation, Name.Constant), '#pop'),
|
| 131 |
+
(r'(record)(\s*)(\()('+macro_re+r')',
|
| 132 |
+
bygroups(Name.Entity, Whitespace, Punctuation, Name.Label), '#pop'),
|
| 133 |
+
(atom_re, Name.Entity, '#pop'),
|
| 134 |
+
],
|
| 135 |
+
'map_key': [
|
| 136 |
+
include('root'),
|
| 137 |
+
(r'=>', Punctuation, 'map_val'),
|
| 138 |
+
(r':=', Punctuation, 'map_val'),
|
| 139 |
+
(r'\}', Punctuation, '#pop'),
|
| 140 |
+
],
|
| 141 |
+
'map_val': [
|
| 142 |
+
include('root'),
|
| 143 |
+
(r',', Punctuation, '#pop'),
|
| 144 |
+
(r'(?=\})', Punctuation, '#pop'),
|
| 145 |
+
],
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class ErlangShellLexer(Lexer):
|
| 150 |
+
"""
|
| 151 |
+
Shell sessions in erl (for Erlang code).
|
| 152 |
+
"""
|
| 153 |
+
name = 'Erlang erl session'
|
| 154 |
+
aliases = ['erl']
|
| 155 |
+
filenames = ['*.erl-sh']
|
| 156 |
+
mimetypes = ['text/x-erl-shellsession']
|
| 157 |
+
url = 'https://www.erlang.org/'
|
| 158 |
+
version_added = '1.1'
|
| 159 |
+
|
| 160 |
+
_prompt_re = re.compile(r'(?:\([\w@_.]+\))?\d+>(?=\s|\Z)')
|
| 161 |
+
|
| 162 |
+
def get_tokens_unprocessed(self, text):
|
| 163 |
+
erlexer = ErlangLexer(**self.options)
|
| 164 |
+
|
| 165 |
+
curcode = ''
|
| 166 |
+
insertions = []
|
| 167 |
+
for match in line_re.finditer(text):
|
| 168 |
+
line = match.group()
|
| 169 |
+
m = self._prompt_re.match(line)
|
| 170 |
+
if m is not None:
|
| 171 |
+
end = m.end()
|
| 172 |
+
insertions.append((len(curcode),
|
| 173 |
+
[(0, Generic.Prompt, line[:end])]))
|
| 174 |
+
curcode += line[end:]
|
| 175 |
+
else:
|
| 176 |
+
if curcode:
|
| 177 |
+
yield from do_insertions(insertions,
|
| 178 |
+
erlexer.get_tokens_unprocessed(curcode))
|
| 179 |
+
curcode = ''
|
| 180 |
+
insertions = []
|
| 181 |
+
if line.startswith('*'):
|
| 182 |
+
yield match.start(), Generic.Traceback, line
|
| 183 |
+
else:
|
| 184 |
+
yield match.start(), Generic.Output, line
|
| 185 |
+
if curcode:
|
| 186 |
+
yield from do_insertions(insertions,
|
| 187 |
+
erlexer.get_tokens_unprocessed(curcode))
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def gen_elixir_string_rules(name, symbol, token):
|
| 191 |
+
states = {}
|
| 192 |
+
states['string_' + name] = [
|
| 193 |
+
(rf'[^#{symbol}\\]+', token),
|
| 194 |
+
include('escapes'),
|
| 195 |
+
(r'\\.', token),
|
| 196 |
+
(rf'({symbol})', bygroups(token), "#pop"),
|
| 197 |
+
include('interpol')
|
| 198 |
+
]
|
| 199 |
+
return states
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def gen_elixir_sigstr_rules(term, term_class, token, interpol=True):
|
| 203 |
+
if interpol:
|
| 204 |
+
return [
|
| 205 |
+
(rf'[^#{term_class}\\]+', token),
|
| 206 |
+
include('escapes'),
|
| 207 |
+
(r'\\.', token),
|
| 208 |
+
(rf'{term}[a-zA-Z]*', token, '#pop'),
|
| 209 |
+
include('interpol')
|
| 210 |
+
]
|
| 211 |
+
else:
|
| 212 |
+
return [
|
| 213 |
+
(rf'[^{term_class}\\]+', token),
|
| 214 |
+
(r'\\.', token),
|
| 215 |
+
(rf'{term}[a-zA-Z]*', token, '#pop'),
|
| 216 |
+
]
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
class ElixirLexer(RegexLexer):
|
| 220 |
+
"""
|
| 221 |
+
For the Elixir language.
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
name = 'Elixir'
|
| 225 |
+
url = 'https://elixir-lang.org'
|
| 226 |
+
aliases = ['elixir', 'ex', 'exs']
|
| 227 |
+
filenames = ['*.ex', '*.eex', '*.exs', '*.leex']
|
| 228 |
+
mimetypes = ['text/x-elixir']
|
| 229 |
+
version_added = '1.5'
|
| 230 |
+
|
| 231 |
+
KEYWORD = ('fn', 'do', 'end', 'after', 'else', 'rescue', 'catch')
|
| 232 |
+
KEYWORD_OPERATOR = ('not', 'and', 'or', 'when', 'in')
|
| 233 |
+
BUILTIN = (
|
| 234 |
+
'case', 'cond', 'for', 'if', 'unless', 'try', 'receive', 'raise',
|
| 235 |
+
'quote', 'unquote', 'unquote_splicing', 'throw', 'super',
|
| 236 |
+
)
|
| 237 |
+
BUILTIN_DECLARATION = (
|
| 238 |
+
'def', 'defp', 'defmodule', 'defprotocol', 'defmacro', 'defmacrop',
|
| 239 |
+
'defdelegate', 'defexception', 'defstruct', 'defimpl', 'defcallback',
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
BUILTIN_NAMESPACE = ('import', 'require', 'use', 'alias')
|
| 243 |
+
CONSTANT = ('nil', 'true', 'false')
|
| 244 |
+
|
| 245 |
+
PSEUDO_VAR = ('_', '__MODULE__', '__DIR__', '__ENV__', '__CALLER__')
|
| 246 |
+
|
| 247 |
+
OPERATORS3 = (
|
| 248 |
+
'<<<', '>>>', '|||', '&&&', '^^^', '~~~', '===', '!==',
|
| 249 |
+
'~>>', '<~>', '|~>', '<|>',
|
| 250 |
+
)
|
| 251 |
+
OPERATORS2 = (
|
| 252 |
+
'==', '!=', '<=', '>=', '&&', '||', '<>', '++', '--', '|>', '=~',
|
| 253 |
+
'->', '<-', '|', '.', '=', '~>', '<~',
|
| 254 |
+
)
|
| 255 |
+
OPERATORS1 = ('<', '>', '+', '-', '*', '/', '!', '^', '&')
|
| 256 |
+
|
| 257 |
+
PUNCTUATION = (
|
| 258 |
+
'\\\\', '<<', '>>', '=>', '(', ')', ':', ';', ',', '[', ']',
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
def get_tokens_unprocessed(self, text):
|
| 262 |
+
for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
|
| 263 |
+
if token is Name:
|
| 264 |
+
if value in self.KEYWORD:
|
| 265 |
+
yield index, Keyword, value
|
| 266 |
+
elif value in self.KEYWORD_OPERATOR:
|
| 267 |
+
yield index, Operator.Word, value
|
| 268 |
+
elif value in self.BUILTIN:
|
| 269 |
+
yield index, Keyword, value
|
| 270 |
+
elif value in self.BUILTIN_DECLARATION:
|
| 271 |
+
yield index, Keyword.Declaration, value
|
| 272 |
+
elif value in self.BUILTIN_NAMESPACE:
|
| 273 |
+
yield index, Keyword.Namespace, value
|
| 274 |
+
elif value in self.CONSTANT:
|
| 275 |
+
yield index, Name.Constant, value
|
| 276 |
+
elif value in self.PSEUDO_VAR:
|
| 277 |
+
yield index, Name.Builtin.Pseudo, value
|
| 278 |
+
else:
|
| 279 |
+
yield index, token, value
|
| 280 |
+
else:
|
| 281 |
+
yield index, token, value
|
| 282 |
+
|
| 283 |
+
def gen_elixir_sigil_rules():
|
| 284 |
+
# all valid sigil terminators (excluding heredocs)
|
| 285 |
+
terminators = [
|
| 286 |
+
(r'\{', r'\}', '}', 'cb'),
|
| 287 |
+
(r'\[', r'\]', r'\]', 'sb'),
|
| 288 |
+
(r'\(', r'\)', ')', 'pa'),
|
| 289 |
+
('<', '>', '>', 'ab'),
|
| 290 |
+
('/', '/', '/', 'slas'),
|
| 291 |
+
(r'\|', r'\|', '|', 'pipe'),
|
| 292 |
+
('"', '"', '"', 'quot'),
|
| 293 |
+
("'", "'", "'", 'apos'),
|
| 294 |
+
]
|
| 295 |
+
|
| 296 |
+
# heredocs have slightly different rules
|
| 297 |
+
triquotes = [(r'"""', 'triquot'), (r"'''", 'triapos')]
|
| 298 |
+
|
| 299 |
+
token = String.Other
|
| 300 |
+
states = {'sigils': []}
|
| 301 |
+
|
| 302 |
+
for term, name in triquotes:
|
| 303 |
+
states['sigils'] += [
|
| 304 |
+
(rf'(~[a-z])({term})', bygroups(token, String.Heredoc),
|
| 305 |
+
(name + '-end', name + '-intp')),
|
| 306 |
+
(rf'(~[A-Z])({term})', bygroups(token, String.Heredoc),
|
| 307 |
+
(name + '-end', name + '-no-intp')),
|
| 308 |
+
]
|
| 309 |
+
|
| 310 |
+
states[name + '-end'] = [
|
| 311 |
+
(r'[a-zA-Z]+', token, '#pop'),
|
| 312 |
+
default('#pop'),
|
| 313 |
+
]
|
| 314 |
+
states[name + '-intp'] = [
|
| 315 |
+
(r'^(\s*)(' + term + ')', bygroups(Whitespace, String.Heredoc), '#pop'),
|
| 316 |
+
include('heredoc_interpol'),
|
| 317 |
+
]
|
| 318 |
+
states[name + '-no-intp'] = [
|
| 319 |
+
(r'^(\s*)(' + term +')', bygroups(Whitespace, String.Heredoc), '#pop'),
|
| 320 |
+
include('heredoc_no_interpol'),
|
| 321 |
+
]
|
| 322 |
+
|
| 323 |
+
for lterm, rterm, rterm_class, name in terminators:
|
| 324 |
+
states['sigils'] += [
|
| 325 |
+
(r'~[a-z]' + lterm, token, name + '-intp'),
|
| 326 |
+
(r'~[A-Z]' + lterm, token, name + '-no-intp'),
|
| 327 |
+
]
|
| 328 |
+
states[name + '-intp'] = \
|
| 329 |
+
gen_elixir_sigstr_rules(rterm, rterm_class, token)
|
| 330 |
+
states[name + '-no-intp'] = \
|
| 331 |
+
gen_elixir_sigstr_rules(rterm, rterm_class, token, interpol=False)
|
| 332 |
+
|
| 333 |
+
return states
|
| 334 |
+
|
| 335 |
+
op3_re = "|".join(re.escape(s) for s in OPERATORS3)
|
| 336 |
+
op2_re = "|".join(re.escape(s) for s in OPERATORS2)
|
| 337 |
+
op1_re = "|".join(re.escape(s) for s in OPERATORS1)
|
| 338 |
+
ops_re = rf'(?:{op3_re}|{op2_re}|{op1_re})'
|
| 339 |
+
punctuation_re = "|".join(re.escape(s) for s in PUNCTUATION)
|
| 340 |
+
alnum = r'\w'
|
| 341 |
+
name_re = rf'(?:\.\.\.|[a-z_]{alnum}*[!?]?)'
|
| 342 |
+
modname_re = rf'[A-Z]{alnum}*(?:\.[A-Z]{alnum}*)*'
|
| 343 |
+
complex_name_re = rf'(?:{name_re}|{modname_re}|{ops_re})'
|
| 344 |
+
special_atom_re = r'(?:\.\.\.|<<>>|%\{\}|%|\{\})'
|
| 345 |
+
|
| 346 |
+
long_hex_char_re = r'(\\x\{)([\da-fA-F]+)(\})'
|
| 347 |
+
hex_char_re = r'(\\x[\da-fA-F]{1,2})'
|
| 348 |
+
escape_char_re = r'(\\[abdefnrstv])'
|
| 349 |
+
|
| 350 |
+
tokens = {
|
| 351 |
+
'root': [
|
| 352 |
+
(r'\s+', Whitespace),
|
| 353 |
+
(r'#.*$', Comment.Single),
|
| 354 |
+
|
| 355 |
+
# Various kinds of characters
|
| 356 |
+
(r'(\?)' + long_hex_char_re,
|
| 357 |
+
bygroups(String.Char,
|
| 358 |
+
String.Escape, Number.Hex, String.Escape)),
|
| 359 |
+
(r'(\?)' + hex_char_re,
|
| 360 |
+
bygroups(String.Char, String.Escape)),
|
| 361 |
+
(r'(\?)' + escape_char_re,
|
| 362 |
+
bygroups(String.Char, String.Escape)),
|
| 363 |
+
(r'\?\\?.', String.Char),
|
| 364 |
+
|
| 365 |
+
# '::' has to go before atoms
|
| 366 |
+
(r':::', String.Symbol),
|
| 367 |
+
(r'::', Operator),
|
| 368 |
+
|
| 369 |
+
# atoms
|
| 370 |
+
(r':' + special_atom_re, String.Symbol),
|
| 371 |
+
(r':' + complex_name_re, String.Symbol),
|
| 372 |
+
(r':"', String.Symbol, 'string_double_atom'),
|
| 373 |
+
(r":'", String.Symbol, 'string_single_atom'),
|
| 374 |
+
|
| 375 |
+
# [keywords: ...]
|
| 376 |
+
(rf'({special_atom_re}|{complex_name_re})(:)(?=\s|\n)',
|
| 377 |
+
bygroups(String.Symbol, Punctuation)),
|
| 378 |
+
|
| 379 |
+
# @attributes
|
| 380 |
+
(r'@' + name_re, Name.Attribute),
|
| 381 |
+
|
| 382 |
+
# identifiers
|
| 383 |
+
(name_re, Name),
|
| 384 |
+
(rf'(%?)({modname_re})', bygroups(Punctuation, Name.Class)),
|
| 385 |
+
|
| 386 |
+
# operators and punctuation
|
| 387 |
+
(op3_re, Operator),
|
| 388 |
+
(op2_re, Operator),
|
| 389 |
+
(punctuation_re, Punctuation),
|
| 390 |
+
(r'&\d', Name.Entity), # anon func arguments
|
| 391 |
+
(op1_re, Operator),
|
| 392 |
+
|
| 393 |
+
# numbers
|
| 394 |
+
(r'0b[01]+', Number.Bin),
|
| 395 |
+
(r'0o[0-7]+', Number.Oct),
|
| 396 |
+
(r'0x[\da-fA-F]+', Number.Hex),
|
| 397 |
+
(r'\d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?', Number.Float),
|
| 398 |
+
(r'\d(_?\d)*', Number.Integer),
|
| 399 |
+
|
| 400 |
+
# strings and heredocs
|
| 401 |
+
(r'(""")(\s*)', bygroups(String.Heredoc, Whitespace),
|
| 402 |
+
'heredoc_double'),
|
| 403 |
+
(r"(''')(\s*)$", bygroups(String.Heredoc, Whitespace),
|
| 404 |
+
'heredoc_single'),
|
| 405 |
+
(r'"', String.Double, 'string_double'),
|
| 406 |
+
(r"'", String.Single, 'string_single'),
|
| 407 |
+
|
| 408 |
+
include('sigils'),
|
| 409 |
+
|
| 410 |
+
(r'%\{', Punctuation, 'map_key'),
|
| 411 |
+
(r'\{', Punctuation, 'tuple'),
|
| 412 |
+
],
|
| 413 |
+
'heredoc_double': [
|
| 414 |
+
(r'^(\s*)(""")', bygroups(Whitespace, String.Heredoc), '#pop'),
|
| 415 |
+
include('heredoc_interpol'),
|
| 416 |
+
],
|
| 417 |
+
'heredoc_single': [
|
| 418 |
+
(r"^\s*'''", String.Heredoc, '#pop'),
|
| 419 |
+
include('heredoc_interpol'),
|
| 420 |
+
],
|
| 421 |
+
'heredoc_interpol': [
|
| 422 |
+
(r'[^#\\\n]+', String.Heredoc),
|
| 423 |
+
include('escapes'),
|
| 424 |
+
(r'\\.', String.Heredoc),
|
| 425 |
+
(r'\n+', String.Heredoc),
|
| 426 |
+
include('interpol'),
|
| 427 |
+
],
|
| 428 |
+
'heredoc_no_interpol': [
|
| 429 |
+
(r'[^\\\n]+', String.Heredoc),
|
| 430 |
+
(r'\\.', String.Heredoc),
|
| 431 |
+
(r'\n+', Whitespace),
|
| 432 |
+
],
|
| 433 |
+
'escapes': [
|
| 434 |
+
(long_hex_char_re,
|
| 435 |
+
bygroups(String.Escape, Number.Hex, String.Escape)),
|
| 436 |
+
(hex_char_re, String.Escape),
|
| 437 |
+
(escape_char_re, String.Escape),
|
| 438 |
+
],
|
| 439 |
+
'interpol': [
|
| 440 |
+
(r'#\{', String.Interpol, 'interpol_string'),
|
| 441 |
+
],
|
| 442 |
+
'interpol_string': [
|
| 443 |
+
(r'\}', String.Interpol, "#pop"),
|
| 444 |
+
include('root')
|
| 445 |
+
],
|
| 446 |
+
'map_key': [
|
| 447 |
+
include('root'),
|
| 448 |
+
(r':', Punctuation, 'map_val'),
|
| 449 |
+
(r'=>', Punctuation, 'map_val'),
|
| 450 |
+
(r'\}', Punctuation, '#pop'),
|
| 451 |
+
],
|
| 452 |
+
'map_val': [
|
| 453 |
+
include('root'),
|
| 454 |
+
(r',', Punctuation, '#pop'),
|
| 455 |
+
(r'(?=\})', Punctuation, '#pop'),
|
| 456 |
+
],
|
| 457 |
+
'tuple': [
|
| 458 |
+
include('root'),
|
| 459 |
+
(r'\}', Punctuation, '#pop'),
|
| 460 |
+
],
|
| 461 |
+
}
|
| 462 |
+
tokens.update(gen_elixir_string_rules('double', '"', String.Double))
|
| 463 |
+
tokens.update(gen_elixir_string_rules('single', "'", String.Single))
|
| 464 |
+
tokens.update(gen_elixir_string_rules('double_atom', '"', String.Symbol))
|
| 465 |
+
tokens.update(gen_elixir_string_rules('single_atom', "'", String.Symbol))
|
| 466 |
+
tokens.update(gen_elixir_sigil_rules())
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
class ElixirConsoleLexer(Lexer):
|
| 470 |
+
"""
|
| 471 |
+
For Elixir interactive console (iex) output like:
|
| 472 |
+
|
| 473 |
+
.. sourcecode:: iex
|
| 474 |
+
|
| 475 |
+
iex> [head | tail] = [1,2,3]
|
| 476 |
+
[1,2,3]
|
| 477 |
+
iex> head
|
| 478 |
+
1
|
| 479 |
+
iex> tail
|
| 480 |
+
[2,3]
|
| 481 |
+
iex> [head | tail]
|
| 482 |
+
[1,2,3]
|
| 483 |
+
iex> length [head | tail]
|
| 484 |
+
3
|
| 485 |
+
"""
|
| 486 |
+
|
| 487 |
+
name = 'Elixir iex session'
|
| 488 |
+
aliases = ['iex']
|
| 489 |
+
mimetypes = ['text/x-elixir-shellsession']
|
| 490 |
+
url = 'https://elixir-lang.org'
|
| 491 |
+
version_added = '1.5'
|
| 492 |
+
|
| 493 |
+
_prompt_re = re.compile(r'(iex|\.{3})((?:\([\w@_.]+\))?\d+|\(\d+\))?> ')
|
| 494 |
+
|
| 495 |
+
def get_tokens_unprocessed(self, text):
|
| 496 |
+
exlexer = ElixirLexer(**self.options)
|
| 497 |
+
|
| 498 |
+
curcode = ''
|
| 499 |
+
in_error = False
|
| 500 |
+
insertions = []
|
| 501 |
+
for match in line_re.finditer(text):
|
| 502 |
+
line = match.group()
|
| 503 |
+
if line.startswith('** '):
|
| 504 |
+
in_error = True
|
| 505 |
+
insertions.append((len(curcode),
|
| 506 |
+
[(0, Generic.Error, line[:-1])]))
|
| 507 |
+
curcode += line[-1:]
|
| 508 |
+
else:
|
| 509 |
+
m = self._prompt_re.match(line)
|
| 510 |
+
if m is not None:
|
| 511 |
+
in_error = False
|
| 512 |
+
end = m.end()
|
| 513 |
+
insertions.append((len(curcode),
|
| 514 |
+
[(0, Generic.Prompt, line[:end])]))
|
| 515 |
+
curcode += line[end:]
|
| 516 |
+
else:
|
| 517 |
+
if curcode:
|
| 518 |
+
yield from do_insertions(
|
| 519 |
+
insertions, exlexer.get_tokens_unprocessed(curcode))
|
| 520 |
+
curcode = ''
|
| 521 |
+
insertions = []
|
| 522 |
+
token = Generic.Error if in_error else Generic.Output
|
| 523 |
+
yield match.start(), token, line
|
| 524 |
+
if curcode:
|
| 525 |
+
yield from do_insertions(
|
| 526 |
+
insertions, exlexer.get_tokens_unprocessed(curcode))
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/esoteric.py
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.esoteric
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for esoteric languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, words, bygroups
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, \
|
| 13 |
+
Punctuation, Error, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'CAmkESLexer',
|
| 16 |
+
'CapDLLexer', 'AheuiLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class BrainfuckLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
Lexer for the esoteric BrainFuck language.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
name = 'Brainfuck'
|
| 25 |
+
url = 'http://www.muppetlabs.com/~breadbox/bf/'
|
| 26 |
+
aliases = ['brainfuck', 'bf']
|
| 27 |
+
filenames = ['*.bf', '*.b']
|
| 28 |
+
mimetypes = ['application/x-brainfuck']
|
| 29 |
+
version_added = ''
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'common': [
|
| 33 |
+
# use different colors for different instruction types
|
| 34 |
+
(r'[.,]+', Name.Tag),
|
| 35 |
+
(r'[+-]+', Name.Builtin),
|
| 36 |
+
(r'[<>]+', Name.Variable),
|
| 37 |
+
(r'[^.,+\-<>\[\]]+', Comment),
|
| 38 |
+
],
|
| 39 |
+
'root': [
|
| 40 |
+
(r'\[', Keyword, 'loop'),
|
| 41 |
+
(r'\]', Error),
|
| 42 |
+
include('common'),
|
| 43 |
+
],
|
| 44 |
+
'loop': [
|
| 45 |
+
(r'\[', Keyword, '#push'),
|
| 46 |
+
(r'\]', Keyword, '#pop'),
|
| 47 |
+
include('common'),
|
| 48 |
+
]
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
def analyse_text(text):
|
| 52 |
+
"""It's safe to assume that a program which mostly consists of + -
|
| 53 |
+
and < > is brainfuck."""
|
| 54 |
+
plus_minus_count = 0
|
| 55 |
+
greater_less_count = 0
|
| 56 |
+
|
| 57 |
+
range_to_check = max(256, len(text))
|
| 58 |
+
|
| 59 |
+
for c in text[:range_to_check]:
|
| 60 |
+
if c == '+' or c == '-':
|
| 61 |
+
plus_minus_count += 1
|
| 62 |
+
if c == '<' or c == '>':
|
| 63 |
+
greater_less_count += 1
|
| 64 |
+
|
| 65 |
+
if plus_minus_count > (0.25 * range_to_check):
|
| 66 |
+
return 1.0
|
| 67 |
+
if greater_less_count > (0.25 * range_to_check):
|
| 68 |
+
return 1.0
|
| 69 |
+
|
| 70 |
+
result = 0
|
| 71 |
+
if '[-]' in text:
|
| 72 |
+
result += 0.5
|
| 73 |
+
|
| 74 |
+
return result
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class BefungeLexer(RegexLexer):
|
| 78 |
+
"""
|
| 79 |
+
Lexer for the esoteric Befunge language.
|
| 80 |
+
"""
|
| 81 |
+
name = 'Befunge'
|
| 82 |
+
url = 'http://en.wikipedia.org/wiki/Befunge'
|
| 83 |
+
aliases = ['befunge']
|
| 84 |
+
filenames = ['*.befunge']
|
| 85 |
+
mimetypes = ['application/x-befunge']
|
| 86 |
+
version_added = '0.7'
|
| 87 |
+
|
| 88 |
+
tokens = {
|
| 89 |
+
'root': [
|
| 90 |
+
(r'[0-9a-f]', Number),
|
| 91 |
+
(r'[+*/%!`-]', Operator), # Traditional math
|
| 92 |
+
(r'[<>^v?\[\]rxjk]', Name.Variable), # Move, imperatives
|
| 93 |
+
(r'[:\\$.,n]', Name.Builtin), # Stack ops, imperatives
|
| 94 |
+
(r'[|_mw]', Keyword),
|
| 95 |
+
(r'[{}]', Name.Tag), # Befunge-98 stack ops
|
| 96 |
+
(r'".*?"', String.Double), # Strings don't appear to allow escapes
|
| 97 |
+
(r'\'.', String.Single), # Single character
|
| 98 |
+
(r'[#;]', Comment), # Trampoline... depends on direction hit
|
| 99 |
+
(r'[pg&~=@iotsy]', Keyword), # Misc
|
| 100 |
+
(r'[()A-Z]', Comment), # Fingerprints
|
| 101 |
+
(r'\s+', Whitespace), # Whitespace doesn't matter
|
| 102 |
+
],
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class CAmkESLexer(RegexLexer):
|
| 107 |
+
"""
|
| 108 |
+
Basic lexer for the input language for the CAmkES component platform.
|
| 109 |
+
"""
|
| 110 |
+
name = 'CAmkES'
|
| 111 |
+
url = 'https://sel4.systems/CAmkES/'
|
| 112 |
+
aliases = ['camkes', 'idl4']
|
| 113 |
+
filenames = ['*.camkes', '*.idl4']
|
| 114 |
+
version_added = '2.1'
|
| 115 |
+
|
| 116 |
+
tokens = {
|
| 117 |
+
'root': [
|
| 118 |
+
# C pre-processor directive
|
| 119 |
+
(r'^(\s*)(#.*)(\n)', bygroups(Whitespace, Comment.Preproc,
|
| 120 |
+
Whitespace)),
|
| 121 |
+
|
| 122 |
+
# Whitespace, comments
|
| 123 |
+
(r'\s+', Whitespace),
|
| 124 |
+
(r'/\*(.|\n)*?\*/', Comment),
|
| 125 |
+
(r'//.*$', Comment),
|
| 126 |
+
|
| 127 |
+
(r'[\[(){},.;\]]', Punctuation),
|
| 128 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 129 |
+
|
| 130 |
+
(words(('assembly', 'attribute', 'component', 'composition',
|
| 131 |
+
'configuration', 'connection', 'connector', 'consumes',
|
| 132 |
+
'control', 'dataport', 'Dataport', 'Dataports', 'emits',
|
| 133 |
+
'event', 'Event', 'Events', 'export', 'from', 'group',
|
| 134 |
+
'hardware', 'has', 'interface', 'Interface', 'maybe',
|
| 135 |
+
'procedure', 'Procedure', 'Procedures', 'provides',
|
| 136 |
+
'template', 'thread', 'threads', 'to', 'uses', 'with'),
|
| 137 |
+
suffix=r'\b'), Keyword),
|
| 138 |
+
|
| 139 |
+
(words(('bool', 'boolean', 'Buf', 'char', 'character', 'double',
|
| 140 |
+
'float', 'in', 'inout', 'int', 'int16_6', 'int32_t',
|
| 141 |
+
'int64_t', 'int8_t', 'integer', 'mutex', 'out', 'real',
|
| 142 |
+
'refin', 'semaphore', 'signed', 'string', 'struct',
|
| 143 |
+
'uint16_t', 'uint32_t', 'uint64_t', 'uint8_t', 'uintptr_t',
|
| 144 |
+
'unsigned', 'void'),
|
| 145 |
+
suffix=r'\b'), Keyword.Type),
|
| 146 |
+
|
| 147 |
+
# Recognised attributes
|
| 148 |
+
(r'[a-zA-Z_]\w*_(priority|domain|buffer)', Keyword.Reserved),
|
| 149 |
+
(words(('dma_pool', 'from_access', 'to_access'), suffix=r'\b'),
|
| 150 |
+
Keyword.Reserved),
|
| 151 |
+
|
| 152 |
+
# CAmkES-level include
|
| 153 |
+
(r'(import)(\s+)((?:<[^>]*>|"[^"]*");)',
|
| 154 |
+
bygroups(Comment.Preproc, Whitespace, Comment.Preproc)),
|
| 155 |
+
|
| 156 |
+
# C-level include
|
| 157 |
+
(r'(include)(\s+)((?:<[^>]*>|"[^"]*");)',
|
| 158 |
+
bygroups(Comment.Preproc, Whitespace, Comment.Preproc)),
|
| 159 |
+
|
| 160 |
+
# Literals
|
| 161 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 162 |
+
(r'-?[\d]+', Number),
|
| 163 |
+
(r'-?[\d]+\.[\d]+', Number.Float),
|
| 164 |
+
(r'"[^"]*"', String),
|
| 165 |
+
(r'[Tt]rue|[Ff]alse', Name.Builtin),
|
| 166 |
+
|
| 167 |
+
# Identifiers
|
| 168 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 169 |
+
],
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
class CapDLLexer(RegexLexer):
|
| 174 |
+
"""
|
| 175 |
+
Basic lexer for CapDL.
|
| 176 |
+
|
| 177 |
+
The source of the primary tool that reads such specifications is available
|
| 178 |
+
at https://github.com/seL4/capdl/tree/master/capDL-tool. Note that this
|
| 179 |
+
lexer only supports a subset of the grammar. For example, identifiers can
|
| 180 |
+
shadow type names, but these instances are currently incorrectly
|
| 181 |
+
highlighted as types. Supporting this would need a stateful lexer that is
|
| 182 |
+
considered unnecessarily complex for now.
|
| 183 |
+
"""
|
| 184 |
+
name = 'CapDL'
|
| 185 |
+
url = 'https://ssrg.nicta.com.au/publications/nictaabstracts/Kuz_KLW_10.abstract.pml'
|
| 186 |
+
aliases = ['capdl']
|
| 187 |
+
filenames = ['*.cdl']
|
| 188 |
+
version_added = '2.2'
|
| 189 |
+
|
| 190 |
+
tokens = {
|
| 191 |
+
'root': [
|
| 192 |
+
# C pre-processor directive
|
| 193 |
+
(r'^(\s*)(#.*)(\n)',
|
| 194 |
+
bygroups(Whitespace, Comment.Preproc, Whitespace)),
|
| 195 |
+
|
| 196 |
+
# Whitespace, comments
|
| 197 |
+
(r'\s+', Whitespace),
|
| 198 |
+
(r'/\*(.|\n)*?\*/', Comment),
|
| 199 |
+
(r'(//|--).*$', Comment),
|
| 200 |
+
|
| 201 |
+
(r'[<>\[(){},:;=\]]', Punctuation),
|
| 202 |
+
(r'\.\.', Punctuation),
|
| 203 |
+
|
| 204 |
+
(words(('arch', 'arm11', 'caps', 'child_of', 'ia32', 'irq', 'maps',
|
| 205 |
+
'objects'), suffix=r'\b'), Keyword),
|
| 206 |
+
|
| 207 |
+
(words(('aep', 'asid_pool', 'cnode', 'ep', 'frame', 'io_device',
|
| 208 |
+
'io_ports', 'io_pt', 'notification', 'pd', 'pt', 'tcb',
|
| 209 |
+
'ut', 'vcpu'), suffix=r'\b'), Keyword.Type),
|
| 210 |
+
|
| 211 |
+
# Properties
|
| 212 |
+
(words(('asid', 'addr', 'badge', 'cached', 'dom', 'domainID', 'elf',
|
| 213 |
+
'fault_ep', 'G', 'guard', 'guard_size', 'init', 'ip',
|
| 214 |
+
'prio', 'sp', 'R', 'RG', 'RX', 'RW', 'RWG', 'RWX', 'W',
|
| 215 |
+
'WG', 'WX', 'level', 'masked', 'master_reply', 'paddr',
|
| 216 |
+
'ports', 'reply', 'uncached'), suffix=r'\b'),
|
| 217 |
+
Keyword.Reserved),
|
| 218 |
+
|
| 219 |
+
# Literals
|
| 220 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 221 |
+
(r'\d+(\.\d+)?(k|M)?', Number),
|
| 222 |
+
(words(('bits',), suffix=r'\b'), Number),
|
| 223 |
+
(words(('cspace', 'vspace', 'reply_slot', 'caller_slot',
|
| 224 |
+
'ipc_buffer_slot'), suffix=r'\b'), Number),
|
| 225 |
+
|
| 226 |
+
# Identifiers
|
| 227 |
+
(r'[a-zA-Z_][-@\.\w]*', Name),
|
| 228 |
+
],
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
class RedcodeLexer(RegexLexer):
|
| 233 |
+
"""
|
| 234 |
+
A simple Redcode lexer based on ICWS'94.
|
| 235 |
+
Contributed by Adam Blinkinsop <blinks@acm.org>.
|
| 236 |
+
"""
|
| 237 |
+
name = 'Redcode'
|
| 238 |
+
aliases = ['redcode']
|
| 239 |
+
filenames = ['*.cw']
|
| 240 |
+
url = 'https://en.wikipedia.org/wiki/Core_War'
|
| 241 |
+
version_added = '0.8'
|
| 242 |
+
|
| 243 |
+
opcodes = ('DAT', 'MOV', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD',
|
| 244 |
+
'JMP', 'JMZ', 'JMN', 'DJN', 'CMP', 'SLT', 'SPL',
|
| 245 |
+
'ORG', 'EQU', 'END')
|
| 246 |
+
modifiers = ('A', 'B', 'AB', 'BA', 'F', 'X', 'I')
|
| 247 |
+
|
| 248 |
+
tokens = {
|
| 249 |
+
'root': [
|
| 250 |
+
# Whitespace:
|
| 251 |
+
(r'\s+', Whitespace),
|
| 252 |
+
(r';.*$', Comment.Single),
|
| 253 |
+
# Lexemes:
|
| 254 |
+
# Identifiers
|
| 255 |
+
(r'\b({})\b'.format('|'.join(opcodes)), Name.Function),
|
| 256 |
+
(r'\b({})\b'.format('|'.join(modifiers)), Name.Decorator),
|
| 257 |
+
(r'[A-Za-z_]\w+', Name),
|
| 258 |
+
# Operators
|
| 259 |
+
(r'[-+*/%]', Operator),
|
| 260 |
+
(r'[#$@<>]', Operator), # mode
|
| 261 |
+
(r'[.,]', Punctuation), # mode
|
| 262 |
+
# Numbers
|
| 263 |
+
(r'[-+]?\d+', Number.Integer),
|
| 264 |
+
],
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
class AheuiLexer(RegexLexer):
|
| 269 |
+
"""
|
| 270 |
+
Aheui is esoteric language based on Korean alphabets.
|
| 271 |
+
"""
|
| 272 |
+
|
| 273 |
+
name = 'Aheui'
|
| 274 |
+
url = 'http://aheui.github.io/'
|
| 275 |
+
aliases = ['aheui']
|
| 276 |
+
filenames = ['*.aheui']
|
| 277 |
+
version_added = ''
|
| 278 |
+
|
| 279 |
+
tokens = {
|
| 280 |
+
'root': [
|
| 281 |
+
('['
|
| 282 |
+
'나-낳냐-냫너-넣녀-녛노-놓뇨-눟뉴-닇'
|
| 283 |
+
'다-닿댜-댷더-덯뎌-뎧도-돟됴-둫듀-딓'
|
| 284 |
+
'따-땋땨-떃떠-떻뗘-뗳또-똫뚀-뚷뜌-띟'
|
| 285 |
+
'라-랗랴-럏러-렇려-렿로-롷료-뤃류-릫'
|
| 286 |
+
'마-맣먀-먛머-멓며-몋모-뫃묘-뭏뮤-믷'
|
| 287 |
+
'바-밯뱌-뱧버-벟벼-볗보-봏뵤-붛뷰-빃'
|
| 288 |
+
'빠-빻뺘-뺳뻐-뻫뼈-뼣뽀-뽛뾰-뿧쀼-삏'
|
| 289 |
+
'사-샇샤-샿서-섷셔-셯소-솧쇼-숳슈-싛'
|
| 290 |
+
'싸-쌓쌰-썋써-쎃쎠-쎻쏘-쏳쑈-쑿쓔-씧'
|
| 291 |
+
'자-잫쟈-쟣저-젛져-졓조-좋죠-줗쥬-즿'
|
| 292 |
+
'차-챃챠-챻처-첳쳐-쳫초-촣쵸-춯츄-칗'
|
| 293 |
+
'카-캏캬-컇커-컿켜-켷코-콯쿄-쿻큐-킣'
|
| 294 |
+
'타-탛탸-턓터-텋텨-톃토-톻툐-퉇튜-틯'
|
| 295 |
+
'파-팧퍄-퍟퍼-펗펴-폏포-퐇표-풓퓨-픻'
|
| 296 |
+
'하-핳햐-햫허-헣혀-혛호-홓효-훟휴-힇'
|
| 297 |
+
']', Operator),
|
| 298 |
+
('.', Comment),
|
| 299 |
+
],
|
| 300 |
+
}
|
.cache/uv/archive-v0/-QecaSt9lkcuAvMMDLevW/pygments/lexers/ezhil.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ezhil
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments lexers for Ezhil language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, words
|
| 14 |
+
from pygments.token import Keyword, Comment, Name, String, Number, \
|
| 15 |
+
Punctuation, Operator, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['EzhilLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class EzhilLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for Ezhil, a Tamil script-based programming language.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Ezhil'
|
| 25 |
+
url = 'http://ezhillang.org'
|
| 26 |
+
aliases = ['ezhil']
|
| 27 |
+
filenames = ['*.n']
|
| 28 |
+
mimetypes = ['text/x-ezhil']
|
| 29 |
+
version_added = '2.1'
|
| 30 |
+
# Refer to tamil.utf8.tamil_letters from open-tamil for a stricter version of this.
|
| 31 |
+
# This much simpler version is close enough, and includes combining marks.
|
| 32 |
+
_TALETTERS = '[a-zA-Z_]|[\u0b80-\u0bff]'
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
include('keywords'),
|
| 36 |
+
(r'#.*$', Comment.Single),
|
| 37 |
+
(r'[@+/*,^\-%]|[!<>=]=?|&&?|\|\|?', Operator),
|
| 38 |
+
('இல்', Operator.Word),
|
| 39 |
+
(words(('assert', 'max', 'min',
|
| 40 |
+
'நீளம்', 'சரம்_இடமாற்று', 'சரம்_கண்டுபிடி',
|
| 41 |
+
'பட்டியல்', 'பின்இணை', 'வரிசைப்படுத்து',
|
| 42 |
+
'எடு', 'தலைகீழ்', 'நீட்டிக்க', 'நுழைக்க', 'வை',
|
| 43 |
+
'கோப்பை_திற', 'கோப்பை_எழுது', 'கோப்பை_மூடு',
|
| 44 |
+
'pi', 'sin', 'cos', 'tan', 'sqrt', 'hypot', 'pow',
|
| 45 |
+
'exp', 'log', 'log10', 'exit',
|
| 46 |
+
), suffix=r'\b'), Name.Builtin),
|
| 47 |
+
(r'(True|False)\b', Keyword.Constant),
|
| 48 |
+
(r'[^\S\n]+', Whitespace),
|
| 49 |
+
include('identifier'),
|
| 50 |
+
include('literal'),
|
| 51 |
+
(r'[(){}\[\]:;.]', Punctuation),
|
| 52 |
+
],
|
| 53 |
+
'keywords': [
|
| 54 |
+
('பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword),
|
| 55 |
+
],
|
| 56 |
+
'identifier': [
|
| 57 |
+
('(?:'+_TALETTERS+')(?:[0-9]|'+_TALETTERS+')*', Name),
|
| 58 |
+
],
|
| 59 |
+
'literal': [
|
| 60 |
+
(r'".*?"', String),
|
| 61 |
+
(r'\d+((\.\d*)?[eE][+-]?\d+|\.\d*)', Number.Float),
|
| 62 |
+
(r'\d+', Number.Integer),
|
| 63 |
+
]
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
def analyse_text(text):
|
| 67 |
+
"""This language uses Tamil-script. We'll assume that if there's a
|
| 68 |
+
decent amount of Tamil-characters, it's this language. This assumption
|
| 69 |
+
is obviously horribly off if someone uses string literals in tamil
|
| 70 |
+
in another language."""
|
| 71 |
+
if len(re.findall(r'[\u0b80-\u0bff]', text)) > 10:
|
| 72 |
+
return 0.25
|
| 73 |
+
|
| 74 |
+
def __init__(self, **options):
|
| 75 |
+
super().__init__(**options)
|
| 76 |
+
self.encoding = options.get('encoding', 'utf-8')
|