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/2/7/7/6/0/2776091d74378df9859068b389c0d96d3f76c8668c74613451e22e86.body +3 -0
- .cache/pip/http-v2/c/d/5/d/e/cd5de44b899cbe1869765c21b55cffc53c0c0ffa9d3c6f1fd40a42a2.body +3 -0
- .cache/pip/http-v2/d/2/5/3/1/d2531450b00c0f876e3ca84ca161003746b7b3d143f1136ba3f06223.body +3 -0
- .cache/pip/http-v2/d/3/2/9/d/d329d269473dcb26bc2fcf82e354619e8463ba8855d5a3b77637c124.body +3 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/__init__.py +82 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/__main__.py +17 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/cmdline.py +668 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/console.py +70 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/filter.py +70 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/formatter.py +129 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexer.py +963 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/smithy.py +77 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/snobol.py +82 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/sophia.py +102 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/sql.py +1111 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/stata.py +170 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tal.py +77 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tcl.py +148 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/teal.py +88 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/teraterm.py +335 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/text.py +27 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/textedit.py +205 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/theorem.py +410 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/thingsdb.py +143 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tlb.py +59 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tls.py +54 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tnt.py +270 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/trafficscript.py +51 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/typoscript.py +216 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/ul4.py +309 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/unicon.py +413 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/urbi.py +145 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/usd.py +85 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/varnish.py +189 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/verification.py +113 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/verifpal.py +65 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/vip.py +150 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/vyper.py +140 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/web.py +24 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webassembly.py +119 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webidl.py +298 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webmisc.py +1006 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wgsl.py +406 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/whiley.py +115 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wowtoc.py +120 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wren.py +98 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/x10.py +66 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/xorg.py +38 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/yang.py +103 -0
- .cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/yara.py +69 -0
.cache/pip/http-v2/2/7/7/6/0/2776091d74378df9859068b389c0d96d3f76c8668c74613451e22e86.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6dc0b3fd2169c9157deed50b4d519553a3655c8c6a96027136d654592be973a9
|
| 3 |
+
size 10894600
|
.cache/pip/http-v2/c/d/5/d/e/cd5de44b899cbe1869765c21b55cffc53c0c0ffa9d3c6f1fd40a42a2.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20db3583e7ecad78b59172dc0f2b714dcacd50333846b3f62c69c7e396d6c654
|
| 3 |
+
size 273113
|
.cache/pip/http-v2/d/2/5/3/1/d2531450b00c0f876e3ca84ca161003746b7b3d143f1136ba3f06223.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be5f93a1d21981bfb802ded0d77a0caa92d4342a47d45754fac77e314a506344
|
| 3 |
+
size 10031353
|
.cache/pip/http-v2/d/3/2/9/d/d329d269473dcb26bc2fcf82e354619e8463ba8855d5a3b77637c124.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d229510bbf63d76ba24392e87dca636200d3da7374b56c7dc9fe74ee8d1559ed
|
| 3 |
+
size 237167
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/__init__.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Pygments
|
| 3 |
+
~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Pygments is a syntax highlighting package written in Python.
|
| 6 |
+
|
| 7 |
+
It is a generic syntax highlighter for general use in all kinds of software
|
| 8 |
+
such as forum systems, wikis or other applications that need to prettify
|
| 9 |
+
source code. Highlights are:
|
| 10 |
+
|
| 11 |
+
* a wide range of common languages and markup formats is supported
|
| 12 |
+
* special attention is paid to details, increasing quality by a fair amount
|
| 13 |
+
* support for new languages and formats are added easily
|
| 14 |
+
* a number of output formats, presently HTML, LaTeX, RTF, SVG, all image
|
| 15 |
+
formats that PIL supports, and ANSI sequences
|
| 16 |
+
* it is usable as a command-line tool and as a library
|
| 17 |
+
* ... and it highlights even Brainfuck!
|
| 18 |
+
|
| 19 |
+
The `Pygments master branch`_ is installable with ``easy_install Pygments==dev``.
|
| 20 |
+
|
| 21 |
+
.. _Pygments master branch:
|
| 22 |
+
https://github.com/pygments/pygments/archive/master.zip#egg=Pygments-dev
|
| 23 |
+
|
| 24 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 25 |
+
:license: BSD, see LICENSE for details.
|
| 26 |
+
"""
|
| 27 |
+
from io import StringIO, BytesIO
|
| 28 |
+
|
| 29 |
+
__version__ = '2.20.0'
|
| 30 |
+
__docformat__ = 'restructuredtext'
|
| 31 |
+
|
| 32 |
+
__all__ = ['lex', 'format', 'highlight']
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def lex(code, lexer):
|
| 36 |
+
"""
|
| 37 |
+
Lex `code` with the `lexer` (must be a `Lexer` instance)
|
| 38 |
+
and return an iterable of tokens. Currently, this only calls
|
| 39 |
+
`lexer.get_tokens()`.
|
| 40 |
+
"""
|
| 41 |
+
try:
|
| 42 |
+
return lexer.get_tokens(code)
|
| 43 |
+
except TypeError:
|
| 44 |
+
# Heuristic to catch a common mistake.
|
| 45 |
+
from pygments.lexer import RegexLexer
|
| 46 |
+
if isinstance(lexer, type) and issubclass(lexer, RegexLexer):
|
| 47 |
+
raise TypeError('lex() argument must be a lexer instance, '
|
| 48 |
+
'not a class')
|
| 49 |
+
raise
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builtin
|
| 53 |
+
"""
|
| 54 |
+
Format ``tokens`` (an iterable of tokens) with the formatter ``formatter``
|
| 55 |
+
(a `Formatter` instance).
|
| 56 |
+
|
| 57 |
+
If ``outfile`` is given and a valid file object (an object with a
|
| 58 |
+
``write`` method), the result will be written to it, otherwise it
|
| 59 |
+
is returned as a string.
|
| 60 |
+
"""
|
| 61 |
+
try:
|
| 62 |
+
if not outfile:
|
| 63 |
+
realoutfile = getattr(formatter, 'encoding', None) and BytesIO() or StringIO()
|
| 64 |
+
formatter.format(tokens, realoutfile)
|
| 65 |
+
return realoutfile.getvalue()
|
| 66 |
+
else:
|
| 67 |
+
formatter.format(tokens, outfile)
|
| 68 |
+
except TypeError:
|
| 69 |
+
# Heuristic to catch a common mistake.
|
| 70 |
+
from pygments.formatter import Formatter
|
| 71 |
+
if isinstance(formatter, type) and issubclass(formatter, Formatter):
|
| 72 |
+
raise TypeError('format() argument must be a formatter instance, '
|
| 73 |
+
'not a class')
|
| 74 |
+
raise
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def highlight(code, lexer, formatter, outfile=None):
|
| 78 |
+
"""
|
| 79 |
+
This is the most high-level highlighting function. It combines `lex` and
|
| 80 |
+
`format` in one function.
|
| 81 |
+
"""
|
| 82 |
+
return format(lex(code, lexer), formatter, outfile)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/__main__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.__main__
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Main entry point for ``python -m pygments``.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import sys
|
| 12 |
+
import pygments.cmdline
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
sys.exit(pygments.cmdline.main(sys.argv))
|
| 16 |
+
except KeyboardInterrupt:
|
| 17 |
+
sys.exit(1)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/cmdline.py
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.cmdline
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Command line interface.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
import sys
|
| 13 |
+
import shutil
|
| 14 |
+
import argparse
|
| 15 |
+
from textwrap import dedent
|
| 16 |
+
|
| 17 |
+
from pygments import __version__, highlight
|
| 18 |
+
from pygments.util import ClassNotFound, OptionError, docstring_headline, \
|
| 19 |
+
guess_decode, guess_decode_from_terminal, terminal_encoding, \
|
| 20 |
+
UnclosingTextIOWrapper
|
| 21 |
+
from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
|
| 22 |
+
load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
|
| 23 |
+
from pygments.lexers.special import TextLexer
|
| 24 |
+
from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
|
| 25 |
+
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
|
| 26 |
+
load_formatter_from_file, get_formatter_for_filename, find_formatter_class
|
| 27 |
+
from pygments.formatters.terminal import TerminalFormatter
|
| 28 |
+
from pygments.formatters.terminal256 import Terminal256Formatter, TerminalTrueColorFormatter
|
| 29 |
+
from pygments.filters import get_all_filters, find_filter_class
|
| 30 |
+
from pygments.styles import get_all_styles, get_style_by_name
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _parse_options(o_strs):
|
| 34 |
+
opts = {}
|
| 35 |
+
if not o_strs:
|
| 36 |
+
return opts
|
| 37 |
+
for o_str in o_strs:
|
| 38 |
+
if not o_str.strip():
|
| 39 |
+
continue
|
| 40 |
+
o_args = o_str.split(',')
|
| 41 |
+
for o_arg in o_args:
|
| 42 |
+
o_arg = o_arg.strip()
|
| 43 |
+
try:
|
| 44 |
+
o_key, o_val = o_arg.split('=', 1)
|
| 45 |
+
o_key = o_key.strip()
|
| 46 |
+
o_val = o_val.strip()
|
| 47 |
+
except ValueError:
|
| 48 |
+
opts[o_arg] = True
|
| 49 |
+
else:
|
| 50 |
+
opts[o_key] = o_val
|
| 51 |
+
return opts
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _parse_filters(f_strs):
|
| 55 |
+
filters = []
|
| 56 |
+
if not f_strs:
|
| 57 |
+
return filters
|
| 58 |
+
for f_str in f_strs:
|
| 59 |
+
if ':' in f_str:
|
| 60 |
+
fname, fopts = f_str.split(':', 1)
|
| 61 |
+
filters.append((fname, _parse_options([fopts])))
|
| 62 |
+
else:
|
| 63 |
+
filters.append((f_str, {}))
|
| 64 |
+
return filters
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _print_help(what, name):
|
| 68 |
+
try:
|
| 69 |
+
if what == 'lexer':
|
| 70 |
+
cls = get_lexer_by_name(name)
|
| 71 |
+
print(f"Help on the {cls.name} lexer:")
|
| 72 |
+
print(dedent(cls.__doc__))
|
| 73 |
+
elif what == 'formatter':
|
| 74 |
+
cls = find_formatter_class(name)
|
| 75 |
+
print(f"Help on the {cls.name} formatter:")
|
| 76 |
+
print(dedent(cls.__doc__))
|
| 77 |
+
elif what == 'filter':
|
| 78 |
+
cls = find_filter_class(name)
|
| 79 |
+
print(f"Help on the {name} filter:")
|
| 80 |
+
print(dedent(cls.__doc__))
|
| 81 |
+
return 0
|
| 82 |
+
except (AttributeError, ValueError):
|
| 83 |
+
print(f"{what} not found!", file=sys.stderr)
|
| 84 |
+
return 1
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _print_list(what):
|
| 88 |
+
if what == 'lexer':
|
| 89 |
+
print()
|
| 90 |
+
print("Lexers:")
|
| 91 |
+
print("~~~~~~~")
|
| 92 |
+
|
| 93 |
+
info = []
|
| 94 |
+
for fullname, names, exts, _ in get_all_lexers():
|
| 95 |
+
tup = (', '.join(names)+':', fullname,
|
| 96 |
+
exts and '(filenames ' + ', '.join(exts) + ')' or '')
|
| 97 |
+
info.append(tup)
|
| 98 |
+
info.sort()
|
| 99 |
+
for i in info:
|
| 100 |
+
print(('* {}\n {} {}').format(*i))
|
| 101 |
+
|
| 102 |
+
elif what == 'formatter':
|
| 103 |
+
print()
|
| 104 |
+
print("Formatters:")
|
| 105 |
+
print("~~~~~~~~~~~")
|
| 106 |
+
|
| 107 |
+
info = []
|
| 108 |
+
for cls in get_all_formatters():
|
| 109 |
+
doc = docstring_headline(cls)
|
| 110 |
+
tup = (', '.join(cls.aliases) + ':', doc, cls.filenames and
|
| 111 |
+
'(filenames ' + ', '.join(cls.filenames) + ')' or '')
|
| 112 |
+
info.append(tup)
|
| 113 |
+
info.sort()
|
| 114 |
+
for i in info:
|
| 115 |
+
print(('* {}\n {} {}').format(*i))
|
| 116 |
+
|
| 117 |
+
elif what == 'filter':
|
| 118 |
+
print()
|
| 119 |
+
print("Filters:")
|
| 120 |
+
print("~~~~~~~~")
|
| 121 |
+
|
| 122 |
+
for name in get_all_filters():
|
| 123 |
+
cls = find_filter_class(name)
|
| 124 |
+
print("* " + name + ':')
|
| 125 |
+
print(f" {docstring_headline(cls)}")
|
| 126 |
+
|
| 127 |
+
elif what == 'style':
|
| 128 |
+
print()
|
| 129 |
+
print("Styles:")
|
| 130 |
+
print("~~~~~~~")
|
| 131 |
+
|
| 132 |
+
for name in get_all_styles():
|
| 133 |
+
cls = get_style_by_name(name)
|
| 134 |
+
print("* " + name + ':')
|
| 135 |
+
print(f" {docstring_headline(cls)}")
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def _print_list_as_json(requested_items):
|
| 139 |
+
import json
|
| 140 |
+
result = {}
|
| 141 |
+
if 'lexer' in requested_items:
|
| 142 |
+
info = {}
|
| 143 |
+
for fullname, names, filenames, mimetypes in get_all_lexers():
|
| 144 |
+
info[fullname] = {
|
| 145 |
+
'aliases': names,
|
| 146 |
+
'filenames': filenames,
|
| 147 |
+
'mimetypes': mimetypes
|
| 148 |
+
}
|
| 149 |
+
result['lexers'] = info
|
| 150 |
+
|
| 151 |
+
if 'formatter' in requested_items:
|
| 152 |
+
info = {}
|
| 153 |
+
for cls in get_all_formatters():
|
| 154 |
+
doc = docstring_headline(cls)
|
| 155 |
+
info[cls.name] = {
|
| 156 |
+
'aliases': cls.aliases,
|
| 157 |
+
'filenames': cls.filenames,
|
| 158 |
+
'doc': doc
|
| 159 |
+
}
|
| 160 |
+
result['formatters'] = info
|
| 161 |
+
|
| 162 |
+
if 'filter' in requested_items:
|
| 163 |
+
info = {}
|
| 164 |
+
for name in get_all_filters():
|
| 165 |
+
cls = find_filter_class(name)
|
| 166 |
+
info[name] = {
|
| 167 |
+
'doc': docstring_headline(cls)
|
| 168 |
+
}
|
| 169 |
+
result['filters'] = info
|
| 170 |
+
|
| 171 |
+
if 'style' in requested_items:
|
| 172 |
+
info = {}
|
| 173 |
+
for name in get_all_styles():
|
| 174 |
+
cls = get_style_by_name(name)
|
| 175 |
+
info[name] = {
|
| 176 |
+
'doc': docstring_headline(cls)
|
| 177 |
+
}
|
| 178 |
+
result['styles'] = info
|
| 179 |
+
|
| 180 |
+
json.dump(result, sys.stdout)
|
| 181 |
+
|
| 182 |
+
def main_inner(parser, argns):
|
| 183 |
+
if argns.help:
|
| 184 |
+
parser.print_help()
|
| 185 |
+
return 0
|
| 186 |
+
|
| 187 |
+
if argns.V:
|
| 188 |
+
print(f'Pygments version {__version__}, (c) 2006-present by Georg Brandl, Matthäus '
|
| 189 |
+
'Chajdas and contributors.')
|
| 190 |
+
return 0
|
| 191 |
+
|
| 192 |
+
def is_only_option(opt):
|
| 193 |
+
return not any(v for (k, v) in vars(argns).items() if k != opt)
|
| 194 |
+
|
| 195 |
+
# handle ``pygmentize -L``
|
| 196 |
+
if argns.L is not None:
|
| 197 |
+
arg_set = set()
|
| 198 |
+
for k, v in vars(argns).items():
|
| 199 |
+
if v:
|
| 200 |
+
arg_set.add(k)
|
| 201 |
+
|
| 202 |
+
arg_set.discard('L')
|
| 203 |
+
arg_set.discard('json')
|
| 204 |
+
|
| 205 |
+
if arg_set:
|
| 206 |
+
parser.print_help(sys.stderr)
|
| 207 |
+
return 2
|
| 208 |
+
|
| 209 |
+
# print version
|
| 210 |
+
if not argns.json:
|
| 211 |
+
main(['', '-V'])
|
| 212 |
+
allowed_types = {'lexer', 'formatter', 'filter', 'style'}
|
| 213 |
+
largs = [arg.rstrip('s') for arg in argns.L]
|
| 214 |
+
if any(arg not in allowed_types for arg in largs):
|
| 215 |
+
parser.print_help(sys.stderr)
|
| 216 |
+
return 0
|
| 217 |
+
if not largs:
|
| 218 |
+
largs = allowed_types
|
| 219 |
+
if not argns.json:
|
| 220 |
+
for arg in largs:
|
| 221 |
+
_print_list(arg)
|
| 222 |
+
else:
|
| 223 |
+
_print_list_as_json(largs)
|
| 224 |
+
return 0
|
| 225 |
+
|
| 226 |
+
# handle ``pygmentize -H``
|
| 227 |
+
if argns.H:
|
| 228 |
+
if not is_only_option('H'):
|
| 229 |
+
parser.print_help(sys.stderr)
|
| 230 |
+
return 2
|
| 231 |
+
what, name = argns.H
|
| 232 |
+
if what not in ('lexer', 'formatter', 'filter'):
|
| 233 |
+
parser.print_help(sys.stderr)
|
| 234 |
+
return 2
|
| 235 |
+
return _print_help(what, name)
|
| 236 |
+
|
| 237 |
+
# parse -O options
|
| 238 |
+
parsed_opts = _parse_options(argns.O or [])
|
| 239 |
+
|
| 240 |
+
# parse -P options
|
| 241 |
+
for p_opt in argns.P or []:
|
| 242 |
+
try:
|
| 243 |
+
name, value = p_opt.split('=', 1)
|
| 244 |
+
except ValueError:
|
| 245 |
+
parsed_opts[p_opt] = True
|
| 246 |
+
else:
|
| 247 |
+
parsed_opts[name] = value
|
| 248 |
+
|
| 249 |
+
# encodings
|
| 250 |
+
inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
|
| 251 |
+
outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
|
| 252 |
+
|
| 253 |
+
# handle ``pygmentize -N``
|
| 254 |
+
if argns.N:
|
| 255 |
+
lexer = find_lexer_class_for_filename(argns.N)
|
| 256 |
+
if lexer is None:
|
| 257 |
+
lexer = TextLexer
|
| 258 |
+
|
| 259 |
+
print(lexer.aliases[0])
|
| 260 |
+
return 0
|
| 261 |
+
|
| 262 |
+
# handle ``pygmentize -C``
|
| 263 |
+
if argns.C:
|
| 264 |
+
inp = sys.stdin.buffer.read()
|
| 265 |
+
try:
|
| 266 |
+
lexer = guess_lexer(inp, inencoding=inencoding)
|
| 267 |
+
except ClassNotFound:
|
| 268 |
+
lexer = TextLexer
|
| 269 |
+
|
| 270 |
+
print(lexer.aliases[0])
|
| 271 |
+
return 0
|
| 272 |
+
|
| 273 |
+
# handle ``pygmentize -S``
|
| 274 |
+
S_opt = argns.S
|
| 275 |
+
a_opt = argns.a
|
| 276 |
+
if S_opt is not None:
|
| 277 |
+
f_opt = argns.f
|
| 278 |
+
if not f_opt:
|
| 279 |
+
parser.print_help(sys.stderr)
|
| 280 |
+
return 2
|
| 281 |
+
if argns.l or argns.INPUTFILE:
|
| 282 |
+
parser.print_help(sys.stderr)
|
| 283 |
+
return 2
|
| 284 |
+
|
| 285 |
+
try:
|
| 286 |
+
parsed_opts['style'] = S_opt
|
| 287 |
+
fmter = get_formatter_by_name(f_opt, **parsed_opts)
|
| 288 |
+
except ClassNotFound as err:
|
| 289 |
+
print(err, file=sys.stderr)
|
| 290 |
+
return 1
|
| 291 |
+
|
| 292 |
+
print(fmter.get_style_defs(a_opt or ''))
|
| 293 |
+
return 0
|
| 294 |
+
|
| 295 |
+
# if no -S is given, -a is not allowed
|
| 296 |
+
if argns.a is not None:
|
| 297 |
+
parser.print_help(sys.stderr)
|
| 298 |
+
return 2
|
| 299 |
+
|
| 300 |
+
# parse -F options
|
| 301 |
+
F_opts = _parse_filters(argns.F or [])
|
| 302 |
+
|
| 303 |
+
# -x: allow custom (eXternal) lexers and formatters
|
| 304 |
+
allow_custom_lexer_formatter = bool(argns.x)
|
| 305 |
+
|
| 306 |
+
# select lexer
|
| 307 |
+
lexer = None
|
| 308 |
+
|
| 309 |
+
# given by name?
|
| 310 |
+
lexername = argns.l
|
| 311 |
+
if lexername:
|
| 312 |
+
# custom lexer, located relative to user's cwd
|
| 313 |
+
if allow_custom_lexer_formatter and '.py' in lexername:
|
| 314 |
+
try:
|
| 315 |
+
filename = None
|
| 316 |
+
name = None
|
| 317 |
+
if ':' in lexername:
|
| 318 |
+
filename, name = lexername.rsplit(':', 1)
|
| 319 |
+
|
| 320 |
+
if '.py' in name:
|
| 321 |
+
# This can happen on Windows: If the lexername is
|
| 322 |
+
# C:\lexer.py -- return to normal load path in that case
|
| 323 |
+
name = None
|
| 324 |
+
|
| 325 |
+
if filename and name:
|
| 326 |
+
lexer = load_lexer_from_file(filename, name,
|
| 327 |
+
**parsed_opts)
|
| 328 |
+
else:
|
| 329 |
+
lexer = load_lexer_from_file(lexername, **parsed_opts)
|
| 330 |
+
except ClassNotFound as err:
|
| 331 |
+
print('Error:', err, file=sys.stderr)
|
| 332 |
+
return 1
|
| 333 |
+
else:
|
| 334 |
+
try:
|
| 335 |
+
lexer = get_lexer_by_name(lexername, **parsed_opts)
|
| 336 |
+
except (OptionError, ClassNotFound) as err:
|
| 337 |
+
print('Error:', err, file=sys.stderr)
|
| 338 |
+
return 1
|
| 339 |
+
|
| 340 |
+
# read input code
|
| 341 |
+
code = None
|
| 342 |
+
|
| 343 |
+
if argns.INPUTFILE:
|
| 344 |
+
if argns.s:
|
| 345 |
+
print('Error: -s option not usable when input file specified',
|
| 346 |
+
file=sys.stderr)
|
| 347 |
+
return 2
|
| 348 |
+
|
| 349 |
+
infn = argns.INPUTFILE
|
| 350 |
+
try:
|
| 351 |
+
with open(infn, 'rb') as infp:
|
| 352 |
+
code = infp.read()
|
| 353 |
+
except Exception as err:
|
| 354 |
+
print('Error: cannot read infile:', err, file=sys.stderr)
|
| 355 |
+
return 1
|
| 356 |
+
if not inencoding:
|
| 357 |
+
code, inencoding = guess_decode(code)
|
| 358 |
+
|
| 359 |
+
# do we have to guess the lexer?
|
| 360 |
+
if not lexer:
|
| 361 |
+
try:
|
| 362 |
+
lexer = get_lexer_for_filename(infn, code, **parsed_opts)
|
| 363 |
+
except ClassNotFound as err:
|
| 364 |
+
if argns.g:
|
| 365 |
+
try:
|
| 366 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 367 |
+
except ClassNotFound:
|
| 368 |
+
lexer = TextLexer(**parsed_opts)
|
| 369 |
+
else:
|
| 370 |
+
print('Error:', err, file=sys.stderr)
|
| 371 |
+
return 1
|
| 372 |
+
except OptionError as err:
|
| 373 |
+
print('Error:', err, file=sys.stderr)
|
| 374 |
+
return 1
|
| 375 |
+
|
| 376 |
+
elif not argns.s: # treat stdin as full file (-s support is later)
|
| 377 |
+
# read code from terminal, always in binary mode since we want to
|
| 378 |
+
# decode ourselves and be tolerant with it
|
| 379 |
+
code = sys.stdin.buffer.read() # use .buffer to get a binary stream
|
| 380 |
+
if not inencoding:
|
| 381 |
+
code, inencoding = guess_decode_from_terminal(code, sys.stdin)
|
| 382 |
+
# else the lexer will do the decoding
|
| 383 |
+
if not lexer:
|
| 384 |
+
try:
|
| 385 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 386 |
+
except ClassNotFound:
|
| 387 |
+
lexer = TextLexer(**parsed_opts)
|
| 388 |
+
|
| 389 |
+
else: # -s option needs a lexer with -l
|
| 390 |
+
if not lexer:
|
| 391 |
+
print('Error: when using -s a lexer has to be selected with -l',
|
| 392 |
+
file=sys.stderr)
|
| 393 |
+
return 2
|
| 394 |
+
|
| 395 |
+
# process filters
|
| 396 |
+
for fname, fopts in F_opts:
|
| 397 |
+
try:
|
| 398 |
+
lexer.add_filter(fname, **fopts)
|
| 399 |
+
except ClassNotFound as err:
|
| 400 |
+
print('Error:', err, file=sys.stderr)
|
| 401 |
+
return 1
|
| 402 |
+
|
| 403 |
+
# select formatter
|
| 404 |
+
outfn = argns.o
|
| 405 |
+
fmter = argns.f
|
| 406 |
+
if fmter:
|
| 407 |
+
# custom formatter, located relative to user's cwd
|
| 408 |
+
if allow_custom_lexer_formatter and '.py' in fmter:
|
| 409 |
+
try:
|
| 410 |
+
filename = None
|
| 411 |
+
name = None
|
| 412 |
+
if ':' in fmter:
|
| 413 |
+
# Same logic as above for custom lexer
|
| 414 |
+
filename, name = fmter.rsplit(':', 1)
|
| 415 |
+
|
| 416 |
+
if '.py' in name:
|
| 417 |
+
name = None
|
| 418 |
+
|
| 419 |
+
if filename and name:
|
| 420 |
+
fmter = load_formatter_from_file(filename, name,
|
| 421 |
+
**parsed_opts)
|
| 422 |
+
else:
|
| 423 |
+
fmter = load_formatter_from_file(fmter, **parsed_opts)
|
| 424 |
+
except ClassNotFound as err:
|
| 425 |
+
print('Error:', err, file=sys.stderr)
|
| 426 |
+
return 1
|
| 427 |
+
else:
|
| 428 |
+
try:
|
| 429 |
+
fmter = get_formatter_by_name(fmter, **parsed_opts)
|
| 430 |
+
except (OptionError, ClassNotFound) as err:
|
| 431 |
+
print('Error:', err, file=sys.stderr)
|
| 432 |
+
return 1
|
| 433 |
+
|
| 434 |
+
if outfn:
|
| 435 |
+
if not fmter:
|
| 436 |
+
try:
|
| 437 |
+
fmter = get_formatter_for_filename(outfn, **parsed_opts)
|
| 438 |
+
except (OptionError, ClassNotFound) as err:
|
| 439 |
+
print('Error:', err, file=sys.stderr)
|
| 440 |
+
return 1
|
| 441 |
+
try:
|
| 442 |
+
outfile = open(outfn, 'wb')
|
| 443 |
+
except Exception as err:
|
| 444 |
+
print('Error: cannot open outfile:', err, file=sys.stderr)
|
| 445 |
+
return 1
|
| 446 |
+
else:
|
| 447 |
+
if not fmter:
|
| 448 |
+
if os.environ.get('COLORTERM','') in ('truecolor', '24bit'):
|
| 449 |
+
fmter = TerminalTrueColorFormatter(**parsed_opts)
|
| 450 |
+
elif '256' in os.environ.get('TERM', ''):
|
| 451 |
+
fmter = Terminal256Formatter(**parsed_opts)
|
| 452 |
+
else:
|
| 453 |
+
fmter = TerminalFormatter(**parsed_opts)
|
| 454 |
+
outfile = sys.stdout.buffer
|
| 455 |
+
|
| 456 |
+
# determine output encoding if not explicitly selected
|
| 457 |
+
if not outencoding:
|
| 458 |
+
if outfn:
|
| 459 |
+
# output file? use lexer encoding for now (can still be None)
|
| 460 |
+
fmter.encoding = inencoding
|
| 461 |
+
else:
|
| 462 |
+
# else use terminal encoding
|
| 463 |
+
fmter.encoding = terminal_encoding(sys.stdout)
|
| 464 |
+
|
| 465 |
+
# provide coloring under Windows, if possible
|
| 466 |
+
if not outfn and sys.platform in ('win32', 'cygwin') and \
|
| 467 |
+
fmter.name in ('Terminal', 'Terminal256'): # pragma: no cover
|
| 468 |
+
# unfortunately colorama doesn't support binary streams on Py3
|
| 469 |
+
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
|
| 470 |
+
fmter.encoding = None
|
| 471 |
+
try:
|
| 472 |
+
import colorama.initialise
|
| 473 |
+
except ImportError:
|
| 474 |
+
pass
|
| 475 |
+
else:
|
| 476 |
+
outfile = colorama.initialise.wrap_stream(
|
| 477 |
+
outfile, convert=None, strip=None, autoreset=False, wrap=True)
|
| 478 |
+
|
| 479 |
+
# When using the LaTeX formatter and the option `escapeinside` is
|
| 480 |
+
# specified, we need a special lexer which collects escaped text
|
| 481 |
+
# before running the chosen language lexer.
|
| 482 |
+
escapeinside = parsed_opts.get('escapeinside', '')
|
| 483 |
+
if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter):
|
| 484 |
+
left = escapeinside[0]
|
| 485 |
+
right = escapeinside[1]
|
| 486 |
+
lexer = LatexEmbeddedLexer(left, right, lexer)
|
| 487 |
+
|
| 488 |
+
# ... and do it!
|
| 489 |
+
if not argns.s:
|
| 490 |
+
# process whole input as per normal...
|
| 491 |
+
try:
|
| 492 |
+
highlight(code, lexer, fmter, outfile)
|
| 493 |
+
finally:
|
| 494 |
+
if outfn:
|
| 495 |
+
outfile.close()
|
| 496 |
+
return 0
|
| 497 |
+
else:
|
| 498 |
+
# line by line processing of stdin (eg: for 'tail -f')...
|
| 499 |
+
try:
|
| 500 |
+
while 1:
|
| 501 |
+
line = sys.stdin.buffer.readline()
|
| 502 |
+
if not line:
|
| 503 |
+
break
|
| 504 |
+
if not inencoding:
|
| 505 |
+
line = guess_decode_from_terminal(line, sys.stdin)[0]
|
| 506 |
+
highlight(line, lexer, fmter, outfile)
|
| 507 |
+
if hasattr(outfile, 'flush'):
|
| 508 |
+
outfile.flush()
|
| 509 |
+
return 0
|
| 510 |
+
except KeyboardInterrupt: # pragma: no cover
|
| 511 |
+
return 0
|
| 512 |
+
finally:
|
| 513 |
+
if outfn:
|
| 514 |
+
outfile.close()
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
class HelpFormatter(argparse.HelpFormatter):
|
| 518 |
+
def __init__(self, prog, indent_increment=2, max_help_position=16, width=None):
|
| 519 |
+
if width is None:
|
| 520 |
+
try:
|
| 521 |
+
width = shutil.get_terminal_size().columns - 2
|
| 522 |
+
except Exception:
|
| 523 |
+
pass
|
| 524 |
+
argparse.HelpFormatter.__init__(self, prog, indent_increment,
|
| 525 |
+
max_help_position, width)
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
def main(args=sys.argv):
|
| 529 |
+
"""
|
| 530 |
+
Main command line entry point.
|
| 531 |
+
"""
|
| 532 |
+
desc = "Highlight an input file and write the result to an output file."
|
| 533 |
+
parser = argparse.ArgumentParser(description=desc, add_help=False,
|
| 534 |
+
formatter_class=HelpFormatter)
|
| 535 |
+
|
| 536 |
+
operation = parser.add_argument_group('Main operation')
|
| 537 |
+
lexersel = operation.add_mutually_exclusive_group()
|
| 538 |
+
lexersel.add_argument(
|
| 539 |
+
'-l', metavar='LEXER',
|
| 540 |
+
help='Specify the lexer to use. (Query names with -L.) If not '
|
| 541 |
+
'given and -g is not present, the lexer is guessed from the filename.')
|
| 542 |
+
lexersel.add_argument(
|
| 543 |
+
'-g', action='store_true',
|
| 544 |
+
help='Guess the lexer from the file contents, or pass through '
|
| 545 |
+
'as plain text if nothing can be guessed.')
|
| 546 |
+
operation.add_argument(
|
| 547 |
+
'-F', metavar='FILTER[:options]', action='append',
|
| 548 |
+
help='Add a filter to the token stream. (Query names with -L.) '
|
| 549 |
+
'Filter options are given after a colon if necessary.')
|
| 550 |
+
operation.add_argument(
|
| 551 |
+
'-f', metavar='FORMATTER',
|
| 552 |
+
help='Specify the formatter to use. (Query names with -L.) '
|
| 553 |
+
'If not given, the formatter is guessed from the output filename, '
|
| 554 |
+
'and defaults to the terminal formatter if the output is to the '
|
| 555 |
+
'terminal or an unknown file extension.')
|
| 556 |
+
operation.add_argument(
|
| 557 |
+
'-O', metavar='OPTION=value[,OPTION=value,...]', action='append',
|
| 558 |
+
help='Give options to the lexer and formatter as a comma-separated '
|
| 559 |
+
'list of key-value pairs. '
|
| 560 |
+
'Example: `-O bg=light,python=cool`.')
|
| 561 |
+
operation.add_argument(
|
| 562 |
+
'-P', metavar='OPTION=value', action='append',
|
| 563 |
+
help='Give a single option to the lexer and formatter - with this '
|
| 564 |
+
'you can pass options whose value contains commas and equal signs. '
|
| 565 |
+
'Example: `-P "heading=Pygments, the Python highlighter"`.')
|
| 566 |
+
operation.add_argument(
|
| 567 |
+
'-o', metavar='OUTPUTFILE',
|
| 568 |
+
help='Where to write the output. Defaults to standard output.')
|
| 569 |
+
|
| 570 |
+
operation.add_argument(
|
| 571 |
+
'INPUTFILE', nargs='?',
|
| 572 |
+
help='Where to read the input. Defaults to standard input.')
|
| 573 |
+
|
| 574 |
+
flags = parser.add_argument_group('Operation flags')
|
| 575 |
+
flags.add_argument(
|
| 576 |
+
'-v', action='store_true',
|
| 577 |
+
help='Print a detailed traceback on unhandled exceptions, which '
|
| 578 |
+
'is useful for debugging and bug reports.')
|
| 579 |
+
flags.add_argument(
|
| 580 |
+
'-s', action='store_true',
|
| 581 |
+
help='Process lines one at a time until EOF, rather than waiting to '
|
| 582 |
+
'process the entire file. This only works for stdin, only for lexers '
|
| 583 |
+
'with no line-spanning constructs, and is intended for streaming '
|
| 584 |
+
'input such as you get from `tail -f`. '
|
| 585 |
+
'Example usage: `tail -f sql.log | pygmentize -s -l sql`.')
|
| 586 |
+
flags.add_argument(
|
| 587 |
+
'-x', action='store_true',
|
| 588 |
+
help='Allow custom lexers and formatters to be loaded from a .py file '
|
| 589 |
+
'relative to the current working directory. For example, '
|
| 590 |
+
'`-l ./customlexer.py -x`. By default, this option expects a file '
|
| 591 |
+
'with a class named CustomLexer or CustomFormatter; you can also '
|
| 592 |
+
'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
|
| 593 |
+
'Users should be very careful not to use this option with untrusted '
|
| 594 |
+
'files, because it will import and run them.')
|
| 595 |
+
flags.add_argument('--json', help='Output as JSON. This can '
|
| 596 |
+
'be only used in conjunction with -L.',
|
| 597 |
+
default=False,
|
| 598 |
+
action='store_true')
|
| 599 |
+
|
| 600 |
+
special_modes_group = parser.add_argument_group(
|
| 601 |
+
'Special modes - do not do any highlighting')
|
| 602 |
+
special_modes = special_modes_group.add_mutually_exclusive_group()
|
| 603 |
+
special_modes.add_argument(
|
| 604 |
+
'-S', metavar='STYLE -f formatter',
|
| 605 |
+
help='Print style definitions for STYLE for a formatter '
|
| 606 |
+
'given with -f. The argument given by -a is formatter '
|
| 607 |
+
'dependent.')
|
| 608 |
+
special_modes.add_argument(
|
| 609 |
+
'-L', nargs='*', metavar='WHAT',
|
| 610 |
+
help='List lexers, formatters, styles or filters -- '
|
| 611 |
+
'give additional arguments for the thing(s) you want to list '
|
| 612 |
+
'(e.g. "styles"), or omit them to list everything.')
|
| 613 |
+
special_modes.add_argument(
|
| 614 |
+
'-N', metavar='FILENAME',
|
| 615 |
+
help='Guess and print out a lexer name based solely on the given '
|
| 616 |
+
'filename. Does not take input or highlight anything. If no specific '
|
| 617 |
+
'lexer can be determined, "text" is printed.')
|
| 618 |
+
special_modes.add_argument(
|
| 619 |
+
'-C', action='store_true',
|
| 620 |
+
help='Like -N, but print out a lexer name based solely on '
|
| 621 |
+
'a given content from standard input.')
|
| 622 |
+
special_modes.add_argument(
|
| 623 |
+
'-H', action='store', nargs=2, metavar=('NAME', 'TYPE'),
|
| 624 |
+
help='Print detailed help for the object <name> of type <type>, '
|
| 625 |
+
'where <type> is one of "lexer", "formatter" or "filter".')
|
| 626 |
+
special_modes.add_argument(
|
| 627 |
+
'-V', action='store_true',
|
| 628 |
+
help='Print the package version.')
|
| 629 |
+
special_modes.add_argument(
|
| 630 |
+
'-h', '--help', action='store_true',
|
| 631 |
+
help='Print this help.')
|
| 632 |
+
special_modes_group.add_argument(
|
| 633 |
+
'-a', metavar='ARG',
|
| 634 |
+
help='Formatter-specific additional argument for the -S (print '
|
| 635 |
+
'style sheet) mode.')
|
| 636 |
+
|
| 637 |
+
argns = parser.parse_args(args[1:])
|
| 638 |
+
|
| 639 |
+
try:
|
| 640 |
+
return main_inner(parser, argns)
|
| 641 |
+
except BrokenPipeError:
|
| 642 |
+
# someone closed our stdout, e.g. by quitting a pager.
|
| 643 |
+
return 0
|
| 644 |
+
except Exception:
|
| 645 |
+
if argns.v:
|
| 646 |
+
print(file=sys.stderr)
|
| 647 |
+
print('*' * 65, file=sys.stderr)
|
| 648 |
+
print('An unhandled exception occurred while highlighting.',
|
| 649 |
+
file=sys.stderr)
|
| 650 |
+
print('Please report the whole traceback to the issue tracker at',
|
| 651 |
+
file=sys.stderr)
|
| 652 |
+
print('<https://github.com/pygments/pygments/issues>.',
|
| 653 |
+
file=sys.stderr)
|
| 654 |
+
print('*' * 65, file=sys.stderr)
|
| 655 |
+
print(file=sys.stderr)
|
| 656 |
+
raise
|
| 657 |
+
import traceback
|
| 658 |
+
info = traceback.format_exception(*sys.exc_info())
|
| 659 |
+
msg = info[-1].strip()
|
| 660 |
+
if len(info) >= 3:
|
| 661 |
+
# extract relevant file and position info
|
| 662 |
+
msg += '\n (f{})'.format(info[-2].split('\n')[0].strip()[1:])
|
| 663 |
+
print(file=sys.stderr)
|
| 664 |
+
print('*** Error while highlighting:', file=sys.stderr)
|
| 665 |
+
print(msg, file=sys.stderr)
|
| 666 |
+
print('*** If this is a bug you want to report, please rerun with -v.',
|
| 667 |
+
file=sys.stderr)
|
| 668 |
+
return 1
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/console.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.console
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Format colored console output.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
esc = "\x1b["
|
| 12 |
+
|
| 13 |
+
codes = {}
|
| 14 |
+
codes[""] = ""
|
| 15 |
+
codes["reset"] = esc + "39;49;00m"
|
| 16 |
+
|
| 17 |
+
codes["bold"] = esc + "01m"
|
| 18 |
+
codes["faint"] = esc + "02m"
|
| 19 |
+
codes["standout"] = esc + "03m"
|
| 20 |
+
codes["underline"] = esc + "04m"
|
| 21 |
+
codes["blink"] = esc + "05m"
|
| 22 |
+
codes["overline"] = esc + "06m"
|
| 23 |
+
|
| 24 |
+
dark_colors = ["black", "red", "green", "yellow", "blue",
|
| 25 |
+
"magenta", "cyan", "gray"]
|
| 26 |
+
light_colors = ["brightblack", "brightred", "brightgreen", "brightyellow", "brightblue",
|
| 27 |
+
"brightmagenta", "brightcyan", "white"]
|
| 28 |
+
|
| 29 |
+
x = 30
|
| 30 |
+
for dark, light in zip(dark_colors, light_colors):
|
| 31 |
+
codes[dark] = esc + "%im" % x
|
| 32 |
+
codes[light] = esc + "%im" % (60 + x)
|
| 33 |
+
x += 1
|
| 34 |
+
|
| 35 |
+
del dark, light, x
|
| 36 |
+
|
| 37 |
+
codes["white"] = codes["bold"]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def reset_color():
|
| 41 |
+
return codes["reset"]
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def colorize(color_key, text):
|
| 45 |
+
return codes[color_key] + text + codes["reset"]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def ansiformat(attr, text):
|
| 49 |
+
"""
|
| 50 |
+
Format ``text`` with a color and/or some attributes::
|
| 51 |
+
|
| 52 |
+
color normal color
|
| 53 |
+
*color* bold color
|
| 54 |
+
_color_ underlined color
|
| 55 |
+
+color+ blinking color
|
| 56 |
+
"""
|
| 57 |
+
result = []
|
| 58 |
+
if attr[:1] == attr[-1:] == '+':
|
| 59 |
+
result.append(codes['blink'])
|
| 60 |
+
attr = attr[1:-1]
|
| 61 |
+
if attr[:1] == attr[-1:] == '*':
|
| 62 |
+
result.append(codes['bold'])
|
| 63 |
+
attr = attr[1:-1]
|
| 64 |
+
if attr[:1] == attr[-1:] == '_':
|
| 65 |
+
result.append(codes['underline'])
|
| 66 |
+
attr = attr[1:-1]
|
| 67 |
+
result.append(codes[attr])
|
| 68 |
+
result.append(text)
|
| 69 |
+
result.append(codes['reset'])
|
| 70 |
+
return ''.join(result)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/filter.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.filter
|
| 3 |
+
~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Module that implements the default filter.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def apply_filters(stream, filters, lexer=None):
|
| 13 |
+
"""
|
| 14 |
+
Use this method to apply an iterable of filters to
|
| 15 |
+
a stream. If lexer is given it's forwarded to the
|
| 16 |
+
filter, otherwise the filter receives `None`.
|
| 17 |
+
"""
|
| 18 |
+
def _apply(filter_, stream):
|
| 19 |
+
yield from filter_.filter(lexer, stream)
|
| 20 |
+
for filter_ in filters:
|
| 21 |
+
stream = _apply(filter_, stream)
|
| 22 |
+
return stream
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def simplefilter(f):
|
| 26 |
+
"""
|
| 27 |
+
Decorator that converts a function into a filter::
|
| 28 |
+
|
| 29 |
+
@simplefilter
|
| 30 |
+
def lowercase(self, lexer, stream, options):
|
| 31 |
+
for ttype, value in stream:
|
| 32 |
+
yield ttype, value.lower()
|
| 33 |
+
"""
|
| 34 |
+
return type(f.__name__, (FunctionFilter,), {
|
| 35 |
+
'__module__': getattr(f, '__module__'),
|
| 36 |
+
'__doc__': f.__doc__,
|
| 37 |
+
'function': f,
|
| 38 |
+
})
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class Filter:
|
| 42 |
+
"""
|
| 43 |
+
Default filter. Subclass this class or use the `simplefilter`
|
| 44 |
+
decorator to create own filters.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
def __init__(self, **options):
|
| 48 |
+
self.options = options
|
| 49 |
+
|
| 50 |
+
def filter(self, lexer, stream):
|
| 51 |
+
raise NotImplementedError()
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class FunctionFilter(Filter):
|
| 55 |
+
"""
|
| 56 |
+
Abstract class used by `simplefilter` to create simple
|
| 57 |
+
function filters on the fly. The `simplefilter` decorator
|
| 58 |
+
automatically creates subclasses of this class for
|
| 59 |
+
functions passed to it.
|
| 60 |
+
"""
|
| 61 |
+
function = None
|
| 62 |
+
|
| 63 |
+
def __init__(self, **options):
|
| 64 |
+
if not hasattr(self, 'function'):
|
| 65 |
+
raise TypeError(f'{self.__class__.__name__!r} used without bound function')
|
| 66 |
+
Filter.__init__(self, **options)
|
| 67 |
+
|
| 68 |
+
def filter(self, lexer, stream):
|
| 69 |
+
# pylint: disable=not-callable
|
| 70 |
+
yield from self.function(lexer, stream, self.options)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/formatter.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.formatter
|
| 3 |
+
~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Base formatter class.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import codecs
|
| 12 |
+
|
| 13 |
+
from pygments.util import get_bool_opt
|
| 14 |
+
from pygments.styles import get_style_by_name
|
| 15 |
+
|
| 16 |
+
__all__ = ['Formatter']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _lookup_style(style):
|
| 20 |
+
if isinstance(style, str):
|
| 21 |
+
return get_style_by_name(style)
|
| 22 |
+
return style
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class Formatter:
|
| 26 |
+
"""
|
| 27 |
+
Converts a token stream to text.
|
| 28 |
+
|
| 29 |
+
Formatters should have attributes to help selecting them. These
|
| 30 |
+
are similar to the corresponding :class:`~pygments.lexer.Lexer`
|
| 31 |
+
attributes.
|
| 32 |
+
|
| 33 |
+
.. autoattribute:: name
|
| 34 |
+
:no-value:
|
| 35 |
+
|
| 36 |
+
.. autoattribute:: aliases
|
| 37 |
+
:no-value:
|
| 38 |
+
|
| 39 |
+
.. autoattribute:: filenames
|
| 40 |
+
:no-value:
|
| 41 |
+
|
| 42 |
+
You can pass options as keyword arguments to the constructor.
|
| 43 |
+
All formatters accept these basic options:
|
| 44 |
+
|
| 45 |
+
``style``
|
| 46 |
+
The style to use, can be a string or a Style subclass
|
| 47 |
+
(default: "default"). Not used by e.g. the
|
| 48 |
+
TerminalFormatter.
|
| 49 |
+
``full``
|
| 50 |
+
Tells the formatter to output a "full" document, i.e.
|
| 51 |
+
a complete self-contained document. This doesn't have
|
| 52 |
+
any effect for some formatters (default: false).
|
| 53 |
+
``title``
|
| 54 |
+
If ``full`` is true, the title that should be used to
|
| 55 |
+
caption the document (default: '').
|
| 56 |
+
``encoding``
|
| 57 |
+
If given, must be an encoding name. This will be used to
|
| 58 |
+
convert the Unicode token strings to byte strings in the
|
| 59 |
+
output. If it is "" or None, Unicode strings will be written
|
| 60 |
+
to the output file, which most file-like objects do not
|
| 61 |
+
support (default: None).
|
| 62 |
+
``outencoding``
|
| 63 |
+
Overrides ``encoding`` if given.
|
| 64 |
+
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
#: Full name for the formatter, in human-readable form.
|
| 68 |
+
name = None
|
| 69 |
+
|
| 70 |
+
#: A list of short, unique identifiers that can be used to lookup
|
| 71 |
+
#: the formatter from a list, e.g. using :func:`.get_formatter_by_name()`.
|
| 72 |
+
aliases = []
|
| 73 |
+
|
| 74 |
+
#: A list of fnmatch patterns that match filenames for which this
|
| 75 |
+
#: formatter can produce output. The patterns in this list should be unique
|
| 76 |
+
#: among all formatters.
|
| 77 |
+
filenames = []
|
| 78 |
+
|
| 79 |
+
#: If True, this formatter outputs Unicode strings when no encoding
|
| 80 |
+
#: option is given.
|
| 81 |
+
unicodeoutput = True
|
| 82 |
+
|
| 83 |
+
def __init__(self, **options):
|
| 84 |
+
"""
|
| 85 |
+
As with lexers, this constructor takes arbitrary optional arguments,
|
| 86 |
+
and if you override it, you should first process your own options, then
|
| 87 |
+
call the base class implementation.
|
| 88 |
+
"""
|
| 89 |
+
self.style = _lookup_style(options.get('style', 'default'))
|
| 90 |
+
self.full = get_bool_opt(options, 'full', False)
|
| 91 |
+
self.title = options.get('title', '')
|
| 92 |
+
self.encoding = options.get('encoding', None) or None
|
| 93 |
+
if self.encoding in ('guess', 'chardet'):
|
| 94 |
+
# can happen for e.g. pygmentize -O encoding=guess
|
| 95 |
+
self.encoding = 'utf-8'
|
| 96 |
+
self.encoding = options.get('outencoding') or self.encoding
|
| 97 |
+
self.options = options
|
| 98 |
+
|
| 99 |
+
def get_style_defs(self, arg=''):
|
| 100 |
+
"""
|
| 101 |
+
This method must return statements or declarations suitable to define
|
| 102 |
+
the current style for subsequent highlighted text (e.g. CSS classes
|
| 103 |
+
in the `HTMLFormatter`).
|
| 104 |
+
|
| 105 |
+
The optional argument `arg` can be used to modify the generation and
|
| 106 |
+
is formatter dependent (it is standardized because it can be given on
|
| 107 |
+
the command line).
|
| 108 |
+
|
| 109 |
+
This method is called by the ``-S`` :doc:`command-line option <cmdline>`,
|
| 110 |
+
the `arg` is then given by the ``-a`` option.
|
| 111 |
+
"""
|
| 112 |
+
return ''
|
| 113 |
+
|
| 114 |
+
def format(self, tokensource, outfile):
|
| 115 |
+
"""
|
| 116 |
+
This method must format the tokens from the `tokensource` iterable and
|
| 117 |
+
write the formatted version to the file object `outfile`.
|
| 118 |
+
|
| 119 |
+
Formatter options can control how exactly the tokens are converted.
|
| 120 |
+
"""
|
| 121 |
+
if self.encoding:
|
| 122 |
+
# wrap the outfile in a StreamWriter
|
| 123 |
+
outfile = codecs.lookup(self.encoding)[3](outfile)
|
| 124 |
+
return self.format_unencoded(tokensource, outfile)
|
| 125 |
+
|
| 126 |
+
# Allow writing Formatter[str] or Formatter[bytes]. That's equivalent to
|
| 127 |
+
# Formatter. This helps when using third-party type stubs from typeshed.
|
| 128 |
+
def __class_getitem__(cls, name):
|
| 129 |
+
return cls
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexer.py
ADDED
|
@@ -0,0 +1,963 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexer
|
| 3 |
+
~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Base lexer classes.
|
| 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 sys
|
| 13 |
+
import time
|
| 14 |
+
|
| 15 |
+
from pygments.filter import apply_filters, Filter
|
| 16 |
+
from pygments.filters import get_filter_by_name
|
| 17 |
+
from pygments.token import Error, Text, Other, Whitespace, _TokenType
|
| 18 |
+
from pygments.util import get_bool_opt, get_int_opt, get_list_opt, \
|
| 19 |
+
make_analysator, Future, guess_decode
|
| 20 |
+
from pygments.regexopt import regex_opt
|
| 21 |
+
|
| 22 |
+
__all__ = ['Lexer', 'RegexLexer', 'ExtendedRegexLexer', 'DelegatingLexer',
|
| 23 |
+
'LexerContext', 'include', 'inherit', 'bygroups', 'using', 'this',
|
| 24 |
+
'default', 'words', 'line_re']
|
| 25 |
+
|
| 26 |
+
line_re = re.compile('.*?\n')
|
| 27 |
+
|
| 28 |
+
_encoding_map = [(b'\xef\xbb\xbf', 'utf-8'),
|
| 29 |
+
(b'\xff\xfe\0\0', 'utf-32'),
|
| 30 |
+
(b'\0\0\xfe\xff', 'utf-32be'),
|
| 31 |
+
(b'\xff\xfe', 'utf-16'),
|
| 32 |
+
(b'\xfe\xff', 'utf-16be')]
|
| 33 |
+
|
| 34 |
+
_default_analyse = staticmethod(lambda x: 0.0)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class LexerMeta(type):
|
| 38 |
+
"""
|
| 39 |
+
This metaclass automagically converts ``analyse_text`` methods into
|
| 40 |
+
static methods which always return float values.
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
def __new__(mcs, name, bases, d):
|
| 44 |
+
if 'analyse_text' in d:
|
| 45 |
+
d['analyse_text'] = make_analysator(d['analyse_text'])
|
| 46 |
+
return type.__new__(mcs, name, bases, d)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class Lexer(metaclass=LexerMeta):
|
| 50 |
+
"""
|
| 51 |
+
Lexer for a specific language.
|
| 52 |
+
|
| 53 |
+
See also :doc:`lexerdevelopment`, a high-level guide to writing
|
| 54 |
+
lexers.
|
| 55 |
+
|
| 56 |
+
Lexer classes have attributes used for choosing the most appropriate
|
| 57 |
+
lexer based on various criteria.
|
| 58 |
+
|
| 59 |
+
.. autoattribute:: name
|
| 60 |
+
:no-value:
|
| 61 |
+
.. autoattribute:: aliases
|
| 62 |
+
:no-value:
|
| 63 |
+
.. autoattribute:: filenames
|
| 64 |
+
:no-value:
|
| 65 |
+
.. autoattribute:: alias_filenames
|
| 66 |
+
.. autoattribute:: mimetypes
|
| 67 |
+
:no-value:
|
| 68 |
+
.. autoattribute:: priority
|
| 69 |
+
|
| 70 |
+
Lexers included in Pygments should have two additional attributes:
|
| 71 |
+
|
| 72 |
+
.. autoattribute:: url
|
| 73 |
+
:no-value:
|
| 74 |
+
.. autoattribute:: version_added
|
| 75 |
+
:no-value:
|
| 76 |
+
|
| 77 |
+
Lexers included in Pygments may have additional attributes:
|
| 78 |
+
|
| 79 |
+
.. autoattribute:: _example
|
| 80 |
+
:no-value:
|
| 81 |
+
|
| 82 |
+
You can pass options to the constructor. The basic options recognized
|
| 83 |
+
by all lexers and processed by the base `Lexer` class are:
|
| 84 |
+
|
| 85 |
+
``stripnl``
|
| 86 |
+
Strip leading and trailing newlines from the input (default: True).
|
| 87 |
+
``stripall``
|
| 88 |
+
Strip all leading and trailing whitespace from the input
|
| 89 |
+
(default: False).
|
| 90 |
+
``ensurenl``
|
| 91 |
+
Make sure that the input ends with a newline (default: True). This
|
| 92 |
+
is required for some lexers that consume input linewise.
|
| 93 |
+
|
| 94 |
+
.. versionadded:: 1.3
|
| 95 |
+
|
| 96 |
+
``tabsize``
|
| 97 |
+
If given and greater than 0, expand tabs in the input (default: 0).
|
| 98 |
+
``encoding``
|
| 99 |
+
If given, must be an encoding name. This encoding will be used to
|
| 100 |
+
convert the input string to Unicode, if it is not already a Unicode
|
| 101 |
+
string (default: ``'guess'``, which uses a simple UTF-8 / Locale /
|
| 102 |
+
Latin1 detection. Can also be ``'chardet'`` to use the chardet
|
| 103 |
+
library, if it is installed.
|
| 104 |
+
``inencoding``
|
| 105 |
+
Overrides the ``encoding`` if given.
|
| 106 |
+
"""
|
| 107 |
+
|
| 108 |
+
#: Full name of the lexer, in human-readable form
|
| 109 |
+
name = None
|
| 110 |
+
|
| 111 |
+
#: A list of short, unique identifiers that can be used to look
|
| 112 |
+
#: up the lexer from a list, e.g., using `get_lexer_by_name()`.
|
| 113 |
+
aliases = []
|
| 114 |
+
|
| 115 |
+
#: A list of `fnmatch` patterns that match filenames which contain
|
| 116 |
+
#: content for this lexer. The patterns in this list should be unique among
|
| 117 |
+
#: all lexers.
|
| 118 |
+
filenames = []
|
| 119 |
+
|
| 120 |
+
#: A list of `fnmatch` patterns that match filenames which may or may not
|
| 121 |
+
#: contain content for this lexer. This list is used by the
|
| 122 |
+
#: :func:`.guess_lexer_for_filename()` function, to determine which lexers
|
| 123 |
+
#: are then included in guessing the correct one. That means that
|
| 124 |
+
#: e.g. every lexer for HTML and a template language should include
|
| 125 |
+
#: ``\*.html`` in this list.
|
| 126 |
+
alias_filenames = []
|
| 127 |
+
|
| 128 |
+
#: A list of MIME types for content that can be lexed with this lexer.
|
| 129 |
+
mimetypes = []
|
| 130 |
+
|
| 131 |
+
#: Priority, should multiple lexers match and no content is provided
|
| 132 |
+
priority = 0
|
| 133 |
+
|
| 134 |
+
#: URL of the language specification/definition. Used in the Pygments
|
| 135 |
+
#: documentation. Set to an empty string to disable.
|
| 136 |
+
url = None
|
| 137 |
+
|
| 138 |
+
#: Version of Pygments in which the lexer was added.
|
| 139 |
+
version_added = None
|
| 140 |
+
|
| 141 |
+
#: Example file name. Relative to the ``tests/examplefiles`` directory.
|
| 142 |
+
#: This is used by the documentation generator to show an example.
|
| 143 |
+
_example = None
|
| 144 |
+
|
| 145 |
+
def __init__(self, **options):
|
| 146 |
+
"""
|
| 147 |
+
This constructor takes arbitrary options as keyword arguments.
|
| 148 |
+
Every subclass must first process its own options and then call
|
| 149 |
+
the `Lexer` constructor, since it processes the basic
|
| 150 |
+
options like `stripnl`.
|
| 151 |
+
|
| 152 |
+
An example looks like this:
|
| 153 |
+
|
| 154 |
+
.. sourcecode:: python
|
| 155 |
+
|
| 156 |
+
def __init__(self, **options):
|
| 157 |
+
self.compress = options.get('compress', '')
|
| 158 |
+
Lexer.__init__(self, **options)
|
| 159 |
+
|
| 160 |
+
As these options must all be specifiable as strings (due to the
|
| 161 |
+
command line usage), there are various utility functions
|
| 162 |
+
available to help with that, see `Utilities`_.
|
| 163 |
+
"""
|
| 164 |
+
self.options = options
|
| 165 |
+
self.stripnl = get_bool_opt(options, 'stripnl', True)
|
| 166 |
+
self.stripall = get_bool_opt(options, 'stripall', False)
|
| 167 |
+
self.ensurenl = get_bool_opt(options, 'ensurenl', True)
|
| 168 |
+
self.tabsize = get_int_opt(options, 'tabsize', 0)
|
| 169 |
+
self.encoding = options.get('encoding', 'guess')
|
| 170 |
+
self.encoding = options.get('inencoding') or self.encoding
|
| 171 |
+
self.filters = []
|
| 172 |
+
for filter_ in get_list_opt(options, 'filters', ()):
|
| 173 |
+
self.add_filter(filter_)
|
| 174 |
+
|
| 175 |
+
def __repr__(self):
|
| 176 |
+
if self.options:
|
| 177 |
+
return f'<pygments.lexers.{self.__class__.__name__} with {self.options!r}>'
|
| 178 |
+
else:
|
| 179 |
+
return f'<pygments.lexers.{self.__class__.__name__}>'
|
| 180 |
+
|
| 181 |
+
def add_filter(self, filter_, **options):
|
| 182 |
+
"""
|
| 183 |
+
Add a new stream filter to this lexer.
|
| 184 |
+
"""
|
| 185 |
+
if not isinstance(filter_, Filter):
|
| 186 |
+
filter_ = get_filter_by_name(filter_, **options)
|
| 187 |
+
self.filters.append(filter_)
|
| 188 |
+
|
| 189 |
+
def analyse_text(text):
|
| 190 |
+
"""
|
| 191 |
+
A static method which is called for lexer guessing.
|
| 192 |
+
|
| 193 |
+
It should analyse the text and return a float in the range
|
| 194 |
+
from ``0.0`` to ``1.0``. If it returns ``0.0``, the lexer
|
| 195 |
+
will not be selected as the most probable one, if it returns
|
| 196 |
+
``1.0``, it will be selected immediately. This is used by
|
| 197 |
+
`guess_lexer`.
|
| 198 |
+
|
| 199 |
+
The `LexerMeta` metaclass automatically wraps this function so
|
| 200 |
+
that it works like a static method (no ``self`` or ``cls``
|
| 201 |
+
parameter) and the return value is automatically converted to
|
| 202 |
+
`float`. If the return value is an object that is boolean `False`
|
| 203 |
+
it's the same as if the return values was ``0.0``.
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
def _preprocess_lexer_input(self, text):
|
| 207 |
+
"""Apply preprocessing such as decoding the input, removing BOM and normalizing newlines."""
|
| 208 |
+
|
| 209 |
+
if not isinstance(text, str):
|
| 210 |
+
if self.encoding == 'guess':
|
| 211 |
+
text, _ = guess_decode(text)
|
| 212 |
+
elif self.encoding == 'chardet':
|
| 213 |
+
try:
|
| 214 |
+
import chardet
|
| 215 |
+
except ImportError as e:
|
| 216 |
+
raise ImportError('To enable chardet encoding guessing, '
|
| 217 |
+
'please install the chardet library '
|
| 218 |
+
'from http://chardet.feedparser.org/') from e
|
| 219 |
+
# check for BOM first
|
| 220 |
+
decoded = None
|
| 221 |
+
for bom, encoding in _encoding_map:
|
| 222 |
+
if text.startswith(bom):
|
| 223 |
+
decoded = text[len(bom):].decode(encoding, 'replace')
|
| 224 |
+
break
|
| 225 |
+
# no BOM found, so use chardet
|
| 226 |
+
if decoded is None:
|
| 227 |
+
enc = chardet.detect(text[:1024]) # Guess using first 1KB
|
| 228 |
+
decoded = text.decode(enc.get('encoding') or 'utf-8',
|
| 229 |
+
'replace')
|
| 230 |
+
text = decoded
|
| 231 |
+
else:
|
| 232 |
+
text = text.decode(self.encoding)
|
| 233 |
+
if text.startswith('\ufeff'):
|
| 234 |
+
text = text[len('\ufeff'):]
|
| 235 |
+
else:
|
| 236 |
+
if text.startswith('\ufeff'):
|
| 237 |
+
text = text[len('\ufeff'):]
|
| 238 |
+
|
| 239 |
+
# text now *is* a unicode string
|
| 240 |
+
text = text.replace('\r\n', '\n')
|
| 241 |
+
text = text.replace('\r', '\n')
|
| 242 |
+
if self.stripall:
|
| 243 |
+
text = text.strip()
|
| 244 |
+
elif self.stripnl:
|
| 245 |
+
text = text.strip('\n')
|
| 246 |
+
if self.tabsize > 0:
|
| 247 |
+
text = text.expandtabs(self.tabsize)
|
| 248 |
+
if self.ensurenl and not text.endswith('\n'):
|
| 249 |
+
text += '\n'
|
| 250 |
+
|
| 251 |
+
return text
|
| 252 |
+
|
| 253 |
+
def get_tokens(self, text, unfiltered=False):
|
| 254 |
+
"""
|
| 255 |
+
This method is the basic interface of a lexer. It is called by
|
| 256 |
+
the `highlight()` function. It must process the text and return an
|
| 257 |
+
iterable of ``(tokentype, value)`` pairs from `text`.
|
| 258 |
+
|
| 259 |
+
Normally, you don't need to override this method. The default
|
| 260 |
+
implementation processes the options recognized by all lexers
|
| 261 |
+
(`stripnl`, `stripall` and so on), and then yields all tokens
|
| 262 |
+
from `get_tokens_unprocessed()`, with the ``index`` dropped.
|
| 263 |
+
|
| 264 |
+
If `unfiltered` is set to `True`, the filtering mechanism is
|
| 265 |
+
bypassed even if filters are defined.
|
| 266 |
+
"""
|
| 267 |
+
text = self._preprocess_lexer_input(text)
|
| 268 |
+
|
| 269 |
+
def streamer():
|
| 270 |
+
for _, t, v in self.get_tokens_unprocessed(text):
|
| 271 |
+
yield t, v
|
| 272 |
+
stream = streamer()
|
| 273 |
+
if not unfiltered:
|
| 274 |
+
stream = apply_filters(stream, self.filters, self)
|
| 275 |
+
return stream
|
| 276 |
+
|
| 277 |
+
def get_tokens_unprocessed(self, text):
|
| 278 |
+
"""
|
| 279 |
+
This method should process the text and return an iterable of
|
| 280 |
+
``(index, tokentype, value)`` tuples where ``index`` is the starting
|
| 281 |
+
position of the token within the input text.
|
| 282 |
+
|
| 283 |
+
It must be overridden by subclasses. It is recommended to
|
| 284 |
+
implement it as a generator to maximize effectiveness.
|
| 285 |
+
"""
|
| 286 |
+
raise NotImplementedError
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
class DelegatingLexer(Lexer):
|
| 290 |
+
"""
|
| 291 |
+
This lexer takes two lexer as arguments. A root lexer and
|
| 292 |
+
a language lexer. First everything is scanned using the language
|
| 293 |
+
lexer, afterwards all ``Other`` tokens are lexed using the root
|
| 294 |
+
lexer.
|
| 295 |
+
|
| 296 |
+
The lexers from the ``template`` lexer package use this base lexer.
|
| 297 |
+
"""
|
| 298 |
+
|
| 299 |
+
def __init__(self, _root_lexer, _language_lexer, _needle=Other, **options):
|
| 300 |
+
self.root_lexer = _root_lexer(**options)
|
| 301 |
+
self.language_lexer = _language_lexer(**options)
|
| 302 |
+
self.needle = _needle
|
| 303 |
+
Lexer.__init__(self, **options)
|
| 304 |
+
|
| 305 |
+
def get_tokens_unprocessed(self, text):
|
| 306 |
+
buffered = ''
|
| 307 |
+
insertions = []
|
| 308 |
+
lng_buffer = []
|
| 309 |
+
for i, t, v in self.language_lexer.get_tokens_unprocessed(text):
|
| 310 |
+
if t is self.needle:
|
| 311 |
+
if lng_buffer:
|
| 312 |
+
insertions.append((len(buffered), lng_buffer))
|
| 313 |
+
lng_buffer = []
|
| 314 |
+
buffered += v
|
| 315 |
+
else:
|
| 316 |
+
lng_buffer.append((i, t, v))
|
| 317 |
+
if lng_buffer:
|
| 318 |
+
insertions.append((len(buffered), lng_buffer))
|
| 319 |
+
return do_insertions(insertions,
|
| 320 |
+
self.root_lexer.get_tokens_unprocessed(buffered))
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
# ------------------------------------------------------------------------------
|
| 324 |
+
# RegexLexer and ExtendedRegexLexer
|
| 325 |
+
#
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
class include(str): # pylint: disable=invalid-name
|
| 329 |
+
"""
|
| 330 |
+
Indicates that a state should include rules from another state.
|
| 331 |
+
"""
|
| 332 |
+
pass
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
class _inherit:
|
| 336 |
+
"""
|
| 337 |
+
Indicates the a state should inherit from its superclass.
|
| 338 |
+
"""
|
| 339 |
+
def __repr__(self):
|
| 340 |
+
return 'inherit'
|
| 341 |
+
|
| 342 |
+
inherit = _inherit() # pylint: disable=invalid-name
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
class combined(tuple): # pylint: disable=invalid-name
|
| 346 |
+
"""
|
| 347 |
+
Indicates a state combined from multiple states.
|
| 348 |
+
"""
|
| 349 |
+
|
| 350 |
+
def __new__(cls, *args):
|
| 351 |
+
return tuple.__new__(cls, args)
|
| 352 |
+
|
| 353 |
+
def __init__(self, *args):
|
| 354 |
+
# tuple.__init__ doesn't do anything
|
| 355 |
+
pass
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
class _PseudoMatch:
|
| 359 |
+
"""
|
| 360 |
+
A pseudo match object constructed from a string.
|
| 361 |
+
"""
|
| 362 |
+
|
| 363 |
+
def __init__(self, start, text):
|
| 364 |
+
self._text = text
|
| 365 |
+
self._start = start
|
| 366 |
+
|
| 367 |
+
def start(self, arg=None):
|
| 368 |
+
return self._start
|
| 369 |
+
|
| 370 |
+
def end(self, arg=None):
|
| 371 |
+
return self._start + len(self._text)
|
| 372 |
+
|
| 373 |
+
def group(self, arg=None):
|
| 374 |
+
if arg:
|
| 375 |
+
raise IndexError('No such group')
|
| 376 |
+
return self._text
|
| 377 |
+
|
| 378 |
+
def groups(self):
|
| 379 |
+
return (self._text,)
|
| 380 |
+
|
| 381 |
+
def groupdict(self):
|
| 382 |
+
return {}
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
def bygroups(*args):
|
| 386 |
+
"""
|
| 387 |
+
Callback that yields multiple actions for each group in the match.
|
| 388 |
+
"""
|
| 389 |
+
def callback(lexer, match, ctx=None):
|
| 390 |
+
for i, action in enumerate(args):
|
| 391 |
+
if action is None:
|
| 392 |
+
continue
|
| 393 |
+
elif type(action) is _TokenType:
|
| 394 |
+
data = match.group(i + 1)
|
| 395 |
+
if data:
|
| 396 |
+
yield match.start(i + 1), action, data
|
| 397 |
+
else:
|
| 398 |
+
data = match.group(i + 1)
|
| 399 |
+
if data is not None:
|
| 400 |
+
if ctx:
|
| 401 |
+
ctx.pos = match.start(i + 1)
|
| 402 |
+
for item in action(lexer,
|
| 403 |
+
_PseudoMatch(match.start(i + 1), data), ctx):
|
| 404 |
+
if item:
|
| 405 |
+
yield item
|
| 406 |
+
if ctx:
|
| 407 |
+
ctx.pos = match.end()
|
| 408 |
+
return callback
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
class _This:
|
| 412 |
+
"""
|
| 413 |
+
Special singleton used for indicating the caller class.
|
| 414 |
+
Used by ``using``.
|
| 415 |
+
"""
|
| 416 |
+
|
| 417 |
+
this = _This()
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def using(_other, **kwargs):
|
| 421 |
+
"""
|
| 422 |
+
Callback that processes the match with a different lexer.
|
| 423 |
+
|
| 424 |
+
The keyword arguments are forwarded to the lexer, except `state` which
|
| 425 |
+
is handled separately.
|
| 426 |
+
|
| 427 |
+
`state` specifies the state that the new lexer will start in, and can
|
| 428 |
+
be an enumerable such as ('root', 'inline', 'string') or a simple
|
| 429 |
+
string which is assumed to be on top of the root state.
|
| 430 |
+
|
| 431 |
+
Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.
|
| 432 |
+
"""
|
| 433 |
+
gt_kwargs = {}
|
| 434 |
+
if 'state' in kwargs:
|
| 435 |
+
s = kwargs.pop('state')
|
| 436 |
+
if isinstance(s, (list, tuple)):
|
| 437 |
+
gt_kwargs['stack'] = s
|
| 438 |
+
else:
|
| 439 |
+
gt_kwargs['stack'] = ('root', s)
|
| 440 |
+
|
| 441 |
+
if _other is this:
|
| 442 |
+
def callback(lexer, match, ctx=None):
|
| 443 |
+
# if keyword arguments are given the callback
|
| 444 |
+
# function has to create a new lexer instance
|
| 445 |
+
if kwargs:
|
| 446 |
+
# XXX: cache that somehow
|
| 447 |
+
d = dict(lexer.options)
|
| 448 |
+
d.update(kwargs)
|
| 449 |
+
lx = lexer.__class__(**d)
|
| 450 |
+
else:
|
| 451 |
+
lx = lexer
|
| 452 |
+
s = match.start()
|
| 453 |
+
for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
|
| 454 |
+
yield i + s, t, v
|
| 455 |
+
if ctx:
|
| 456 |
+
ctx.pos = match.end()
|
| 457 |
+
else:
|
| 458 |
+
def callback(lexer, match, ctx=None):
|
| 459 |
+
# XXX: cache that somehow
|
| 460 |
+
d = dict(lexer.options)
|
| 461 |
+
d.update(kwargs)
|
| 462 |
+
lx = _other(**d)
|
| 463 |
+
|
| 464 |
+
s = match.start()
|
| 465 |
+
for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):
|
| 466 |
+
yield i + s, t, v
|
| 467 |
+
if ctx:
|
| 468 |
+
ctx.pos = match.end()
|
| 469 |
+
return callback
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
class default:
|
| 473 |
+
"""
|
| 474 |
+
Indicates a state or state action (e.g. #pop) to apply.
|
| 475 |
+
For example default('#pop') is equivalent to ('', Token, '#pop')
|
| 476 |
+
Note that state tuples may be used as well.
|
| 477 |
+
|
| 478 |
+
.. versionadded:: 2.0
|
| 479 |
+
"""
|
| 480 |
+
def __init__(self, state):
|
| 481 |
+
self.state = state
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
class words(Future):
|
| 485 |
+
"""
|
| 486 |
+
Indicates a list of literal words that is transformed into an optimized
|
| 487 |
+
regex that matches any of the words.
|
| 488 |
+
|
| 489 |
+
.. versionadded:: 2.0
|
| 490 |
+
"""
|
| 491 |
+
def __init__(self, words, prefix='', suffix=''):
|
| 492 |
+
self.words = words
|
| 493 |
+
self.prefix = prefix
|
| 494 |
+
self.suffix = suffix
|
| 495 |
+
|
| 496 |
+
def get(self):
|
| 497 |
+
return regex_opt(self.words, prefix=self.prefix, suffix=self.suffix)
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
class RegexLexerMeta(LexerMeta):
|
| 501 |
+
"""
|
| 502 |
+
Metaclass for RegexLexer, creates the self._tokens attribute from
|
| 503 |
+
self.tokens on the first instantiation.
|
| 504 |
+
"""
|
| 505 |
+
|
| 506 |
+
def _process_regex(cls, regex, rflags, state):
|
| 507 |
+
"""Preprocess the regular expression component of a token definition."""
|
| 508 |
+
if isinstance(regex, Future):
|
| 509 |
+
regex = regex.get()
|
| 510 |
+
return re.compile(regex, rflags).match
|
| 511 |
+
|
| 512 |
+
def _process_token(cls, token):
|
| 513 |
+
"""Preprocess the token component of a token definition."""
|
| 514 |
+
assert type(token) is _TokenType or callable(token), \
|
| 515 |
+
f'token type must be simple type or callable, not {token!r}'
|
| 516 |
+
return token
|
| 517 |
+
|
| 518 |
+
def _process_new_state(cls, new_state, unprocessed, processed):
|
| 519 |
+
"""Preprocess the state transition action of a token definition."""
|
| 520 |
+
if isinstance(new_state, str):
|
| 521 |
+
# an existing state
|
| 522 |
+
if new_state == '#pop':
|
| 523 |
+
return -1
|
| 524 |
+
elif new_state in unprocessed:
|
| 525 |
+
return (new_state,)
|
| 526 |
+
elif new_state == '#push':
|
| 527 |
+
return new_state
|
| 528 |
+
elif new_state[:5] == '#pop:':
|
| 529 |
+
return -int(new_state[5:])
|
| 530 |
+
else:
|
| 531 |
+
assert False, f'unknown new state {new_state!r}'
|
| 532 |
+
elif isinstance(new_state, combined):
|
| 533 |
+
# combine a new state from existing ones
|
| 534 |
+
tmp_state = '_tmp_%d' % cls._tmpname
|
| 535 |
+
cls._tmpname += 1
|
| 536 |
+
itokens = []
|
| 537 |
+
for istate in new_state:
|
| 538 |
+
assert istate != new_state, f'circular state ref {istate!r}'
|
| 539 |
+
itokens.extend(cls._process_state(unprocessed,
|
| 540 |
+
processed, istate))
|
| 541 |
+
processed[tmp_state] = itokens
|
| 542 |
+
return (tmp_state,)
|
| 543 |
+
elif isinstance(new_state, tuple):
|
| 544 |
+
# push more than one state
|
| 545 |
+
for istate in new_state:
|
| 546 |
+
assert (istate in unprocessed or
|
| 547 |
+
istate in ('#pop', '#push')), \
|
| 548 |
+
'unknown new state ' + istate
|
| 549 |
+
return new_state
|
| 550 |
+
else:
|
| 551 |
+
assert False, f'unknown new state def {new_state!r}'
|
| 552 |
+
|
| 553 |
+
def _process_state(cls, unprocessed, processed, state):
|
| 554 |
+
"""Preprocess a single state definition."""
|
| 555 |
+
assert isinstance(state, str), f"wrong state name {state!r}"
|
| 556 |
+
assert state[0] != '#', f"invalid state name {state!r}"
|
| 557 |
+
if state in processed:
|
| 558 |
+
return processed[state]
|
| 559 |
+
tokens = processed[state] = []
|
| 560 |
+
rflags = cls.flags
|
| 561 |
+
for tdef in unprocessed[state]:
|
| 562 |
+
if isinstance(tdef, include):
|
| 563 |
+
# it's a state reference
|
| 564 |
+
assert tdef != state, f"circular state reference {state!r}"
|
| 565 |
+
tokens.extend(cls._process_state(unprocessed, processed,
|
| 566 |
+
str(tdef)))
|
| 567 |
+
continue
|
| 568 |
+
if isinstance(tdef, _inherit):
|
| 569 |
+
# should be processed already, but may not in the case of:
|
| 570 |
+
# 1. the state has no counterpart in any parent
|
| 571 |
+
# 2. the state includes more than one 'inherit'
|
| 572 |
+
continue
|
| 573 |
+
if isinstance(tdef, default):
|
| 574 |
+
new_state = cls._process_new_state(tdef.state, unprocessed, processed)
|
| 575 |
+
tokens.append((re.compile('').match, None, new_state))
|
| 576 |
+
continue
|
| 577 |
+
|
| 578 |
+
assert type(tdef) is tuple, f"wrong rule def {tdef!r}"
|
| 579 |
+
|
| 580 |
+
try:
|
| 581 |
+
rex = cls._process_regex(tdef[0], rflags, state)
|
| 582 |
+
except Exception as err:
|
| 583 |
+
raise ValueError(f"uncompilable regex {tdef[0]!r} in state {state!r} of {cls!r}: {err}") from err
|
| 584 |
+
|
| 585 |
+
token = cls._process_token(tdef[1])
|
| 586 |
+
|
| 587 |
+
if len(tdef) == 2:
|
| 588 |
+
new_state = None
|
| 589 |
+
else:
|
| 590 |
+
new_state = cls._process_new_state(tdef[2],
|
| 591 |
+
unprocessed, processed)
|
| 592 |
+
|
| 593 |
+
tokens.append((rex, token, new_state))
|
| 594 |
+
return tokens
|
| 595 |
+
|
| 596 |
+
def process_tokendef(cls, name, tokendefs=None):
|
| 597 |
+
"""Preprocess a dictionary of token definitions."""
|
| 598 |
+
processed = cls._all_tokens[name] = {}
|
| 599 |
+
tokendefs = tokendefs or cls.tokens[name]
|
| 600 |
+
for state in list(tokendefs):
|
| 601 |
+
cls._process_state(tokendefs, processed, state)
|
| 602 |
+
return processed
|
| 603 |
+
|
| 604 |
+
def get_tokendefs(cls):
|
| 605 |
+
"""
|
| 606 |
+
Merge tokens from superclasses in MRO order, returning a single tokendef
|
| 607 |
+
dictionary.
|
| 608 |
+
|
| 609 |
+
Any state that is not defined by a subclass will be inherited
|
| 610 |
+
automatically. States that *are* defined by subclasses will, by
|
| 611 |
+
default, override that state in the superclass. If a subclass wishes to
|
| 612 |
+
inherit definitions from a superclass, it can use the special value
|
| 613 |
+
"inherit", which will cause the superclass' state definition to be
|
| 614 |
+
included at that point in the state.
|
| 615 |
+
"""
|
| 616 |
+
tokens = {}
|
| 617 |
+
inheritable = {}
|
| 618 |
+
for c in cls.__mro__:
|
| 619 |
+
toks = c.__dict__.get('tokens', {})
|
| 620 |
+
|
| 621 |
+
for state, items in toks.items():
|
| 622 |
+
curitems = tokens.get(state)
|
| 623 |
+
if curitems is None:
|
| 624 |
+
# N.b. because this is assigned by reference, sufficiently
|
| 625 |
+
# deep hierarchies are processed incrementally (e.g. for
|
| 626 |
+
# A(B), B(C), C(RegexLexer), B will be premodified so X(B)
|
| 627 |
+
# will not see any inherits in B).
|
| 628 |
+
tokens[state] = items
|
| 629 |
+
try:
|
| 630 |
+
inherit_ndx = items.index(inherit)
|
| 631 |
+
except ValueError:
|
| 632 |
+
continue
|
| 633 |
+
inheritable[state] = inherit_ndx
|
| 634 |
+
continue
|
| 635 |
+
|
| 636 |
+
inherit_ndx = inheritable.pop(state, None)
|
| 637 |
+
if inherit_ndx is None:
|
| 638 |
+
continue
|
| 639 |
+
|
| 640 |
+
# Replace the "inherit" value with the items
|
| 641 |
+
curitems[inherit_ndx:inherit_ndx+1] = items
|
| 642 |
+
try:
|
| 643 |
+
# N.b. this is the index in items (that is, the superclass
|
| 644 |
+
# copy), so offset required when storing below.
|
| 645 |
+
new_inh_ndx = items.index(inherit)
|
| 646 |
+
except ValueError:
|
| 647 |
+
pass
|
| 648 |
+
else:
|
| 649 |
+
inheritable[state] = inherit_ndx + new_inh_ndx
|
| 650 |
+
|
| 651 |
+
return tokens
|
| 652 |
+
|
| 653 |
+
def __call__(cls, *args, **kwds):
|
| 654 |
+
"""Instantiate cls after preprocessing its token definitions."""
|
| 655 |
+
if '_tokens' not in cls.__dict__:
|
| 656 |
+
cls._all_tokens = {}
|
| 657 |
+
cls._tmpname = 0
|
| 658 |
+
if hasattr(cls, 'token_variants') and cls.token_variants:
|
| 659 |
+
# don't process yet
|
| 660 |
+
pass
|
| 661 |
+
else:
|
| 662 |
+
cls._tokens = cls.process_tokendef('', cls.get_tokendefs())
|
| 663 |
+
|
| 664 |
+
return type.__call__(cls, *args, **kwds)
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
class RegexLexer(Lexer, metaclass=RegexLexerMeta):
|
| 668 |
+
"""
|
| 669 |
+
Base for simple stateful regular expression-based lexers.
|
| 670 |
+
Simplifies the lexing process so that you need only
|
| 671 |
+
provide a list of states and regular expressions.
|
| 672 |
+
"""
|
| 673 |
+
|
| 674 |
+
#: Flags for compiling the regular expressions.
|
| 675 |
+
#: Defaults to MULTILINE.
|
| 676 |
+
flags = re.MULTILINE
|
| 677 |
+
|
| 678 |
+
#: At all time there is a stack of states. Initially, the stack contains
|
| 679 |
+
#: a single state 'root'. The top of the stack is called "the current state".
|
| 680 |
+
#:
|
| 681 |
+
#: Dict of ``{'state': [(regex, tokentype, new_state), ...], ...}``
|
| 682 |
+
#:
|
| 683 |
+
#: ``new_state`` can be omitted to signify no state transition.
|
| 684 |
+
#: If ``new_state`` is a string, it is pushed on the stack. This ensure
|
| 685 |
+
#: the new current state is ``new_state``.
|
| 686 |
+
#: If ``new_state`` is a tuple of strings, all of those strings are pushed
|
| 687 |
+
#: on the stack and the current state will be the last element of the list.
|
| 688 |
+
#: ``new_state`` can also be ``combined('state1', 'state2', ...)``
|
| 689 |
+
#: to signify a new, anonymous state combined from the rules of two
|
| 690 |
+
#: or more existing ones.
|
| 691 |
+
#: Furthermore, it can be '#pop' to signify going back one step in
|
| 692 |
+
#: the state stack, or '#push' to push the current state on the stack
|
| 693 |
+
#: again. Note that if you push while in a combined state, the combined
|
| 694 |
+
#: state itself is pushed, and not only the state in which the rule is
|
| 695 |
+
#: defined.
|
| 696 |
+
#:
|
| 697 |
+
#: The tuple can also be replaced with ``include('state')``, in which
|
| 698 |
+
#: case the rules from the state named by the string are included in the
|
| 699 |
+
#: current one.
|
| 700 |
+
tokens = {}
|
| 701 |
+
|
| 702 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 703 |
+
"""
|
| 704 |
+
Split ``text`` into (tokentype, text) pairs.
|
| 705 |
+
|
| 706 |
+
``stack`` is the initial stack (default: ``['root']``)
|
| 707 |
+
"""
|
| 708 |
+
pos = 0
|
| 709 |
+
tokendefs = self._tokens
|
| 710 |
+
statestack = list(stack)
|
| 711 |
+
statetokens = tokendefs[statestack[-1]]
|
| 712 |
+
while 1:
|
| 713 |
+
for rexmatch, action, new_state in statetokens:
|
| 714 |
+
m = rexmatch(text, pos)
|
| 715 |
+
if m:
|
| 716 |
+
if action is not None:
|
| 717 |
+
if type(action) is _TokenType:
|
| 718 |
+
yield pos, action, m.group()
|
| 719 |
+
else:
|
| 720 |
+
yield from action(self, m)
|
| 721 |
+
pos = m.end()
|
| 722 |
+
if new_state is not None:
|
| 723 |
+
# state transition
|
| 724 |
+
if isinstance(new_state, tuple):
|
| 725 |
+
for state in new_state:
|
| 726 |
+
if state == '#pop':
|
| 727 |
+
if len(statestack) > 1:
|
| 728 |
+
statestack.pop()
|
| 729 |
+
elif state == '#push':
|
| 730 |
+
statestack.append(statestack[-1])
|
| 731 |
+
else:
|
| 732 |
+
statestack.append(state)
|
| 733 |
+
elif isinstance(new_state, int):
|
| 734 |
+
# pop, but keep at least one state on the stack
|
| 735 |
+
# (random code leading to unexpected pops should
|
| 736 |
+
# not allow exceptions)
|
| 737 |
+
if abs(new_state) >= len(statestack):
|
| 738 |
+
del statestack[1:]
|
| 739 |
+
else:
|
| 740 |
+
del statestack[new_state:]
|
| 741 |
+
elif new_state == '#push':
|
| 742 |
+
statestack.append(statestack[-1])
|
| 743 |
+
else:
|
| 744 |
+
assert False, f"wrong state def: {new_state!r}"
|
| 745 |
+
statetokens = tokendefs[statestack[-1]]
|
| 746 |
+
break
|
| 747 |
+
else:
|
| 748 |
+
# We are here only if all state tokens have been considered
|
| 749 |
+
# and there was not a match on any of them.
|
| 750 |
+
try:
|
| 751 |
+
if text[pos] == '\n':
|
| 752 |
+
# at EOL, reset state to "root"
|
| 753 |
+
statestack = ['root']
|
| 754 |
+
statetokens = tokendefs['root']
|
| 755 |
+
yield pos, Whitespace, '\n'
|
| 756 |
+
pos += 1
|
| 757 |
+
continue
|
| 758 |
+
yield pos, Error, text[pos]
|
| 759 |
+
pos += 1
|
| 760 |
+
except IndexError:
|
| 761 |
+
break
|
| 762 |
+
|
| 763 |
+
|
| 764 |
+
class LexerContext:
|
| 765 |
+
"""
|
| 766 |
+
A helper object that holds lexer position data.
|
| 767 |
+
"""
|
| 768 |
+
|
| 769 |
+
def __init__(self, text, pos, stack=None, end=None):
|
| 770 |
+
self.text = text
|
| 771 |
+
self.pos = pos
|
| 772 |
+
self.end = end or len(text) # end=0 not supported ;-)
|
| 773 |
+
self.stack = stack or ['root']
|
| 774 |
+
|
| 775 |
+
def __repr__(self):
|
| 776 |
+
return f'LexerContext({self.text!r}, {self.pos!r}, {self.stack!r})'
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
class ExtendedRegexLexer(RegexLexer):
|
| 780 |
+
"""
|
| 781 |
+
A RegexLexer that uses a context object to store its state.
|
| 782 |
+
"""
|
| 783 |
+
|
| 784 |
+
def get_tokens_unprocessed(self, text=None, context=None):
|
| 785 |
+
"""
|
| 786 |
+
Split ``text`` into (tokentype, text) pairs.
|
| 787 |
+
If ``context`` is given, use this lexer context instead.
|
| 788 |
+
"""
|
| 789 |
+
tokendefs = self._tokens
|
| 790 |
+
if not context:
|
| 791 |
+
ctx = LexerContext(text, 0)
|
| 792 |
+
statetokens = tokendefs['root']
|
| 793 |
+
else:
|
| 794 |
+
ctx = context
|
| 795 |
+
statetokens = tokendefs[ctx.stack[-1]]
|
| 796 |
+
text = ctx.text
|
| 797 |
+
while 1:
|
| 798 |
+
for rexmatch, action, new_state in statetokens:
|
| 799 |
+
m = rexmatch(text, ctx.pos, ctx.end)
|
| 800 |
+
if m:
|
| 801 |
+
if action is not None:
|
| 802 |
+
if type(action) is _TokenType:
|
| 803 |
+
yield ctx.pos, action, m.group()
|
| 804 |
+
ctx.pos = m.end()
|
| 805 |
+
else:
|
| 806 |
+
yield from action(self, m, ctx)
|
| 807 |
+
if not new_state:
|
| 808 |
+
# altered the state stack?
|
| 809 |
+
statetokens = tokendefs[ctx.stack[-1]]
|
| 810 |
+
# CAUTION: callback must set ctx.pos!
|
| 811 |
+
if new_state is not None:
|
| 812 |
+
# state transition
|
| 813 |
+
if isinstance(new_state, tuple):
|
| 814 |
+
for state in new_state:
|
| 815 |
+
if state == '#pop':
|
| 816 |
+
if len(ctx.stack) > 1:
|
| 817 |
+
ctx.stack.pop()
|
| 818 |
+
elif state == '#push':
|
| 819 |
+
ctx.stack.append(ctx.stack[-1])
|
| 820 |
+
else:
|
| 821 |
+
ctx.stack.append(state)
|
| 822 |
+
elif isinstance(new_state, int):
|
| 823 |
+
# see RegexLexer for why this check is made
|
| 824 |
+
if abs(new_state) >= len(ctx.stack):
|
| 825 |
+
del ctx.stack[1:]
|
| 826 |
+
else:
|
| 827 |
+
del ctx.stack[new_state:]
|
| 828 |
+
elif new_state == '#push':
|
| 829 |
+
ctx.stack.append(ctx.stack[-1])
|
| 830 |
+
else:
|
| 831 |
+
assert False, f"wrong state def: {new_state!r}"
|
| 832 |
+
statetokens = tokendefs[ctx.stack[-1]]
|
| 833 |
+
break
|
| 834 |
+
else:
|
| 835 |
+
try:
|
| 836 |
+
if ctx.pos >= ctx.end:
|
| 837 |
+
break
|
| 838 |
+
if text[ctx.pos] == '\n':
|
| 839 |
+
# at EOL, reset state to "root"
|
| 840 |
+
ctx.stack = ['root']
|
| 841 |
+
statetokens = tokendefs['root']
|
| 842 |
+
yield ctx.pos, Text, '\n'
|
| 843 |
+
ctx.pos += 1
|
| 844 |
+
continue
|
| 845 |
+
yield ctx.pos, Error, text[ctx.pos]
|
| 846 |
+
ctx.pos += 1
|
| 847 |
+
except IndexError:
|
| 848 |
+
break
|
| 849 |
+
|
| 850 |
+
|
| 851 |
+
def do_insertions(insertions, tokens):
|
| 852 |
+
"""
|
| 853 |
+
Helper for lexers which must combine the results of several
|
| 854 |
+
sublexers.
|
| 855 |
+
|
| 856 |
+
``insertions`` is a list of ``(index, itokens)`` pairs.
|
| 857 |
+
Each ``itokens`` iterable should be inserted at position
|
| 858 |
+
``index`` into the token stream given by the ``tokens``
|
| 859 |
+
argument.
|
| 860 |
+
|
| 861 |
+
The result is a combined token stream.
|
| 862 |
+
|
| 863 |
+
TODO: clean up the code here.
|
| 864 |
+
"""
|
| 865 |
+
insertions = iter(insertions)
|
| 866 |
+
try:
|
| 867 |
+
index, itokens = next(insertions)
|
| 868 |
+
except StopIteration:
|
| 869 |
+
# no insertions
|
| 870 |
+
yield from tokens
|
| 871 |
+
return
|
| 872 |
+
|
| 873 |
+
realpos = None
|
| 874 |
+
insleft = True
|
| 875 |
+
|
| 876 |
+
# iterate over the token stream where we want to insert
|
| 877 |
+
# the tokens from the insertion list.
|
| 878 |
+
for i, t, v in tokens:
|
| 879 |
+
# first iteration. store the position of first item
|
| 880 |
+
if realpos is None:
|
| 881 |
+
realpos = i
|
| 882 |
+
oldi = 0
|
| 883 |
+
while insleft and i + len(v) >= index:
|
| 884 |
+
tmpval = v[oldi:index - i]
|
| 885 |
+
if tmpval:
|
| 886 |
+
yield realpos, t, tmpval
|
| 887 |
+
realpos += len(tmpval)
|
| 888 |
+
for it_index, it_token, it_value in itokens:
|
| 889 |
+
yield realpos, it_token, it_value
|
| 890 |
+
realpos += len(it_value)
|
| 891 |
+
oldi = index - i
|
| 892 |
+
try:
|
| 893 |
+
index, itokens = next(insertions)
|
| 894 |
+
except StopIteration:
|
| 895 |
+
insleft = False
|
| 896 |
+
break # not strictly necessary
|
| 897 |
+
if oldi < len(v):
|
| 898 |
+
yield realpos, t, v[oldi:]
|
| 899 |
+
realpos += len(v) - oldi
|
| 900 |
+
|
| 901 |
+
# leftover tokens
|
| 902 |
+
while insleft:
|
| 903 |
+
# no normal tokens, set realpos to zero
|
| 904 |
+
realpos = realpos or 0
|
| 905 |
+
for p, t, v in itokens:
|
| 906 |
+
yield realpos, t, v
|
| 907 |
+
realpos += len(v)
|
| 908 |
+
try:
|
| 909 |
+
index, itokens = next(insertions)
|
| 910 |
+
except StopIteration:
|
| 911 |
+
insleft = False
|
| 912 |
+
break # not strictly necessary
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
class ProfilingRegexLexerMeta(RegexLexerMeta):
|
| 916 |
+
"""Metaclass for ProfilingRegexLexer, collects regex timing info."""
|
| 917 |
+
|
| 918 |
+
def _process_regex(cls, regex, rflags, state):
|
| 919 |
+
if isinstance(regex, words):
|
| 920 |
+
rex = regex_opt(regex.words, prefix=regex.prefix,
|
| 921 |
+
suffix=regex.suffix)
|
| 922 |
+
else:
|
| 923 |
+
rex = regex
|
| 924 |
+
compiled = re.compile(rex, rflags)
|
| 925 |
+
|
| 926 |
+
def match_func(text, pos, endpos=sys.maxsize):
|
| 927 |
+
info = cls._prof_data[-1].setdefault((state, rex), [0, 0.0])
|
| 928 |
+
t0 = time.time()
|
| 929 |
+
res = compiled.match(text, pos, endpos)
|
| 930 |
+
t1 = time.time()
|
| 931 |
+
info[0] += 1
|
| 932 |
+
info[1] += t1 - t0
|
| 933 |
+
return res
|
| 934 |
+
return match_func
|
| 935 |
+
|
| 936 |
+
|
| 937 |
+
class ProfilingRegexLexer(RegexLexer, metaclass=ProfilingRegexLexerMeta):
|
| 938 |
+
"""Drop-in replacement for RegexLexer that does profiling of its regexes."""
|
| 939 |
+
|
| 940 |
+
_prof_data = []
|
| 941 |
+
_prof_sort_index = 4 # defaults to time per call
|
| 942 |
+
|
| 943 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 944 |
+
# this needs to be a stack, since using(this) will produce nested calls
|
| 945 |
+
self.__class__._prof_data.append({})
|
| 946 |
+
yield from RegexLexer.get_tokens_unprocessed(self, text, stack)
|
| 947 |
+
rawdata = self.__class__._prof_data.pop()
|
| 948 |
+
data = sorted(((s, repr(r).strip('u\'').replace('\\\\', '\\')[:65],
|
| 949 |
+
n, 1000 * t, 1000 * t / n)
|
| 950 |
+
for ((s, r), (n, t)) in rawdata.items()),
|
| 951 |
+
key=lambda x: x[self._prof_sort_index],
|
| 952 |
+
reverse=True)
|
| 953 |
+
sum_total = sum(x[3] for x in data)
|
| 954 |
+
|
| 955 |
+
print()
|
| 956 |
+
print('Profiling result for %s lexing %d chars in %.3f ms' %
|
| 957 |
+
(self.__class__.__name__, len(text), sum_total))
|
| 958 |
+
print('=' * 110)
|
| 959 |
+
print('%-20s %-64s ncalls tottime percall' % ('state', 'regex'))
|
| 960 |
+
print('-' * 110)
|
| 961 |
+
for d in data:
|
| 962 |
+
print('%-20s %-65s %5d %8.4f %8.4f' % d)
|
| 963 |
+
print('=' * 110)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/smithy.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.smithy
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Smithy IDL.
|
| 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, Keyword, Name, String, \
|
| 13 |
+
Number, Whitespace, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['SmithyLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SmithyLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Smithy IDL
|
| 21 |
+
"""
|
| 22 |
+
name = 'Smithy'
|
| 23 |
+
url = 'https://awslabs.github.io/smithy/'
|
| 24 |
+
filenames = ['*.smithy']
|
| 25 |
+
aliases = ['smithy']
|
| 26 |
+
version_added = '2.10'
|
| 27 |
+
|
| 28 |
+
unquoted = r'[A-Za-z0-9_\.#$-]+'
|
| 29 |
+
identifier = r"[A-Za-z0-9_\.#$-]+"
|
| 30 |
+
|
| 31 |
+
simple_shapes = (
|
| 32 |
+
'use', 'byte', 'short', 'integer', 'long', 'float', 'document',
|
| 33 |
+
'double', 'bigInteger', 'bigDecimal', 'boolean', 'blob', 'string',
|
| 34 |
+
'timestamp',
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
aggregate_shapes = (
|
| 38 |
+
'apply', 'list', 'map', 'set', 'structure', 'union', 'resource',
|
| 39 |
+
'operation', 'service', 'trait'
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
tokens = {
|
| 43 |
+
'root': [
|
| 44 |
+
(r'///.*$', Comment.Multiline),
|
| 45 |
+
(r'//.*$', Comment),
|
| 46 |
+
(r'@[0-9a-zA-Z\.#-]*', Name.Decorator),
|
| 47 |
+
(r'(=)', Name.Decorator),
|
| 48 |
+
(r'^(\$version)(:)(.+)',
|
| 49 |
+
bygroups(Keyword.Declaration, Name.Decorator, Name.Class)),
|
| 50 |
+
(r'^(namespace)(\s+' + identifier + r')\b',
|
| 51 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 52 |
+
(words(simple_shapes,
|
| 53 |
+
prefix=r'^', suffix=r'(\s+' + identifier + r')\b'),
|
| 54 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 55 |
+
(words(aggregate_shapes,
|
| 56 |
+
prefix=r'^', suffix=r'(\s+' + identifier + r')'),
|
| 57 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 58 |
+
(r'^(metadata)(\s+)((?:\S+)|(?:\"[^"]+\"))(\s*)(=)',
|
| 59 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class,
|
| 60 |
+
Whitespace, Name.Decorator)),
|
| 61 |
+
(r"(true|false|null)", Keyword.Constant),
|
| 62 |
+
(r"(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)", Number),
|
| 63 |
+
(identifier + ":", Name.Label),
|
| 64 |
+
(identifier, Name.Variable.Class),
|
| 65 |
+
(r'\[', Text, "#push"),
|
| 66 |
+
(r'\]', Text, "#pop"),
|
| 67 |
+
(r'\(', Text, "#push"),
|
| 68 |
+
(r'\)', Text, "#pop"),
|
| 69 |
+
(r'\{', Text, "#push"),
|
| 70 |
+
(r'\}', Text, "#pop"),
|
| 71 |
+
(r'"{3}(\\\\|\n|\\")*"{3}', String.Doc),
|
| 72 |
+
(r'"(\\\\|\n|\\"|[^"])*"', String.Double),
|
| 73 |
+
(r"'(\\\\|\n|\\'|[^'])*'", String.Single),
|
| 74 |
+
(r'[:,]+', Punctuation),
|
| 75 |
+
(r'\s+', Whitespace),
|
| 76 |
+
]
|
| 77 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/snobol.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.snobol
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the SNOBOL 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
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['SnobolLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SnobolLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the SNOBOL4 programming language.
|
| 21 |
+
|
| 22 |
+
Recognizes the common ASCII equivalents of the original SNOBOL4 operators.
|
| 23 |
+
Does not require spaces around binary operators.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = "Snobol"
|
| 27 |
+
aliases = ["snobol"]
|
| 28 |
+
filenames = ['*.snobol']
|
| 29 |
+
mimetypes = ['text/x-snobol']
|
| 30 |
+
url = 'https://www.regressive.org/snobol4'
|
| 31 |
+
version_added = '1.5'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
# root state, start of line
|
| 35 |
+
# comments, continuation lines, and directives start in column 1
|
| 36 |
+
# as do labels
|
| 37 |
+
'root': [
|
| 38 |
+
(r'\*.*\n', Comment),
|
| 39 |
+
(r'[+.] ', Punctuation, 'statement'),
|
| 40 |
+
(r'-.*\n', Comment),
|
| 41 |
+
(r'END\s*\n', Name.Label, 'heredoc'),
|
| 42 |
+
(r'[A-Za-z$][\w$]*', Name.Label, 'statement'),
|
| 43 |
+
(r'\s+', Text, 'statement'),
|
| 44 |
+
],
|
| 45 |
+
# statement state, line after continuation or label
|
| 46 |
+
'statement': [
|
| 47 |
+
(r'\s*\n', Text, '#pop'),
|
| 48 |
+
(r'\s+', Text),
|
| 49 |
+
(r'(?<=[^\w.])(LT|LE|EQ|NE|GE|GT|INTEGER|IDENT|DIFFER|LGT|SIZE|'
|
| 50 |
+
r'REPLACE|TRIM|DUPL|REMDR|DATE|TIME|EVAL|APPLY|OPSYN|LOAD|UNLOAD|'
|
| 51 |
+
r'LEN|SPAN|BREAK|ANY|NOTANY|TAB|RTAB|REM|POS|RPOS|FAIL|FENCE|'
|
| 52 |
+
r'ABORT|ARB|ARBNO|BAL|SUCCEED|INPUT|OUTPUT|TERMINAL)(?=[^\w.])',
|
| 53 |
+
Name.Builtin),
|
| 54 |
+
(r'[A-Za-z][\w.]*', Name),
|
| 55 |
+
# ASCII equivalents of original operators
|
| 56 |
+
# | for the EBCDIC equivalent, ! likewise
|
| 57 |
+
# \ for EBCDIC negation
|
| 58 |
+
(r'\*\*|[?$.!%*/#+\-@|&\\=]', Operator),
|
| 59 |
+
(r'"[^"]*"', String),
|
| 60 |
+
(r"'[^']*'", String),
|
| 61 |
+
# Accept SPITBOL syntax for real numbers
|
| 62 |
+
# as well as Macro SNOBOL4
|
| 63 |
+
(r'[0-9]+(?=[^.EeDd])', Number.Integer),
|
| 64 |
+
(r'[0-9]+(\.[0-9]*)?([EDed][-+]?[0-9]+)?', Number.Float),
|
| 65 |
+
# Goto
|
| 66 |
+
(r':', Punctuation, 'goto'),
|
| 67 |
+
(r'[()<>,;]', Punctuation),
|
| 68 |
+
],
|
| 69 |
+
# Goto block
|
| 70 |
+
'goto': [
|
| 71 |
+
(r'\s*\n', Text, "#pop:2"),
|
| 72 |
+
(r'\s+', Text),
|
| 73 |
+
(r'F|S', Keyword),
|
| 74 |
+
(r'(\()([A-Za-z][\w.]*)(\))',
|
| 75 |
+
bygroups(Punctuation, Name.Label, Punctuation))
|
| 76 |
+
],
|
| 77 |
+
# everything after the END statement is basically one
|
| 78 |
+
# big heredoc.
|
| 79 |
+
'heredoc': [
|
| 80 |
+
(r'.*\n', String.Heredoc)
|
| 81 |
+
]
|
| 82 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/sophia.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sophia
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Sophia.
|
| 6 |
+
|
| 7 |
+
Derived from pygments/lexers/reason.py.
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, default, words
|
| 14 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 15 |
+
Punctuation, String, Text
|
| 16 |
+
|
| 17 |
+
__all__ = ['SophiaLexer']
|
| 18 |
+
|
| 19 |
+
class SophiaLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
A Sophia lexer.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
name = 'Sophia'
|
| 25 |
+
aliases = ['sophia']
|
| 26 |
+
filenames = ['*.aes']
|
| 27 |
+
mimetypes = []
|
| 28 |
+
url = 'https://docs.aeternity.com/aesophia'
|
| 29 |
+
version_added = '2.11'
|
| 30 |
+
|
| 31 |
+
keywords = (
|
| 32 |
+
'contract', 'include', 'let', 'switch', 'type', 'record', 'datatype',
|
| 33 |
+
'if', 'elif', 'else', 'function', 'stateful', 'payable', 'public',
|
| 34 |
+
'entrypoint', 'private', 'indexed', 'namespace', 'interface', 'main',
|
| 35 |
+
'using', 'as', 'for', 'hiding',
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
builtins = ('state', 'put', 'abort', 'require')
|
| 39 |
+
|
| 40 |
+
word_operators = ('mod', 'band', 'bor', 'bxor', 'bnot')
|
| 41 |
+
|
| 42 |
+
primitive_types = ('int', 'address', 'bool', 'bits', 'bytes', 'string',
|
| 43 |
+
'list', 'option', 'char', 'unit', 'map', 'event',
|
| 44 |
+
'hash', 'signature', 'oracle', 'oracle_query')
|
| 45 |
+
|
| 46 |
+
tokens = {
|
| 47 |
+
'escape-sequence': [
|
| 48 |
+
(r'\\[\\"\'ntbr]', String.Escape),
|
| 49 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 50 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 51 |
+
],
|
| 52 |
+
'root': [
|
| 53 |
+
(r'\s+', Text.Whitespace),
|
| 54 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 55 |
+
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Class, 'dotted'),
|
| 56 |
+
(r'\b([A-Z][\w\']*)', Name.Function),
|
| 57 |
+
(r'//.*?\n', Comment.Single),
|
| 58 |
+
(r'\/\*(?!/)', Comment.Multiline, 'comment'),
|
| 59 |
+
|
| 60 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 61 |
+
(r'#[\da-fA-F][\da-fA-F_]*', Name.Label),
|
| 62 |
+
(r'\d[\d_]*', Number.Integer),
|
| 63 |
+
|
| 64 |
+
(words(keywords, suffix=r'\b'), Keyword),
|
| 65 |
+
(words(builtins, suffix=r'\b'), Name.Builtin),
|
| 66 |
+
(words(word_operators, prefix=r'\b', suffix=r'\b'), Operator.Word),
|
| 67 |
+
(words(primitive_types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 68 |
+
|
| 69 |
+
(r'[=!<>+\\*/:&|?~@^-]', Operator.Word),
|
| 70 |
+
(r'[.;:{}(),\[\]]', Punctuation),
|
| 71 |
+
|
| 72 |
+
(r"(ak_|ok_|oq_|ct_)[\w']*", Name.Label),
|
| 73 |
+
(r"[^\W\d][\w']*", Name),
|
| 74 |
+
|
| 75 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
|
| 76 |
+
String.Char),
|
| 77 |
+
(r"'.'", String.Char),
|
| 78 |
+
(r"'[a-z][\w]*", Name.Variable),
|
| 79 |
+
|
| 80 |
+
(r'"', String.Double, 'string')
|
| 81 |
+
],
|
| 82 |
+
'comment': [
|
| 83 |
+
(r'[^/*]+', Comment.Multiline),
|
| 84 |
+
(r'\/\*', Comment.Multiline, '#push'),
|
| 85 |
+
(r'\*\/', Comment.Multiline, '#pop'),
|
| 86 |
+
(r'\*', Comment.Multiline),
|
| 87 |
+
],
|
| 88 |
+
'string': [
|
| 89 |
+
(r'[^\\"]+', String.Double),
|
| 90 |
+
include('escape-sequence'),
|
| 91 |
+
(r'\\\n', String.Double),
|
| 92 |
+
(r'"', String.Double, '#pop'),
|
| 93 |
+
],
|
| 94 |
+
'dotted': [
|
| 95 |
+
(r'\s+', Text),
|
| 96 |
+
(r'\.', Punctuation),
|
| 97 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Function),
|
| 98 |
+
(r'[A-Z][\w\']*', Name.Function, '#pop'),
|
| 99 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 100 |
+
default('#pop'),
|
| 101 |
+
],
|
| 102 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/sql.py
ADDED
|
@@ -0,0 +1,1111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for various SQL dialects and related interactive sessions.
|
| 6 |
+
|
| 7 |
+
Postgres specific lexers:
|
| 8 |
+
|
| 9 |
+
`PostgresLexer`
|
| 10 |
+
A SQL lexer for the PostgreSQL dialect. Differences w.r.t. the SQL
|
| 11 |
+
lexer are:
|
| 12 |
+
|
| 13 |
+
- keywords and data types list parsed from the PG docs (run the
|
| 14 |
+
`_postgres_builtins` module to update them);
|
| 15 |
+
- Content of $-strings parsed using a specific lexer, e.g. the content
|
| 16 |
+
of a PL/Python function is parsed using the Python lexer;
|
| 17 |
+
- parse PG specific constructs: E-strings, $-strings, U&-strings,
|
| 18 |
+
different operators and punctuation.
|
| 19 |
+
|
| 20 |
+
`PlPgsqlLexer`
|
| 21 |
+
A lexer for the PL/pgSQL language. Adds a few specific construct on
|
| 22 |
+
top of the PG SQL lexer (such as <<label>>).
|
| 23 |
+
|
| 24 |
+
`PostgresConsoleLexer`
|
| 25 |
+
A lexer to highlight an interactive psql session:
|
| 26 |
+
|
| 27 |
+
- identifies the prompt and does its best to detect the end of command
|
| 28 |
+
in multiline statement where not all the lines are prefixed by a
|
| 29 |
+
prompt, telling them apart from the output;
|
| 30 |
+
- highlights errors in the output and notification levels;
|
| 31 |
+
- handles psql backslash commands.
|
| 32 |
+
|
| 33 |
+
`PostgresExplainLexer`
|
| 34 |
+
A lexer to highlight Postgres execution plan.
|
| 35 |
+
|
| 36 |
+
The ``tests/examplefiles`` contains a few test files with data to be
|
| 37 |
+
parsed by these lexers.
|
| 38 |
+
|
| 39 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 40 |
+
:license: BSD, see LICENSE for details.
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
import collections
|
| 44 |
+
import re
|
| 45 |
+
|
| 46 |
+
from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups, words
|
| 47 |
+
from pygments.lexers import _googlesql_builtins
|
| 48 |
+
from pygments.lexers import _mysql_builtins
|
| 49 |
+
from pygments.lexers import _postgres_builtins
|
| 50 |
+
from pygments.lexers import _sql_builtins
|
| 51 |
+
from pygments.lexers import _tsql_builtins
|
| 52 |
+
from pygments.lexers import get_lexer_by_name, ClassNotFound
|
| 53 |
+
from pygments.token import Punctuation, Whitespace, Text, Comment, Operator, \
|
| 54 |
+
Keyword, Name, String, Number, Generic, Literal
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
__all__ = ['GoogleSqlLexer', 'PostgresLexer', 'PlPgsqlLexer',
|
| 58 |
+
'PostgresConsoleLexer', 'PostgresExplainLexer', 'SqlLexer',
|
| 59 |
+
'TransactSqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'RqlLexer']
|
| 60 |
+
|
| 61 |
+
line_re = re.compile('.*?\n')
|
| 62 |
+
sqlite_prompt_re = re.compile(r'^(?:sqlite| ...)>(?= )')
|
| 63 |
+
|
| 64 |
+
language_re = re.compile(r"\s+LANGUAGE\s+'?(\w+)'?", re.IGNORECASE)
|
| 65 |
+
|
| 66 |
+
do_re = re.compile(r'\bDO\b', re.IGNORECASE)
|
| 67 |
+
|
| 68 |
+
# Regular expressions for analyse_text()
|
| 69 |
+
name_between_bracket_re = re.compile(r'\[[a-zA-Z_]\w*\]')
|
| 70 |
+
name_between_backtick_re = re.compile(r'`[a-zA-Z_]\w*`')
|
| 71 |
+
tsql_go_re = re.compile(r'\bgo\b', re.IGNORECASE)
|
| 72 |
+
tsql_declare_re = re.compile(r'\bdeclare\s+@', re.IGNORECASE)
|
| 73 |
+
tsql_variable_re = re.compile(r'@[a-zA-Z_]\w*\b')
|
| 74 |
+
|
| 75 |
+
# Identifiers for analyse_text()
|
| 76 |
+
googlesql_identifiers = (
|
| 77 |
+
_googlesql_builtins.functionnames
|
| 78 |
+
+ _googlesql_builtins.keywords
|
| 79 |
+
+ _googlesql_builtins.types)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def language_callback(lexer, match):
|
| 83 |
+
"""Parse the content of a $-string using a lexer
|
| 84 |
+
|
| 85 |
+
The lexer is chosen looking for a nearby LANGUAGE or assumed as
|
| 86 |
+
plpgsql if inside a DO statement and no LANGUAGE has been found.
|
| 87 |
+
"""
|
| 88 |
+
lx = None
|
| 89 |
+
m = language_re.match(lexer.text[match.end():match.end()+100])
|
| 90 |
+
if m is not None:
|
| 91 |
+
lx = lexer._get_lexer(m.group(1))
|
| 92 |
+
else:
|
| 93 |
+
m = list(language_re.finditer(
|
| 94 |
+
lexer.text[max(0, match.start()-100):match.start()]))
|
| 95 |
+
if m:
|
| 96 |
+
lx = lexer._get_lexer(m[-1].group(1))
|
| 97 |
+
else:
|
| 98 |
+
m = list(do_re.finditer(
|
| 99 |
+
lexer.text[max(0, match.start()-25):match.start()]))
|
| 100 |
+
if m:
|
| 101 |
+
lx = lexer._get_lexer('plpgsql')
|
| 102 |
+
|
| 103 |
+
# 1 = $, 2 = delimiter, 3 = $
|
| 104 |
+
yield (match.start(1), String, match.group(1))
|
| 105 |
+
yield (match.start(2), String.Delimiter, match.group(2))
|
| 106 |
+
yield (match.start(3), String, match.group(3))
|
| 107 |
+
# 4 = string contents
|
| 108 |
+
if lx:
|
| 109 |
+
yield from lx.get_tokens_unprocessed(match.group(4))
|
| 110 |
+
else:
|
| 111 |
+
yield (match.start(4), String, match.group(4))
|
| 112 |
+
# 5 = $, 6 = delimiter, 7 = $
|
| 113 |
+
yield (match.start(5), String, match.group(5))
|
| 114 |
+
yield (match.start(6), String.Delimiter, match.group(6))
|
| 115 |
+
yield (match.start(7), String, match.group(7))
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class PostgresBase:
|
| 119 |
+
"""Base class for Postgres-related lexers.
|
| 120 |
+
|
| 121 |
+
This is implemented as a mixin to avoid the Lexer metaclass kicking in.
|
| 122 |
+
this way the different lexer don't have a common Lexer ancestor. If they
|
| 123 |
+
had, _tokens could be created on this ancestor and not updated for the
|
| 124 |
+
other classes, resulting e.g. in PL/pgSQL parsed as SQL. This shortcoming
|
| 125 |
+
seem to suggest that regexp lexers are not really subclassable.
|
| 126 |
+
"""
|
| 127 |
+
def get_tokens_unprocessed(self, text, *args):
|
| 128 |
+
# Have a copy of the entire text to be used by `language_callback`.
|
| 129 |
+
self.text = text
|
| 130 |
+
yield from super().get_tokens_unprocessed(text, *args)
|
| 131 |
+
|
| 132 |
+
def _get_lexer(self, lang):
|
| 133 |
+
if lang.lower() == 'sql':
|
| 134 |
+
return get_lexer_by_name('postgresql', **self.options)
|
| 135 |
+
|
| 136 |
+
tries = [lang]
|
| 137 |
+
if lang.startswith('pl'):
|
| 138 |
+
tries.append(lang[2:])
|
| 139 |
+
if lang.endswith('u'):
|
| 140 |
+
tries.append(lang[:-1])
|
| 141 |
+
if lang.startswith('pl') and lang.endswith('u'):
|
| 142 |
+
tries.append(lang[2:-1])
|
| 143 |
+
|
| 144 |
+
for lx in tries:
|
| 145 |
+
try:
|
| 146 |
+
return get_lexer_by_name(lx, **self.options)
|
| 147 |
+
except ClassNotFound:
|
| 148 |
+
pass
|
| 149 |
+
else:
|
| 150 |
+
# TODO: better logging
|
| 151 |
+
# print >>sys.stderr, "language not found:", lang
|
| 152 |
+
return None
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class PostgresLexer(PostgresBase, RegexLexer):
|
| 156 |
+
"""
|
| 157 |
+
Lexer for the PostgreSQL dialect of SQL.
|
| 158 |
+
"""
|
| 159 |
+
|
| 160 |
+
name = 'PostgreSQL SQL dialect'
|
| 161 |
+
aliases = ['postgresql', 'postgres']
|
| 162 |
+
mimetypes = ['text/x-postgresql']
|
| 163 |
+
url = 'https://www.postgresql.org'
|
| 164 |
+
version_added = '1.5'
|
| 165 |
+
|
| 166 |
+
flags = re.IGNORECASE
|
| 167 |
+
tokens = {
|
| 168 |
+
'root': [
|
| 169 |
+
(r'\s+', Whitespace),
|
| 170 |
+
(r'--.*\n?', Comment.Single),
|
| 171 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 172 |
+
(r'(' + '|'.join(s.replace(" ", r"\s+")
|
| 173 |
+
for s in _postgres_builtins.DATATYPES +
|
| 174 |
+
_postgres_builtins.PSEUDO_TYPES) + r')\b',
|
| 175 |
+
Name.Builtin),
|
| 176 |
+
(words(_postgres_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 177 |
+
(r'[+*/<>=~!@#%^&|`?-]+', Operator),
|
| 178 |
+
(r'::', Operator), # cast
|
| 179 |
+
(r'\$\d+', Name.Variable),
|
| 180 |
+
(r'([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?', Number.Float),
|
| 181 |
+
(r'[0-9]+', Number.Integer),
|
| 182 |
+
(r"((?:E|U&)?)(')", bygroups(String.Affix, String.Single), 'string'),
|
| 183 |
+
# quoted identifier
|
| 184 |
+
(r'((?:U&)?)(")', bygroups(String.Affix, String.Name), 'quoted-ident'),
|
| 185 |
+
(r'(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)', language_callback),
|
| 186 |
+
(r'[a-z_]\w*', Name),
|
| 187 |
+
|
| 188 |
+
# psql variable in SQL
|
| 189 |
+
(r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
|
| 190 |
+
|
| 191 |
+
(r'[;:()\[\]{},.]', Punctuation),
|
| 192 |
+
],
|
| 193 |
+
'multiline-comments': [
|
| 194 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 195 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 196 |
+
(r'[^/*]+', Comment.Multiline),
|
| 197 |
+
(r'[/*]', Comment.Multiline)
|
| 198 |
+
],
|
| 199 |
+
'string': [
|
| 200 |
+
(r"[^']+", String.Single),
|
| 201 |
+
(r"''", String.Single),
|
| 202 |
+
(r"'", String.Single, '#pop'),
|
| 203 |
+
],
|
| 204 |
+
'quoted-ident': [
|
| 205 |
+
(r'[^"]+', String.Name),
|
| 206 |
+
(r'""', String.Name),
|
| 207 |
+
(r'"', String.Name, '#pop'),
|
| 208 |
+
],
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class PlPgsqlLexer(PostgresBase, RegexLexer):
|
| 213 |
+
"""
|
| 214 |
+
Handle the extra syntax in Pl/pgSQL language.
|
| 215 |
+
"""
|
| 216 |
+
name = 'PL/pgSQL'
|
| 217 |
+
aliases = ['plpgsql']
|
| 218 |
+
mimetypes = ['text/x-plpgsql']
|
| 219 |
+
url = 'https://www.postgresql.org/docs/current/plpgsql.html'
|
| 220 |
+
version_added = '1.5'
|
| 221 |
+
|
| 222 |
+
flags = re.IGNORECASE
|
| 223 |
+
# FIXME: use inheritance
|
| 224 |
+
tokens = {name: state[:] for (name, state) in PostgresLexer.tokens.items()}
|
| 225 |
+
|
| 226 |
+
# extend the keywords list
|
| 227 |
+
for i, pattern in enumerate(tokens['root']):
|
| 228 |
+
if pattern[1] == Keyword:
|
| 229 |
+
tokens['root'][i] = (
|
| 230 |
+
words(_postgres_builtins.KEYWORDS +
|
| 231 |
+
_postgres_builtins.PLPGSQL_KEYWORDS, suffix=r'\b'),
|
| 232 |
+
Keyword)
|
| 233 |
+
del i
|
| 234 |
+
break
|
| 235 |
+
else:
|
| 236 |
+
assert 0, "SQL keywords not found"
|
| 237 |
+
|
| 238 |
+
# Add specific PL/pgSQL rules (before the SQL ones)
|
| 239 |
+
tokens['root'][:0] = [
|
| 240 |
+
(r'\%[a-z]\w*\b', Name.Builtin), # actually, a datatype
|
| 241 |
+
(r':=', Operator),
|
| 242 |
+
(r'\<\<[a-z]\w*\>\>', Name.Label),
|
| 243 |
+
(r'\#[a-z]\w*\b', Keyword.Pseudo), # #variable_conflict
|
| 244 |
+
]
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
class PsqlRegexLexer(PostgresBase, RegexLexer):
|
| 248 |
+
"""
|
| 249 |
+
Extend the PostgresLexer adding support specific for psql commands.
|
| 250 |
+
|
| 251 |
+
This is not a complete psql lexer yet as it lacks prompt support
|
| 252 |
+
and output rendering.
|
| 253 |
+
"""
|
| 254 |
+
|
| 255 |
+
name = 'PostgreSQL console - regexp based lexer'
|
| 256 |
+
aliases = [] # not public
|
| 257 |
+
|
| 258 |
+
flags = re.IGNORECASE
|
| 259 |
+
tokens = {name: state[:] for (name, state) in PostgresLexer.tokens.items()}
|
| 260 |
+
|
| 261 |
+
tokens['root'].append(
|
| 262 |
+
(r'\\[^\s]+', Keyword.Pseudo, 'psql-command'))
|
| 263 |
+
tokens['psql-command'] = [
|
| 264 |
+
(r'\n', Text, 'root'),
|
| 265 |
+
(r'\s+', Whitespace),
|
| 266 |
+
(r'\\[^\s]+', Keyword.Pseudo),
|
| 267 |
+
(r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
|
| 268 |
+
(r"'(''|[^'])*'", String.Single),
|
| 269 |
+
(r"`([^`])*`", String.Backtick),
|
| 270 |
+
(r"[^\s]+", String.Symbol),
|
| 271 |
+
]
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
re_prompt = re.compile(r'^(\S.*?)??[=\-\(\$\'\"][#>]')
|
| 275 |
+
re_psql_command = re.compile(r'\s*\\')
|
| 276 |
+
re_end_command = re.compile(r';\s*(--.*?)?$')
|
| 277 |
+
re_psql_command = re.compile(r'(\s*)(\\.+?)(\s+)$')
|
| 278 |
+
re_error = re.compile(r'(ERROR|FATAL):')
|
| 279 |
+
re_message = re.compile(
|
| 280 |
+
r'((?:DEBUG|INFO|NOTICE|WARNING|ERROR|'
|
| 281 |
+
r'FATAL|HINT|DETAIL|CONTEXT|LINE [0-9]+):)(.*?\n)')
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class lookahead:
|
| 285 |
+
"""Wrap an iterator and allow pushing back an item."""
|
| 286 |
+
def __init__(self, x):
|
| 287 |
+
self.iter = iter(x)
|
| 288 |
+
self._nextitem = None
|
| 289 |
+
|
| 290 |
+
def __iter__(self):
|
| 291 |
+
return self
|
| 292 |
+
|
| 293 |
+
def send(self, i):
|
| 294 |
+
self._nextitem = i
|
| 295 |
+
return i
|
| 296 |
+
|
| 297 |
+
def __next__(self):
|
| 298 |
+
if self._nextitem is not None:
|
| 299 |
+
ni = self._nextitem
|
| 300 |
+
self._nextitem = None
|
| 301 |
+
return ni
|
| 302 |
+
return next(self.iter)
|
| 303 |
+
next = __next__
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class PostgresConsoleLexer(Lexer):
|
| 307 |
+
"""
|
| 308 |
+
Lexer for psql sessions.
|
| 309 |
+
"""
|
| 310 |
+
|
| 311 |
+
name = 'PostgreSQL console (psql)'
|
| 312 |
+
aliases = ['psql', 'postgresql-console', 'postgres-console']
|
| 313 |
+
mimetypes = ['text/x-postgresql-psql']
|
| 314 |
+
url = 'https://www.postgresql.org'
|
| 315 |
+
version_added = '1.5'
|
| 316 |
+
_example = "psql/psql_session.txt"
|
| 317 |
+
|
| 318 |
+
def get_tokens_unprocessed(self, data):
|
| 319 |
+
sql = PsqlRegexLexer(**self.options)
|
| 320 |
+
|
| 321 |
+
lines = lookahead(line_re.findall(data))
|
| 322 |
+
|
| 323 |
+
# prompt-output cycle
|
| 324 |
+
while 1:
|
| 325 |
+
|
| 326 |
+
# consume the lines of the command: start with an optional prompt
|
| 327 |
+
# and continue until the end of command is detected
|
| 328 |
+
curcode = ''
|
| 329 |
+
insertions = []
|
| 330 |
+
for line in lines:
|
| 331 |
+
# Identify a shell prompt in case of psql commandline example
|
| 332 |
+
if line.startswith('$') and not curcode:
|
| 333 |
+
lexer = get_lexer_by_name('console', **self.options)
|
| 334 |
+
yield from lexer.get_tokens_unprocessed(line)
|
| 335 |
+
break
|
| 336 |
+
|
| 337 |
+
# Identify a psql prompt
|
| 338 |
+
mprompt = re_prompt.match(line)
|
| 339 |
+
if mprompt is not None:
|
| 340 |
+
insertions.append((len(curcode),
|
| 341 |
+
[(0, Generic.Prompt, mprompt.group())]))
|
| 342 |
+
curcode += line[len(mprompt.group()):]
|
| 343 |
+
else:
|
| 344 |
+
curcode += line
|
| 345 |
+
|
| 346 |
+
# Check if this is the end of the command
|
| 347 |
+
# TODO: better handle multiline comments at the end with
|
| 348 |
+
# a lexer with an external state?
|
| 349 |
+
if re_psql_command.match(curcode) \
|
| 350 |
+
or re_end_command.search(curcode):
|
| 351 |
+
break
|
| 352 |
+
|
| 353 |
+
# Emit the combined stream of command and prompt(s)
|
| 354 |
+
yield from do_insertions(insertions,
|
| 355 |
+
sql.get_tokens_unprocessed(curcode))
|
| 356 |
+
|
| 357 |
+
# Emit the output lines
|
| 358 |
+
out_token = Generic.Output
|
| 359 |
+
for line in lines:
|
| 360 |
+
mprompt = re_prompt.match(line)
|
| 361 |
+
if mprompt is not None:
|
| 362 |
+
# push the line back to have it processed by the prompt
|
| 363 |
+
lines.send(line)
|
| 364 |
+
break
|
| 365 |
+
|
| 366 |
+
mmsg = re_message.match(line)
|
| 367 |
+
if mmsg is not None:
|
| 368 |
+
if mmsg.group(1).startswith("ERROR") \
|
| 369 |
+
or mmsg.group(1).startswith("FATAL"):
|
| 370 |
+
out_token = Generic.Error
|
| 371 |
+
yield (mmsg.start(1), Generic.Strong, mmsg.group(1))
|
| 372 |
+
yield (mmsg.start(2), out_token, mmsg.group(2))
|
| 373 |
+
else:
|
| 374 |
+
yield (0, out_token, line)
|
| 375 |
+
else:
|
| 376 |
+
return
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
class PostgresExplainLexer(RegexLexer):
|
| 380 |
+
"""
|
| 381 |
+
Handle PostgreSQL EXPLAIN output
|
| 382 |
+
"""
|
| 383 |
+
|
| 384 |
+
name = 'PostgreSQL EXPLAIN dialect'
|
| 385 |
+
aliases = ['postgres-explain']
|
| 386 |
+
filenames = ['*.explain']
|
| 387 |
+
mimetypes = ['text/x-postgresql-explain']
|
| 388 |
+
url = 'https://www.postgresql.org/docs/current/using-explain.html'
|
| 389 |
+
version_added = '2.15'
|
| 390 |
+
|
| 391 |
+
tokens = {
|
| 392 |
+
'root': [
|
| 393 |
+
(r'(:|\(|\)|ms|kB|->|\.\.|\,|\/|=|%)', Punctuation),
|
| 394 |
+
(r'(\s+)', Whitespace),
|
| 395 |
+
|
| 396 |
+
# This match estimated cost and effectively measured counters with ANALYZE
|
| 397 |
+
# Then, we move to instrumentation state
|
| 398 |
+
(r'(cost)(=?)', bygroups(Name.Class, Punctuation), 'instrumentation'),
|
| 399 |
+
(r'(actual)( )(=?)', bygroups(Name.Class, Whitespace, Punctuation), 'instrumentation'),
|
| 400 |
+
|
| 401 |
+
# Misc keywords
|
| 402 |
+
(words(('actual', 'Memory Usage', 'Disk Usage', 'Memory', 'Buckets',
|
| 403 |
+
'Batches', 'originally', 'row', 'rows', 'Hits', 'Misses',
|
| 404 |
+
'Evictions', 'Overflows', 'Planned Partitions', 'Estimates',
|
| 405 |
+
'capacity', 'distinct keys', 'lookups', 'hit percent',
|
| 406 |
+
'Index Searches', 'Storage', 'Disk Maximum Storage'), suffix=r'\b'),
|
| 407 |
+
Comment.Single),
|
| 408 |
+
|
| 409 |
+
(r'(hit|read|dirtied|written|write|time|calls)(=)', bygroups(Comment.Single, Operator)),
|
| 410 |
+
(r'(shared|temp|local)', Keyword.Pseudo),
|
| 411 |
+
|
| 412 |
+
# We move to sort state in order to emphasize specific keywords (especially disk access)
|
| 413 |
+
(r'(Sort Method)(: )', bygroups(Comment.Preproc, Punctuation), 'sort'),
|
| 414 |
+
|
| 415 |
+
# These keywords can be followed by an object, like a table
|
| 416 |
+
(r'(Sort Key|Group Key|Presorted Key|Hash Key)(:)( )',
|
| 417 |
+
bygroups(Comment.Preproc, Punctuation, Whitespace), 'object_name'),
|
| 418 |
+
(r'(Cache Key|Cache Mode)(:)( )', bygroups(Comment, Punctuation, Whitespace), 'object_name'),
|
| 419 |
+
|
| 420 |
+
# These keywords can be followed by a predicate
|
| 421 |
+
(words(('Join Filter', 'Subplans Removed', 'Filter', 'Merge Cond',
|
| 422 |
+
'Hash Cond', 'Index Cond', 'Recheck Cond', 'Heap Blocks',
|
| 423 |
+
'TID Cond', 'Run Condition', 'Order By', 'Function Call',
|
| 424 |
+
'Table Function Call', 'Inner Unique', 'Params Evaluated',
|
| 425 |
+
'Single Copy', 'Sampling', 'One-Time Filter', 'Output',
|
| 426 |
+
'Relations', 'Remote SQL', 'Disabled'), suffix=r'\b'),
|
| 427 |
+
Comment.Preproc, 'predicate'),
|
| 428 |
+
|
| 429 |
+
# Special keyword to handle ON CONFLICT
|
| 430 |
+
(r'Conflict ', Comment.Preproc, 'conflict'),
|
| 431 |
+
|
| 432 |
+
# Special keyword for InitPlan or SubPlan
|
| 433 |
+
(r'(InitPlan|SubPlan)( )(\d+)( )',
|
| 434 |
+
bygroups(Keyword, Whitespace, Number.Integer, Whitespace),
|
| 435 |
+
'init_plan'),
|
| 436 |
+
|
| 437 |
+
(words(('Sort Method', 'Join Filter', 'Planning time',
|
| 438 |
+
'Planning Time', 'Execution time', 'Execution Time',
|
| 439 |
+
'Workers Planned', 'Workers Launched', 'Buffers',
|
| 440 |
+
'Planning', 'Worker', 'Query Identifier', 'Time',
|
| 441 |
+
'Full-sort Groups', 'Pre-sorted Groups'), suffix=r'\b'), Comment.Preproc),
|
| 442 |
+
|
| 443 |
+
# Emphasize these keywords
|
| 444 |
+
|
| 445 |
+
(words(('Rows Removed by Join Filter', 'Rows Removed by Filter',
|
| 446 |
+
'Rows Removed by Index Recheck',
|
| 447 |
+
'Heap Fetches', 'never executed'),
|
| 448 |
+
suffix=r'\b'), Name.Exception),
|
| 449 |
+
(r'(I/O Timings)(:)( )', bygroups(Name.Exception, Punctuation, Whitespace)),
|
| 450 |
+
|
| 451 |
+
(words(_postgres_builtins.EXPLAIN_KEYWORDS, suffix=r'\b'), Keyword),
|
| 452 |
+
|
| 453 |
+
# join keywords
|
| 454 |
+
(r'((Right|Left|Full|Semi|Anti) Join)', Keyword.Type),
|
| 455 |
+
(r'(Parallel |Async |Finalize |Partial )', Comment.Preproc),
|
| 456 |
+
(r'Backward', Comment.Preproc),
|
| 457 |
+
(r'(Intersect|Except|Hash)', Comment.Preproc),
|
| 458 |
+
|
| 459 |
+
(r'(CTE)( )(\w*)?', bygroups(Comment, Whitespace, Name.Variable)),
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
# Treat "on" and "using" as a punctuation
|
| 463 |
+
(r'(on|using)', Punctuation, 'object_name'),
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
# strings
|
| 467 |
+
(r"'(''|[^'])*'", String.Single),
|
| 468 |
+
# numbers
|
| 469 |
+
(r'-?\d+\.\d+', Number.Float),
|
| 470 |
+
(r'(-?\d+)', Number.Integer),
|
| 471 |
+
|
| 472 |
+
# boolean
|
| 473 |
+
(r'(true|false)', Name.Constant),
|
| 474 |
+
# explain header
|
| 475 |
+
(r'\s*QUERY PLAN\s*\n\s*-+', Comment.Single),
|
| 476 |
+
# Settings
|
| 477 |
+
(r'(Settings)(:)( )', bygroups(Comment.Preproc, Punctuation, Whitespace), 'setting'),
|
| 478 |
+
|
| 479 |
+
# Handle JIT counters
|
| 480 |
+
(r'(JIT|Functions|Options|Timing)(:)', bygroups(Comment.Preproc, Punctuation)),
|
| 481 |
+
(r'(Inlining|Optimization|Expressions|Deforming|Generation|Emission|Total)', Keyword.Pseudo),
|
| 482 |
+
|
| 483 |
+
# Handle Triggers counters
|
| 484 |
+
(r'(Trigger)( )(\S*)(:)( )',
|
| 485 |
+
bygroups(Comment.Preproc, Whitespace, Name.Variable, Punctuation, Whitespace)),
|
| 486 |
+
|
| 487 |
+
],
|
| 488 |
+
'expression': [
|
| 489 |
+
# matches any kind of parenthesized expression
|
| 490 |
+
# the first opening paren is matched by the 'caller'
|
| 491 |
+
(r'\(', Punctuation, '#push'),
|
| 492 |
+
(r'\)', Punctuation, '#pop'),
|
| 493 |
+
(r'(never executed)', Name.Exception),
|
| 494 |
+
(r'[^)(]+', Comment),
|
| 495 |
+
],
|
| 496 |
+
'object_name': [
|
| 497 |
+
|
| 498 |
+
# This is a cost or analyze measure
|
| 499 |
+
(r'(\(cost)(=?)', bygroups(Name.Class, Punctuation), 'instrumentation'),
|
| 500 |
+
(r'(\(actual)( )(=?)', bygroups(Name.Class, Whitespace, Punctuation), 'instrumentation'),
|
| 501 |
+
|
| 502 |
+
# if object_name is parenthesized, mark opening paren as
|
| 503 |
+
# punctuation, call 'expression', and exit state
|
| 504 |
+
(r'\(', Punctuation, 'expression'),
|
| 505 |
+
(r'(on)', Punctuation),
|
| 506 |
+
# matches possibly schema-qualified table and column names
|
| 507 |
+
(r'\w+(\.\w+)*( USING \S+| \w+ USING \S+)', Name.Variable),
|
| 508 |
+
(r'\"?\w+\"?(?:\.\"?\w+\"?)?', Name.Variable),
|
| 509 |
+
(r'\'\S*\'', Name.Variable),
|
| 510 |
+
|
| 511 |
+
# if we encounter a comma, another object is listed
|
| 512 |
+
(r',\n', Punctuation, 'object_name'),
|
| 513 |
+
(r',', Punctuation, 'object_name'),
|
| 514 |
+
|
| 515 |
+
# special case: "*SELECT*"
|
| 516 |
+
(r'"\*SELECT\*( \d+)?"(.\w+)?', Name.Variable),
|
| 517 |
+
(r'"\*VALUES\*(_\d+)?"(.\w+)?', Name.Variable),
|
| 518 |
+
(r'"ANY_subquery"', Name.Variable),
|
| 519 |
+
|
| 520 |
+
# Variable $1 ...
|
| 521 |
+
(r'\$\d+', Name.Variable),
|
| 522 |
+
# cast
|
| 523 |
+
(r'::\w+', Name.Variable),
|
| 524 |
+
(r' +', Whitespace),
|
| 525 |
+
(r'"', Punctuation),
|
| 526 |
+
(r'\[\.\.\.\]', Punctuation),
|
| 527 |
+
(r'\)', Punctuation, '#pop'),
|
| 528 |
+
],
|
| 529 |
+
'predicate': [
|
| 530 |
+
# if predicate is parenthesized, mark paren as punctuation
|
| 531 |
+
(r'(\()([^\n]*)(\))', bygroups(Punctuation, Name.Variable, Punctuation), '#pop'),
|
| 532 |
+
# otherwise color until newline
|
| 533 |
+
(r'[^\n]*', Name.Variable, '#pop'),
|
| 534 |
+
],
|
| 535 |
+
'instrumentation': [
|
| 536 |
+
(r'=|\.\.', Punctuation),
|
| 537 |
+
(r' +', Whitespace),
|
| 538 |
+
(r'(rows|width|time|loops)', Name.Class),
|
| 539 |
+
(r'\d+\.\d+', Number.Float),
|
| 540 |
+
(r'(\d+)', Number.Integer),
|
| 541 |
+
(r'\)', Punctuation, '#pop'),
|
| 542 |
+
],
|
| 543 |
+
'conflict': [
|
| 544 |
+
(r'(Resolution: )(\w+)', bygroups(Comment.Preproc, Name.Variable)),
|
| 545 |
+
(r'(Arbiter \w+:)', Comment.Preproc, 'object_name'),
|
| 546 |
+
(r'(Filter: )', Comment.Preproc, 'predicate'),
|
| 547 |
+
],
|
| 548 |
+
'setting': [
|
| 549 |
+
(r'([a-z_]*?)(\s*)(=)(\s*)(\'.*?\')', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)),
|
| 550 |
+
(r'\, ', Punctuation),
|
| 551 |
+
],
|
| 552 |
+
'init_plan': [
|
| 553 |
+
(r'\(', Punctuation),
|
| 554 |
+
(r'returns \$\d+(,\$\d+)?', Name.Variable),
|
| 555 |
+
(r'\)', Punctuation, '#pop'),
|
| 556 |
+
],
|
| 557 |
+
'sort': [
|
| 558 |
+
(r':|kB', Punctuation),
|
| 559 |
+
(r'(quicksort|top-N|heapsort|Average|Memory|Peak)', Comment.Prepoc),
|
| 560 |
+
(r'(external|merge|Disk|sort)', Name.Exception),
|
| 561 |
+
(r'(\d+)', Number.Integer),
|
| 562 |
+
(r' +', Whitespace),
|
| 563 |
+
],
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
class SqlLexer(RegexLexer):
|
| 568 |
+
"""
|
| 569 |
+
Lexer for Structured Query Language. Currently, this lexer does
|
| 570 |
+
not recognize any special syntax except ANSI SQL.
|
| 571 |
+
"""
|
| 572 |
+
|
| 573 |
+
name = 'SQL'
|
| 574 |
+
aliases = ['sql']
|
| 575 |
+
filenames = ['*.sql']
|
| 576 |
+
mimetypes = ['text/x-sql']
|
| 577 |
+
url = 'https://en.wikipedia.org/wiki/SQL'
|
| 578 |
+
version_added = ''
|
| 579 |
+
|
| 580 |
+
flags = re.IGNORECASE
|
| 581 |
+
tokens = {
|
| 582 |
+
'root': [
|
| 583 |
+
(r'\s+', Whitespace),
|
| 584 |
+
(r'--.*\n?', Comment.Single),
|
| 585 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 586 |
+
(words(_sql_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 587 |
+
(words(_sql_builtins.DATATYPES, suffix=r'\b'), Name.Builtin),
|
| 588 |
+
(r'[+*/<>=~!@#%^&|`?-]', Operator),
|
| 589 |
+
(r'[0-9]+', Number.Integer),
|
| 590 |
+
# TODO: Backslash escapes?
|
| 591 |
+
(r"'(''|[^'])*'", String.Single),
|
| 592 |
+
(r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
|
| 593 |
+
(r'[a-z_][\w$]*', Name), # allow $s in strings for Oracle
|
| 594 |
+
(r'[;:()\[\],.]', Punctuation)
|
| 595 |
+
],
|
| 596 |
+
'multiline-comments': [
|
| 597 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 598 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 599 |
+
(r'[^/*]+', Comment.Multiline),
|
| 600 |
+
(r'[/*]', Comment.Multiline)
|
| 601 |
+
]
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
def analyse_text(self, text):
|
| 605 |
+
return
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class TransactSqlLexer(RegexLexer):
|
| 609 |
+
"""
|
| 610 |
+
Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to
|
| 611 |
+
SQL.
|
| 612 |
+
|
| 613 |
+
The list of keywords includes ODBC and keywords reserved for future use.
|
| 614 |
+
"""
|
| 615 |
+
|
| 616 |
+
name = 'Transact-SQL'
|
| 617 |
+
aliases = ['tsql', 't-sql']
|
| 618 |
+
filenames = ['*.sql']
|
| 619 |
+
mimetypes = ['text/x-tsql']
|
| 620 |
+
url = 'https://www.tsql.info'
|
| 621 |
+
version_added = ''
|
| 622 |
+
|
| 623 |
+
flags = re.IGNORECASE
|
| 624 |
+
|
| 625 |
+
tokens = {
|
| 626 |
+
'root': [
|
| 627 |
+
(r'\s+', Whitespace),
|
| 628 |
+
(r'--.*[$|\n]?', Comment.Single),
|
| 629 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 630 |
+
(words(_tsql_builtins.OPERATORS), Operator),
|
| 631 |
+
(words(_tsql_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word),
|
| 632 |
+
(words(_tsql_builtins.TYPES, suffix=r'\b'), Name.Class),
|
| 633 |
+
(words(_tsql_builtins.FUNCTIONS, suffix=r'\b'), Name.Function),
|
| 634 |
+
(r'(goto)(\s+)(\w+\b)', bygroups(Keyword, Whitespace, Name.Label)),
|
| 635 |
+
(words(_tsql_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 636 |
+
(r'(\[)([^]]+)(\])', bygroups(Operator, Name, Operator)),
|
| 637 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 638 |
+
# Float variant 1, for example: 1., 1.e2, 1.2e3
|
| 639 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float),
|
| 640 |
+
# Float variant 2, for example: .1, .1e2
|
| 641 |
+
(r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
|
| 642 |
+
# Float variant 3, for example: 123e45
|
| 643 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float),
|
| 644 |
+
(r'[0-9]+', Number.Integer),
|
| 645 |
+
(r"'(''|[^'])*'", String.Single),
|
| 646 |
+
(r'"(""|[^"])*"', String.Symbol),
|
| 647 |
+
(r'[;(),.]', Punctuation),
|
| 648 |
+
# Below we use \w even for the first "real" character because
|
| 649 |
+
# tokens starting with a digit have already been recognized
|
| 650 |
+
# as Number above.
|
| 651 |
+
(r'@@\w+', Name.Builtin),
|
| 652 |
+
(r'@\w+', Name.Variable),
|
| 653 |
+
(r'(\w+)(:)', bygroups(Name.Label, Punctuation)),
|
| 654 |
+
(r'#?#?\w+', Name), # names for temp tables and anything else
|
| 655 |
+
(r'\?', Name.Variable.Magic), # parameter for prepared statements
|
| 656 |
+
],
|
| 657 |
+
'multiline-comments': [
|
| 658 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 659 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 660 |
+
(r'[^/*]+', Comment.Multiline),
|
| 661 |
+
(r'[/*]', Comment.Multiline)
|
| 662 |
+
]
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
def analyse_text(text):
|
| 666 |
+
rating = 0
|
| 667 |
+
if tsql_declare_re.search(text):
|
| 668 |
+
# Found T-SQL variable declaration.
|
| 669 |
+
rating = 1.0
|
| 670 |
+
else:
|
| 671 |
+
name_between_backtick_count = len(
|
| 672 |
+
name_between_backtick_re.findall(text))
|
| 673 |
+
name_between_bracket_count = len(
|
| 674 |
+
name_between_bracket_re.findall(text))
|
| 675 |
+
# We need to check if there are any names using
|
| 676 |
+
# backticks or brackets, as otherwise both are 0
|
| 677 |
+
# and 0 >= 2 * 0, so we would always assume it's true
|
| 678 |
+
dialect_name_count = name_between_backtick_count + name_between_bracket_count
|
| 679 |
+
if dialect_name_count >= 1 and \
|
| 680 |
+
name_between_bracket_count >= 2 * name_between_backtick_count:
|
| 681 |
+
# Found at least twice as many [name] as `name`.
|
| 682 |
+
rating += 0.5
|
| 683 |
+
elif name_between_bracket_count > name_between_backtick_count:
|
| 684 |
+
rating += 0.2
|
| 685 |
+
elif name_between_bracket_count > 0:
|
| 686 |
+
rating += 0.1
|
| 687 |
+
if tsql_variable_re.search(text) is not None:
|
| 688 |
+
rating += 0.1
|
| 689 |
+
if tsql_go_re.search(text) is not None:
|
| 690 |
+
rating += 0.1
|
| 691 |
+
return rating
|
| 692 |
+
|
| 693 |
+
|
| 694 |
+
class MySqlLexer(RegexLexer):
|
| 695 |
+
"""The Oracle MySQL lexer.
|
| 696 |
+
|
| 697 |
+
This lexer does not attempt to maintain strict compatibility with
|
| 698 |
+
MariaDB syntax or keywords. Although MySQL and MariaDB's common code
|
| 699 |
+
history suggests there may be significant overlap between the two,
|
| 700 |
+
compatibility between the two is not a target for this lexer.
|
| 701 |
+
"""
|
| 702 |
+
|
| 703 |
+
name = 'MySQL'
|
| 704 |
+
aliases = ['mysql']
|
| 705 |
+
mimetypes = ['text/x-mysql']
|
| 706 |
+
url = 'https://www.mysql.com'
|
| 707 |
+
version_added = ''
|
| 708 |
+
|
| 709 |
+
flags = re.IGNORECASE
|
| 710 |
+
tokens = {
|
| 711 |
+
'root': [
|
| 712 |
+
(r'\s+', Whitespace),
|
| 713 |
+
|
| 714 |
+
# Comments
|
| 715 |
+
(r'(?:#|--\s+).*', Comment.Single),
|
| 716 |
+
(r'/\*\+', Comment.Special, 'optimizer-hints'),
|
| 717 |
+
(r'/\*', Comment.Multiline, 'multiline-comment'),
|
| 718 |
+
|
| 719 |
+
# Hexadecimal literals
|
| 720 |
+
(r"x'([0-9a-f]{2})+'", Number.Hex), # MySQL requires paired hex characters in this form.
|
| 721 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 722 |
+
|
| 723 |
+
# Binary literals
|
| 724 |
+
(r"b'[01]+'", Number.Bin),
|
| 725 |
+
(r'0b[01]+', Number.Bin),
|
| 726 |
+
|
| 727 |
+
# Numeric literals
|
| 728 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), # Mandatory integer, optional fraction and exponent
|
| 729 |
+
(r'[0-9]*\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Mandatory fraction, optional integer and exponent
|
| 730 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float), # Exponents with integer significands are still floats
|
| 731 |
+
(r'[0-9]+(?=[^0-9a-z$_\u0080-\uffff])', Number.Integer), # Integers that are not in a schema object name
|
| 732 |
+
|
| 733 |
+
# Date literals
|
| 734 |
+
(r"\{\s*d\s*(?P<quote>['\"])\s*\d{2}(\d{2})?.?\d{2}.?\d{2}\s*(?P=quote)\s*\}",
|
| 735 |
+
Literal.Date),
|
| 736 |
+
|
| 737 |
+
# Time literals
|
| 738 |
+
(r"\{\s*t\s*(?P<quote>['\"])\s*(?:\d+\s+)?\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?\s*(?P=quote)\s*\}",
|
| 739 |
+
Literal.Date),
|
| 740 |
+
|
| 741 |
+
# Timestamp literals
|
| 742 |
+
(
|
| 743 |
+
r"\{\s*ts\s*(?P<quote>['\"])\s*"
|
| 744 |
+
r"\d{2}(?:\d{2})?.?\d{2}.?\d{2}" # Date part
|
| 745 |
+
r"\s+" # Whitespace between date and time
|
| 746 |
+
r"\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?" # Time part
|
| 747 |
+
r"\s*(?P=quote)\s*\}",
|
| 748 |
+
Literal.Date
|
| 749 |
+
),
|
| 750 |
+
|
| 751 |
+
# String literals
|
| 752 |
+
(r"'", String.Single, 'single-quoted-string'),
|
| 753 |
+
(r'"', String.Double, 'double-quoted-string'),
|
| 754 |
+
|
| 755 |
+
# Variables
|
| 756 |
+
(r'@@(?:global\.|persist\.|persist_only\.|session\.)?[a-z_]+', Name.Variable),
|
| 757 |
+
(r'@[a-z0-9_$.]+', Name.Variable),
|
| 758 |
+
(r"@'", Name.Variable, 'single-quoted-variable'),
|
| 759 |
+
(r'@"', Name.Variable, 'double-quoted-variable'),
|
| 760 |
+
(r"@`", Name.Variable, 'backtick-quoted-variable'),
|
| 761 |
+
(r'\?', Name.Variable), # For demonstrating prepared statements
|
| 762 |
+
|
| 763 |
+
# Operators
|
| 764 |
+
(r'[!%&*+/:<=>^|~-]+', Operator),
|
| 765 |
+
|
| 766 |
+
# Exceptions; these words tokenize differently in different contexts.
|
| 767 |
+
(r'\b(set)(?!\s*\()', Keyword),
|
| 768 |
+
(r'\b(character)(\s+)(set)\b', bygroups(Keyword, Whitespace, Keyword)),
|
| 769 |
+
# In all other known cases, "SET" is tokenized by MYSQL_DATATYPES.
|
| 770 |
+
|
| 771 |
+
(words(_mysql_builtins.MYSQL_CONSTANTS, prefix=r'\b', suffix=r'\b'),
|
| 772 |
+
Name.Constant),
|
| 773 |
+
(words(_mysql_builtins.MYSQL_DATATYPES, prefix=r'\b', suffix=r'\b'),
|
| 774 |
+
Keyword.Type),
|
| 775 |
+
(words(_mysql_builtins.MYSQL_KEYWORDS, prefix=r'\b', suffix=r'\b'),
|
| 776 |
+
Keyword),
|
| 777 |
+
(words(_mysql_builtins.MYSQL_FUNCTIONS, prefix=r'\b', suffix=r'\b(\s*)(\()'),
|
| 778 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 779 |
+
|
| 780 |
+
# Schema object names
|
| 781 |
+
#
|
| 782 |
+
# Note: Although the first regex supports unquoted all-numeric
|
| 783 |
+
# identifiers, this will not be a problem in practice because
|
| 784 |
+
# numeric literals have already been handled above.
|
| 785 |
+
#
|
| 786 |
+
('[0-9a-z$_\u0080-\uffff]+', Name),
|
| 787 |
+
(r'`', Name.Quoted, 'schema-object-name'),
|
| 788 |
+
|
| 789 |
+
# Punctuation
|
| 790 |
+
(r'[(),.;]', Punctuation),
|
| 791 |
+
],
|
| 792 |
+
|
| 793 |
+
# Multiline comment substates
|
| 794 |
+
# ---------------------------
|
| 795 |
+
|
| 796 |
+
'optimizer-hints': [
|
| 797 |
+
(r'[^*a-z]+', Comment.Special),
|
| 798 |
+
(r'\*/', Comment.Special, '#pop'),
|
| 799 |
+
(words(_mysql_builtins.MYSQL_OPTIMIZER_HINTS, suffix=r'\b'),
|
| 800 |
+
Comment.Preproc),
|
| 801 |
+
('[a-z]+', Comment.Special),
|
| 802 |
+
(r'\*', Comment.Special),
|
| 803 |
+
],
|
| 804 |
+
|
| 805 |
+
'multiline-comment': [
|
| 806 |
+
(r'[^*]+', Comment.Multiline),
|
| 807 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 808 |
+
(r'\*', Comment.Multiline),
|
| 809 |
+
],
|
| 810 |
+
|
| 811 |
+
# String substates
|
| 812 |
+
# ----------------
|
| 813 |
+
|
| 814 |
+
'single-quoted-string': [
|
| 815 |
+
(r"[^'\\]+", String.Single),
|
| 816 |
+
(r"''", String.Escape),
|
| 817 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 818 |
+
(r"'", String.Single, '#pop'),
|
| 819 |
+
],
|
| 820 |
+
|
| 821 |
+
'double-quoted-string': [
|
| 822 |
+
(r'[^"\\]+', String.Double),
|
| 823 |
+
(r'""', String.Escape),
|
| 824 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 825 |
+
(r'"', String.Double, '#pop'),
|
| 826 |
+
],
|
| 827 |
+
|
| 828 |
+
# Variable substates
|
| 829 |
+
# ------------------
|
| 830 |
+
|
| 831 |
+
'single-quoted-variable': [
|
| 832 |
+
(r"[^']+", Name.Variable),
|
| 833 |
+
(r"''", Name.Variable),
|
| 834 |
+
(r"'", Name.Variable, '#pop'),
|
| 835 |
+
],
|
| 836 |
+
|
| 837 |
+
'double-quoted-variable': [
|
| 838 |
+
(r'[^"]+', Name.Variable),
|
| 839 |
+
(r'""', Name.Variable),
|
| 840 |
+
(r'"', Name.Variable, '#pop'),
|
| 841 |
+
],
|
| 842 |
+
|
| 843 |
+
'backtick-quoted-variable': [
|
| 844 |
+
(r'[^`]+', Name.Variable),
|
| 845 |
+
(r'``', Name.Variable),
|
| 846 |
+
(r'`', Name.Variable, '#pop'),
|
| 847 |
+
],
|
| 848 |
+
|
| 849 |
+
# Schema object name substates
|
| 850 |
+
# ----------------------------
|
| 851 |
+
#
|
| 852 |
+
# "Name.Quoted" and "Name.Quoted.Escape" are non-standard but
|
| 853 |
+
# formatters will style them as "Name" by default but add
|
| 854 |
+
# additional styles based on the token name. This gives users
|
| 855 |
+
# flexibility to add custom styles as desired.
|
| 856 |
+
#
|
| 857 |
+
'schema-object-name': [
|
| 858 |
+
(r'[^`]+', Name.Quoted),
|
| 859 |
+
(r'``', Name.Quoted.Escape),
|
| 860 |
+
(r'`', Name.Quoted, '#pop'),
|
| 861 |
+
],
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
def analyse_text(text):
|
| 865 |
+
rating = 0
|
| 866 |
+
name_between_backtick_count = len(
|
| 867 |
+
name_between_backtick_re.findall(text))
|
| 868 |
+
name_between_bracket_count = len(
|
| 869 |
+
name_between_bracket_re.findall(text))
|
| 870 |
+
# Same logic as above in the TSQL analysis
|
| 871 |
+
dialect_name_count = name_between_backtick_count + name_between_bracket_count
|
| 872 |
+
if dialect_name_count >= 1 and \
|
| 873 |
+
name_between_backtick_count >= 2 * name_between_bracket_count:
|
| 874 |
+
# Found at least twice as many `name` as [name].
|
| 875 |
+
rating += 0.5
|
| 876 |
+
elif name_between_backtick_count > name_between_bracket_count:
|
| 877 |
+
rating += 0.2
|
| 878 |
+
elif name_between_backtick_count > 0:
|
| 879 |
+
rating += 0.1
|
| 880 |
+
return rating
|
| 881 |
+
|
| 882 |
+
|
| 883 |
+
class GoogleSqlLexer(RegexLexer):
|
| 884 |
+
"""
|
| 885 |
+
GoogleSQL is Google's standard SQL dialect, formerly known as ZetaSQL.
|
| 886 |
+
|
| 887 |
+
The list of keywords includes reserved words for future use.
|
| 888 |
+
"""
|
| 889 |
+
|
| 890 |
+
name = 'GoogleSQL'
|
| 891 |
+
aliases = ['googlesql', 'zetasql']
|
| 892 |
+
filenames = ['*.googlesql', '*.googlesql.sql']
|
| 893 |
+
mimetypes = ['text/x-google-sql', 'text/x-google-sql-aux']
|
| 894 |
+
url = 'https://cloud.google.com/bigquery/googlesql'
|
| 895 |
+
version_added = '2.19'
|
| 896 |
+
|
| 897 |
+
flags = re.IGNORECASE
|
| 898 |
+
tokens = {
|
| 899 |
+
'root': [
|
| 900 |
+
(r'\s+', Whitespace),
|
| 901 |
+
|
| 902 |
+
# Comments
|
| 903 |
+
(r'(?:#|--\s+).*', Comment.Single),
|
| 904 |
+
(r'/\*', Comment.Multiline, 'multiline-comment'),
|
| 905 |
+
|
| 906 |
+
# Hexadecimal literals
|
| 907 |
+
(r"x'([0-9a-f]{2})+'", Number.Hex),
|
| 908 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 909 |
+
|
| 910 |
+
# Binary literals
|
| 911 |
+
(r"b'[01]+'", Number.Bin),
|
| 912 |
+
(r'0b[01]+', Number.Bin),
|
| 913 |
+
|
| 914 |
+
# Numeric literals
|
| 915 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), # Mandatory integer, optional fraction and exponent
|
| 916 |
+
(r'[0-9]*\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Mandatory fraction, optional integer and exponent
|
| 917 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float), # Exponents with integer significands are still floats
|
| 918 |
+
(r'[0-9]+(?=[^0-9a-z$_\u0080-\uffff])', Number.Integer), # Integers that are not in a schema object name
|
| 919 |
+
|
| 920 |
+
# Date literals
|
| 921 |
+
(r"\{\s*d\s*(?P<quote>['\"])\s*\d{2}(\d{2})?.?\d{2}.?\d{2}\s*(?P=quote)\s*\}",
|
| 922 |
+
Literal.Date),
|
| 923 |
+
|
| 924 |
+
# Time literals
|
| 925 |
+
(r"\{\s*t\s*(?P<quote>['\"])\s*(?:\d+\s+)?\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?\s*(?P=quote)\s*\}",
|
| 926 |
+
Literal.Date),
|
| 927 |
+
|
| 928 |
+
# Timestamp literals
|
| 929 |
+
(
|
| 930 |
+
r"\{\s*ts\s*(?P<quote>['\"])\s*"
|
| 931 |
+
r"\d{2}(?:\d{2})?.?\d{2}.?\d{2}" # Date part
|
| 932 |
+
r"\s+" # Whitespace between date and time
|
| 933 |
+
r"\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?" # Time part
|
| 934 |
+
r"\s*(?P=quote)\s*\}",
|
| 935 |
+
Literal.Date
|
| 936 |
+
),
|
| 937 |
+
|
| 938 |
+
# String literals
|
| 939 |
+
(r"'", String.Single, 'single-quoted-string'),
|
| 940 |
+
(r'"', String.Double, 'double-quoted-string'),
|
| 941 |
+
|
| 942 |
+
# Variables
|
| 943 |
+
(r'@@(?:global\.|persist\.|persist_only\.|session\.)?[a-z_]+', Name.Variable),
|
| 944 |
+
(r'@[a-z0-9_$.]+', Name.Variable),
|
| 945 |
+
(r"@'", Name.Variable, 'single-quoted-variable'),
|
| 946 |
+
(r'@"', Name.Variable, 'double-quoted-variable'),
|
| 947 |
+
(r"@`", Name.Variable, 'backtick-quoted-variable'),
|
| 948 |
+
(r'\?', Name.Variable), # For demonstrating prepared statements
|
| 949 |
+
|
| 950 |
+
# Exceptions; these words tokenize differently in different contexts.
|
| 951 |
+
(r'\b(set)(?!\s*\()', Keyword),
|
| 952 |
+
(r'\b(character)(\s+)(set)\b', bygroups(Keyword, Whitespace, Keyword)),
|
| 953 |
+
|
| 954 |
+
# Constants, types, keywords, functions, operators
|
| 955 |
+
(words(_googlesql_builtins.constants, prefix=r'\b', suffix=r'\b'), Name.Constant),
|
| 956 |
+
(words(_googlesql_builtins.types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 957 |
+
(words(_googlesql_builtins.keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 958 |
+
(words(_googlesql_builtins.functionnames, prefix=r'\b', suffix=r'\b(\s*)(\()'),
|
| 959 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 960 |
+
(words(_googlesql_builtins.operators, prefix=r'\b', suffix=r'\b'), Operator),
|
| 961 |
+
|
| 962 |
+
# Schema object names
|
| 963 |
+
#
|
| 964 |
+
# Note: Although the first regex supports unquoted all-numeric
|
| 965 |
+
# identifiers, this will not be a problem in practice because
|
| 966 |
+
# numeric literals have already been handled above.
|
| 967 |
+
#
|
| 968 |
+
('[0-9a-z$_\u0080-\uffff]+', Name),
|
| 969 |
+
(r'`', Name.Quoted, 'schema-object-name'),
|
| 970 |
+
|
| 971 |
+
# Punctuation
|
| 972 |
+
(r'[(),.;]', Punctuation),
|
| 973 |
+
],
|
| 974 |
+
|
| 975 |
+
# Multiline comment substates
|
| 976 |
+
# ---------------------------
|
| 977 |
+
|
| 978 |
+
'multiline-comment': [
|
| 979 |
+
(r'[^*]+', Comment.Multiline),
|
| 980 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 981 |
+
(r'\*', Comment.Multiline),
|
| 982 |
+
],
|
| 983 |
+
|
| 984 |
+
# String substates
|
| 985 |
+
# ----------------
|
| 986 |
+
|
| 987 |
+
'single-quoted-string': [
|
| 988 |
+
(r"[^'\\]+", String.Single),
|
| 989 |
+
(r"''", String.Escape),
|
| 990 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 991 |
+
(r"'", String.Single, '#pop'),
|
| 992 |
+
],
|
| 993 |
+
|
| 994 |
+
'double-quoted-string': [
|
| 995 |
+
(r'[^"\\]+', String.Double),
|
| 996 |
+
(r'""', String.Escape),
|
| 997 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 998 |
+
(r'"', String.Double, '#pop'),
|
| 999 |
+
],
|
| 1000 |
+
|
| 1001 |
+
# Variable substates
|
| 1002 |
+
# ------------------
|
| 1003 |
+
|
| 1004 |
+
'single-quoted-variable': [
|
| 1005 |
+
(r"[^']+", Name.Variable),
|
| 1006 |
+
(r"''", Name.Variable),
|
| 1007 |
+
(r"'", Name.Variable, '#pop'),
|
| 1008 |
+
],
|
| 1009 |
+
|
| 1010 |
+
'double-quoted-variable': [
|
| 1011 |
+
(r'[^"]+', Name.Variable),
|
| 1012 |
+
(r'""', Name.Variable),
|
| 1013 |
+
(r'"', Name.Variable, '#pop'),
|
| 1014 |
+
],
|
| 1015 |
+
|
| 1016 |
+
'backtick-quoted-variable': [
|
| 1017 |
+
(r'[^`]+', Name.Variable),
|
| 1018 |
+
(r'``', Name.Variable),
|
| 1019 |
+
(r'`', Name.Variable, '#pop'),
|
| 1020 |
+
],
|
| 1021 |
+
|
| 1022 |
+
# Schema object name substates
|
| 1023 |
+
# ----------------------------
|
| 1024 |
+
#
|
| 1025 |
+
# "Name.Quoted" and "Name.Quoted.Escape" are non-standard but
|
| 1026 |
+
# formatters will style them as "Name" by default but add
|
| 1027 |
+
# additional styles based on the token name. This gives users
|
| 1028 |
+
# flexibility to add custom styles as desired.
|
| 1029 |
+
#
|
| 1030 |
+
'schema-object-name': [
|
| 1031 |
+
(r'[^`]+', Name.Quoted),
|
| 1032 |
+
(r'``', Name.Quoted.Escape),
|
| 1033 |
+
(r'`', Name.Quoted, '#pop'),
|
| 1034 |
+
],
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
def analyse_text(text):
|
| 1038 |
+
tokens = collections.Counter(text.split())
|
| 1039 |
+
return 0.001 * sum(count for t, count in tokens.items()
|
| 1040 |
+
if t in googlesql_identifiers)
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
class SqliteConsoleLexer(Lexer):
|
| 1044 |
+
"""
|
| 1045 |
+
Lexer for example sessions using sqlite3.
|
| 1046 |
+
"""
|
| 1047 |
+
|
| 1048 |
+
name = 'sqlite3con'
|
| 1049 |
+
aliases = ['sqlite3']
|
| 1050 |
+
filenames = ['*.sqlite3-console']
|
| 1051 |
+
mimetypes = ['text/x-sqlite3-console']
|
| 1052 |
+
url = 'https://www.sqlite.org'
|
| 1053 |
+
version_added = '0.11'
|
| 1054 |
+
_example = "sqlite3/sqlite3.sqlite3-console"
|
| 1055 |
+
|
| 1056 |
+
def get_tokens_unprocessed(self, data):
|
| 1057 |
+
sql = SqlLexer(**self.options)
|
| 1058 |
+
|
| 1059 |
+
curcode = ''
|
| 1060 |
+
insertions = []
|
| 1061 |
+
for match in line_re.finditer(data):
|
| 1062 |
+
line = match.group()
|
| 1063 |
+
prompt_match = sqlite_prompt_re.match(line)
|
| 1064 |
+
if prompt_match is not None:
|
| 1065 |
+
insertions.append((len(curcode),
|
| 1066 |
+
[(0, Generic.Prompt, line[:7])]))
|
| 1067 |
+
insertions.append((len(curcode),
|
| 1068 |
+
[(7, Whitespace, ' ')]))
|
| 1069 |
+
curcode += line[8:]
|
| 1070 |
+
else:
|
| 1071 |
+
if curcode:
|
| 1072 |
+
yield from do_insertions(insertions,
|
| 1073 |
+
sql.get_tokens_unprocessed(curcode))
|
| 1074 |
+
curcode = ''
|
| 1075 |
+
insertions = []
|
| 1076 |
+
if line.startswith('SQL error: '):
|
| 1077 |
+
yield (match.start(), Generic.Traceback, line)
|
| 1078 |
+
else:
|
| 1079 |
+
yield (match.start(), Generic.Output, line)
|
| 1080 |
+
if curcode:
|
| 1081 |
+
yield from do_insertions(insertions,
|
| 1082 |
+
sql.get_tokens_unprocessed(curcode))
|
| 1083 |
+
|
| 1084 |
+
|
| 1085 |
+
class RqlLexer(RegexLexer):
|
| 1086 |
+
"""
|
| 1087 |
+
Lexer for Relation Query Language.
|
| 1088 |
+
"""
|
| 1089 |
+
name = 'RQL'
|
| 1090 |
+
url = 'http://www.logilab.org/project/rql'
|
| 1091 |
+
aliases = ['rql']
|
| 1092 |
+
filenames = ['*.rql']
|
| 1093 |
+
mimetypes = ['text/x-rql']
|
| 1094 |
+
version_added = '2.0'
|
| 1095 |
+
|
| 1096 |
+
flags = re.IGNORECASE
|
| 1097 |
+
tokens = {
|
| 1098 |
+
'root': [
|
| 1099 |
+
(r'\s+', Whitespace),
|
| 1100 |
+
(r'(DELETE|SET|INSERT|UNION|DISTINCT|WITH|WHERE|BEING|OR'
|
| 1101 |
+
r'|AND|NOT|GROUPBY|HAVING|ORDERBY|ASC|DESC|LIMIT|OFFSET'
|
| 1102 |
+
r'|TODAY|NOW|TRUE|FALSE|NULL|EXISTS)\b', Keyword),
|
| 1103 |
+
(r'[+*/<>=%-]', Operator),
|
| 1104 |
+
(r'(Any|is|instance_of|CWEType|CWRelation)\b', Name.Builtin),
|
| 1105 |
+
(r'[0-9]+', Number.Integer),
|
| 1106 |
+
(r'[A-Z_]\w*\??', Name),
|
| 1107 |
+
(r"'(''|[^'])*'", String.Single),
|
| 1108 |
+
(r'"(""|[^"])*"', String.Single),
|
| 1109 |
+
(r'[;:()\[\],.]', Punctuation)
|
| 1110 |
+
],
|
| 1111 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/stata.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.stata
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Stata
|
| 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 |
+
from pygments.lexer import RegexLexer, default, include, words
|
| 13 |
+
from pygments.token import Comment, Keyword, Name, Number, \
|
| 14 |
+
String, Text, Operator
|
| 15 |
+
|
| 16 |
+
from pygments.lexers._stata_builtins import builtins_base, builtins_functions
|
| 17 |
+
|
| 18 |
+
__all__ = ['StataLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class StataLexer(RegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
For Stata do files.
|
| 24 |
+
"""
|
| 25 |
+
# Syntax based on
|
| 26 |
+
# - http://fmwww.bc.edu/RePEc/bocode/s/synlightlist.ado
|
| 27 |
+
# - https://github.com/isagalaev/highlight.js/blob/master/src/languages/stata.js
|
| 28 |
+
# - https://github.com/jpitblado/vim-stata/blob/master/syntax/stata.vim
|
| 29 |
+
|
| 30 |
+
name = 'Stata'
|
| 31 |
+
url = 'http://www.stata.com/'
|
| 32 |
+
version_added = '2.2'
|
| 33 |
+
aliases = ['stata', 'do']
|
| 34 |
+
filenames = ['*.do', '*.ado']
|
| 35 |
+
mimetypes = ['text/x-stata', 'text/stata', 'application/x-stata']
|
| 36 |
+
flags = re.MULTILINE | re.DOTALL
|
| 37 |
+
|
| 38 |
+
tokens = {
|
| 39 |
+
'root': [
|
| 40 |
+
include('comments'),
|
| 41 |
+
include('strings'),
|
| 42 |
+
include('macros'),
|
| 43 |
+
include('numbers'),
|
| 44 |
+
include('keywords'),
|
| 45 |
+
include('operators'),
|
| 46 |
+
include('format'),
|
| 47 |
+
(r'.', Text),
|
| 48 |
+
],
|
| 49 |
+
# Comments are a complicated beast in Stata because they can be
|
| 50 |
+
# nested and there are a few corner cases with that. See:
|
| 51 |
+
# - github.com/kylebarron/language-stata/issues/90
|
| 52 |
+
# - statalist.org/forums/forum/general-stata-discussion/general/1448244
|
| 53 |
+
'comments': [
|
| 54 |
+
(r'(^//|(?<=\s)//)(?!/)', Comment.Single, 'comments-double-slash'),
|
| 55 |
+
(r'^\s*\*', Comment.Single, 'comments-star'),
|
| 56 |
+
(r'/\*', Comment.Multiline, 'comments-block'),
|
| 57 |
+
(r'(^///|(?<=\s)///)', Comment.Special, 'comments-triple-slash')
|
| 58 |
+
],
|
| 59 |
+
'comments-block': [
|
| 60 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 61 |
+
# this ends and restarts a comment block. but need to catch this so
|
| 62 |
+
# that it doesn\'t start _another_ level of comment blocks
|
| 63 |
+
(r'\*/\*', Comment.Multiline),
|
| 64 |
+
(r'(\*/\s+\*(?!/)[^\n]*)|(\*/)', Comment.Multiline, '#pop'),
|
| 65 |
+
# Match anything else as a character inside the comment
|
| 66 |
+
(r'.', Comment.Multiline),
|
| 67 |
+
],
|
| 68 |
+
'comments-star': [
|
| 69 |
+
(r'///.*?\n', Comment.Single,
|
| 70 |
+
('#pop', 'comments-triple-slash')),
|
| 71 |
+
(r'(^//|(?<=\s)//)(?!/)', Comment.Single,
|
| 72 |
+
('#pop', 'comments-double-slash')),
|
| 73 |
+
(r'/\*', Comment.Multiline, 'comments-block'),
|
| 74 |
+
(r'.(?=\n)', Comment.Single, '#pop'),
|
| 75 |
+
(r'.', Comment.Single),
|
| 76 |
+
],
|
| 77 |
+
'comments-triple-slash': [
|
| 78 |
+
(r'\n', Comment.Special, '#pop'),
|
| 79 |
+
# A // breaks out of a comment for the rest of the line
|
| 80 |
+
(r'//.*?(?=\n)', Comment.Single, '#pop'),
|
| 81 |
+
(r'.', Comment.Special),
|
| 82 |
+
],
|
| 83 |
+
'comments-double-slash': [
|
| 84 |
+
(r'\n', Text, '#pop'),
|
| 85 |
+
(r'.', Comment.Single),
|
| 86 |
+
],
|
| 87 |
+
# `"compound string"' and regular "string"; note the former are
|
| 88 |
+
# nested.
|
| 89 |
+
'strings': [
|
| 90 |
+
(r'`"', String, 'string-compound'),
|
| 91 |
+
(r'(?<!`)"', String, 'string-regular'),
|
| 92 |
+
],
|
| 93 |
+
'string-compound': [
|
| 94 |
+
(r'`"', String, '#push'),
|
| 95 |
+
(r'"\'', String, '#pop'),
|
| 96 |
+
(r'\\\\|\\"|\\\$|\\`|\\\n', String.Escape),
|
| 97 |
+
include('macros'),
|
| 98 |
+
(r'.', String)
|
| 99 |
+
],
|
| 100 |
+
'string-regular': [
|
| 101 |
+
(r'(")(?!\')|(?=\n)', String, '#pop'),
|
| 102 |
+
(r'\\\\|\\"|\\\$|\\`|\\\n', String.Escape),
|
| 103 |
+
include('macros'),
|
| 104 |
+
(r'.', String)
|
| 105 |
+
],
|
| 106 |
+
# A local is usually
|
| 107 |
+
# `\w{0,31}'
|
| 108 |
+
# `:extended macro'
|
| 109 |
+
# `=expression'
|
| 110 |
+
# `[rsen](results)'
|
| 111 |
+
# `(++--)scalar(++--)'
|
| 112 |
+
#
|
| 113 |
+
# However, there are all sorts of weird rules wrt edge
|
| 114 |
+
# cases. Instead of writing 27 exceptions, anything inside
|
| 115 |
+
# `' is a local.
|
| 116 |
+
#
|
| 117 |
+
# A global is more restricted, so we do follow rules. Note only
|
| 118 |
+
# locals explicitly enclosed ${} can be nested.
|
| 119 |
+
'macros': [
|
| 120 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested'),
|
| 121 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 122 |
+
(r'`', Name.Variable, 'macro-local'),
|
| 123 |
+
],
|
| 124 |
+
'macro-local': [
|
| 125 |
+
(r'`', Name.Variable, '#push'),
|
| 126 |
+
(r"'", Name.Variable, '#pop'),
|
| 127 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested'),
|
| 128 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 129 |
+
(r'.', Name.Variable), # fallback
|
| 130 |
+
],
|
| 131 |
+
'macro-global-nested': [
|
| 132 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, '#push'),
|
| 133 |
+
(r'\}', Name.Variable.Global, '#pop'),
|
| 134 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 135 |
+
(r'`', Name.Variable, 'macro-local'),
|
| 136 |
+
(r'\w', Name.Variable.Global), # fallback
|
| 137 |
+
default('#pop'),
|
| 138 |
+
],
|
| 139 |
+
'macro-global-name': [
|
| 140 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested', '#pop'),
|
| 141 |
+
(r'\$', Name.Variable.Global, 'macro-global-name', '#pop'),
|
| 142 |
+
(r'`', Name.Variable, 'macro-local', '#pop'),
|
| 143 |
+
(r'\w{1,32}', Name.Variable.Global, '#pop'),
|
| 144 |
+
],
|
| 145 |
+
# Built in functions and statements
|
| 146 |
+
'keywords': [
|
| 147 |
+
(words(builtins_functions, prefix = r'\b', suffix = r'(?=\()'),
|
| 148 |
+
Name.Function),
|
| 149 |
+
(words(builtins_base, prefix = r'(^\s*|\s)', suffix = r'\b'),
|
| 150 |
+
Keyword),
|
| 151 |
+
],
|
| 152 |
+
# http://www.stata.com/help.cgi?operators
|
| 153 |
+
'operators': [
|
| 154 |
+
(r'-|==|<=|>=|<|>|&|!=', Operator),
|
| 155 |
+
(r'\*|\+|\^|/|!|~|==|~=', Operator)
|
| 156 |
+
],
|
| 157 |
+
# Stata numbers
|
| 158 |
+
'numbers': [
|
| 159 |
+
# decimal number
|
| 160 |
+
(r'\b[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[i]?\b',
|
| 161 |
+
Number),
|
| 162 |
+
],
|
| 163 |
+
# Stata formats
|
| 164 |
+
'format': [
|
| 165 |
+
(r'%-?\d{1,2}(\.\d{1,2})?[gfe]c?', Name.Other),
|
| 166 |
+
(r'%(21x|16H|16L|8H|8L)', Name.Other),
|
| 167 |
+
(r'%-?(tc|tC|td|tw|tm|tq|th|ty|tg)\S{0,32}', Name.Other),
|
| 168 |
+
(r'%[-~]?\d{1,4}s', Name.Other),
|
| 169 |
+
]
|
| 170 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tal.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Uxntal
|
| 6 |
+
|
| 7 |
+
.. versionadded:: 2.12
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, words
|
| 14 |
+
from pygments.token import Comment, Keyword, Name, String, Number, \
|
| 15 |
+
Punctuation, Whitespace, Literal
|
| 16 |
+
|
| 17 |
+
__all__ = ['TalLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class TalLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Uxntal source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Tal'
|
| 26 |
+
aliases = ['tal', 'uxntal']
|
| 27 |
+
filenames = ['*.tal']
|
| 28 |
+
mimetypes = ['text/x-uxntal']
|
| 29 |
+
url = 'https://wiki.xxiivv.com/site/uxntal.html'
|
| 30 |
+
version_added = '2.12'
|
| 31 |
+
|
| 32 |
+
instructions = [
|
| 33 |
+
'BRK', 'LIT', 'INC', 'POP', 'DUP', 'NIP', 'SWP', 'OVR', 'ROT',
|
| 34 |
+
'EQU', 'NEQ', 'GTH', 'LTH', 'JMP', 'JCN', 'JSR', 'STH',
|
| 35 |
+
'LDZ', 'STZ', 'LDR', 'STR', 'LDA', 'STA', 'DEI', 'DEO',
|
| 36 |
+
'ADD', 'SUB', 'MUL', 'DIV', 'AND', 'ORA', 'EOR', 'SFT'
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
tokens = {
|
| 40 |
+
# the comment delimiters must not be adjacent to non-space characters.
|
| 41 |
+
# this means ( foo ) is a valid comment but (foo) is not. this also
|
| 42 |
+
# applies to nested comments.
|
| 43 |
+
'comment': [
|
| 44 |
+
(r'(?<!\S)\((?!\S)', Comment.Multiline, '#push'), # nested comments
|
| 45 |
+
(r'(?<!\S)\)(?!\S)', Comment.Multiline, '#pop'), # nested comments
|
| 46 |
+
(r'[^()]+', Comment.Multiline), # comments
|
| 47 |
+
(r'[()]+', Comment.Multiline), # comments
|
| 48 |
+
],
|
| 49 |
+
'root': [
|
| 50 |
+
(r'\s+', Whitespace), # spaces
|
| 51 |
+
(r'(?<!\S)\((?!\S)', Comment.Multiline, 'comment'), # comments
|
| 52 |
+
(words(instructions, prefix=r'(?<!\S)', suffix=r'2?k?r?(?!\S)'),
|
| 53 |
+
Keyword.Reserved), # instructions
|
| 54 |
+
(r'[][{}](?!\S)', Punctuation), # delimiters
|
| 55 |
+
(r'#([0-9a-f]{2}){1,2}(?!\S)', Number.Hex), # integer
|
| 56 |
+
(r'"\S+', String), # raw string
|
| 57 |
+
(r'([0-9a-f]{2}){1,2}(?!\S)', Literal), # raw integer
|
| 58 |
+
(r'[|$][0-9a-f]{1,4}(?!\S)', Keyword.Declaration), # abs/rel pad
|
| 59 |
+
(r'%\S+', Name.Decorator), # macro
|
| 60 |
+
(r'@\S+', Name.Function), # label
|
| 61 |
+
(r'&\S+', Name.Label), # sublabel
|
| 62 |
+
(r'/\S+', Name.Tag), # spacer
|
| 63 |
+
(r'\.\S+', Name.Variable.Magic), # literal zero page addr
|
| 64 |
+
(r',\S+', Name.Variable.Instance), # literal rel addr
|
| 65 |
+
(r';\S+', Name.Variable.Global), # literal abs addr
|
| 66 |
+
(r'-\S+', Literal), # raw zero page addr
|
| 67 |
+
(r'_\S+', Literal), # raw relative addr
|
| 68 |
+
(r'=\S+', Literal), # raw absolute addr
|
| 69 |
+
(r'!\S+', Name.Function), # immediate jump
|
| 70 |
+
(r'\?\S+', Name.Function), # conditional immediate jump
|
| 71 |
+
(r'~\S+', Keyword.Namespace), # include
|
| 72 |
+
(r'\S+', Name.Function), # macro invocation, immediate subroutine
|
| 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
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tcl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Tcl and related 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
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Whitespace
|
| 14 |
+
from pygments.util import shebang_matches
|
| 15 |
+
|
| 16 |
+
__all__ = ['TclLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class TclLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For Tcl source code.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
keyword_cmds_re = words((
|
| 25 |
+
'after', 'apply', 'array', 'break', 'catch', 'continue', 'elseif',
|
| 26 |
+
'else', 'error', 'eval', 'expr', 'for', 'foreach', 'global', 'if',
|
| 27 |
+
'namespace', 'proc', 'rename', 'return', 'set', 'switch', 'then',
|
| 28 |
+
'trace', 'unset', 'update', 'uplevel', 'upvar', 'variable', 'vwait',
|
| 29 |
+
'while'), prefix=r'\b', suffix=r'\b')
|
| 30 |
+
|
| 31 |
+
builtin_cmds_re = words((
|
| 32 |
+
'append', 'bgerror', 'binary', 'cd', 'chan', 'clock', 'close',
|
| 33 |
+
'concat', 'dde', 'dict', 'encoding', 'eof', 'exec', 'exit', 'fblocked',
|
| 34 |
+
'fconfigure', 'fcopy', 'file', 'fileevent', 'flush', 'format', 'gets',
|
| 35 |
+
'glob', 'history', 'http', 'incr', 'info', 'interp', 'join', 'lappend',
|
| 36 |
+
'lassign', 'lindex', 'linsert', 'list', 'llength', 'load', 'loadTk',
|
| 37 |
+
'lrange', 'lrepeat', 'lreplace', 'lreverse', 'lsearch', 'lset', 'lsort',
|
| 38 |
+
'mathfunc', 'mathop', 'memory', 'msgcat', 'open', 'package', 'pid',
|
| 39 |
+
'pkg::create', 'pkg_mkIndex', 'platform', 'platform::shell', 'puts',
|
| 40 |
+
'pwd', 're_syntax', 'read', 'refchan', 'regexp', 'registry', 'regsub',
|
| 41 |
+
'scan', 'seek', 'socket', 'source', 'split', 'string', 'subst', 'tell',
|
| 42 |
+
'time', 'tm', 'unknown', 'unload'), prefix=r'\b', suffix=r'\b')
|
| 43 |
+
|
| 44 |
+
name = 'Tcl'
|
| 45 |
+
url = 'https://www.tcl.tk/about/language.html'
|
| 46 |
+
aliases = ['tcl']
|
| 47 |
+
filenames = ['*.tcl', '*.rvt']
|
| 48 |
+
mimetypes = ['text/x-tcl', 'text/x-script.tcl', 'application/x-tcl']
|
| 49 |
+
version_added = '0.10'
|
| 50 |
+
|
| 51 |
+
def _gen_command_rules(keyword_cmds_re, builtin_cmds_re, context=""):
|
| 52 |
+
return [
|
| 53 |
+
(keyword_cmds_re, Keyword, 'params' + context),
|
| 54 |
+
(builtin_cmds_re, Name.Builtin, 'params' + context),
|
| 55 |
+
(r'([\w.-]+)', Name.Variable, 'params' + context),
|
| 56 |
+
(r'#', Comment, 'comment'),
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
tokens = {
|
| 60 |
+
'root': [
|
| 61 |
+
include('command'),
|
| 62 |
+
include('basic'),
|
| 63 |
+
include('data'),
|
| 64 |
+
(r'\}', Keyword), # HACK: somehow we miscounted our braces
|
| 65 |
+
],
|
| 66 |
+
'command': _gen_command_rules(keyword_cmds_re, builtin_cmds_re),
|
| 67 |
+
'command-in-brace': _gen_command_rules(keyword_cmds_re,
|
| 68 |
+
builtin_cmds_re,
|
| 69 |
+
"-in-brace"),
|
| 70 |
+
'command-in-bracket': _gen_command_rules(keyword_cmds_re,
|
| 71 |
+
builtin_cmds_re,
|
| 72 |
+
"-in-bracket"),
|
| 73 |
+
'command-in-paren': _gen_command_rules(keyword_cmds_re,
|
| 74 |
+
builtin_cmds_re,
|
| 75 |
+
"-in-paren"),
|
| 76 |
+
'basic': [
|
| 77 |
+
(r'\(', Keyword, 'paren'),
|
| 78 |
+
(r'\[', Keyword, 'bracket'),
|
| 79 |
+
(r'\{', Keyword, 'brace'),
|
| 80 |
+
(r'"', String.Double, 'string'),
|
| 81 |
+
(r'(eq|ne|in|ni)\b', Operator.Word),
|
| 82 |
+
(r'!=|==|<<|>>|<=|>=|&&|\|\||\*\*|[-+~!*/%<>&^|?:]', Operator),
|
| 83 |
+
],
|
| 84 |
+
'data': [
|
| 85 |
+
(r'\s+', Whitespace),
|
| 86 |
+
(r'0x[a-fA-F0-9]+', Number.Hex),
|
| 87 |
+
(r'0[0-7]+', Number.Oct),
|
| 88 |
+
(r'\d+\.\d+', Number.Float),
|
| 89 |
+
(r'\d+', Number.Integer),
|
| 90 |
+
(r'\$[\w.:-]+', Name.Variable),
|
| 91 |
+
(r'\$\{[\w.:-]+\}', Name.Variable),
|
| 92 |
+
(r'[\w.,@:-]+', Text),
|
| 93 |
+
],
|
| 94 |
+
'params': [
|
| 95 |
+
(r';', Keyword, '#pop'),
|
| 96 |
+
(r'\n', Text, '#pop'),
|
| 97 |
+
(r'(else|elseif|then)\b', Keyword),
|
| 98 |
+
include('basic'),
|
| 99 |
+
include('data'),
|
| 100 |
+
],
|
| 101 |
+
'params-in-brace': [
|
| 102 |
+
(r'\}', Keyword, ('#pop', '#pop')),
|
| 103 |
+
include('params')
|
| 104 |
+
],
|
| 105 |
+
'params-in-paren': [
|
| 106 |
+
(r'\)', Keyword, ('#pop', '#pop')),
|
| 107 |
+
include('params')
|
| 108 |
+
],
|
| 109 |
+
'params-in-bracket': [
|
| 110 |
+
(r'\]', Keyword, ('#pop', '#pop')),
|
| 111 |
+
include('params')
|
| 112 |
+
],
|
| 113 |
+
'string': [
|
| 114 |
+
(r'\[', String.Double, 'string-square'),
|
| 115 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\])', String.Double),
|
| 116 |
+
(r'"', String.Double, '#pop')
|
| 117 |
+
],
|
| 118 |
+
'string-square': [
|
| 119 |
+
(r'\[', String.Double, 'string-square'),
|
| 120 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|\\\n|[^\]\\])', String.Double),
|
| 121 |
+
(r'\]', String.Double, '#pop')
|
| 122 |
+
],
|
| 123 |
+
'brace': [
|
| 124 |
+
(r'\}', Keyword, '#pop'),
|
| 125 |
+
include('command-in-brace'),
|
| 126 |
+
include('basic'),
|
| 127 |
+
include('data'),
|
| 128 |
+
],
|
| 129 |
+
'paren': [
|
| 130 |
+
(r'\)', Keyword, '#pop'),
|
| 131 |
+
include('command-in-paren'),
|
| 132 |
+
include('basic'),
|
| 133 |
+
include('data'),
|
| 134 |
+
],
|
| 135 |
+
'bracket': [
|
| 136 |
+
(r'\]', Keyword, '#pop'),
|
| 137 |
+
include('command-in-bracket'),
|
| 138 |
+
include('basic'),
|
| 139 |
+
include('data'),
|
| 140 |
+
],
|
| 141 |
+
'comment': [
|
| 142 |
+
(r'.*[^\\]\n', Comment, '#pop'),
|
| 143 |
+
(r'.*\\\n', Comment),
|
| 144 |
+
],
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
def analyse_text(text):
|
| 148 |
+
return shebang_matches(text, r'(tcl)')
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/teal.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.teal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for TEAL.
|
| 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, words
|
| 12 |
+
from pygments.token import Comment, Name, Number, String, Text, Keyword, \
|
| 13 |
+
Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['TealLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TealLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For the Transaction Execution Approval Language (TEAL)
|
| 21 |
+
|
| 22 |
+
For more information about the grammar, see:
|
| 23 |
+
https://github.com/algorand/go-algorand/blob/master/data/transactions/logic/assembler.go
|
| 24 |
+
"""
|
| 25 |
+
name = 'teal'
|
| 26 |
+
url = 'https://developer.algorand.org/docs/reference/teal/specification/'
|
| 27 |
+
aliases = ['teal']
|
| 28 |
+
filenames = ['*.teal']
|
| 29 |
+
version_added = '2.9'
|
| 30 |
+
|
| 31 |
+
keywords = words({
|
| 32 |
+
'Sender', 'Fee', 'FirstValid', 'FirstValidTime', 'LastValid', 'Note',
|
| 33 |
+
'Lease', 'Receiver', 'Amount', 'CloseRemainderTo', 'VotePK',
|
| 34 |
+
'SelectionPK', 'VoteFirst', 'VoteLast', 'VoteKeyDilution', 'Type',
|
| 35 |
+
'TypeEnum', 'XferAsset', 'AssetAmount', 'AssetSender', 'AssetReceiver',
|
| 36 |
+
'AssetCloseTo', 'GroupIndex', 'TxID', 'ApplicationID', 'OnCompletion',
|
| 37 |
+
'ApplicationArgs', 'NumAppArgs', 'Accounts', 'NumAccounts',
|
| 38 |
+
'ApprovalProgram', 'ClearStateProgram', 'RekeyTo', 'ConfigAsset',
|
| 39 |
+
'ConfigAssetTotal', 'ConfigAssetDecimals', 'ConfigAssetDefaultFrozen',
|
| 40 |
+
'ConfigAssetUnitName', 'ConfigAssetName', 'ConfigAssetURL',
|
| 41 |
+
'ConfigAssetMetadataHash', 'ConfigAssetManager', 'ConfigAssetReserve',
|
| 42 |
+
'ConfigAssetFreeze', 'ConfigAssetClawback', 'FreezeAsset',
|
| 43 |
+
'FreezeAssetAccount', 'FreezeAssetFrozen',
|
| 44 |
+
'NoOp', 'OptIn', 'CloseOut', 'ClearState', 'UpdateApplication',
|
| 45 |
+
'DeleteApplication',
|
| 46 |
+
'MinTxnFee', 'MinBalance', 'MaxTxnLife', 'ZeroAddress', 'GroupSize',
|
| 47 |
+
'LogicSigVersion', 'Round', 'LatestTimestamp', 'CurrentApplicationID',
|
| 48 |
+
'AssetBalance', 'AssetFrozen',
|
| 49 |
+
'AssetTotal', 'AssetDecimals', 'AssetDefaultFrozen', 'AssetUnitName',
|
| 50 |
+
'AssetName', 'AssetURL', 'AssetMetadataHash', 'AssetManager',
|
| 51 |
+
'AssetReserve', 'AssetFreeze', 'AssetClawback',
|
| 52 |
+
}, suffix=r'\b')
|
| 53 |
+
|
| 54 |
+
identifier = r'[^ \t\n]+(?=\/\/)|[^ \t\n]+'
|
| 55 |
+
newline = r'\r?\n'
|
| 56 |
+
tokens = {
|
| 57 |
+
'root': [
|
| 58 |
+
include('whitespace'),
|
| 59 |
+
# pragmas match specifically on the space character
|
| 60 |
+
(r'^#pragma .*' + newline, Comment.Directive),
|
| 61 |
+
# labels must be followed by a space,
|
| 62 |
+
# but anything after that is ignored
|
| 63 |
+
('(' + identifier + ':' + ')' + '([ \t].*)',
|
| 64 |
+
bygroups(Name.Label, Comment.Single)),
|
| 65 |
+
(identifier, Name.Function, 'function-args'),
|
| 66 |
+
],
|
| 67 |
+
'function-args': [
|
| 68 |
+
include('whitespace'),
|
| 69 |
+
(r'"', String, 'string'),
|
| 70 |
+
(r'(b(?:ase)?(?:32|64) ?)(\(?[a-zA-Z0-9+/=]+\)?)',
|
| 71 |
+
bygroups(String.Affix, String.Other)),
|
| 72 |
+
(r'[A-Z2-7]{58}', Number), # address
|
| 73 |
+
(r'0x[\da-fA-F]+', Number.Hex),
|
| 74 |
+
(r'\d+', Number.Integer),
|
| 75 |
+
(keywords, Keyword),
|
| 76 |
+
(identifier, Name.Attributes), # branch targets
|
| 77 |
+
(newline, Text, '#pop'),
|
| 78 |
+
],
|
| 79 |
+
'string': [
|
| 80 |
+
(r'\\(?:["nrt\\]|x\d\d)', String.Escape),
|
| 81 |
+
(r'[^\\\"\n]+', String),
|
| 82 |
+
(r'"', String, '#pop'),
|
| 83 |
+
],
|
| 84 |
+
'whitespace': [
|
| 85 |
+
(r'[ \t]+', Whitespace),
|
| 86 |
+
(r'//[^\n]+', Comment.Single),
|
| 87 |
+
],
|
| 88 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/teraterm.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.teraterm
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Tera Term macro files.
|
| 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, Name, String, \
|
| 15 |
+
Number, Keyword, Error
|
| 16 |
+
|
| 17 |
+
__all__ = ['TeraTermLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class TeraTermLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Tera Term macro source code.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Tera Term macro'
|
| 25 |
+
url = 'https://ttssh2.osdn.jp/'
|
| 26 |
+
aliases = ['teratermmacro', 'teraterm', 'ttl']
|
| 27 |
+
filenames = ['*.ttl']
|
| 28 |
+
mimetypes = ['text/x-teratermmacro']
|
| 29 |
+
version_added = '2.4'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
include('comments'),
|
| 34 |
+
include('labels'),
|
| 35 |
+
include('commands'),
|
| 36 |
+
include('builtin-variables'),
|
| 37 |
+
include('user-variables'),
|
| 38 |
+
include('operators'),
|
| 39 |
+
include('numeric-literals'),
|
| 40 |
+
include('string-literals'),
|
| 41 |
+
include('all-whitespace'),
|
| 42 |
+
(r'\S', Text),
|
| 43 |
+
],
|
| 44 |
+
'comments': [
|
| 45 |
+
(r';[^\r\n]*', Comment.Single),
|
| 46 |
+
(r'/\*', Comment.Multiline, 'in-comment'),
|
| 47 |
+
],
|
| 48 |
+
'in-comment': [
|
| 49 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 50 |
+
(r'[^*/]+', Comment.Multiline),
|
| 51 |
+
(r'[*/]', Comment.Multiline)
|
| 52 |
+
],
|
| 53 |
+
'labels': [
|
| 54 |
+
(r'(?i)^(\s*)(:[a-z0-9_]+)', bygroups(Text.Whitespace, Name.Label)),
|
| 55 |
+
],
|
| 56 |
+
'commands': [
|
| 57 |
+
(
|
| 58 |
+
r'(?i)\b('
|
| 59 |
+
r'basename|'
|
| 60 |
+
r'beep|'
|
| 61 |
+
r'bplusrecv|'
|
| 62 |
+
r'bplussend|'
|
| 63 |
+
r'break|'
|
| 64 |
+
r'bringupbox|'
|
| 65 |
+
# 'call' is handled separately.
|
| 66 |
+
r'callmenu|'
|
| 67 |
+
r'changedir|'
|
| 68 |
+
r'checksum16|'
|
| 69 |
+
r'checksum16file|'
|
| 70 |
+
r'checksum32|'
|
| 71 |
+
r'checksum32file|'
|
| 72 |
+
r'checksum8|'
|
| 73 |
+
r'checksum8file|'
|
| 74 |
+
r'clearscreen|'
|
| 75 |
+
r'clipb2var|'
|
| 76 |
+
r'closesbox|'
|
| 77 |
+
r'closett|'
|
| 78 |
+
r'code2str|'
|
| 79 |
+
r'connect|'
|
| 80 |
+
r'continue|'
|
| 81 |
+
r'crc16|'
|
| 82 |
+
r'crc16file|'
|
| 83 |
+
r'crc32|'
|
| 84 |
+
r'crc32file|'
|
| 85 |
+
r'cygconnect|'
|
| 86 |
+
r'delpassword|'
|
| 87 |
+
r'delpassword2|'
|
| 88 |
+
r'dirname|'
|
| 89 |
+
r'dirnamebox|'
|
| 90 |
+
r'disconnect|'
|
| 91 |
+
r'dispstr|'
|
| 92 |
+
r'do|'
|
| 93 |
+
r'else|'
|
| 94 |
+
r'elseif|'
|
| 95 |
+
r'enablekeyb|'
|
| 96 |
+
r'end|'
|
| 97 |
+
r'endif|'
|
| 98 |
+
r'enduntil|'
|
| 99 |
+
r'endwhile|'
|
| 100 |
+
r'exec|'
|
| 101 |
+
r'execcmnd|'
|
| 102 |
+
r'exit|'
|
| 103 |
+
r'expandenv|'
|
| 104 |
+
r'fileclose|'
|
| 105 |
+
r'fileconcat|'
|
| 106 |
+
r'filecopy|'
|
| 107 |
+
r'filecreate|'
|
| 108 |
+
r'filedelete|'
|
| 109 |
+
r'filelock|'
|
| 110 |
+
r'filemarkptr|'
|
| 111 |
+
r'filenamebox|'
|
| 112 |
+
r'fileopen|'
|
| 113 |
+
r'fileread|'
|
| 114 |
+
r'filereadln|'
|
| 115 |
+
r'filerename|'
|
| 116 |
+
r'filesearch|'
|
| 117 |
+
r'fileseek|'
|
| 118 |
+
r'fileseekback|'
|
| 119 |
+
r'filestat|'
|
| 120 |
+
r'filestrseek|'
|
| 121 |
+
r'filestrseek2|'
|
| 122 |
+
r'filetruncate|'
|
| 123 |
+
r'fileunlock|'
|
| 124 |
+
r'filewrite|'
|
| 125 |
+
r'filewriteln|'
|
| 126 |
+
r'findclose|'
|
| 127 |
+
r'findfirst|'
|
| 128 |
+
r'findnext|'
|
| 129 |
+
r'flushrecv|'
|
| 130 |
+
r'foldercreate|'
|
| 131 |
+
r'folderdelete|'
|
| 132 |
+
r'foldersearch|'
|
| 133 |
+
r'for|'
|
| 134 |
+
r'getdate|'
|
| 135 |
+
r'getdir|'
|
| 136 |
+
r'getenv|'
|
| 137 |
+
r'getfileattr|'
|
| 138 |
+
r'gethostname|'
|
| 139 |
+
r'getipv4addr|'
|
| 140 |
+
r'getipv6addr|'
|
| 141 |
+
r'getmodemstatus|'
|
| 142 |
+
r'getpassword|'
|
| 143 |
+
r'getpassword2|'
|
| 144 |
+
r'getspecialfolder|'
|
| 145 |
+
r'gettime|'
|
| 146 |
+
r'gettitle|'
|
| 147 |
+
r'getttdir|'
|
| 148 |
+
r'getttpos|'
|
| 149 |
+
r'getver|'
|
| 150 |
+
# 'goto' is handled separately.
|
| 151 |
+
r'if|'
|
| 152 |
+
r'ifdefined|'
|
| 153 |
+
r'include|'
|
| 154 |
+
r'inputbox|'
|
| 155 |
+
r'int2str|'
|
| 156 |
+
r'intdim|'
|
| 157 |
+
r'ispassword|'
|
| 158 |
+
r'ispassword2|'
|
| 159 |
+
r'kmtfinish|'
|
| 160 |
+
r'kmtget|'
|
| 161 |
+
r'kmtrecv|'
|
| 162 |
+
r'kmtsend|'
|
| 163 |
+
r'listbox|'
|
| 164 |
+
r'loadkeymap|'
|
| 165 |
+
r'logautoclosemode|'
|
| 166 |
+
r'logclose|'
|
| 167 |
+
r'loginfo|'
|
| 168 |
+
r'logopen|'
|
| 169 |
+
r'logpause|'
|
| 170 |
+
r'logrotate|'
|
| 171 |
+
r'logstart|'
|
| 172 |
+
r'logwrite|'
|
| 173 |
+
r'loop|'
|
| 174 |
+
r'makepath|'
|
| 175 |
+
r'messagebox|'
|
| 176 |
+
r'mpause|'
|
| 177 |
+
r'next|'
|
| 178 |
+
r'passwordbox|'
|
| 179 |
+
r'pause|'
|
| 180 |
+
r'quickvanrecv|'
|
| 181 |
+
r'quickvansend|'
|
| 182 |
+
r'random|'
|
| 183 |
+
r'recvfile'
|
| 184 |
+
r'recvln|'
|
| 185 |
+
r'regexoption|'
|
| 186 |
+
r'restoresetup|'
|
| 187 |
+
r'return|'
|
| 188 |
+
r'rotateleft|'
|
| 189 |
+
r'rotateright|'
|
| 190 |
+
r'scprecv|'
|
| 191 |
+
r'scpsend|'
|
| 192 |
+
r'send|'
|
| 193 |
+
r'sendbinary|'
|
| 194 |
+
r'sendbreak|'
|
| 195 |
+
r'sendbroadcast|'
|
| 196 |
+
r'sendfile|'
|
| 197 |
+
r'sendkcode|'
|
| 198 |
+
r'sendln|'
|
| 199 |
+
r'sendlnbroadcast|'
|
| 200 |
+
r'sendlnmulticast|'
|
| 201 |
+
r'sendmulticast|'
|
| 202 |
+
r'sendtext|'
|
| 203 |
+
r'setbaud|'
|
| 204 |
+
r'setdate|'
|
| 205 |
+
r'setdebug|'
|
| 206 |
+
r'setdir|'
|
| 207 |
+
r'setdlgpos|'
|
| 208 |
+
r'setdtr|'
|
| 209 |
+
r'setecho|'
|
| 210 |
+
r'setenv|'
|
| 211 |
+
r'setexitcode|'
|
| 212 |
+
r'setfileattr|'
|
| 213 |
+
r'setflowctrl|'
|
| 214 |
+
r'setmulticastname|'
|
| 215 |
+
r'setpassword|'
|
| 216 |
+
r'setpassword2|'
|
| 217 |
+
r'setrts|'
|
| 218 |
+
r'setserialdelaychar'
|
| 219 |
+
r'setserialdelayline'
|
| 220 |
+
r'setspeed|'
|
| 221 |
+
r'setsync|'
|
| 222 |
+
r'settime|'
|
| 223 |
+
r'settitle|'
|
| 224 |
+
r'show|'
|
| 225 |
+
r'showtt|'
|
| 226 |
+
r'sprintf|'
|
| 227 |
+
r'sprintf2|'
|
| 228 |
+
r'statusbox|'
|
| 229 |
+
r'str2code|'
|
| 230 |
+
r'str2int|'
|
| 231 |
+
r'strcompare|'
|
| 232 |
+
r'strconcat|'
|
| 233 |
+
r'strcopy|'
|
| 234 |
+
r'strdim|'
|
| 235 |
+
r'strinsert|'
|
| 236 |
+
r'strjoin|'
|
| 237 |
+
r'strlen|'
|
| 238 |
+
r'strmatch|'
|
| 239 |
+
r'strremove|'
|
| 240 |
+
r'strreplace|'
|
| 241 |
+
r'strscan|'
|
| 242 |
+
r'strspecial|'
|
| 243 |
+
r'strsplit|'
|
| 244 |
+
r'strtrim|'
|
| 245 |
+
r'testlink|'
|
| 246 |
+
r'then|'
|
| 247 |
+
r'tolower|'
|
| 248 |
+
r'toupper|'
|
| 249 |
+
r'unlink|'
|
| 250 |
+
r'until|'
|
| 251 |
+
r'uptime|'
|
| 252 |
+
r'var2clipb|'
|
| 253 |
+
r'wait|'
|
| 254 |
+
r'wait4all|'
|
| 255 |
+
r'waitevent|'
|
| 256 |
+
r'waitln|'
|
| 257 |
+
r'waitn|'
|
| 258 |
+
r'waitrecv|'
|
| 259 |
+
r'waitregex|'
|
| 260 |
+
r'while|'
|
| 261 |
+
r'xmodemrecv|'
|
| 262 |
+
r'xmodemsend|'
|
| 263 |
+
r'yesnobox|'
|
| 264 |
+
r'ymodemrecv|'
|
| 265 |
+
r'ymodemsend|'
|
| 266 |
+
r'zmodemrecv|'
|
| 267 |
+
r'zmodemsend'
|
| 268 |
+
r')\b',
|
| 269 |
+
Keyword,
|
| 270 |
+
),
|
| 271 |
+
(r'(?i)(call|goto)([ \t]+)([a-z0-9_]+)',
|
| 272 |
+
bygroups(Keyword, Text.Whitespace, Name.Label)),
|
| 273 |
+
],
|
| 274 |
+
'builtin-variables': [
|
| 275 |
+
(
|
| 276 |
+
r'(?i)('
|
| 277 |
+
r'groupmatchstr1|'
|
| 278 |
+
r'groupmatchstr2|'
|
| 279 |
+
r'groupmatchstr3|'
|
| 280 |
+
r'groupmatchstr4|'
|
| 281 |
+
r'groupmatchstr5|'
|
| 282 |
+
r'groupmatchstr6|'
|
| 283 |
+
r'groupmatchstr7|'
|
| 284 |
+
r'groupmatchstr8|'
|
| 285 |
+
r'groupmatchstr9|'
|
| 286 |
+
r'inputstr|'
|
| 287 |
+
r'matchstr|'
|
| 288 |
+
r'mtimeout|'
|
| 289 |
+
r'param1|'
|
| 290 |
+
r'param2|'
|
| 291 |
+
r'param3|'
|
| 292 |
+
r'param4|'
|
| 293 |
+
r'param5|'
|
| 294 |
+
r'param6|'
|
| 295 |
+
r'param7|'
|
| 296 |
+
r'param8|'
|
| 297 |
+
r'param9|'
|
| 298 |
+
r'paramcnt|'
|
| 299 |
+
r'params|'
|
| 300 |
+
r'result|'
|
| 301 |
+
r'timeout'
|
| 302 |
+
r')\b',
|
| 303 |
+
Name.Builtin
|
| 304 |
+
),
|
| 305 |
+
],
|
| 306 |
+
'user-variables': [
|
| 307 |
+
(r'(?i)[a-z_][a-z0-9_]*', Name.Variable),
|
| 308 |
+
],
|
| 309 |
+
'numeric-literals': [
|
| 310 |
+
(r'(-?)([0-9]+)', bygroups(Operator, Number.Integer)),
|
| 311 |
+
(r'(?i)\$[0-9a-f]+', Number.Hex),
|
| 312 |
+
],
|
| 313 |
+
'string-literals': [
|
| 314 |
+
(r'(?i)#(?:[0-9]+|\$[0-9a-f]+)', String.Char),
|
| 315 |
+
(r"'[^'\n]*'", String.Single),
|
| 316 |
+
(r'"[^"\n]*"', String.Double),
|
| 317 |
+
# Opening quotes without a closing quote on the same line are errors.
|
| 318 |
+
(r"('[^']*)(\n)", bygroups(Error, Text.Whitespace)),
|
| 319 |
+
(r'("[^"]*)(\n)', bygroups(Error, Text.Whitespace)),
|
| 320 |
+
],
|
| 321 |
+
'operators': [
|
| 322 |
+
(r'and|not|or|xor', Operator.Word),
|
| 323 |
+
(r'[!%&*+<=>^~\|\/-]+', Operator),
|
| 324 |
+
(r'[()]', String.Symbol),
|
| 325 |
+
],
|
| 326 |
+
'all-whitespace': [
|
| 327 |
+
(r'\s+', Text.Whitespace),
|
| 328 |
+
],
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
# Turtle and Tera Term macro files share the same file extension
|
| 332 |
+
# but each has a recognizable and distinct syntax.
|
| 333 |
+
def analyse_text(text):
|
| 334 |
+
if re.search(TeraTermLexer.tokens['commands'][0][0], text):
|
| 335 |
+
return 0.01
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/text.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.text
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for non-source code file types.
|
| 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.configs import ApacheConfLexer, NginxConfLexer, \
|
| 13 |
+
SquidConfLexer, LighttpdConfLexer, IniLexer, RegeditLexer, PropertiesLexer, \
|
| 14 |
+
UnixConfigLexer
|
| 15 |
+
from pygments.lexers.console import PyPyLogLexer
|
| 16 |
+
from pygments.lexers.textedit import VimLexer
|
| 17 |
+
from pygments.lexers.markup import BBCodeLexer, MoinWikiLexer, RstLexer, \
|
| 18 |
+
TexLexer, GroffLexer
|
| 19 |
+
from pygments.lexers.installers import DebianControlLexer, DebianSourcesLexer, SourcesListLexer
|
| 20 |
+
from pygments.lexers.make import MakefileLexer, BaseMakefileLexer, CMakeLexer
|
| 21 |
+
from pygments.lexers.haxe import HxmlLexer
|
| 22 |
+
from pygments.lexers.sgf import SmartGameFormatLexer
|
| 23 |
+
from pygments.lexers.diff import DiffLexer, DarcsPatchLexer
|
| 24 |
+
from pygments.lexers.data import YamlLexer
|
| 25 |
+
from pygments.lexers.textfmts import IrcLogsLexer, GettextLexer, HttpLexer
|
| 26 |
+
|
| 27 |
+
__all__ = []
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/textedit.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.textedit
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for languages related to text processing.
|
| 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 |
+
from bisect import bisect
|
| 13 |
+
|
| 14 |
+
from pygments.lexer import RegexLexer, bygroups, default, include, this, using
|
| 15 |
+
from pygments.lexers.python import PythonLexer
|
| 16 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 17 |
+
Punctuation, String, Text, Whitespace
|
| 18 |
+
|
| 19 |
+
__all__ = ['AwkLexer', 'SedLexer', 'VimLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class AwkLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For Awk scripts.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Awk'
|
| 28 |
+
aliases = ['awk', 'gawk', 'mawk', 'nawk']
|
| 29 |
+
filenames = ['*.awk']
|
| 30 |
+
mimetypes = ['application/x-awk']
|
| 31 |
+
url = 'https://en.wikipedia.org/wiki/AWK'
|
| 32 |
+
version_added = '1.5'
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'commentsandwhitespace': [
|
| 36 |
+
(r'\s+', Text),
|
| 37 |
+
(r'#.*$', Comment.Single)
|
| 38 |
+
],
|
| 39 |
+
'slashstartsregex': [
|
| 40 |
+
include('commentsandwhitespace'),
|
| 41 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 42 |
+
r'\B', String.Regex, '#pop'),
|
| 43 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 44 |
+
default('#pop')
|
| 45 |
+
],
|
| 46 |
+
'badregex': [
|
| 47 |
+
(r'\n', Text, '#pop')
|
| 48 |
+
],
|
| 49 |
+
'root': [
|
| 50 |
+
(r'^(?=\s|/)', Text, 'slashstartsregex'),
|
| 51 |
+
include('commentsandwhitespace'),
|
| 52 |
+
(r'\+\+|--|\|\||&&|in\b|\$|!?~|\?|:|'
|
| 53 |
+
r'(\*\*|[-<>+*%\^/!=|])=?', Operator, 'slashstartsregex'),
|
| 54 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 55 |
+
(r'[})\].]', Punctuation),
|
| 56 |
+
(r'(break|continue|do|while|exit|for|if|else|'
|
| 57 |
+
r'return)\b', Keyword, 'slashstartsregex'),
|
| 58 |
+
(r'function\b', Keyword.Declaration, 'slashstartsregex'),
|
| 59 |
+
(r'(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|'
|
| 60 |
+
r'length|match|split|sprintf|sub|substr|tolower|toupper|close|'
|
| 61 |
+
r'fflush|getline|next|nextfile|print|printf|strftime|systime|'
|
| 62 |
+
r'delete|system)\b', Keyword.Reserved),
|
| 63 |
+
(r'(ARGC|ARGIND|ARGV|BEGIN|CONVFMT|ENVIRON|END|ERRNO|FIELDWIDTHS|'
|
| 64 |
+
r'FILENAME|FNR|FS|IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|'
|
| 65 |
+
r'RSTART|RT|SUBSEP)\b', Name.Builtin),
|
| 66 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 67 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 68 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 69 |
+
(r'[0-9]+', Number.Integer),
|
| 70 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 71 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 72 |
+
]
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class SedLexer(RegexLexer):
|
| 77 |
+
"""
|
| 78 |
+
Lexer for Sed script files.
|
| 79 |
+
"""
|
| 80 |
+
name = 'Sed'
|
| 81 |
+
aliases = ['sed', 'gsed', 'ssed']
|
| 82 |
+
filenames = ['*.sed', '*.[gs]sed']
|
| 83 |
+
mimetypes = ['text/x-sed']
|
| 84 |
+
url = 'https://en.wikipedia.org/wiki/Sed'
|
| 85 |
+
version_added = ''
|
| 86 |
+
flags = re.MULTILINE
|
| 87 |
+
|
| 88 |
+
# Match the contents within delimiters such as /<contents>/
|
| 89 |
+
_inside_delims = r'((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)'
|
| 90 |
+
|
| 91 |
+
tokens = {
|
| 92 |
+
'root': [
|
| 93 |
+
(r'\s+', Whitespace),
|
| 94 |
+
(r'#.*$', Comment.Single),
|
| 95 |
+
(r'[0-9]+', Number.Integer),
|
| 96 |
+
(r'\$', Operator),
|
| 97 |
+
(r'[{};,!]', Punctuation),
|
| 98 |
+
(r'[dDFgGhHlnNpPqQxz=]', Keyword),
|
| 99 |
+
(r'([berRtTvwW:])([^;\n]*)', bygroups(Keyword, String.Single)),
|
| 100 |
+
(r'([aci])((?:.*?\\\n)*(?:.*?[^\\]$))', bygroups(Keyword, String.Double)),
|
| 101 |
+
(r'([qQ])([0-9]*)', bygroups(Keyword, Number.Integer)),
|
| 102 |
+
(r'(/)' + _inside_delims + r'(/)', bygroups(Punctuation, String.Regex, Punctuation)),
|
| 103 |
+
(r'(\\(.))' + _inside_delims + r'(\2)',
|
| 104 |
+
bygroups(Punctuation, None, String.Regex, Punctuation)),
|
| 105 |
+
(r'(y)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)',
|
| 106 |
+
bygroups(Keyword, Punctuation, String.Single, Punctuation, String.Single, Punctuation)),
|
| 107 |
+
(r'(s)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)((?:[gpeIiMm]|[0-9])*)',
|
| 108 |
+
bygroups(Keyword, Punctuation, String.Regex, Punctuation, String.Single, Punctuation,
|
| 109 |
+
Keyword))
|
| 110 |
+
]
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
class VimLexer(RegexLexer):
|
| 114 |
+
"""
|
| 115 |
+
Lexer for VimL script files.
|
| 116 |
+
"""
|
| 117 |
+
name = 'VimL'
|
| 118 |
+
aliases = ['vim']
|
| 119 |
+
filenames = ['*.vim', '.vimrc', '.exrc', '.gvimrc',
|
| 120 |
+
'_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc']
|
| 121 |
+
mimetypes = ['text/x-vim']
|
| 122 |
+
url = 'https://www.vim.org'
|
| 123 |
+
version_added = '0.8'
|
| 124 |
+
|
| 125 |
+
flags = re.MULTILINE
|
| 126 |
+
|
| 127 |
+
_python = r'py(?:t(?:h(?:o(?:n)?)?)?)?'
|
| 128 |
+
|
| 129 |
+
tokens = {
|
| 130 |
+
'root': [
|
| 131 |
+
(r'^([ \t:]*)(' + _python + r')([ \t]*)(<<)([ \t]*)(.*)((?:\n|.)*)(\6)',
|
| 132 |
+
bygroups(using(this), Keyword, Text, Operator, Text, Text,
|
| 133 |
+
using(PythonLexer), Text)),
|
| 134 |
+
(r'^([ \t:]*)(' + _python + r')([ \t])(.*)',
|
| 135 |
+
bygroups(using(this), Keyword, Text, using(PythonLexer))),
|
| 136 |
+
|
| 137 |
+
(r'^\s*".*', Comment),
|
| 138 |
+
|
| 139 |
+
(r'[ \t]+', Text),
|
| 140 |
+
# TODO: regexes can have other delims
|
| 141 |
+
(r'/[^/\\\n]*(?:\\[\s\S][^/\\\n]*)*/', String.Regex),
|
| 142 |
+
(r'"[^"\\\n]*(?:\\[\s\S][^"\\\n]*)*"', String.Double),
|
| 143 |
+
(r"'[^\n']*(?:''[^\n']*)*'", String.Single),
|
| 144 |
+
|
| 145 |
+
# Who decided that doublequote was a good comment character??
|
| 146 |
+
(r'(?<=\s)"[^\-:.%#=*].*', Comment),
|
| 147 |
+
(r'-?\d+', Number),
|
| 148 |
+
(r'#[0-9a-f]{6}', Number.Hex),
|
| 149 |
+
(r'^:', Punctuation),
|
| 150 |
+
(r'[()<>+=!|,~-]', Punctuation), # Inexact list. Looks decent.
|
| 151 |
+
(r'\b(let|if|else|endif|elseif|fun|function|endfunction)\b',
|
| 152 |
+
Keyword),
|
| 153 |
+
(r'\b(NONE|bold|italic|underline|dark|light)\b', Name.Builtin),
|
| 154 |
+
(r'\b\w+\b', Name.Other), # These are postprocessed below
|
| 155 |
+
(r'.', Text),
|
| 156 |
+
],
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
def __init__(self, **options):
|
| 160 |
+
from pygments.lexers._vim_builtins import auto, command, option
|
| 161 |
+
self._cmd = command
|
| 162 |
+
self._opt = option
|
| 163 |
+
self._aut = auto
|
| 164 |
+
|
| 165 |
+
RegexLexer.__init__(self, **options)
|
| 166 |
+
|
| 167 |
+
def is_in(self, w, mapping):
|
| 168 |
+
r"""
|
| 169 |
+
It's kind of difficult to decide if something might be a keyword
|
| 170 |
+
in VimL because it allows you to abbreviate them. In fact,
|
| 171 |
+
'ab[breviate]' is a good example. :ab, :abbre, or :abbreviate are
|
| 172 |
+
valid ways to call it so rather than making really awful regexps
|
| 173 |
+
like::
|
| 174 |
+
|
| 175 |
+
\bab(?:b(?:r(?:e(?:v(?:i(?:a(?:t(?:e)?)?)?)?)?)?)?)?\b
|
| 176 |
+
|
| 177 |
+
we match `\b\w+\b` and then call is_in() on those tokens. See
|
| 178 |
+
`scripts/get_vimkw.py` for how the lists are extracted.
|
| 179 |
+
"""
|
| 180 |
+
p = bisect(mapping, (w,))
|
| 181 |
+
if p > 0:
|
| 182 |
+
if mapping[p-1][0] == w[:len(mapping[p-1][0])] and \
|
| 183 |
+
mapping[p-1][1][:len(w)] == w:
|
| 184 |
+
return True
|
| 185 |
+
if p < len(mapping):
|
| 186 |
+
return mapping[p][0] == w[:len(mapping[p][0])] and \
|
| 187 |
+
mapping[p][1][:len(w)] == w
|
| 188 |
+
return False
|
| 189 |
+
|
| 190 |
+
def get_tokens_unprocessed(self, text):
|
| 191 |
+
# TODO: builtins are only subsequent tokens on lines
|
| 192 |
+
# and 'keywords' only happen at the beginning except
|
| 193 |
+
# for :au ones
|
| 194 |
+
for index, token, value in \
|
| 195 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 196 |
+
if token is Name.Other:
|
| 197 |
+
if self.is_in(value, self._cmd):
|
| 198 |
+
yield index, Keyword, value
|
| 199 |
+
elif self.is_in(value, self._opt) or \
|
| 200 |
+
self.is_in(value, self._aut):
|
| 201 |
+
yield index, Name.Builtin, value
|
| 202 |
+
else:
|
| 203 |
+
yield index, Text, value
|
| 204 |
+
else:
|
| 205 |
+
yield index, token, value
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/theorem.py
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.theorem
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for theorem-proving languages.
|
| 6 |
+
|
| 7 |
+
See also :mod:`pygments.lexers.lean`
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, default, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Generic, Whitespace
|
| 16 |
+
# compatibility import
|
| 17 |
+
from pygments.lexers.lean import LeanLexer # noqa: F401
|
| 18 |
+
|
| 19 |
+
__all__ = ['RocqLexer', 'IsabelleLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class RocqLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For the Rocq Prover.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Rocq Prover'
|
| 28 |
+
url = 'https://rocq-prover.org/'
|
| 29 |
+
aliases = ['coq', 'rocq', 'rocq-prover']
|
| 30 |
+
filenames = ['*.v']
|
| 31 |
+
mimetypes = ['text/x-coq', 'text/x-rocq']
|
| 32 |
+
version_added = '1.5'
|
| 33 |
+
|
| 34 |
+
flags = 0 # no re.MULTILINE
|
| 35 |
+
|
| 36 |
+
keywords1 = (
|
| 37 |
+
# Vernacular commands
|
| 38 |
+
'Section', 'Module', 'End', 'Require', 'Import', 'Export', 'Include', 'Variable',
|
| 39 |
+
'Variables', 'Parameter', 'Parameters', 'Axiom', 'Axioms', 'Hypothesis',
|
| 40 |
+
'Hypotheses', 'Notation', 'Local', 'Tactic', 'Reserved', 'Scope',
|
| 41 |
+
'Open', 'Close', 'Bind', 'Declare', 'Delimit', 'Definition', 'Example', 'Let',
|
| 42 |
+
'Ltac', 'Ltac2', 'Fixpoint', 'CoFixpoint', 'Morphism', 'Relation', 'Implicit',
|
| 43 |
+
'Arguments', 'Types', 'Contextual', 'Strict', 'Prenex',
|
| 44 |
+
'Implicits', 'Inductive', 'CoInductive', 'Record', 'Structure',
|
| 45 |
+
'Variant', 'Canonical', 'Coercion', 'Theorem', 'Lemma', 'Fact',
|
| 46 |
+
'Remark', 'Corollary', 'Proposition', 'Property', 'Goal',
|
| 47 |
+
'Proof', 'Restart', 'Save', 'Qed', 'Defined', 'Abort', 'Admitted',
|
| 48 |
+
'Hint', 'Resolve', 'Rewrite', 'View', 'Search', 'Compute', 'Eval',
|
| 49 |
+
'Show', 'Print', 'Printing', 'All', 'Graph', 'Projections', 'inside',
|
| 50 |
+
'outside', 'Check', 'Global', 'Instance', 'Class', 'Existing',
|
| 51 |
+
'Universe', 'Polymorphic', 'Monomorphic', 'Context', 'Scheme', 'From',
|
| 52 |
+
'Undo', 'Fail', 'Function', 'Program', 'Elpi', 'Extract', 'Opaque',
|
| 53 |
+
'Transparent', 'Unshelve', 'Next Obligation',
|
| 54 |
+
)
|
| 55 |
+
keywords2 = (
|
| 56 |
+
# Gallina
|
| 57 |
+
'forall', 'exists', 'exists2', 'fun', 'fix', 'cofix', 'struct',
|
| 58 |
+
'match', 'end', 'in', 'return', 'let', 'if', 'is', 'then', 'else',
|
| 59 |
+
'for', 'of', 'nosimpl', 'with', 'as',
|
| 60 |
+
)
|
| 61 |
+
keywords3 = (
|
| 62 |
+
# Sorts
|
| 63 |
+
'Type', 'Prop', 'SProp', 'Set',
|
| 64 |
+
)
|
| 65 |
+
keywords4 = (
|
| 66 |
+
# Tactics
|
| 67 |
+
'pose', 'set', 'move', 'case', 'elim', 'apply', 'clear', 'hnf', 'intro',
|
| 68 |
+
'intros', 'generalize', 'rename', 'pattern', 'after', 'destruct',
|
| 69 |
+
'induction', 'using', 'refine', 'inversion', 'injection', 'rewrite',
|
| 70 |
+
'congr', 'unlock', 'compute', 'ring', 'field', 'replace', 'fold',
|
| 71 |
+
'unfold', 'change', 'cutrewrite', 'simpl', 'have', 'suff', 'wlog',
|
| 72 |
+
'suffices', 'without', 'loss', 'nat_norm', 'assert', 'cut', 'trivial',
|
| 73 |
+
'revert', 'bool_congr', 'nat_congr', 'symmetry', 'transitivity', 'auto',
|
| 74 |
+
'split', 'left', 'right', 'autorewrite', 'tauto', 'setoid_rewrite',
|
| 75 |
+
'intuition', 'eauto', 'eapply', 'econstructor', 'etransitivity',
|
| 76 |
+
'constructor', 'erewrite', 'red', 'cbv', 'lazy', 'vm_compute',
|
| 77 |
+
'native_compute', 'subst',
|
| 78 |
+
)
|
| 79 |
+
keywords5 = (
|
| 80 |
+
# Terminators
|
| 81 |
+
'by', 'now', 'done', 'exact', 'reflexivity',
|
| 82 |
+
'tauto', 'romega', 'omega', 'lia', 'nia', 'lra', 'nra', 'psatz',
|
| 83 |
+
'assumption', 'solve', 'contradiction', 'discriminate',
|
| 84 |
+
'congruence', 'admit'
|
| 85 |
+
)
|
| 86 |
+
keywords6 = (
|
| 87 |
+
# Control
|
| 88 |
+
'do', 'last', 'first', 'try', 'idtac', 'repeat',
|
| 89 |
+
)
|
| 90 |
+
# 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
|
| 91 |
+
# 'downto', 'else', 'end', 'exception', 'external', 'false',
|
| 92 |
+
# 'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
|
| 93 |
+
# 'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
|
| 94 |
+
# 'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
|
| 95 |
+
# 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
|
| 96 |
+
# 'type', 'val', 'virtual', 'when', 'while', 'with'
|
| 97 |
+
keyopts = (
|
| 98 |
+
'!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-', r'-\.',
|
| 99 |
+
'->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-',
|
| 100 |
+
'<->', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>',
|
| 101 |
+
r'\[\|', ']', '_', '`', r'\{', r'\{<', r'lp:\{\{', r'\|', r'\|]', r'\}', '~', '=>',
|
| 102 |
+
r'/\\', r'\\/', r'\{\|', r'\|\}',
|
| 103 |
+
# 'Π', 'Σ', # Not defined in the standard library
|
| 104 |
+
'λ', '¬', '∧', '∨', '∀', '∃', '→', '↔', '≠', '≤', '≥',
|
| 105 |
+
)
|
| 106 |
+
operators = r'[!$%&*+\./:<=>?@^|~-]'
|
| 107 |
+
prefix_syms = r'[!?~]'
|
| 108 |
+
infix_syms = r'[=<>@^|&+\*/$%-]'
|
| 109 |
+
|
| 110 |
+
tokens = {
|
| 111 |
+
'root': [
|
| 112 |
+
(r'\s+', Text),
|
| 113 |
+
(r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
|
| 114 |
+
(r'\(\*', Comment, 'comment'),
|
| 115 |
+
(r'\b(?:[^\W\d][\w\']*\.)+[^\W\d][\w\']*\b', Name),
|
| 116 |
+
(r'\bEquations\b\??', Keyword.Namespace),
|
| 117 |
+
(r'\b(Elpi)(\s+)(Program|Query|Accumulate|Command|Typecheck|Db|Export|Tactic)?\b', bygroups(Keyword.Namespace,Text,Keyword.Namespace)),
|
| 118 |
+
# Very weak heuristic to distinguish the Set vernacular from the Set sort
|
| 119 |
+
(r'\bUnset\b|\bSet(?=[ \t]+[A-Z][a-z][^\n]*?\.)', Keyword.Namespace, 'set-options'),
|
| 120 |
+
(r'\b(?:String|Number)\s+Notation', Keyword.Namespace, 'sn-notation'),
|
| 121 |
+
(words(keywords1, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
|
| 122 |
+
(words(keywords2, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 123 |
+
(words(keywords3, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 124 |
+
(words(keywords4, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 125 |
+
(words(keywords5, prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
|
| 126 |
+
(words(keywords6, prefix=r'\b', suffix=r'\b'), Keyword.Reserved),
|
| 127 |
+
# (r'\b([A-Z][\w\']*)(\.)', Name.Namespace, 'dotted'),
|
| 128 |
+
(r'\b([A-Z][\w\']*)', Name),
|
| 129 |
+
(r'({})'.format('|'.join(keyopts[::-1])), Operator),
|
| 130 |
+
(rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
|
| 131 |
+
|
| 132 |
+
(r"[^\W\d][\w']*", Name),
|
| 133 |
+
|
| 134 |
+
(r'\d[\d_]*', Number.Integer),
|
| 135 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 136 |
+
(r'0[oO][0-7][0-7_]*', Number.Oct),
|
| 137 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 138 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
|
| 139 |
+
|
| 140 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char),
|
| 141 |
+
|
| 142 |
+
(r"'.'", String.Char),
|
| 143 |
+
(r"'", Keyword), # a stray quote is another syntax element
|
| 144 |
+
|
| 145 |
+
(r'"', String.Double, 'string'),
|
| 146 |
+
|
| 147 |
+
(r'[~?][a-z][\w\']*:', Name),
|
| 148 |
+
(r'\S', Name.Builtin.Pseudo),
|
| 149 |
+
],
|
| 150 |
+
'set-options': [
|
| 151 |
+
(r'\s+', Text),
|
| 152 |
+
(r'[A-Z]\w*', Keyword.Namespace),
|
| 153 |
+
(r'"', String.Double, 'string'),
|
| 154 |
+
(r'\d+', Number.Integer),
|
| 155 |
+
(r'\.', Punctuation, '#pop'),
|
| 156 |
+
],
|
| 157 |
+
'sn-notation': [
|
| 158 |
+
(r'\s+', Text),
|
| 159 |
+
# Extra keywords to highlight only in this scope
|
| 160 |
+
(r'\b(?:via|mapping|abstract|warning|after)\b', Keyword),
|
| 161 |
+
(r'=>|[()\[\]:,]', Operator),
|
| 162 |
+
(r'\b[^\W\d][\w\']*(?:\.[^\W\d][\w\']*)*\b', Name),
|
| 163 |
+
(r'\d[\d_]*', Number.Integer),
|
| 164 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 165 |
+
(r'\(\*', Comment, 'comment'),
|
| 166 |
+
(r'\.', Punctuation, '#pop'),
|
| 167 |
+
],
|
| 168 |
+
'comment': [
|
| 169 |
+
# Consume comments like ***** as one token
|
| 170 |
+
(r'([^(*)]+|\*+(?!\)))+', Comment),
|
| 171 |
+
(r'\(\*', Comment, '#push'),
|
| 172 |
+
(r'\*\)', Comment, '#pop'),
|
| 173 |
+
(r'[(*)]', Comment),
|
| 174 |
+
],
|
| 175 |
+
'string': [
|
| 176 |
+
(r'[^"]+', String.Double),
|
| 177 |
+
(r'""', String.Double),
|
| 178 |
+
(r'"', String.Double, '#pop'),
|
| 179 |
+
],
|
| 180 |
+
'dotted': [
|
| 181 |
+
(r'\s+', Text),
|
| 182 |
+
(r'\.', Punctuation),
|
| 183 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
|
| 184 |
+
(r'[A-Z][\w\']*', Name.Class, '#pop'),
|
| 185 |
+
(r'[a-z][a-z0-9_\']*', Name, '#pop'),
|
| 186 |
+
default('#pop')
|
| 187 |
+
],
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
def analyse_text(text):
|
| 191 |
+
if 'Qed' in text and 'Proof' in text:
|
| 192 |
+
return 1
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
class IsabelleLexer(RegexLexer):
|
| 196 |
+
"""
|
| 197 |
+
For the Isabelle proof assistant.
|
| 198 |
+
"""
|
| 199 |
+
|
| 200 |
+
name = 'Isabelle'
|
| 201 |
+
url = 'https://isabelle.in.tum.de/'
|
| 202 |
+
aliases = ['isabelle']
|
| 203 |
+
filenames = ['*.thy']
|
| 204 |
+
mimetypes = ['text/x-isabelle']
|
| 205 |
+
version_added = '2.0'
|
| 206 |
+
|
| 207 |
+
keyword_minor = (
|
| 208 |
+
'and', 'assumes', 'attach', 'avoids', 'binder', 'checking',
|
| 209 |
+
'class_instance', 'class_relation', 'code_module', 'congs',
|
| 210 |
+
'constant', 'constrains', 'datatypes', 'defines', 'file', 'fixes',
|
| 211 |
+
'for', 'functions', 'hints', 'identifier', 'if', 'imports', 'in',
|
| 212 |
+
'includes', 'infix', 'infixl', 'infixr', 'is', 'keywords', 'lazy',
|
| 213 |
+
'module_name', 'monos', 'morphisms', 'no_discs_sels', 'notes',
|
| 214 |
+
'obtains', 'open', 'output', 'overloaded', 'parametric', 'permissive',
|
| 215 |
+
'pervasive', 'rep_compat', 'shows', 'structure', 'type_class',
|
| 216 |
+
'type_constructor', 'unchecked', 'unsafe', 'where',
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
keyword_diag = (
|
| 220 |
+
'ML_command', 'ML_val', 'class_deps', 'code_deps', 'code_thms',
|
| 221 |
+
'display_drafts', 'find_consts', 'find_theorems', 'find_unused_assms',
|
| 222 |
+
'full_prf', 'help', 'locale_deps', 'nitpick', 'pr', 'prf',
|
| 223 |
+
'print_abbrevs', 'print_antiquotations', 'print_attributes',
|
| 224 |
+
'print_binds', 'print_bnfs', 'print_bundles',
|
| 225 |
+
'print_case_translations', 'print_cases', 'print_claset',
|
| 226 |
+
'print_classes', 'print_codeproc', 'print_codesetup',
|
| 227 |
+
'print_coercions', 'print_commands', 'print_context',
|
| 228 |
+
'print_defn_rules', 'print_dependencies', 'print_facts',
|
| 229 |
+
'print_induct_rules', 'print_inductives', 'print_interps',
|
| 230 |
+
'print_locale', 'print_locales', 'print_methods', 'print_options',
|
| 231 |
+
'print_orders', 'print_quot_maps', 'print_quotconsts',
|
| 232 |
+
'print_quotients', 'print_quotientsQ3', 'print_quotmapsQ3',
|
| 233 |
+
'print_rules', 'print_simpset', 'print_state', 'print_statement',
|
| 234 |
+
'print_syntax', 'print_theorems', 'print_theory', 'print_trans_rules',
|
| 235 |
+
'prop', 'pwd', 'quickcheck', 'refute', 'sledgehammer', 'smt_status',
|
| 236 |
+
'solve_direct', 'spark_status', 'term', 'thm', 'thm_deps', 'thy_deps',
|
| 237 |
+
'try', 'try0', 'typ', 'unused_thms', 'value', 'values', 'welcome',
|
| 238 |
+
'print_ML_antiquotations', 'print_term_bindings', 'values_prolog',
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
keyword_thy = ('theory', 'begin', 'end')
|
| 242 |
+
|
| 243 |
+
keyword_section = ('header', 'chapter')
|
| 244 |
+
|
| 245 |
+
keyword_subsection = (
|
| 246 |
+
'section', 'subsection', 'subsubsection', 'sect', 'subsect',
|
| 247 |
+
'subsubsect',
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
keyword_theory_decl = (
|
| 251 |
+
'ML', 'ML_file', 'abbreviation', 'adhoc_overloading', 'arities',
|
| 252 |
+
'atom_decl', 'attribute_setup', 'axiomatization', 'bundle',
|
| 253 |
+
'case_of_simps', 'class', 'classes', 'classrel', 'codatatype',
|
| 254 |
+
'code_abort', 'code_class', 'code_const', 'code_datatype',
|
| 255 |
+
'code_identifier', 'code_include', 'code_instance', 'code_modulename',
|
| 256 |
+
'code_monad', 'code_printing', 'code_reflect', 'code_reserved',
|
| 257 |
+
'code_type', 'coinductive', 'coinductive_set', 'consts', 'context',
|
| 258 |
+
'datatype', 'datatype_new', 'datatype_new_compat', 'declaration',
|
| 259 |
+
'declare', 'default_sort', 'defer_recdef', 'definition', 'defs',
|
| 260 |
+
'domain', 'domain_isomorphism', 'domaindef', 'equivariance',
|
| 261 |
+
'export_code', 'extract', 'extract_type', 'fixrec', 'fun',
|
| 262 |
+
'fun_cases', 'hide_class', 'hide_const', 'hide_fact', 'hide_type',
|
| 263 |
+
'import_const_map', 'import_file', 'import_tptp', 'import_type_map',
|
| 264 |
+
'inductive', 'inductive_set', 'instantiation', 'judgment', 'lemmas',
|
| 265 |
+
'lifting_forget', 'lifting_update', 'local_setup', 'locale',
|
| 266 |
+
'method_setup', 'nitpick_params', 'no_adhoc_overloading',
|
| 267 |
+
'no_notation', 'no_syntax', 'no_translations', 'no_type_notation',
|
| 268 |
+
'nominal_datatype', 'nonterminal', 'notation', 'notepad', 'oracle',
|
| 269 |
+
'overloading', 'parse_ast_translation', 'parse_translation',
|
| 270 |
+
'partial_function', 'primcorec', 'primrec', 'primrec_new',
|
| 271 |
+
'print_ast_translation', 'print_translation', 'quickcheck_generator',
|
| 272 |
+
'quickcheck_params', 'realizability', 'realizers', 'recdef', 'record',
|
| 273 |
+
'refute_params', 'setup', 'setup_lifting', 'simproc_setup',
|
| 274 |
+
'simps_of_case', 'sledgehammer_params', 'spark_end', 'spark_open',
|
| 275 |
+
'spark_open_siv', 'spark_open_vcg', 'spark_proof_functions',
|
| 276 |
+
'spark_types', 'statespace', 'syntax', 'syntax_declaration', 'text',
|
| 277 |
+
'text_raw', 'theorems', 'translations', 'type_notation',
|
| 278 |
+
'type_synonym', 'typed_print_translation', 'typedecl', 'hoarestate',
|
| 279 |
+
'install_C_file', 'install_C_types', 'wpc_setup', 'c_defs', 'c_types',
|
| 280 |
+
'memsafe', 'SML_export', 'SML_file', 'SML_import', 'approximate',
|
| 281 |
+
'bnf_axiomatization', 'cartouche', 'datatype_compat',
|
| 282 |
+
'free_constructors', 'functor', 'nominal_function',
|
| 283 |
+
'nominal_termination', 'permanent_interpretation',
|
| 284 |
+
'binds', 'defining', 'smt2_status', 'term_cartouche',
|
| 285 |
+
'boogie_file', 'text_cartouche',
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
keyword_theory_script = ('inductive_cases', 'inductive_simps')
|
| 289 |
+
|
| 290 |
+
keyword_theory_goal = (
|
| 291 |
+
'ax_specification', 'bnf', 'code_pred', 'corollary', 'cpodef',
|
| 292 |
+
'crunch', 'crunch_ignore',
|
| 293 |
+
'enriched_type', 'function', 'instance', 'interpretation', 'lemma',
|
| 294 |
+
'lift_definition', 'nominal_inductive', 'nominal_inductive2',
|
| 295 |
+
'nominal_primrec', 'pcpodef', 'primcorecursive',
|
| 296 |
+
'quotient_definition', 'quotient_type', 'recdef_tc', 'rep_datatype',
|
| 297 |
+
'schematic_corollary', 'schematic_lemma', 'schematic_theorem',
|
| 298 |
+
'spark_vc', 'specification', 'subclass', 'sublocale', 'termination',
|
| 299 |
+
'theorem', 'typedef', 'wrap_free_constructors',
|
| 300 |
+
)
|
| 301 |
+
|
| 302 |
+
keyword_qed = ('by', 'done', 'qed')
|
| 303 |
+
keyword_abandon_proof = ('sorry', 'oops')
|
| 304 |
+
|
| 305 |
+
keyword_proof_goal = ('have', 'hence', 'interpret')
|
| 306 |
+
|
| 307 |
+
keyword_proof_block = ('next', 'proof')
|
| 308 |
+
|
| 309 |
+
keyword_proof_chain = (
|
| 310 |
+
'finally', 'from', 'then', 'ultimately', 'with',
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
keyword_proof_decl = (
|
| 314 |
+
'ML_prf', 'also', 'include', 'including', 'let', 'moreover', 'note',
|
| 315 |
+
'txt', 'txt_raw', 'unfolding', 'using', 'write',
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
+
keyword_proof_asm = ('assume', 'case', 'def', 'fix', 'presume')
|
| 319 |
+
|
| 320 |
+
keyword_proof_asm_goal = ('guess', 'obtain', 'show', 'thus')
|
| 321 |
+
|
| 322 |
+
keyword_proof_script = (
|
| 323 |
+
'apply', 'apply_end', 'apply_trace', 'back', 'defer', 'prefer',
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
operators = (
|
| 327 |
+
'::', ':', '(', ')', '[', ']', '_', '=', ',', '|',
|
| 328 |
+
'+', '-', '!', '?',
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
proof_operators = ('{', '}', '.', '..')
|
| 332 |
+
|
| 333 |
+
tokens = {
|
| 334 |
+
'root': [
|
| 335 |
+
(r'\s+', Whitespace),
|
| 336 |
+
(r'\(\*', Comment, 'comment'),
|
| 337 |
+
(r'\\<open>', String.Symbol, 'cartouche'),
|
| 338 |
+
(r'\{\*|‹', String, 'cartouche'),
|
| 339 |
+
|
| 340 |
+
(words(operators), Operator),
|
| 341 |
+
(words(proof_operators), Operator.Word),
|
| 342 |
+
|
| 343 |
+
(words(keyword_minor, prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
|
| 344 |
+
|
| 345 |
+
(words(keyword_diag, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 346 |
+
|
| 347 |
+
(words(keyword_thy, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 348 |
+
(words(keyword_theory_decl, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 349 |
+
|
| 350 |
+
(words(keyword_section, prefix=r'\b', suffix=r'\b'), Generic.Heading),
|
| 351 |
+
(words(keyword_subsection, prefix=r'\b', suffix=r'\b'), Generic.Subheading),
|
| 352 |
+
|
| 353 |
+
(words(keyword_theory_goal, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
|
| 354 |
+
(words(keyword_theory_script, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
|
| 355 |
+
|
| 356 |
+
(words(keyword_abandon_proof, prefix=r'\b', suffix=r'\b'), Generic.Error),
|
| 357 |
+
|
| 358 |
+
(words(keyword_qed, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 359 |
+
(words(keyword_proof_goal, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 360 |
+
(words(keyword_proof_block, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 361 |
+
(words(keyword_proof_decl, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 362 |
+
|
| 363 |
+
(words(keyword_proof_chain, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 364 |
+
(words(keyword_proof_asm, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 365 |
+
(words(keyword_proof_asm_goal, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 366 |
+
|
| 367 |
+
(words(keyword_proof_script, prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
|
| 368 |
+
|
| 369 |
+
(r'\\<(\w|\^)*>', Text.Symbol),
|
| 370 |
+
|
| 371 |
+
(r"'[^\W\d][.\w']*", Name.Type),
|
| 372 |
+
|
| 373 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 374 |
+
(r'0[oO][0-7][0-7_]*', Number.Oct),
|
| 375 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 376 |
+
|
| 377 |
+
(r'"', String, 'string'),
|
| 378 |
+
(r'`', String.Other, 'fact'),
|
| 379 |
+
(r'[^\s:|\[\]\-()=,+!?{}._][^\s:|\[\]\-()=,+!?{}]*', Name),
|
| 380 |
+
],
|
| 381 |
+
'comment': [
|
| 382 |
+
(r'[^(*)]+', Comment),
|
| 383 |
+
(r'\(\*', Comment, '#push'),
|
| 384 |
+
(r'\*\)', Comment, '#pop'),
|
| 385 |
+
(r'[(*)]', Comment),
|
| 386 |
+
],
|
| 387 |
+
'cartouche': [
|
| 388 |
+
(r'[^{*}\\‹›]+', String),
|
| 389 |
+
(r'\\<open>', String.Symbol, '#push'),
|
| 390 |
+
(r'\{\*|‹', String, '#push'),
|
| 391 |
+
(r'\\<close>', String.Symbol, '#pop'),
|
| 392 |
+
(r'\*\}|›', String, '#pop'),
|
| 393 |
+
(r'\\<(\w|\^)*>', String.Symbol),
|
| 394 |
+
(r'[{*}\\]', String),
|
| 395 |
+
],
|
| 396 |
+
'string': [
|
| 397 |
+
(r'[^"\\]+', String),
|
| 398 |
+
(r'\\<(\w|\^)*>', String.Symbol),
|
| 399 |
+
(r'\\"', String),
|
| 400 |
+
(r'\\', String),
|
| 401 |
+
(r'"', String, '#pop'),
|
| 402 |
+
],
|
| 403 |
+
'fact': [
|
| 404 |
+
(r'[^`\\]+', String.Other),
|
| 405 |
+
(r'\\<(\w|\^)*>', String.Symbol),
|
| 406 |
+
(r'\\`', String.Other),
|
| 407 |
+
(r'\\', String.Other),
|
| 408 |
+
(r'`', String.Other, '#pop'),
|
| 409 |
+
],
|
| 410 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/thingsdb.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.thingsdb
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the ThingsDB 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, bygroups
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, String, Text, \
|
| 13 |
+
Operator, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['ThingsDBLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ThingsDBLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the ThingsDB programming language.
|
| 21 |
+
"""
|
| 22 |
+
name = 'ThingsDB'
|
| 23 |
+
aliases = ['ti', 'thingsdb']
|
| 24 |
+
filenames = ['*.ti']
|
| 25 |
+
url = 'https://www.thingsdb.net'
|
| 26 |
+
version_added = '2.9'
|
| 27 |
+
|
| 28 |
+
tokens = {
|
| 29 |
+
'root': [
|
| 30 |
+
include('expression'),
|
| 31 |
+
],
|
| 32 |
+
'expression': [
|
| 33 |
+
include('comments'),
|
| 34 |
+
include('whitespace'),
|
| 35 |
+
|
| 36 |
+
# numbers
|
| 37 |
+
(r'[-+]?0b[01]+', Number.Bin),
|
| 38 |
+
(r'[-+]?0o[0-8]+', Number.Oct),
|
| 39 |
+
(r'([-+]?0x[0-9a-fA-F]+)', Number.Hex),
|
| 40 |
+
(r'[-+]?[0-9]+', Number.Integer),
|
| 41 |
+
(r'[-+]?((inf|nan)([^0-9A-Za-z_]|$)|[0-9]*\.[0-9]+(e[+-][0-9]+)?)',
|
| 42 |
+
Number.Float),
|
| 43 |
+
|
| 44 |
+
# strings
|
| 45 |
+
(r'(?:"(?:[^"]*)")+', String.Double),
|
| 46 |
+
(r"(?:'(?:[^']*)')+", String.Single),
|
| 47 |
+
(r"(?:`(?:[^`]*)`)+", String.Backtick),
|
| 48 |
+
|
| 49 |
+
# literals
|
| 50 |
+
(r'(true|false|nil)\b', Keyword.Constant),
|
| 51 |
+
|
| 52 |
+
# name constants
|
| 53 |
+
(r'(FULL|USER|GRANT|CHANGE|JOIN|RUN|QUERY|'
|
| 54 |
+
r'DEBUG|INFO|WARNING|ERROR|CRITICAL|'
|
| 55 |
+
r'NO_IDS|INT_MIN|INT_MAX|MATH_E|MATH_PI)\b', Name.Constant),
|
| 56 |
+
|
| 57 |
+
# regular expressions
|
| 58 |
+
(r'(/[^/\\]*(?:\\.[^/\\]*)*/i?)', String.Regex),
|
| 59 |
+
|
| 60 |
+
# name, assignments and functions
|
| 61 |
+
include('names'),
|
| 62 |
+
|
| 63 |
+
(r'[(){}\[\],;]', Punctuation),
|
| 64 |
+
(r'[+\-*/%&|<>^!~@=:?]', Operator),
|
| 65 |
+
],
|
| 66 |
+
'names': [
|
| 67 |
+
(r'(\.)'
|
| 68 |
+
r'(first|last|then|else|load|at|again_in|again_at|err|cancel|'
|
| 69 |
+
r'closure|set_closure|args|set_args|owner|set_owner|equals|copy|'
|
| 70 |
+
r'dup|assign|week|weekday|yday|zone|len|call|doc|emit|extract|'
|
| 71 |
+
r'choice|code|format|msg|each|every|extend|extend_unique|filter|'
|
| 72 |
+
r'find|flat|find_index|has|index_of|count|sum|is_unique|unique|'
|
| 73 |
+
r'join|map|map_id|map_wrap|map_type|vmap|move|pop|push|fill|'
|
| 74 |
+
r'remove|replace|restrict|restriction|shift|sort|splice|to|add|'
|
| 75 |
+
r'one|clear|contains|ends_with|name|lower|replace|reverse|'
|
| 76 |
+
r'starts_with|split|test|trim|trim_left|trim_right|upper|del|ren|'
|
| 77 |
+
r'to_type|to_thing|get|id|keys|reduce|set|some|value|values|wrap|'
|
| 78 |
+
r'unshift|unwrap|search|set_name|bit_count)'
|
| 79 |
+
r'(\()',
|
| 80 |
+
bygroups(Name.Function, Name.Function, Punctuation), 'arguments'),
|
| 81 |
+
(r'(alt_raise|assert|base64_encode|base64_decode|bool|bytes|'
|
| 82 |
+
r'closure|datetime|deep|future|is_future|del_enum|del_type|room|'
|
| 83 |
+
r'is_room|task|tasks|is_task|is_email|is_url|is_tel|is_time_zone|'
|
| 84 |
+
r'timeit|enum|enum_info|enum_map|enums_info|err|regex|is_regex|'
|
| 85 |
+
r'change_id|float|has_enum|has_type|int|is_array|is_ascii|'
|
| 86 |
+
r'is_float|is_bool|is_bytes|is_closure|is_datetime|is_enum|'
|
| 87 |
+
r'is_err|is_mpdata|is_inf|is_int|is_list|is_nan|is_nil|is_raw|'
|
| 88 |
+
r'is_set|is_str|is_thing|is_timeval|is_tuple|is_utf8|json_dump|'
|
| 89 |
+
r'json_load|list|log|import|export|root|mod_enum|mod_type|new|'
|
| 90 |
+
r'new_type|now|raise|rand|range|randint|randstr|refs|rename_enum|'
|
| 91 |
+
r'set|set_enum|set_type|str|thing|timeval|try|type|type_assert|'
|
| 92 |
+
r'type_all|type_count|type_info|types_info|nse|wse|backup_info|'
|
| 93 |
+
r'backups_info|backups_ok|counters|del_backup|has_backup|'
|
| 94 |
+
r'new_backup|node_info|nodes_info|reset_counters|restart_module|'
|
| 95 |
+
r'set_log_level|shutdown|has_module|del_module|module_info|'
|
| 96 |
+
r'modules_info|new_module|deploy_module|rename_module|'
|
| 97 |
+
r'refresh_module|set_module_conf|set_module_scope|'
|
| 98 |
+
r'collections_info|del_collection|del_expired|del_node|del_token|'
|
| 99 |
+
r'del_user|grant|has_collection|has_node|has_token|has_user|'
|
| 100 |
+
r'new_collection|new_node|new_token|new_user|rename_collection|'
|
| 101 |
+
r'rename_user|restore|revoke|set_password|set_time_zone|'
|
| 102 |
+
r'set_default_deep|time_zones_info|user_info|users_info|'
|
| 103 |
+
r'del_procedure|has_procedure|new_procedure|mod_procedure|'
|
| 104 |
+
r'procedure_doc|procedure_info|procedures_info|rename_procedure|'
|
| 105 |
+
r'run|assert_err|auth_err|bad_data_err|cancelled_err|'
|
| 106 |
+
r'rename_type|forbidden_err|lookup_err|max_quota_err|node_err|'
|
| 107 |
+
r'num_arguments_err|operation_err|overflow_err|syntax_err|'
|
| 108 |
+
r'collection_info|type_err|value_err|zero_div_err|whitelist_add|'
|
| 109 |
+
r'whitelist_del|round|abs|ceil|cos|exp|floor|log10|log2|'
|
| 110 |
+
r'loge|pow|sin|sqrt|tan|is_module|commit|history|set_history|'
|
| 111 |
+
r'del_history|ano)'
|
| 112 |
+
r'(\()',
|
| 113 |
+
bygroups(Name.Function, Punctuation),
|
| 114 |
+
'arguments'),
|
| 115 |
+
(r'(\.[A-Za-z_][0-9A-Za-z_]*)'
|
| 116 |
+
r'(\s*)(=)',
|
| 117 |
+
bygroups(Name.Attribute, Text, Operator)),
|
| 118 |
+
(r'\.[A-Za-z_][0-9A-Za-z_]*', Name.Attribute),
|
| 119 |
+
(r'([A-Za-z_][0-9A-Za-z_]*)(\s*)(=)',
|
| 120 |
+
bygroups(Name.Variable, Text, Operator)),
|
| 121 |
+
(r'[A-Za-z_][0-9A-Za-z_]*', Name.Variable),
|
| 122 |
+
],
|
| 123 |
+
'whitespace': [
|
| 124 |
+
(r'\n', Whitespace),
|
| 125 |
+
(r'\s+', Whitespace),
|
| 126 |
+
],
|
| 127 |
+
'comments': [
|
| 128 |
+
(r'//(.*?)\n', Comment.Single),
|
| 129 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 130 |
+
],
|
| 131 |
+
'comment': [
|
| 132 |
+
(r'[^*/]+', Comment.Multiline),
|
| 133 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 134 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 135 |
+
(r'[*/]', Comment.Multiline),
|
| 136 |
+
],
|
| 137 |
+
'arguments': [
|
| 138 |
+
include('expression'),
|
| 139 |
+
(',', Punctuation),
|
| 140 |
+
(r'\(', Punctuation, '#push'),
|
| 141 |
+
(r'\)', Punctuation, '#pop'),
|
| 142 |
+
],
|
| 143 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tlb.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tlb
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for TL-b.
|
| 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
|
| 12 |
+
from pygments.token import Operator, Name, \
|
| 13 |
+
Number, Whitespace, Punctuation, Comment
|
| 14 |
+
|
| 15 |
+
__all__ = ['TlbLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TlbLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For TL-b source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Tl-b'
|
| 24 |
+
aliases = ['tlb']
|
| 25 |
+
filenames = ['*.tlb']
|
| 26 |
+
url = 'https://docs.ton.org/#/overviews/TL-B'
|
| 27 |
+
version_added = ''
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'\s+', Whitespace),
|
| 32 |
+
|
| 33 |
+
include('comments'),
|
| 34 |
+
|
| 35 |
+
(r'[0-9]+', Number),
|
| 36 |
+
(words((
|
| 37 |
+
'+', '-', '*', '=', '?', '~', '.',
|
| 38 |
+
'^', '==', '<', '>', '<=', '>=', '!='
|
| 39 |
+
)), Operator),
|
| 40 |
+
(words(('##', '#<', '#<=')), Name.Tag),
|
| 41 |
+
(r'#[0-9a-f]*_?', Name.Tag),
|
| 42 |
+
(r'\$[01]*_?', Name.Tag),
|
| 43 |
+
|
| 44 |
+
(r'[a-zA-Z_][0-9a-zA-Z_]*', Name),
|
| 45 |
+
|
| 46 |
+
(r'[;():\[\]{}]', Punctuation)
|
| 47 |
+
],
|
| 48 |
+
|
| 49 |
+
'comments': [
|
| 50 |
+
(r'//.*', Comment.Singleline),
|
| 51 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 52 |
+
],
|
| 53 |
+
'comment': [
|
| 54 |
+
(r'[^/*]+', Comment.Multiline),
|
| 55 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 56 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 57 |
+
(r'[*/]', Comment.Multiline),
|
| 58 |
+
],
|
| 59 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tls.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tls
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the TLS presentation 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 Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation, Whitespace
|
| 15 |
+
|
| 16 |
+
__all__ = ['TlsLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class TlsLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
The TLS presentation language, described in RFC 8446.
|
| 22 |
+
"""
|
| 23 |
+
name = 'TLS Presentation Language'
|
| 24 |
+
url = 'https://www.rfc-editor.org/rfc/rfc8446#section-3'
|
| 25 |
+
filenames = []
|
| 26 |
+
aliases = ['tls']
|
| 27 |
+
mimetypes = []
|
| 28 |
+
version_added = '2.16'
|
| 29 |
+
|
| 30 |
+
flags = re.MULTILINE | re.DOTALL
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
(r'\s+', Whitespace),
|
| 35 |
+
# comments
|
| 36 |
+
(r'/[*].*?[*]/', Comment.Multiline),
|
| 37 |
+
# Keywords
|
| 38 |
+
(words(('struct', 'enum', 'select', 'case'), suffix=r'\b'),
|
| 39 |
+
Keyword),
|
| 40 |
+
(words(('uint8', 'uint16', 'uint24', 'uint32', 'uint64', 'opaque'),
|
| 41 |
+
suffix=r'\b'), Keyword.Type),
|
| 42 |
+
# numeric literals
|
| 43 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 44 |
+
(r'[0-9]+', Number.Integer),
|
| 45 |
+
# string literal
|
| 46 |
+
(r'"(\\.|[^"\\])*"', String),
|
| 47 |
+
# tokens
|
| 48 |
+
(r'[.]{2}', Operator),
|
| 49 |
+
(r'[+\-*/&^]', Operator),
|
| 50 |
+
(r'[|<>=!()\[\]{}.,;:\?]', Punctuation),
|
| 51 |
+
# identifiers
|
| 52 |
+
(r'[^\W\d]\w*', Name.Other),
|
| 53 |
+
]
|
| 54 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/tnt.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tnt
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Typographic Number Theory.
|
| 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
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, Number, \
|
| 15 |
+
Punctuation, Error
|
| 16 |
+
|
| 17 |
+
__all__ = ['TNTLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class TNTLexer(Lexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for Typographic Number Theory, as described in the book
|
| 23 |
+
Gödel, Escher, Bach, by Douglas R. Hofstadter
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'Typographic Number Theory'
|
| 27 |
+
url = 'https://github.com/Kenny2github/language-tnt'
|
| 28 |
+
aliases = ['tnt']
|
| 29 |
+
filenames = ['*.tnt']
|
| 30 |
+
version_added = '2.7'
|
| 31 |
+
|
| 32 |
+
cur = []
|
| 33 |
+
|
| 34 |
+
LOGIC = set('⊃→]&∧^|∨Vv')
|
| 35 |
+
OPERATORS = set('+.⋅*')
|
| 36 |
+
VARIABLES = set('abcde')
|
| 37 |
+
PRIMES = set("'′")
|
| 38 |
+
NEGATORS = set('~!')
|
| 39 |
+
QUANTIFIERS = set('AE∀∃')
|
| 40 |
+
NUMBERS = set('0123456789')
|
| 41 |
+
WHITESPACE = set('\t \v\n')
|
| 42 |
+
|
| 43 |
+
RULES = re.compile('''(?xi)
|
| 44 |
+
joining | separation | double-tilde | fantasy\\ rule
|
| 45 |
+
| carry[- ]over(?:\\ of)?(?:\\ line)?\\ ([0-9]+) | detachment
|
| 46 |
+
| contrapositive | De\\ Morgan | switcheroo
|
| 47 |
+
| specification | generalization | interchange
|
| 48 |
+
| existence | symmetry | transitivity
|
| 49 |
+
| add\\ S | drop\\ S | induction
|
| 50 |
+
| axiom\\ ([1-5]) | premise | push | pop
|
| 51 |
+
''')
|
| 52 |
+
LINENOS = re.compile(r'(?:[0-9]+)(?:(?:, ?|,? and )(?:[0-9]+))*')
|
| 53 |
+
COMMENT = re.compile(r'\[[^\n\]]+\]')
|
| 54 |
+
|
| 55 |
+
def __init__(self, *args, **kwargs):
|
| 56 |
+
Lexer.__init__(self, *args, **kwargs)
|
| 57 |
+
self.cur = []
|
| 58 |
+
|
| 59 |
+
def whitespace(self, start, text, required=False):
|
| 60 |
+
"""Tokenize whitespace."""
|
| 61 |
+
end = start
|
| 62 |
+
try:
|
| 63 |
+
while text[end] in self.WHITESPACE:
|
| 64 |
+
end += 1
|
| 65 |
+
except IndexError:
|
| 66 |
+
end = len(text)
|
| 67 |
+
if required and end == start:
|
| 68 |
+
raise AssertionError
|
| 69 |
+
if end != start:
|
| 70 |
+
self.cur.append((start, Text, text[start:end]))
|
| 71 |
+
return end
|
| 72 |
+
|
| 73 |
+
def variable(self, start, text):
|
| 74 |
+
"""Tokenize a variable."""
|
| 75 |
+
if text[start] not in self.VARIABLES:
|
| 76 |
+
raise AssertionError
|
| 77 |
+
end = start+1
|
| 78 |
+
while text[end] in self.PRIMES:
|
| 79 |
+
end += 1
|
| 80 |
+
self.cur.append((start, Name.Variable, text[start:end]))
|
| 81 |
+
return end
|
| 82 |
+
|
| 83 |
+
def term(self, start, text):
|
| 84 |
+
"""Tokenize a term."""
|
| 85 |
+
if text[start] == 'S': # S...S(...) or S...0
|
| 86 |
+
end = start+1
|
| 87 |
+
while text[end] == 'S':
|
| 88 |
+
end += 1
|
| 89 |
+
self.cur.append((start, Number.Integer, text[start:end]))
|
| 90 |
+
return self.term(end, text)
|
| 91 |
+
if text[start] == '0': # the singleton 0
|
| 92 |
+
self.cur.append((start, Number.Integer, text[start]))
|
| 93 |
+
return start+1
|
| 94 |
+
if text[start] in self.VARIABLES: # a''...
|
| 95 |
+
return self.variable(start, text)
|
| 96 |
+
if text[start] == '(': # (...+...)
|
| 97 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 98 |
+
start = self.term(start+1, text)
|
| 99 |
+
if text[start] not in self.OPERATORS:
|
| 100 |
+
raise AssertionError
|
| 101 |
+
self.cur.append((start, Operator, text[start]))
|
| 102 |
+
start = self.term(start+1, text)
|
| 103 |
+
if text[start] != ')':
|
| 104 |
+
raise AssertionError
|
| 105 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 106 |
+
return start+1
|
| 107 |
+
raise AssertionError # no matches
|
| 108 |
+
|
| 109 |
+
def formula(self, start, text):
|
| 110 |
+
"""Tokenize a formula."""
|
| 111 |
+
if text[start] in self.NEGATORS: # ~<...>
|
| 112 |
+
end = start+1
|
| 113 |
+
while text[end] in self.NEGATORS:
|
| 114 |
+
end += 1
|
| 115 |
+
self.cur.append((start, Operator, text[start:end]))
|
| 116 |
+
return self.formula(end, text)
|
| 117 |
+
if text[start] in self.QUANTIFIERS: # Aa:<...>
|
| 118 |
+
self.cur.append((start, Keyword.Declaration, text[start]))
|
| 119 |
+
start = self.variable(start+1, text)
|
| 120 |
+
if text[start] != ':':
|
| 121 |
+
raise AssertionError
|
| 122 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 123 |
+
return self.formula(start+1, text)
|
| 124 |
+
if text[start] == '<': # <...&...>
|
| 125 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 126 |
+
start = self.formula(start+1, text)
|
| 127 |
+
if text[start] not in self.LOGIC:
|
| 128 |
+
raise AssertionError
|
| 129 |
+
self.cur.append((start, Operator, text[start]))
|
| 130 |
+
start = self.formula(start+1, text)
|
| 131 |
+
if text[start] != '>':
|
| 132 |
+
raise AssertionError
|
| 133 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 134 |
+
return start+1
|
| 135 |
+
# ...=...
|
| 136 |
+
start = self.term(start, text)
|
| 137 |
+
if text[start] != '=':
|
| 138 |
+
raise AssertionError
|
| 139 |
+
self.cur.append((start, Operator, text[start]))
|
| 140 |
+
start = self.term(start+1, text)
|
| 141 |
+
return start
|
| 142 |
+
|
| 143 |
+
def rule(self, start, text):
|
| 144 |
+
"""Tokenize a rule."""
|
| 145 |
+
match = self.RULES.match(text, start)
|
| 146 |
+
if match is None:
|
| 147 |
+
raise AssertionError
|
| 148 |
+
groups = sorted(match.regs[1:]) # exclude whole match
|
| 149 |
+
for group in groups:
|
| 150 |
+
if group[0] >= 0: # this group matched
|
| 151 |
+
self.cur.append((start, Keyword, text[start:group[0]]))
|
| 152 |
+
self.cur.append((group[0], Number.Integer,
|
| 153 |
+
text[group[0]:group[1]]))
|
| 154 |
+
if group[1] != match.end():
|
| 155 |
+
self.cur.append((group[1], Keyword,
|
| 156 |
+
text[group[1]:match.end()]))
|
| 157 |
+
break
|
| 158 |
+
else:
|
| 159 |
+
self.cur.append((start, Keyword, text[start:match.end()]))
|
| 160 |
+
return match.end()
|
| 161 |
+
|
| 162 |
+
def lineno(self, start, text):
|
| 163 |
+
"""Tokenize a line referral."""
|
| 164 |
+
end = start
|
| 165 |
+
while text[end] not in self.NUMBERS:
|
| 166 |
+
end += 1
|
| 167 |
+
self.cur.append((start, Punctuation, text[start]))
|
| 168 |
+
self.cur.append((start+1, Text, text[start+1:end]))
|
| 169 |
+
start = end
|
| 170 |
+
match = self.LINENOS.match(text, start)
|
| 171 |
+
if match is None:
|
| 172 |
+
raise AssertionError
|
| 173 |
+
if text[match.end()] != ')':
|
| 174 |
+
raise AssertionError
|
| 175 |
+
self.cur.append((match.start(), Number.Integer, match.group(0)))
|
| 176 |
+
self.cur.append((match.end(), Punctuation, text[match.end()]))
|
| 177 |
+
return match.end() + 1
|
| 178 |
+
|
| 179 |
+
def error_till_line_end(self, start, text):
|
| 180 |
+
"""Mark everything from ``start`` to the end of the line as Error."""
|
| 181 |
+
end = start
|
| 182 |
+
try:
|
| 183 |
+
while text[end] != '\n': # there's whitespace in rules
|
| 184 |
+
end += 1
|
| 185 |
+
except IndexError:
|
| 186 |
+
end = len(text)
|
| 187 |
+
if end != start:
|
| 188 |
+
self.cur.append((start, Error, text[start:end]))
|
| 189 |
+
end = self.whitespace(end, text)
|
| 190 |
+
return end
|
| 191 |
+
|
| 192 |
+
def get_tokens_unprocessed(self, text):
|
| 193 |
+
"""Returns a list of TNT tokens."""
|
| 194 |
+
self.cur = []
|
| 195 |
+
start = end = self.whitespace(0, text)
|
| 196 |
+
while start <= end < len(text):
|
| 197 |
+
try:
|
| 198 |
+
# try line number
|
| 199 |
+
while text[end] in self.NUMBERS:
|
| 200 |
+
end += 1
|
| 201 |
+
if end != start: # actual number present
|
| 202 |
+
self.cur.append((start, Number.Integer, text[start:end]))
|
| 203 |
+
# whitespace is required after a line number
|
| 204 |
+
orig = len(self.cur)
|
| 205 |
+
try:
|
| 206 |
+
start = end = self.whitespace(end, text, True)
|
| 207 |
+
except AssertionError:
|
| 208 |
+
del self.cur[orig:]
|
| 209 |
+
start = end = self.error_till_line_end(end, text)
|
| 210 |
+
continue
|
| 211 |
+
# at this point it could be a comment
|
| 212 |
+
match = self.COMMENT.match(text, start)
|
| 213 |
+
if match is not None:
|
| 214 |
+
self.cur.append((start, Comment, text[start:match.end()]))
|
| 215 |
+
start = end = match.end()
|
| 216 |
+
# anything after the closing bracket is invalid
|
| 217 |
+
start = end = self.error_till_line_end(start, text)
|
| 218 |
+
# do not attempt to process the rest
|
| 219 |
+
continue
|
| 220 |
+
del match
|
| 221 |
+
if text[start] in '[]': # fantasy push or pop
|
| 222 |
+
self.cur.append((start, Keyword, text[start]))
|
| 223 |
+
start += 1
|
| 224 |
+
end += 1
|
| 225 |
+
else:
|
| 226 |
+
# one formula, possibly containing subformulae
|
| 227 |
+
orig = len(self.cur)
|
| 228 |
+
try:
|
| 229 |
+
start = end = self.formula(start, text)
|
| 230 |
+
except (AssertionError, RecursionError): # not well-formed
|
| 231 |
+
del self.cur[orig:]
|
| 232 |
+
while text[end] not in self.WHITESPACE:
|
| 233 |
+
end += 1
|
| 234 |
+
self.cur.append((start, Error, text[start:end]))
|
| 235 |
+
start = end
|
| 236 |
+
# skip whitespace after formula
|
| 237 |
+
orig = len(self.cur)
|
| 238 |
+
try:
|
| 239 |
+
start = end = self.whitespace(end, text, True)
|
| 240 |
+
except AssertionError:
|
| 241 |
+
del self.cur[orig:]
|
| 242 |
+
start = end = self.error_till_line_end(start, text)
|
| 243 |
+
continue
|
| 244 |
+
# rule proving this formula a theorem
|
| 245 |
+
orig = len(self.cur)
|
| 246 |
+
try:
|
| 247 |
+
start = end = self.rule(start, text)
|
| 248 |
+
except AssertionError:
|
| 249 |
+
del self.cur[orig:]
|
| 250 |
+
start = end = self.error_till_line_end(start, text)
|
| 251 |
+
continue
|
| 252 |
+
# skip whitespace after rule
|
| 253 |
+
start = end = self.whitespace(end, text)
|
| 254 |
+
# line marker
|
| 255 |
+
if text[start] == '(':
|
| 256 |
+
orig = len(self.cur)
|
| 257 |
+
try:
|
| 258 |
+
start = end = self.lineno(start, text)
|
| 259 |
+
except AssertionError:
|
| 260 |
+
del self.cur[orig:]
|
| 261 |
+
start = end = self.error_till_line_end(start, text)
|
| 262 |
+
continue
|
| 263 |
+
start = end = self.whitespace(start, text)
|
| 264 |
+
except IndexError:
|
| 265 |
+
try:
|
| 266 |
+
del self.cur[orig:]
|
| 267 |
+
except NameError:
|
| 268 |
+
pass # if orig was never defined, fine
|
| 269 |
+
self.error_till_line_end(start, text)
|
| 270 |
+
return self.cur
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/trafficscript.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.trafficscript
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for RiverBed's TrafficScript (RTS) 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
|
| 12 |
+
from pygments.token import String, Number, Name, Keyword, Operator, Text, Comment
|
| 13 |
+
|
| 14 |
+
__all__ = ['RtsLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class RtsLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For Riverbed Stingray Traffic Manager
|
| 20 |
+
"""
|
| 21 |
+
name = 'TrafficScript'
|
| 22 |
+
aliases = ['trafficscript', 'rts']
|
| 23 |
+
filenames = ['*.rts']
|
| 24 |
+
url = 'https://riverbed.com'
|
| 25 |
+
version_added = '2.1'
|
| 26 |
+
|
| 27 |
+
tokens = {
|
| 28 |
+
'root' : [
|
| 29 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
| 30 |
+
(r'"', String, 'escapable-string'),
|
| 31 |
+
(r'(0x[0-9a-fA-F]+|\d+)', Number),
|
| 32 |
+
(r'\d+\.\d+', Number.Float),
|
| 33 |
+
(r'\$[a-zA-Z](\w|_)*', Name.Variable),
|
| 34 |
+
(r'(if|else|for(each)?|in|while|do|break|sub|return|import)', Keyword),
|
| 35 |
+
(r'[a-zA-Z][\w.]*', Name.Function),
|
| 36 |
+
(r'[-+*/%=,;(){}<>^.!~|&\[\]\?\:]', Operator),
|
| 37 |
+
(r'(>=|<=|==|!=|'
|
| 38 |
+
r'&&|\|\||'
|
| 39 |
+
r'\+=|.=|-=|\*=|/=|%=|<<=|>>=|&=|\|=|\^=|'
|
| 40 |
+
r'>>|<<|'
|
| 41 |
+
r'\+\+|--|=>)', Operator),
|
| 42 |
+
(r'[ \t\r]+', Text),
|
| 43 |
+
(r'#[^\n]*', Comment),
|
| 44 |
+
],
|
| 45 |
+
'escapable-string' : [
|
| 46 |
+
(r'\\[tsn]', String.Escape),
|
| 47 |
+
(r'[^"]', String),
|
| 48 |
+
(r'"', String, '#pop'),
|
| 49 |
+
],
|
| 50 |
+
|
| 51 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/typoscript.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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9 |
+
|
| 10 |
+
`TypoScriptCssDataLexer`
|
| 11 |
+
Lexer that highlights markers, constants and registers within css.
|
| 12 |
+
|
| 13 |
+
`TypoScriptHtmlDataLexer`
|
| 14 |
+
Lexer that highlights markers, constants and registers within html tags.
|
| 15 |
+
|
| 16 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 17 |
+
:license: BSD, see LICENSE for details.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
import re
|
| 21 |
+
|
| 22 |
+
from pygments.lexer import RegexLexer, include, bygroups, using
|
| 23 |
+
from pygments.token import Text, Comment, Name, String, Number, \
|
| 24 |
+
Operator, Punctuation
|
| 25 |
+
|
| 26 |
+
__all__ = ['TypoScriptLexer', 'TypoScriptCssDataLexer', 'TypoScriptHtmlDataLexer']
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class TypoScriptCssDataLexer(RegexLexer):
|
| 30 |
+
"""
|
| 31 |
+
Lexer that highlights markers, constants and registers within css blocks.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
name = 'TypoScriptCssData'
|
| 35 |
+
aliases = ['typoscriptcssdata']
|
| 36 |
+
url = 'http://docs.typo3.org/typo3cms/TyposcriptReference/'
|
| 37 |
+
version_added = '2.2'
|
| 38 |
+
|
| 39 |
+
tokens = {
|
| 40 |
+
'root': [
|
| 41 |
+
# marker: ###MARK###
|
| 42 |
+
(r'(.*)(###\w+###)(.*)', bygroups(String, Name.Constant, String)),
|
| 43 |
+
# constant: {$some.constant}
|
| 44 |
+
(r'(\{)(\$)((?:[\w\-]+\.)*)([\w\-]+)(\})',
|
| 45 |
+
bygroups(String.Symbol, Operator, Name.Constant,
|
| 46 |
+
Name.Constant, String.Symbol)), # constant
|
| 47 |
+
# constant: {register:somevalue}
|
| 48 |
+
(r'(.*)(\{)([\w\-]+)(\s*:\s*)([\w\-]+)(\})(.*)',
|
| 49 |
+
bygroups(String, String.Symbol, Name.Constant, Operator,
|
| 50 |
+
Name.Constant, String.Symbol, String)), # constant
|
| 51 |
+
# whitespace
|
| 52 |
+
(r'\s+', Text),
|
| 53 |
+
# comments
|
| 54 |
+
(r'/\*(?:(?!\*/).)*\*/', Comment),
|
| 55 |
+
(r'(?<!(#|\'|"))(?:#(?!(?:[a-fA-F0-9]{6}|[a-fA-F0-9]{3}))[^\n#]+|//[^\n]*)',
|
| 56 |
+
Comment),
|
| 57 |
+
# other
|
| 58 |
+
(r'[<>,:=.*%+|]', String),
|
| 59 |
+
(r'[\w"\-!/&;(){}]+', String),
|
| 60 |
+
]
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class TypoScriptHtmlDataLexer(RegexLexer):
|
| 65 |
+
"""
|
| 66 |
+
Lexer that highlights markers, constants and registers within html tags.
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
name = 'TypoScriptHtmlData'
|
| 70 |
+
aliases = ['typoscripthtmldata']
|
| 71 |
+
url = 'http://docs.typo3.org/typo3cms/TyposcriptReference/'
|
| 72 |
+
version_added = '2.2'
|
| 73 |
+
|
| 74 |
+
tokens = {
|
| 75 |
+
'root': [
|
| 76 |
+
# INCLUDE_TYPOSCRIPT
|
| 77 |
+
(r'(INCLUDE_TYPOSCRIPT)', Name.Class),
|
| 78 |
+
# Language label or extension resource FILE:... or LLL:... or EXT:...
|
| 79 |
+
(r'(EXT|FILE|LLL):[^}\n"]*', String),
|
| 80 |
+
# marker: ###MARK###
|
| 81 |
+
(r'(.*)(###\w+###)(.*)', bygroups(String, Name.Constant, String)),
|
| 82 |
+
# constant: {$some.constant}
|
| 83 |
+
(r'(\{)(\$)((?:[\w\-]+\.)*)([\w\-]+)(\})',
|
| 84 |
+
bygroups(String.Symbol, Operator, Name.Constant,
|
| 85 |
+
Name.Constant, String.Symbol)), # constant
|
| 86 |
+
# constant: {register:somevalue}
|
| 87 |
+
(r'(.*)(\{)([\w\-]+)(\s*:\s*)([\w\-]+)(\})(.*)',
|
| 88 |
+
bygroups(String, String.Symbol, Name.Constant, Operator,
|
| 89 |
+
Name.Constant, String.Symbol, String)), # constant
|
| 90 |
+
# whitespace
|
| 91 |
+
(r'\s+', Text),
|
| 92 |
+
# other
|
| 93 |
+
(r'[<>,:=.*%+|]', String),
|
| 94 |
+
(r'[\w"\-!/&;(){}#]+', String),
|
| 95 |
+
]
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class TypoScriptLexer(RegexLexer):
|
| 100 |
+
"""
|
| 101 |
+
Lexer for TypoScript code.
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
name = 'TypoScript'
|
| 105 |
+
url = 'http://docs.typo3.org/typo3cms/TyposcriptReference/'
|
| 106 |
+
aliases = ['typoscript']
|
| 107 |
+
filenames = ['*.typoscript']
|
| 108 |
+
mimetypes = ['text/x-typoscript']
|
| 109 |
+
version_added = '2.2'
|
| 110 |
+
|
| 111 |
+
flags = re.DOTALL | re.MULTILINE
|
| 112 |
+
|
| 113 |
+
tokens = {
|
| 114 |
+
'root': [
|
| 115 |
+
include('comment'),
|
| 116 |
+
include('constant'),
|
| 117 |
+
include('html'),
|
| 118 |
+
include('label'),
|
| 119 |
+
include('whitespace'),
|
| 120 |
+
include('keywords'),
|
| 121 |
+
include('punctuation'),
|
| 122 |
+
include('operator'),
|
| 123 |
+
include('structure'),
|
| 124 |
+
include('literal'),
|
| 125 |
+
include('other'),
|
| 126 |
+
],
|
| 127 |
+
'keywords': [
|
| 128 |
+
# Conditions
|
| 129 |
+
(r'(?i)(\[)(browser|compatVersion|dayofmonth|dayofweek|dayofyear|'
|
| 130 |
+
r'device|ELSE|END|GLOBAL|globalString|globalVar|hostname|hour|IP|'
|
| 131 |
+
r'language|loginUser|loginuser|minute|month|page|PIDinRootline|'
|
| 132 |
+
r'PIDupinRootline|system|treeLevel|useragent|userFunc|usergroup|'
|
| 133 |
+
r'version)([^\]]*)(\])',
|
| 134 |
+
bygroups(String.Symbol, Name.Constant, Text, String.Symbol)),
|
| 135 |
+
# Functions
|
| 136 |
+
(r'(?=[\w\-])(HTMLparser|HTMLparser_tags|addParams|cache|encapsLines|'
|
| 137 |
+
r'filelink|if|imageLinkWrap|imgResource|makelinks|numRows|numberFormat|'
|
| 138 |
+
r'parseFunc|replacement|round|select|split|stdWrap|strPad|tableStyle|'
|
| 139 |
+
r'tags|textStyle|typolink)(?![\w\-])', Name.Function),
|
| 140 |
+
# Toplevel objects and _*
|
| 141 |
+
(r'(?:(=?\s*<?\s+|^\s*))(cObj|field|config|content|constants|FEData|'
|
| 142 |
+
r'file|frameset|includeLibs|lib|page|plugin|register|resources|sitemap|'
|
| 143 |
+
r'sitetitle|styles|temp|tt_[^:.\s]*|types|xmlnews|INCLUDE_TYPOSCRIPT|'
|
| 144 |
+
r'_CSS_DEFAULT_STYLE|_DEFAULT_PI_VARS|_LOCAL_LANG)(?![\w\-])',
|
| 145 |
+
bygroups(Operator, Name.Builtin)),
|
| 146 |
+
# Content objects
|
| 147 |
+
(r'(?=[\w\-])(CASE|CLEARGIF|COA|COA_INT|COBJ_ARRAY|COLUMNS|CONTENT|'
|
| 148 |
+
r'CTABLE|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|FORM|HMENU|HRULER|HTML|'
|
| 149 |
+
r'IMAGE|IMGTEXT|IMG_RESOURCE|LOAD_REGISTER|MEDIA|MULTIMEDIA|OTABLE|'
|
| 150 |
+
r'PAGE|QTOBJECT|RECORDS|RESTORE_REGISTER|SEARCHRESULT|SVG|SWFOBJECT|'
|
| 151 |
+
r'TEMPLATE|TEXT|USER|USER_INT)(?![\w\-])', Name.Class),
|
| 152 |
+
# Menu states
|
| 153 |
+
(r'(?=[\w\-])(ACTIFSUBRO|ACTIFSUB|ACTRO|ACT|CURIFSUBRO|CURIFSUB|CURRO|'
|
| 154 |
+
r'CUR|IFSUBRO|IFSUB|NO|SPC|USERDEF1RO|USERDEF1|USERDEF2RO|USERDEF2|'
|
| 155 |
+
r'USRRO|USR)', Name.Class),
|
| 156 |
+
# Menu objects
|
| 157 |
+
(r'(?=[\w\-])(GMENU_FOLDOUT|GMENU_LAYERS|GMENU|IMGMENUITEM|IMGMENU|'
|
| 158 |
+
r'JSMENUITEM|JSMENU|TMENUITEM|TMENU_LAYERS|TMENU)', Name.Class),
|
| 159 |
+
# PHP objects
|
| 160 |
+
(r'(?=[\w\-])(PHP_SCRIPT(_EXT|_INT)?)', Name.Class),
|
| 161 |
+
(r'(?=[\w\-])(userFunc)(?![\w\-])', Name.Function),
|
| 162 |
+
],
|
| 163 |
+
'whitespace': [
|
| 164 |
+
(r'\s+', Text),
|
| 165 |
+
],
|
| 166 |
+
'html': [
|
| 167 |
+
(r'<\S[^\n>]*>', using(TypoScriptHtmlDataLexer)),
|
| 168 |
+
(r'&[^;\n]*;', String),
|
| 169 |
+
(r'(?s)(_CSS_DEFAULT_STYLE)(\s*)(\()(.*(?=\n\)))',
|
| 170 |
+
bygroups(Name.Class, Text, String.Symbol, using(TypoScriptCssDataLexer))),
|
| 171 |
+
],
|
| 172 |
+
'literal': [
|
| 173 |
+
(r'0x[0-9A-Fa-f]+t?', Number.Hex),
|
| 174 |
+
# (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?\s*(?:[^=])', Number.Float),
|
| 175 |
+
(r'[0-9]+', Number.Integer),
|
| 176 |
+
(r'(###\w+###)', Name.Constant),
|
| 177 |
+
],
|
| 178 |
+
'label': [
|
| 179 |
+
# Language label or extension resource FILE:... or LLL:... or EXT:...
|
| 180 |
+
(r'(EXT|FILE|LLL):[^}\n"]*', String),
|
| 181 |
+
# Path to a resource
|
| 182 |
+
(r'(?![^\w\-])([\w\-]+(?:/[\w\-]+)+/?)(\S*\n)',
|
| 183 |
+
bygroups(String, String)),
|
| 184 |
+
],
|
| 185 |
+
'punctuation': [
|
| 186 |
+
(r'[,.]', Punctuation),
|
| 187 |
+
],
|
| 188 |
+
'operator': [
|
| 189 |
+
(r'[<>,:=.*%+|]', Operator),
|
| 190 |
+
],
|
| 191 |
+
'structure': [
|
| 192 |
+
# Brackets and braces
|
| 193 |
+
(r'[{}()\[\]\\]', String.Symbol),
|
| 194 |
+
],
|
| 195 |
+
'constant': [
|
| 196 |
+
# Constant: {$some.constant}
|
| 197 |
+
(r'(\{)(\$)((?:[\w\-]+\.)*)([\w\-]+)(\})',
|
| 198 |
+
bygroups(String.Symbol, Operator, Name.Constant,
|
| 199 |
+
Name.Constant, String.Symbol)), # constant
|
| 200 |
+
# Constant: {register:somevalue}
|
| 201 |
+
(r'(\{)([\w\-]+)(\s*:\s*)([\w\-]+)(\})',
|
| 202 |
+
bygroups(String.Symbol, Name.Constant, Operator,
|
| 203 |
+
Name.Constant, String.Symbol)), # constant
|
| 204 |
+
# Hex color: #ff0077
|
| 205 |
+
(r'(#[a-fA-F0-9]{6}\b|#[a-fA-F0-9]{3}\b)', String.Char)
|
| 206 |
+
],
|
| 207 |
+
'comment': [
|
| 208 |
+
(r'(?<!(#|\'|"))(?:#(?!(?:[a-fA-F0-9]{6}|[a-fA-F0-9]{3}))[^\n#]+|//[^\n]*)',
|
| 209 |
+
Comment),
|
| 210 |
+
(r'/\*(?:(?!\*/).)*\*/', Comment),
|
| 211 |
+
(r'(\s*#\s*\n)', Comment),
|
| 212 |
+
],
|
| 213 |
+
'other': [
|
| 214 |
+
(r'[\w"\-!/&;]+', Text),
|
| 215 |
+
],
|
| 216 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/ul4.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ul4
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the UL4 templating 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, DelegatingLexer, bygroups, words, include
|
| 14 |
+
from pygments.token import Comment, Text, Keyword, String, Number, Literal, \
|
| 15 |
+
Name, Other, Operator
|
| 16 |
+
from pygments.lexers.web import HtmlLexer, XmlLexer, CssLexer, JavascriptLexer
|
| 17 |
+
from pygments.lexers.python import PythonLexer
|
| 18 |
+
|
| 19 |
+
__all__ = ['UL4Lexer', 'HTMLUL4Lexer', 'XMLUL4Lexer', 'CSSUL4Lexer',
|
| 20 |
+
'JavascriptUL4Lexer', 'PythonUL4Lexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class UL4Lexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
Generic lexer for UL4.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
flags = re.MULTILINE | re.DOTALL
|
| 29 |
+
|
| 30 |
+
name = 'UL4'
|
| 31 |
+
aliases = ['ul4']
|
| 32 |
+
filenames = ['*.ul4']
|
| 33 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 34 |
+
version_added = '2.12'
|
| 35 |
+
|
| 36 |
+
tokens = {
|
| 37 |
+
"root": [
|
| 38 |
+
(
|
| 39 |
+
# Template header without name:
|
| 40 |
+
# ``<?ul4?>``
|
| 41 |
+
r"(<\?)(\s*)(ul4)(\s*)(\?>)",
|
| 42 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword,
|
| 43 |
+
Text.Whitespace, Comment.Preproc),
|
| 44 |
+
),
|
| 45 |
+
(
|
| 46 |
+
# Template header with name (potentially followed by the signature):
|
| 47 |
+
# ``<?ul4 foo(bar=42)?>``
|
| 48 |
+
r"(<\?)(\s*)(ul4)(\s*)([a-zA-Z_][a-zA-Z_0-9]*)?",
|
| 49 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword,
|
| 50 |
+
Text.Whitespace, Name.Function),
|
| 51 |
+
"ul4", # Switch to "expression" mode
|
| 52 |
+
),
|
| 53 |
+
(
|
| 54 |
+
# Comment:
|
| 55 |
+
# ``<?note?>...<?end note?>``
|
| 56 |
+
r"<\?\s*note\s*\?>",
|
| 57 |
+
Comment,
|
| 58 |
+
"note", # Switch to "note" mode
|
| 59 |
+
),
|
| 60 |
+
(
|
| 61 |
+
# Comment:
|
| 62 |
+
# ``<?note foobar?>``
|
| 63 |
+
r"<\?\s*note\s.*?\?>",
|
| 64 |
+
Comment,
|
| 65 |
+
),
|
| 66 |
+
(
|
| 67 |
+
# Template documentation:
|
| 68 |
+
# ``<?doc?>...<?end doc?>``
|
| 69 |
+
r"<\?\s*doc\s*\?>",
|
| 70 |
+
String.Doc,
|
| 71 |
+
"doc",
|
| 72 |
+
),
|
| 73 |
+
(
|
| 74 |
+
# Template documentation:
|
| 75 |
+
# ``<?doc foobar?>``
|
| 76 |
+
r"<\?\s*doc\s.*?\?>",
|
| 77 |
+
String.Doc,
|
| 78 |
+
),
|
| 79 |
+
(
|
| 80 |
+
# ``<?ignore?>`` tag for commenting out code:
|
| 81 |
+
# ``<?ignore?>...<?end ignore?>``
|
| 82 |
+
r"<\?\s*ignore\s*\?>",
|
| 83 |
+
Comment,
|
| 84 |
+
"ignore", # Switch to "ignore" mode
|
| 85 |
+
),
|
| 86 |
+
(
|
| 87 |
+
# ``<?def?>`` tag for defining local templates
|
| 88 |
+
# ``<?def foo(bar=42)?>...<?end def?>``
|
| 89 |
+
r"(<\?)(\s*)(def)(\s*)([a-zA-Z_][a-zA-Z_0-9]*)?",
|
| 90 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword,
|
| 91 |
+
Text.Whitespace, Name.Function),
|
| 92 |
+
"ul4", # Switch to "expression" mode
|
| 93 |
+
),
|
| 94 |
+
(
|
| 95 |
+
# The rest of the supported tags
|
| 96 |
+
r"(<\?)(\s*)(printx|print|for|if|elif|else|while|code|renderblocks?|render)\b",
|
| 97 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword),
|
| 98 |
+
"ul4", # Switch to "expression" mode
|
| 99 |
+
),
|
| 100 |
+
(
|
| 101 |
+
# ``<?end?>`` tag for ending ``<?def?>``, ``<?for?>``,
|
| 102 |
+
# ``<?if?>``, ``<?while?>``, ``<?renderblock?>`` and
|
| 103 |
+
# ``<?renderblocks?>`` blocks.
|
| 104 |
+
r"(<\?)(\s*)(end)\b",
|
| 105 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword),
|
| 106 |
+
"end", # Switch to "end tag" mode
|
| 107 |
+
),
|
| 108 |
+
(
|
| 109 |
+
# ``<?whitespace?>`` tag for configuring whitespace handlng
|
| 110 |
+
r"(<\?)(\s*)(whitespace)\b",
|
| 111 |
+
bygroups(Comment.Preproc, Text.Whitespace, Keyword),
|
| 112 |
+
"whitespace", # Switch to "whitespace" mode
|
| 113 |
+
),
|
| 114 |
+
# Plain text
|
| 115 |
+
(r"[^<]+", Other),
|
| 116 |
+
(r"<", Other),
|
| 117 |
+
],
|
| 118 |
+
# Ignore mode ignores everything upto the matching ``<?end ignore?>`` tag
|
| 119 |
+
"ignore": [
|
| 120 |
+
# Nested ``<?ignore?>`` tag
|
| 121 |
+
(r"<\?\s*ignore\s*\?>", Comment, "#push"),
|
| 122 |
+
# ``<?end ignore?>`` tag
|
| 123 |
+
(r"<\?\s*end\s+ignore\s*\?>", Comment, "#pop"),
|
| 124 |
+
# Everything else
|
| 125 |
+
(r"[^<]+", Comment),
|
| 126 |
+
(r".", Comment),
|
| 127 |
+
],
|
| 128 |
+
# Note mode ignores everything upto the matching ``<?end note?>`` tag
|
| 129 |
+
"note": [
|
| 130 |
+
# Nested ``<?note?>`` tag
|
| 131 |
+
(r"<\?\s*note\s*\?>", Comment, "#push"),
|
| 132 |
+
# ``<?end note?>`` tag
|
| 133 |
+
(r"<\?\s*end\s+note\s*\?>", Comment, "#pop"),
|
| 134 |
+
# Everything else
|
| 135 |
+
(r"[^<]+", Comment),
|
| 136 |
+
(r".", Comment),
|
| 137 |
+
],
|
| 138 |
+
# Doc mode ignores everything upto the matching ``<?end doc?>`` tag
|
| 139 |
+
"doc": [
|
| 140 |
+
# Nested ``<?doc?>`` tag
|
| 141 |
+
(r"<\?\s*doc\s*\?>", String.Doc, "#push"),
|
| 142 |
+
# ``<?end doc?>`` tag
|
| 143 |
+
(r"<\?\s*end\s+doc\s*\?>", String.Doc, "#pop"),
|
| 144 |
+
# Everything else
|
| 145 |
+
(r"[^<]+", String.Doc),
|
| 146 |
+
(r".", String.Doc),
|
| 147 |
+
],
|
| 148 |
+
# UL4 expressions
|
| 149 |
+
"ul4": [
|
| 150 |
+
# End the tag
|
| 151 |
+
(r"\?>", Comment.Preproc, "#pop"),
|
| 152 |
+
# Start triple quoted string constant
|
| 153 |
+
("'''", String, "string13"),
|
| 154 |
+
('"""', String, "string23"),
|
| 155 |
+
# Start single quoted string constant
|
| 156 |
+
("'", String, "string1"),
|
| 157 |
+
('"', String, "string2"),
|
| 158 |
+
# Floating point number
|
| 159 |
+
(r"\d+\.\d*([eE][+-]?\d+)?", Number.Float),
|
| 160 |
+
(r"\.\d+([eE][+-]?\d+)?", Number.Float),
|
| 161 |
+
(r"\d+[eE][+-]?\d+", Number.Float),
|
| 162 |
+
# Binary integer: ``0b101010``
|
| 163 |
+
(r"0[bB][01]+", Number.Bin),
|
| 164 |
+
# Octal integer: ``0o52``
|
| 165 |
+
(r"0[oO][0-7]+", Number.Oct),
|
| 166 |
+
# Hexadecimal integer: ``0x2a``
|
| 167 |
+
(r"0[xX][0-9a-fA-F]+", Number.Hex),
|
| 168 |
+
# Date or datetime: ``@(2000-02-29)``/``@(2000-02-29T12:34:56.987654)``
|
| 169 |
+
(r"@\(\d\d\d\d-\d\d-\d\d(T(\d\d:\d\d(:\d\d(\.\d{6})?)?)?)?\)", Literal.Date),
|
| 170 |
+
# Color: ``#fff``, ``#fff8f0`` etc.
|
| 171 |
+
(r"#[0-9a-fA-F]{8}", Literal.Color),
|
| 172 |
+
(r"#[0-9a-fA-F]{6}", Literal.Color),
|
| 173 |
+
(r"#[0-9a-fA-F]{3,4}", Literal.Color),
|
| 174 |
+
# Decimal integer: ``42``
|
| 175 |
+
(r"\d+", Number.Integer),
|
| 176 |
+
# Operators
|
| 177 |
+
(r"//|==|!=|>=|<=|<<|>>|\+=|-=|\*=|/=|//=|<<=|>>=|&=|\|=|^=|=|[\[\]{},:*/().~%&|<>^+-]", Operator),
|
| 178 |
+
# Keywords
|
| 179 |
+
(words(("for", "in", "if", "else", "not", "is", "and", "or"), suffix=r"\b"), Keyword),
|
| 180 |
+
# Builtin constants
|
| 181 |
+
(words(("None", "False", "True"), suffix=r"\b"), Keyword.Constant),
|
| 182 |
+
# Variable names
|
| 183 |
+
(r"[a-zA-Z_][a-zA-Z0-9_]*", Name),
|
| 184 |
+
# Whitespace
|
| 185 |
+
(r"\s+", Text.Whitespace),
|
| 186 |
+
],
|
| 187 |
+
# ``<?end ...?>`` tag for closing the last open block
|
| 188 |
+
"end": [
|
| 189 |
+
(r"\?>", Comment.Preproc, "#pop"),
|
| 190 |
+
(words(("for", "if", "def", "while", "renderblock", "renderblocks"), suffix=r"\b"), Keyword),
|
| 191 |
+
(r"\s+", Text),
|
| 192 |
+
],
|
| 193 |
+
# Content of the ``<?whitespace ...?>`` tag:
|
| 194 |
+
# ``keep``, ``strip`` or ``smart``
|
| 195 |
+
"whitespace": [
|
| 196 |
+
(r"\?>", Comment.Preproc, "#pop"),
|
| 197 |
+
(words(("keep", "strip", "smart"), suffix=r"\b"), Comment.Preproc),
|
| 198 |
+
(r"\s+", Text.Whitespace),
|
| 199 |
+
],
|
| 200 |
+
# Inside a string constant
|
| 201 |
+
"stringescapes": [
|
| 202 |
+
(r"""\\[\\'"abtnfr]""", String.Escape),
|
| 203 |
+
(r"\\x[0-9a-fA-F]{2}", String.Escape),
|
| 204 |
+
(r"\\u[0-9a-fA-F]{4}", String.Escape),
|
| 205 |
+
(r"\\U[0-9a-fA-F]{8}", String.Escape),
|
| 206 |
+
],
|
| 207 |
+
# Inside a triple quoted string started with ``'''``
|
| 208 |
+
"string13": [
|
| 209 |
+
(r"'''", String, "#pop"),
|
| 210 |
+
include("stringescapes"),
|
| 211 |
+
(r"[^\\']+", String),
|
| 212 |
+
(r'.', String),
|
| 213 |
+
],
|
| 214 |
+
# Inside a triple quoted string started with ``"""``
|
| 215 |
+
"string23": [
|
| 216 |
+
(r'"""', String, "#pop"),
|
| 217 |
+
include("stringescapes"),
|
| 218 |
+
(r'[^\\"]+', String),
|
| 219 |
+
(r'.', String),
|
| 220 |
+
],
|
| 221 |
+
# Inside a single quoted string started with ``'``
|
| 222 |
+
"string1": [
|
| 223 |
+
(r"'", String, "#pop"),
|
| 224 |
+
include("stringescapes"),
|
| 225 |
+
(r"[^\\']+", String),
|
| 226 |
+
(r'.', String),
|
| 227 |
+
],
|
| 228 |
+
# Inside a single quoted string started with ``"``
|
| 229 |
+
"string2": [
|
| 230 |
+
(r'"', String, "#pop"),
|
| 231 |
+
include("stringescapes"),
|
| 232 |
+
(r'[^\\"]+', String),
|
| 233 |
+
(r'.', String),
|
| 234 |
+
],
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
class HTMLUL4Lexer(DelegatingLexer):
|
| 238 |
+
"""
|
| 239 |
+
Lexer for UL4 embedded in HTML.
|
| 240 |
+
"""
|
| 241 |
+
|
| 242 |
+
name = 'HTML+UL4'
|
| 243 |
+
aliases = ['html+ul4']
|
| 244 |
+
filenames = ['*.htmlul4']
|
| 245 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 246 |
+
version_added = ''
|
| 247 |
+
|
| 248 |
+
def __init__(self, **options):
|
| 249 |
+
super().__init__(HtmlLexer, UL4Lexer, **options)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
class XMLUL4Lexer(DelegatingLexer):
|
| 253 |
+
"""
|
| 254 |
+
Lexer for UL4 embedded in XML.
|
| 255 |
+
"""
|
| 256 |
+
|
| 257 |
+
name = 'XML+UL4'
|
| 258 |
+
aliases = ['xml+ul4']
|
| 259 |
+
filenames = ['*.xmlul4']
|
| 260 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 261 |
+
version_added = ''
|
| 262 |
+
|
| 263 |
+
def __init__(self, **options):
|
| 264 |
+
super().__init__(XmlLexer, UL4Lexer, **options)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
class CSSUL4Lexer(DelegatingLexer):
|
| 268 |
+
"""
|
| 269 |
+
Lexer for UL4 embedded in CSS.
|
| 270 |
+
"""
|
| 271 |
+
|
| 272 |
+
name = 'CSS+UL4'
|
| 273 |
+
aliases = ['css+ul4']
|
| 274 |
+
filenames = ['*.cssul4']
|
| 275 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 276 |
+
version_added = ''
|
| 277 |
+
|
| 278 |
+
def __init__(self, **options):
|
| 279 |
+
super().__init__(CssLexer, UL4Lexer, **options)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
class JavascriptUL4Lexer(DelegatingLexer):
|
| 283 |
+
"""
|
| 284 |
+
Lexer for UL4 embedded in Javascript.
|
| 285 |
+
"""
|
| 286 |
+
|
| 287 |
+
name = 'Javascript+UL4'
|
| 288 |
+
aliases = ['js+ul4']
|
| 289 |
+
filenames = ['*.jsul4']
|
| 290 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 291 |
+
version_added = ''
|
| 292 |
+
|
| 293 |
+
def __init__(self, **options):
|
| 294 |
+
super().__init__(JavascriptLexer, UL4Lexer, **options)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
class PythonUL4Lexer(DelegatingLexer):
|
| 298 |
+
"""
|
| 299 |
+
Lexer for UL4 embedded in Python.
|
| 300 |
+
"""
|
| 301 |
+
|
| 302 |
+
name = 'Python+UL4'
|
| 303 |
+
aliases = ['py+ul4']
|
| 304 |
+
filenames = ['*.pyul4']
|
| 305 |
+
url = 'https://python.livinglogic.de/UL4.html'
|
| 306 |
+
version_added = ''
|
| 307 |
+
|
| 308 |
+
def __init__(self, **options):
|
| 309 |
+
super().__init__(PythonLexer, UL4Lexer, **options)
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/unicon.py
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.unicon
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Icon and Unicon languages, including ucode VM.
|
| 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, using, this
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['IconLexer', 'UcodeLexer', 'UniconLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class UniconLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Unicon source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Unicon'
|
| 26 |
+
aliases = ['unicon']
|
| 27 |
+
filenames = ['*.icn']
|
| 28 |
+
mimetypes = ['text/unicon']
|
| 29 |
+
url = 'https://www.unicon.org'
|
| 30 |
+
version_added = '2.4'
|
| 31 |
+
|
| 32 |
+
flags = re.MULTILINE
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
(r'[^\S\n]+', Text),
|
| 37 |
+
(r'#.*?\n', Comment.Single),
|
| 38 |
+
(r'[^\S\n]+', Text),
|
| 39 |
+
(r'class|method|procedure', Keyword.Declaration, 'subprogram'),
|
| 40 |
+
(r'(record)(\s+)(\w+)',
|
| 41 |
+
bygroups(Keyword.Declaration, Text, Keyword.Type), 'type_def'),
|
| 42 |
+
(r'(#line|\$C|\$Cend|\$define|\$else|\$endif|\$error|\$ifdef|'
|
| 43 |
+
r'\$ifndef|\$include|\$line|\$undef)\b', Keyword.PreProc),
|
| 44 |
+
(r'(&null|&fail)\b', Keyword.Constant),
|
| 45 |
+
(r'&allocated|&ascii|&clock|&collections|&column|&col|&control|'
|
| 46 |
+
r'&cset|¤t|&dateline|&date|&digits|&dump|'
|
| 47 |
+
r'&errno|&errornumber|&errortext|&errorvalue|&error|&errout|'
|
| 48 |
+
r'&eventcode|&eventvalue|&eventsource|&e|'
|
| 49 |
+
r'&features|&file|&host|&input|&interval|&lcase|&letters|'
|
| 50 |
+
r'&level|&line|&ldrag|&lpress|&lrelease|'
|
| 51 |
+
r'&main|&mdrag|&meta|&mpress|&mrelease|&now|&output|'
|
| 52 |
+
r'&phi|&pick|&pi|&pos|&progname|'
|
| 53 |
+
r'&random|&rdrag|®ions|&resize|&row|&rpress|&rrelease|'
|
| 54 |
+
r'&shift|&source|&storage|&subject|'
|
| 55 |
+
r'&time|&trace|&ucase|&version|'
|
| 56 |
+
r'&window|&x|&y', Keyword.Reserved),
|
| 57 |
+
(r'(by|of|not|to)\b', Keyword.Reserved),
|
| 58 |
+
(r'(global|local|static|abstract)\b', Keyword.Reserved),
|
| 59 |
+
(r'package|link|import', Keyword.Declaration),
|
| 60 |
+
(words((
|
| 61 |
+
'break', 'case', 'create', 'critical', 'default', 'end', 'all',
|
| 62 |
+
'do', 'else', 'every', 'fail', 'if', 'import', 'initial',
|
| 63 |
+
'initially', 'invocable', 'next',
|
| 64 |
+
'repeat', 'return', 'suspend',
|
| 65 |
+
'then', 'thread', 'until', 'while'), prefix=r'\b', suffix=r'\b'),
|
| 66 |
+
Keyword.Reserved),
|
| 67 |
+
(words((
|
| 68 |
+
'Abort', 'abs', 'acos', 'Active', 'Alert', 'any', 'Any', 'Arb',
|
| 69 |
+
'Arbno', 'args', 'array', 'asin', 'atan', 'atanh', 'Attrib',
|
| 70 |
+
'Bal', 'bal', 'Bg', 'Break', 'Breakx',
|
| 71 |
+
'callout', 'center', 'char', 'chdir', 'chmod', 'chown', 'chroot',
|
| 72 |
+
'classname', 'Clip', 'Clone', 'close', 'cofail', 'collect',
|
| 73 |
+
'Color', 'ColorValue', 'condvar', 'constructor', 'copy',
|
| 74 |
+
'CopyArea', 'cos', 'Couple', 'crypt', 'cset', 'ctime',
|
| 75 |
+
'dbcolumns', 'dbdriver', 'dbkeys', 'dblimits', 'dbproduct',
|
| 76 |
+
'dbtables', 'delay', 'delete', 'detab', 'display', 'DrawArc',
|
| 77 |
+
'DrawCircle', 'DrawCube', 'DrawCurve', 'DrawCylinder',
|
| 78 |
+
'DrawDisk', 'DrawImage', 'DrawLine', 'DrawPoint', 'DrawPolygon',
|
| 79 |
+
'DrawRectangle', 'DrawSegment', 'DrawSphere', 'DrawString',
|
| 80 |
+
'DrawTorus', 'dtor',
|
| 81 |
+
'entab', 'EraseArea', 'errorclear', 'Event', 'eventmask',
|
| 82 |
+
'EvGet', 'EvSend', 'exec', 'exit', 'exp', 'Eye',
|
| 83 |
+
'Fail', 'fcntl', 'fdup', 'Fence', 'fetch', 'Fg', 'fieldnames',
|
| 84 |
+
'filepair', 'FillArc', 'FillCircle', 'FillPolygon',
|
| 85 |
+
'FillRectangle', 'find', 'flock', 'flush', 'Font', 'fork',
|
| 86 |
+
'FreeColor', 'FreeSpace', 'function',
|
| 87 |
+
'get', 'getch', 'getche', 'getegid', 'getenv', 'geteuid',
|
| 88 |
+
'getgid', 'getgr', 'gethost', 'getpgrp', 'getpid', 'getppid',
|
| 89 |
+
'getpw', 'getrusage', 'getserv', 'GetSpace', 'gettimeofday',
|
| 90 |
+
'getuid', 'globalnames', 'GotoRC', 'GotoXY', 'gtime', 'hardlink',
|
| 91 |
+
'iand', 'icom', 'IdentityMatrix', 'image', 'InPort', 'insert',
|
| 92 |
+
'Int86', 'integer', 'ioctl', 'ior', 'ishift', 'istate', 'ixor',
|
| 93 |
+
'kbhit', 'key', 'keyword', 'kill',
|
| 94 |
+
'left', 'Len', 'list', 'load', 'loadfunc', 'localnames',
|
| 95 |
+
'lock', 'log', 'Lower', 'lstat',
|
| 96 |
+
'many', 'map', 'match', 'MatrixMode', 'max', 'member',
|
| 97 |
+
'membernames', 'methodnames', 'methods', 'min', 'mkdir', 'move',
|
| 98 |
+
'MultMatrix', 'mutex',
|
| 99 |
+
'name', 'NewColor', 'Normals', 'NotAny', 'numeric',
|
| 100 |
+
'open', 'opencl', 'oprec', 'ord', 'OutPort',
|
| 101 |
+
'PaletteChars', 'PaletteColor', 'PaletteKey', 'paramnames',
|
| 102 |
+
'parent', 'Pattern', 'Peek', 'Pending', 'pipe', 'Pixel',
|
| 103 |
+
'PlayAudio', 'Poke', 'pop', 'PopMatrix', 'Pos', 'pos',
|
| 104 |
+
'proc', 'pull', 'push', 'PushMatrix', 'PushRotate', 'PushScale',
|
| 105 |
+
'PushTranslate', 'put',
|
| 106 |
+
'QueryPointer',
|
| 107 |
+
'Raise', 'read', 'ReadImage', 'readlink', 'reads', 'ready',
|
| 108 |
+
'real', 'receive', 'Refresh', 'Rem', 'remove', 'rename',
|
| 109 |
+
'repl', 'reverse', 'right', 'rmdir', 'Rotate', 'Rpos',
|
| 110 |
+
'Rtab', 'rtod', 'runerr',
|
| 111 |
+
'save', 'Scale', 'seek', 'select', 'send', 'seq',
|
| 112 |
+
'serial', 'set', 'setenv', 'setgid', 'setgrent',
|
| 113 |
+
'sethostent', 'setpgrp', 'setpwent', 'setservent',
|
| 114 |
+
'setuid', 'signal', 'sin', 'sort', 'sortf', 'Span',
|
| 115 |
+
'spawn', 'sql', 'sqrt', 'stat', 'staticnames', 'stop',
|
| 116 |
+
'StopAudio', 'string', 'structure', 'Succeed', 'Swi',
|
| 117 |
+
'symlink', 'sys_errstr', 'system', 'syswrite',
|
| 118 |
+
'Tab', 'tab', 'table', 'tan',
|
| 119 |
+
'Texcoord', 'Texture', 'TextWidth', 'Translate',
|
| 120 |
+
'trap', 'trim', 'truncate', 'trylock', 'type',
|
| 121 |
+
'umask', 'Uncouple', 'unlock', 'upto', 'utime',
|
| 122 |
+
'variable', 'VAttrib',
|
| 123 |
+
'wait', 'WAttrib', 'WDefault', 'WFlush', 'where',
|
| 124 |
+
'WinAssociate', 'WinButton', 'WinColorDialog', 'WindowContents',
|
| 125 |
+
'WinEditRegion', 'WinFontDialog', 'WinMenuBar', 'WinOpenDialog',
|
| 126 |
+
'WinPlayMedia', 'WinSaveDialog', 'WinScrollBar', 'WinSelectDialog',
|
| 127 |
+
'write', 'WriteImage', 'writes', 'WSection',
|
| 128 |
+
'WSync'), prefix=r'\b', suffix=r'\b'),
|
| 129 |
+
Name.Function),
|
| 130 |
+
include('numbers'),
|
| 131 |
+
(r'<@|<<@|>@|>>@|\.>|->|===|~===|\*\*|\+\+|--|\.|~==|~=|<=|>=|==|'
|
| 132 |
+
r'=|<<=|<<|>>=|>>|:=:|:=|->|<->|\+:=|\|', Operator),
|
| 133 |
+
(r'"(?:[^\\"]|\\.)*"', String),
|
| 134 |
+
(r"'(?:[^\\']|\\.)*'", String.Character),
|
| 135 |
+
(r'[*<>+=/&!?@~\\-]', Operator),
|
| 136 |
+
(r'\^', Operator),
|
| 137 |
+
(r'(\w+)(\s*|[(,])', bygroups(Name, using(this))),
|
| 138 |
+
(r"[\[\]]", Punctuation),
|
| 139 |
+
(r"<>|=>|[()|:;,.'`{}%&?]", Punctuation),
|
| 140 |
+
(r'\n+', Text),
|
| 141 |
+
],
|
| 142 |
+
'numbers': [
|
| 143 |
+
(r'\b([+-]?([2-9]|[12][0-9]|3[0-6])[rR][0-9a-zA-Z]+)\b', Number.Hex),
|
| 144 |
+
(r'[+-]?[0-9]*\.([0-9]*)([Ee][+-]?[0-9]*)?', Number.Float),
|
| 145 |
+
(r'\b([+-]?[0-9]+[KMGTPkmgtp]?)\b', Number.Integer),
|
| 146 |
+
],
|
| 147 |
+
'subprogram': [
|
| 148 |
+
(r'\(', Punctuation, ('#pop', 'formal_part')),
|
| 149 |
+
(r';', Punctuation, '#pop'),
|
| 150 |
+
(r'"[^"]+"|\w+', Name.Function),
|
| 151 |
+
include('root'),
|
| 152 |
+
],
|
| 153 |
+
'type_def': [
|
| 154 |
+
(r'\(', Punctuation, 'formal_part'),
|
| 155 |
+
],
|
| 156 |
+
'formal_part': [
|
| 157 |
+
(r'\)', Punctuation, '#pop'),
|
| 158 |
+
(r'\w+', Name.Variable),
|
| 159 |
+
(r',', Punctuation),
|
| 160 |
+
(r'(:string|:integer|:real)\b', Keyword.Reserved),
|
| 161 |
+
include('root'),
|
| 162 |
+
],
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class IconLexer(RegexLexer):
|
| 167 |
+
"""
|
| 168 |
+
Lexer for Icon.
|
| 169 |
+
"""
|
| 170 |
+
name = 'Icon'
|
| 171 |
+
aliases = ['icon']
|
| 172 |
+
filenames = ['*.icon', '*.ICON']
|
| 173 |
+
mimetypes = []
|
| 174 |
+
url = 'https://www2.cs.arizona.edu/icon'
|
| 175 |
+
version_added = '1.6'
|
| 176 |
+
|
| 177 |
+
flags = re.MULTILINE
|
| 178 |
+
|
| 179 |
+
tokens = {
|
| 180 |
+
'root': [
|
| 181 |
+
(r'[^\S\n]+', Text),
|
| 182 |
+
(r'#.*?\n', Comment.Single),
|
| 183 |
+
(r'[^\S\n]+', Text),
|
| 184 |
+
(r'class|method|procedure', Keyword.Declaration, 'subprogram'),
|
| 185 |
+
(r'(record)(\s+)(\w+)',
|
| 186 |
+
bygroups(Keyword.Declaration, Text, Keyword.Type), 'type_def'),
|
| 187 |
+
(r'(#line|\$C|\$Cend|\$define|\$else|\$endif|\$error|\$ifdef|'
|
| 188 |
+
r'\$ifndef|\$include|\$line|\$undef)\b', Keyword.PreProc),
|
| 189 |
+
(r'(&null|&fail)\b', Keyword.Constant),
|
| 190 |
+
(r'&allocated|&ascii|&clock|&collections|&column|&col|&control|'
|
| 191 |
+
r'&cset|¤t|&dateline|&date|&digits|&dump|'
|
| 192 |
+
r'&errno|&errornumber|&errortext|&errorvalue|&error|&errout|'
|
| 193 |
+
r'&eventcode|&eventvalue|&eventsource|&e|'
|
| 194 |
+
r'&features|&file|&host|&input|&interval|&lcase|&letters|'
|
| 195 |
+
r'&level|&line|&ldrag|&lpress|&lrelease|'
|
| 196 |
+
r'&main|&mdrag|&meta|&mpress|&mrelease|&now|&output|'
|
| 197 |
+
r'&phi|&pick|&pi|&pos|&progname|'
|
| 198 |
+
r'&random|&rdrag|®ions|&resize|&row|&rpress|&rrelease|'
|
| 199 |
+
r'&shift|&source|&storage|&subject|'
|
| 200 |
+
r'&time|&trace|&ucase|&version|'
|
| 201 |
+
r'&window|&x|&y', Keyword.Reserved),
|
| 202 |
+
(r'(by|of|not|to)\b', Keyword.Reserved),
|
| 203 |
+
(r'(global|local|static)\b', Keyword.Reserved),
|
| 204 |
+
(r'link', Keyword.Declaration),
|
| 205 |
+
(words((
|
| 206 |
+
'break', 'case', 'create', 'default', 'end', 'all',
|
| 207 |
+
'do', 'else', 'every', 'fail', 'if', 'initial',
|
| 208 |
+
'invocable', 'next',
|
| 209 |
+
'repeat', 'return', 'suspend',
|
| 210 |
+
'then', 'until', 'while'), prefix=r'\b', suffix=r'\b'),
|
| 211 |
+
Keyword.Reserved),
|
| 212 |
+
(words((
|
| 213 |
+
'abs', 'acos', 'Active', 'Alert', 'any',
|
| 214 |
+
'args', 'array', 'asin', 'atan', 'atanh', 'Attrib',
|
| 215 |
+
'bal', 'Bg',
|
| 216 |
+
'callout', 'center', 'char', 'chdir', 'chmod', 'chown', 'chroot',
|
| 217 |
+
'Clip', 'Clone', 'close', 'cofail', 'collect',
|
| 218 |
+
'Color', 'ColorValue', 'condvar', 'copy',
|
| 219 |
+
'CopyArea', 'cos', 'Couple', 'crypt', 'cset', 'ctime',
|
| 220 |
+
'delay', 'delete', 'detab', 'display', 'DrawArc',
|
| 221 |
+
'DrawCircle', 'DrawCube', 'DrawCurve', 'DrawCylinder',
|
| 222 |
+
'DrawDisk', 'DrawImage', 'DrawLine', 'DrawPoint', 'DrawPolygon',
|
| 223 |
+
'DrawRectangle', 'DrawSegment', 'DrawSphere', 'DrawString',
|
| 224 |
+
'DrawTorus', 'dtor',
|
| 225 |
+
'entab', 'EraseArea', 'errorclear', 'Event', 'eventmask',
|
| 226 |
+
'EvGet', 'EvSend', 'exec', 'exit', 'exp', 'Eye',
|
| 227 |
+
'fcntl', 'fdup', 'fetch', 'Fg', 'fieldnames',
|
| 228 |
+
'FillArc', 'FillCircle', 'FillPolygon',
|
| 229 |
+
'FillRectangle', 'find', 'flock', 'flush', 'Font',
|
| 230 |
+
'FreeColor', 'FreeSpace', 'function',
|
| 231 |
+
'get', 'getch', 'getche', 'getenv',
|
| 232 |
+
'GetSpace', 'gettimeofday',
|
| 233 |
+
'getuid', 'globalnames', 'GotoRC', 'GotoXY', 'gtime', 'hardlink',
|
| 234 |
+
'iand', 'icom', 'IdentityMatrix', 'image', 'InPort', 'insert',
|
| 235 |
+
'Int86', 'integer', 'ioctl', 'ior', 'ishift', 'istate', 'ixor',
|
| 236 |
+
'kbhit', 'key', 'keyword', 'kill',
|
| 237 |
+
'left', 'Len', 'list', 'load', 'loadfunc', 'localnames',
|
| 238 |
+
'lock', 'log', 'Lower', 'lstat',
|
| 239 |
+
'many', 'map', 'match', 'MatrixMode', 'max', 'member',
|
| 240 |
+
'membernames', 'methodnames', 'methods', 'min', 'mkdir', 'move',
|
| 241 |
+
'MultMatrix', 'mutex',
|
| 242 |
+
'name', 'NewColor', 'Normals', 'numeric',
|
| 243 |
+
'open', 'opencl', 'oprec', 'ord', 'OutPort',
|
| 244 |
+
'PaletteChars', 'PaletteColor', 'PaletteKey', 'paramnames',
|
| 245 |
+
'parent', 'Pattern', 'Peek', 'Pending', 'pipe', 'Pixel',
|
| 246 |
+
'Poke', 'pop', 'PopMatrix', 'Pos', 'pos',
|
| 247 |
+
'proc', 'pull', 'push', 'PushMatrix', 'PushRotate', 'PushScale',
|
| 248 |
+
'PushTranslate', 'put',
|
| 249 |
+
'QueryPointer',
|
| 250 |
+
'Raise', 'read', 'ReadImage', 'readlink', 'reads', 'ready',
|
| 251 |
+
'real', 'receive', 'Refresh', 'Rem', 'remove', 'rename',
|
| 252 |
+
'repl', 'reverse', 'right', 'rmdir', 'Rotate', 'Rpos',
|
| 253 |
+
'rtod', 'runerr',
|
| 254 |
+
'save', 'Scale', 'seek', 'select', 'send', 'seq',
|
| 255 |
+
'serial', 'set', 'setenv',
|
| 256 |
+
'setuid', 'signal', 'sin', 'sort', 'sortf',
|
| 257 |
+
'spawn', 'sql', 'sqrt', 'stat', 'staticnames', 'stop',
|
| 258 |
+
'string', 'structure', 'Swi',
|
| 259 |
+
'symlink', 'sys_errstr', 'system', 'syswrite',
|
| 260 |
+
'tab', 'table', 'tan',
|
| 261 |
+
'Texcoord', 'Texture', 'TextWidth', 'Translate',
|
| 262 |
+
'trap', 'trim', 'truncate', 'trylock', 'type',
|
| 263 |
+
'umask', 'Uncouple', 'unlock', 'upto', 'utime',
|
| 264 |
+
'variable',
|
| 265 |
+
'wait', 'WAttrib', 'WDefault', 'WFlush', 'where',
|
| 266 |
+
'WinAssociate', 'WinButton', 'WinColorDialog', 'WindowContents',
|
| 267 |
+
'WinEditRegion', 'WinFontDialog', 'WinMenuBar', 'WinOpenDialog',
|
| 268 |
+
'WinPlayMedia', 'WinSaveDialog', 'WinScrollBar', 'WinSelectDialog',
|
| 269 |
+
'write', 'WriteImage', 'writes', 'WSection',
|
| 270 |
+
'WSync'), prefix=r'\b', suffix=r'\b'),
|
| 271 |
+
Name.Function),
|
| 272 |
+
include('numbers'),
|
| 273 |
+
(r'===|~===|\*\*|\+\+|--|\.|==|~==|<=|>=|=|~=|<<=|<<|>>=|>>|'
|
| 274 |
+
r':=:|:=|<->|<-|\+:=|\|\||\|', Operator),
|
| 275 |
+
(r'"(?:[^\\"]|\\.)*"', String),
|
| 276 |
+
(r"'(?:[^\\']|\\.)*'", String.Character),
|
| 277 |
+
(r'[*<>+=/&!?@~\\-]', Operator),
|
| 278 |
+
(r'(\w+)(\s*|[(,])', bygroups(Name, using(this))),
|
| 279 |
+
(r"[\[\]]", Punctuation),
|
| 280 |
+
(r"<>|=>|[()|:;,.'`{}%\^&?]", Punctuation),
|
| 281 |
+
(r'\n+', Text),
|
| 282 |
+
],
|
| 283 |
+
'numbers': [
|
| 284 |
+
(r'\b([+-]?([2-9]|[12][0-9]|3[0-6])[rR][0-9a-zA-Z]+)\b', Number.Hex),
|
| 285 |
+
(r'[+-]?[0-9]*\.([0-9]*)([Ee][+-]?[0-9]*)?', Number.Float),
|
| 286 |
+
(r'\b([+-]?[0-9]+[KMGTPkmgtp]?)\b', Number.Integer),
|
| 287 |
+
],
|
| 288 |
+
'subprogram': [
|
| 289 |
+
(r'\(', Punctuation, ('#pop', 'formal_part')),
|
| 290 |
+
(r';', Punctuation, '#pop'),
|
| 291 |
+
(r'"[^"]+"|\w+', Name.Function),
|
| 292 |
+
include('root'),
|
| 293 |
+
],
|
| 294 |
+
'type_def': [
|
| 295 |
+
(r'\(', Punctuation, 'formal_part'),
|
| 296 |
+
],
|
| 297 |
+
'formal_part': [
|
| 298 |
+
(r'\)', Punctuation, '#pop'),
|
| 299 |
+
(r'\w+', Name.Variable),
|
| 300 |
+
(r',', Punctuation),
|
| 301 |
+
(r'(:string|:integer|:real)\b', Keyword.Reserved),
|
| 302 |
+
include('root'),
|
| 303 |
+
],
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class UcodeLexer(RegexLexer):
|
| 308 |
+
"""
|
| 309 |
+
Lexer for Icon ucode files.
|
| 310 |
+
"""
|
| 311 |
+
name = 'ucode'
|
| 312 |
+
aliases = ['ucode']
|
| 313 |
+
filenames = ['*.u', '*.u1', '*.u2']
|
| 314 |
+
mimetypes = []
|
| 315 |
+
url = 'http://www.unicon.org'
|
| 316 |
+
version_added = '2.4'
|
| 317 |
+
|
| 318 |
+
flags = re.MULTILINE
|
| 319 |
+
|
| 320 |
+
tokens = {
|
| 321 |
+
'root': [
|
| 322 |
+
(r'(#.*\n)', Comment),
|
| 323 |
+
(words((
|
| 324 |
+
'con', 'declend', 'end',
|
| 325 |
+
'global',
|
| 326 |
+
'impl', 'invocable',
|
| 327 |
+
'lab', 'link', 'local',
|
| 328 |
+
'record',
|
| 329 |
+
'uid', 'unions',
|
| 330 |
+
'version'),
|
| 331 |
+
prefix=r'\b', suffix=r'\b'),
|
| 332 |
+
Name.Function),
|
| 333 |
+
(words((
|
| 334 |
+
'colm', 'filen', 'line', 'synt'),
|
| 335 |
+
prefix=r'\b', suffix=r'\b'),
|
| 336 |
+
Comment),
|
| 337 |
+
(words((
|
| 338 |
+
'asgn',
|
| 339 |
+
'bang', 'bscan',
|
| 340 |
+
'cat', 'ccase', 'chfail',
|
| 341 |
+
'coact', 'cofail', 'compl',
|
| 342 |
+
'coret', 'create', 'cset',
|
| 343 |
+
'diff', 'div', 'dup',
|
| 344 |
+
'efail', 'einit', 'end', 'eqv', 'eret',
|
| 345 |
+
'error', 'escan', 'esusp',
|
| 346 |
+
'field',
|
| 347 |
+
'goto',
|
| 348 |
+
'init', 'int', 'inter',
|
| 349 |
+
'invoke',
|
| 350 |
+
'keywd',
|
| 351 |
+
'lconcat', 'lexeq', 'lexge',
|
| 352 |
+
'lexgt', 'lexle', 'lexlt', 'lexne',
|
| 353 |
+
'limit', 'llist', 'lsusp',
|
| 354 |
+
'mark', 'mark0', 'minus', 'mod', 'mult',
|
| 355 |
+
'neg', 'neqv', 'nonnull', 'noop', 'null',
|
| 356 |
+
'number', 'numeq', 'numge', 'numgt',
|
| 357 |
+
'numle', 'numlt', 'numne',
|
| 358 |
+
'pfail', 'plus', 'pnull', 'pop', 'power',
|
| 359 |
+
'pret', 'proc', 'psusp', 'push1', 'pushn1',
|
| 360 |
+
'random', 'rasgn', 'rcv', 'rcvbk', 'real',
|
| 361 |
+
'refresh', 'rswap',
|
| 362 |
+
'sdup', 'sect', 'size', 'snd', 'sndbk',
|
| 363 |
+
'str', 'subsc', 'swap',
|
| 364 |
+
'tabmat', 'tally', 'toby', 'trace',
|
| 365 |
+
'unmark',
|
| 366 |
+
'value', 'var'), prefix=r'\b', suffix=r'\b'),
|
| 367 |
+
Keyword.Declaration),
|
| 368 |
+
(words((
|
| 369 |
+
'any',
|
| 370 |
+
'case',
|
| 371 |
+
'endcase', 'endevery', 'endif',
|
| 372 |
+
'endifelse', 'endrepeat', 'endsuspend',
|
| 373 |
+
'enduntil', 'endwhile', 'every',
|
| 374 |
+
'if', 'ifelse',
|
| 375 |
+
'repeat',
|
| 376 |
+
'suspend',
|
| 377 |
+
'until',
|
| 378 |
+
'while'),
|
| 379 |
+
prefix=r'\b', suffix=r'\b'),
|
| 380 |
+
Name.Constant),
|
| 381 |
+
(r'\d+(\s*|\.$|$)', Number.Integer),
|
| 382 |
+
(r'[+-]?\d*\.\d+(E[-+]?\d+)?', Number.Float),
|
| 383 |
+
(r'[+-]?\d+\.\d*(E[-+]?\d+)?', Number.Float),
|
| 384 |
+
(r"(<>|=>|[()|:;,.'`]|[{}]|[%^]|[&?])", Punctuation),
|
| 385 |
+
(r'\s+\b', Text),
|
| 386 |
+
(r'[\w-]+', Text),
|
| 387 |
+
],
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
def analyse_text(text):
|
| 391 |
+
"""endsuspend and endrepeat are unique to this language, and
|
| 392 |
+
\\self, /self doesn't seem to get used anywhere else either."""
|
| 393 |
+
result = 0
|
| 394 |
+
|
| 395 |
+
if 'endsuspend' in text:
|
| 396 |
+
result += 0.1
|
| 397 |
+
|
| 398 |
+
if 'endrepeat' in text:
|
| 399 |
+
result += 0.1
|
| 400 |
+
|
| 401 |
+
if ':=' in text:
|
| 402 |
+
result += 0.01
|
| 403 |
+
|
| 404 |
+
if 'procedure' in text and 'end' in text:
|
| 405 |
+
result += 0.01
|
| 406 |
+
|
| 407 |
+
# This seems quite unique to unicon -- doesn't appear in any other
|
| 408 |
+
# example source we have (A quick search reveals that \SELF appears in
|
| 409 |
+
# Perl/Raku code)
|
| 410 |
+
if r'\self' in text and r'/self' in text:
|
| 411 |
+
result += 0.5
|
| 412 |
+
|
| 413 |
+
return result
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/urbi.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.urbi
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for UrbiScript 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 ExtendedRegexLexer, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['UrbiscriptLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class UrbiscriptLexer(ExtendedRegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For UrbiScript source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'UrbiScript'
|
| 26 |
+
aliases = ['urbiscript']
|
| 27 |
+
filenames = ['*.u']
|
| 28 |
+
mimetypes = ['application/x-urbiscript']
|
| 29 |
+
url = 'https://github.com/urbiforge/urbi'
|
| 30 |
+
version_added = '1.5'
|
| 31 |
+
|
| 32 |
+
flags = re.DOTALL
|
| 33 |
+
|
| 34 |
+
# TODO
|
| 35 |
+
# - handle Experimental and deprecated tags with specific tokens
|
| 36 |
+
# - handle Angles and Durations with specific tokens
|
| 37 |
+
|
| 38 |
+
def blob_callback(lexer, match, ctx):
|
| 39 |
+
text_before_blob = match.group(1)
|
| 40 |
+
blob_start = match.group(2)
|
| 41 |
+
blob_size_str = match.group(3)
|
| 42 |
+
blob_size = int(blob_size_str)
|
| 43 |
+
yield match.start(), String, text_before_blob
|
| 44 |
+
ctx.pos += len(text_before_blob)
|
| 45 |
+
|
| 46 |
+
# if blob size doesn't match blob format (example : "\B(2)(aaa)")
|
| 47 |
+
# yield blob as a string
|
| 48 |
+
if ctx.text[match.end() + blob_size] != ")":
|
| 49 |
+
result = "\\B(" + blob_size_str + ")("
|
| 50 |
+
yield match.start(), String, result
|
| 51 |
+
ctx.pos += len(result)
|
| 52 |
+
return
|
| 53 |
+
|
| 54 |
+
# if blob is well formatted, yield as Escape
|
| 55 |
+
blob_text = blob_start + ctx.text[match.end():match.end()+blob_size] + ")"
|
| 56 |
+
yield match.start(), String.Escape, blob_text
|
| 57 |
+
ctx.pos = match.end() + blob_size + 1 # +1 is the ending ")"
|
| 58 |
+
|
| 59 |
+
tokens = {
|
| 60 |
+
'root': [
|
| 61 |
+
(r'\s+', Text),
|
| 62 |
+
# comments
|
| 63 |
+
(r'//.*?\n', Comment),
|
| 64 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 65 |
+
(r'(every|for|loop|while)(?:;|&|\||,)', Keyword),
|
| 66 |
+
(words((
|
| 67 |
+
'assert', 'at', 'break', 'case', 'catch', 'closure', 'compl',
|
| 68 |
+
'continue', 'default', 'else', 'enum', 'every', 'external',
|
| 69 |
+
'finally', 'for', 'freezeif', 'if', 'new', 'onleave', 'return',
|
| 70 |
+
'stopif', 'switch', 'this', 'throw', 'timeout', 'try',
|
| 71 |
+
'waituntil', 'whenever', 'while'), suffix=r'\b'),
|
| 72 |
+
Keyword),
|
| 73 |
+
(words((
|
| 74 |
+
'asm', 'auto', 'bool', 'char', 'const_cast', 'delete', 'double',
|
| 75 |
+
'dynamic_cast', 'explicit', 'export', 'extern', 'float', 'friend',
|
| 76 |
+
'goto', 'inline', 'int', 'long', 'mutable', 'namespace', 'register',
|
| 77 |
+
'reinterpret_cast', 'short', 'signed', 'sizeof', 'static_cast',
|
| 78 |
+
'struct', 'template', 'typedef', 'typeid', 'typename', 'union',
|
| 79 |
+
'unsigned', 'using', 'virtual', 'volatile', 'wchar_t'), suffix=r'\b'),
|
| 80 |
+
Keyword.Reserved),
|
| 81 |
+
# deprecated keywords, use a meaningful token when available
|
| 82 |
+
(r'(emit|foreach|internal|loopn|static)\b', Keyword),
|
| 83 |
+
# ignored keywords, use a meaningful token when available
|
| 84 |
+
(r'(private|protected|public)\b', Keyword),
|
| 85 |
+
(r'(var|do|const|function|class)\b', Keyword.Declaration),
|
| 86 |
+
(r'(true|false|nil|void)\b', Keyword.Constant),
|
| 87 |
+
(words((
|
| 88 |
+
'Barrier', 'Binary', 'Boolean', 'CallMessage', 'Channel', 'Code',
|
| 89 |
+
'Comparable', 'Container', 'Control', 'Date', 'Dictionary', 'Directory',
|
| 90 |
+
'Duration', 'Enumeration', 'Event', 'Exception', 'Executable', 'File',
|
| 91 |
+
'Finalizable', 'Float', 'FormatInfo', 'Formatter', 'Global', 'Group',
|
| 92 |
+
'Hash', 'InputStream', 'IoService', 'Job', 'Kernel', 'Lazy', 'List',
|
| 93 |
+
'Loadable', 'Lobby', 'Location', 'Logger', 'Math', 'Mutex', 'nil',
|
| 94 |
+
'Object', 'Orderable', 'OutputStream', 'Pair', 'Path', 'Pattern',
|
| 95 |
+
'Position', 'Primitive', 'Process', 'Profile', 'PseudoLazy', 'PubSub',
|
| 96 |
+
'RangeIterable', 'Regexp', 'Semaphore', 'Server', 'Singleton', 'Socket',
|
| 97 |
+
'StackFrame', 'Stream', 'String', 'System', 'Tag', 'Timeout',
|
| 98 |
+
'Traceable', 'TrajectoryGenerator', 'Triplet', 'Tuple', 'UObject',
|
| 99 |
+
'UValue', 'UVar'), suffix=r'\b'),
|
| 100 |
+
Name.Builtin),
|
| 101 |
+
(r'(?:this)\b', Name.Builtin.Pseudo),
|
| 102 |
+
# don't match single | and &
|
| 103 |
+
(r'(?:[-=+*%/<>~^:]+|\.&?|\|\||&&)', Operator),
|
| 104 |
+
(r'(?:and_eq|and|bitand|bitor|in|not|not_eq|or_eq|or|xor_eq|xor)\b',
|
| 105 |
+
Operator.Word),
|
| 106 |
+
(r'[{}\[\]()]+', Punctuation),
|
| 107 |
+
(r'(?:;|\||,|&|\?|!)+', Punctuation),
|
| 108 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 109 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 110 |
+
# Float, Integer, Angle and Duration
|
| 111 |
+
(r'(?:[0-9]+(?:(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)?'
|
| 112 |
+
r'((?:rad|deg|grad)|(?:ms|s|min|h|d))?)\b', Number.Float),
|
| 113 |
+
# handle binary blob in strings
|
| 114 |
+
(r'"', String.Double, "string.double"),
|
| 115 |
+
(r"'", String.Single, "string.single"),
|
| 116 |
+
],
|
| 117 |
+
'string.double': [
|
| 118 |
+
(r'((?:\\\\|\\"|[^"])*?)(\\B\((\d+)\)\()', blob_callback),
|
| 119 |
+
(r'(\\\\|\\[^\\]|[^"\\])*?"', String.Double, '#pop'),
|
| 120 |
+
],
|
| 121 |
+
'string.single': [
|
| 122 |
+
(r"((?:\\\\|\\'|[^'])*?)(\\B\((\d+)\)\()", blob_callback),
|
| 123 |
+
(r"(\\\\|\\[^\\]|[^'\\])*?'", String.Single, '#pop'),
|
| 124 |
+
],
|
| 125 |
+
# from http://pygments.org/docs/lexerdevelopment/#changing-states
|
| 126 |
+
'comment': [
|
| 127 |
+
(r'[^*/]', Comment.Multiline),
|
| 128 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 129 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 130 |
+
(r'[*/]', Comment.Multiline),
|
| 131 |
+
]
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
def analyse_text(text):
|
| 135 |
+
"""This is fairly similar to C and others, but freezeif and
|
| 136 |
+
waituntil are unique keywords."""
|
| 137 |
+
result = 0
|
| 138 |
+
|
| 139 |
+
if 'freezeif' in text:
|
| 140 |
+
result += 0.05
|
| 141 |
+
|
| 142 |
+
if 'waituntil' in text:
|
| 143 |
+
result += 0.05
|
| 144 |
+
|
| 145 |
+
return result
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/usd.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.usd
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
The module that parses Pixar's Universal Scene Description 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 RegexLexer, bygroups
|
| 12 |
+
from pygments.lexer import words as words_
|
| 13 |
+
from pygments.lexers._usd_builtins import COMMON_ATTRIBUTES, KEYWORDS, \
|
| 14 |
+
OPERATORS, SPECIAL_NAMES, TYPES
|
| 15 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 16 |
+
Punctuation, String, Text, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ["UsdLexer"]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def _keywords(words, type_):
|
| 22 |
+
return [(words_(words, prefix=r"\b", suffix=r"\b"), type_)]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_TYPE = r"(\w+(?:\[\])?)"
|
| 26 |
+
_BASE_ATTRIBUTE = r"(\w+(?:\:\w+)*)(?:(\.)(timeSamples))?"
|
| 27 |
+
_WHITESPACE = r"([ \t]+)"
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class UsdLexer(RegexLexer):
|
| 31 |
+
"""
|
| 32 |
+
A lexer that parses Pixar's Universal Scene Description file format.
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
name = "USD"
|
| 36 |
+
url = 'https://graphics.pixar.com/usd/release/index.html'
|
| 37 |
+
aliases = ["usd", "usda"]
|
| 38 |
+
filenames = ["*.usd", "*.usda"]
|
| 39 |
+
version_added = '2.6'
|
| 40 |
+
|
| 41 |
+
tokens = {
|
| 42 |
+
"root": [
|
| 43 |
+
(rf"(custom){_WHITESPACE}(uniform)(\s+){_TYPE}(\s+){_BASE_ATTRIBUTE}(\s*)(=)",
|
| 44 |
+
bygroups(Keyword.Token, Whitespace, Keyword.Token, Whitespace,
|
| 45 |
+
Keyword.Type, Whitespace, Name.Attribute, Text,
|
| 46 |
+
Name.Keyword.Tokens, Whitespace, Operator)),
|
| 47 |
+
(rf"(custom){_WHITESPACE}{_TYPE}(\s+){_BASE_ATTRIBUTE}(\s*)(=)",
|
| 48 |
+
bygroups(Keyword.Token, Whitespace, Keyword.Type, Whitespace,
|
| 49 |
+
Name.Attribute, Text, Name.Keyword.Tokens, Whitespace,
|
| 50 |
+
Operator)),
|
| 51 |
+
(rf"(uniform){_WHITESPACE}{_TYPE}(\s+){_BASE_ATTRIBUTE}(\s*)(=)",
|
| 52 |
+
bygroups(Keyword.Token, Whitespace, Keyword.Type, Whitespace,
|
| 53 |
+
Name.Attribute, Text, Name.Keyword.Tokens, Whitespace,
|
| 54 |
+
Operator)),
|
| 55 |
+
(rf"{_TYPE}{_WHITESPACE}{_BASE_ATTRIBUTE}(\s*)(=)",
|
| 56 |
+
bygroups(Keyword.Type, Whitespace, Name.Attribute, Text,
|
| 57 |
+
Name.Keyword.Tokens, Whitespace, Operator)),
|
| 58 |
+
] +
|
| 59 |
+
_keywords(KEYWORDS, Keyword.Tokens) +
|
| 60 |
+
_keywords(SPECIAL_NAMES, Name.Builtins) +
|
| 61 |
+
_keywords(COMMON_ATTRIBUTES, Name.Attribute) +
|
| 62 |
+
[(r"\b\w+:[\w:]+\b", Name.Attribute)] +
|
| 63 |
+
_keywords(OPERATORS, Operator) + # more attributes
|
| 64 |
+
[(type_ + r"\[\]", Keyword.Type) for type_ in TYPES] +
|
| 65 |
+
_keywords(TYPES, Keyword.Type) +
|
| 66 |
+
[
|
| 67 |
+
(r"[(){}\[\]]", Punctuation),
|
| 68 |
+
("#.*?$", Comment.Single),
|
| 69 |
+
(",", Punctuation),
|
| 70 |
+
(";", Punctuation), # ";"s are allowed to combine separate metadata lines
|
| 71 |
+
("=", Operator),
|
| 72 |
+
(r"[-]*([0-9]*[.])?[0-9]+(?:e[+-]*\d+)?", Number),
|
| 73 |
+
(r"'''(?:.|\n)*?'''", String),
|
| 74 |
+
(r'"""(?:.|\n)*?"""', String),
|
| 75 |
+
(r"'.*?'", String),
|
| 76 |
+
(r'".*?"', String),
|
| 77 |
+
(r"<(\.\./)*([\w/]+|[\w/]+\.\w+[\w:]*)>", Name.Namespace),
|
| 78 |
+
(r"@.*?@", String.Interpol),
|
| 79 |
+
(r'\(.*"[.\\n]*".*\)', String.Doc),
|
| 80 |
+
(r"\A#usda .+$", Comment.Hashbang),
|
| 81 |
+
(r"\s+", Whitespace),
|
| 82 |
+
(r"\w+", Text),
|
| 83 |
+
(r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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.varnish
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Varnish configuration
|
| 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, using, this, \
|
| 12 |
+
inherit, words
|
| 13 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation, Literal, Whitespace
|
| 15 |
+
|
| 16 |
+
__all__ = ['VCLLexer', 'VCLSnippetLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class VCLLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For Varnish Configuration Language (VCL).
|
| 22 |
+
"""
|
| 23 |
+
name = 'VCL'
|
| 24 |
+
aliases = ['vcl']
|
| 25 |
+
filenames = ['*.vcl']
|
| 26 |
+
mimetypes = ['text/x-vclsrc']
|
| 27 |
+
url = 'https://www.varnish-software.com/developers/tutorials/varnish-configuration-language-vcl'
|
| 28 |
+
version_added = '2.2'
|
| 29 |
+
|
| 30 |
+
def analyse_text(text):
|
| 31 |
+
# If the very first line is 'vcl 4.0;' it's pretty much guaranteed
|
| 32 |
+
# that this is VCL
|
| 33 |
+
if text.startswith('vcl 4.0;'):
|
| 34 |
+
return 1.0
|
| 35 |
+
# Skip over comments and blank lines
|
| 36 |
+
# This is accurate enough that returning 0.9 is reasonable.
|
| 37 |
+
# Almost no VCL files start without some comments.
|
| 38 |
+
elif '\nvcl 4.0;' in text[:1000]:
|
| 39 |
+
return 0.9
|
| 40 |
+
|
| 41 |
+
tokens = {
|
| 42 |
+
'probe': [
|
| 43 |
+
include('whitespace'),
|
| 44 |
+
include('comments'),
|
| 45 |
+
(r'(\.\w+)(\s*=\s*)([^;]*)(;)',
|
| 46 |
+
bygroups(Name.Attribute, Operator, using(this), Punctuation)),
|
| 47 |
+
(r'\}', Punctuation, '#pop'),
|
| 48 |
+
],
|
| 49 |
+
'acl': [
|
| 50 |
+
include('whitespace'),
|
| 51 |
+
include('comments'),
|
| 52 |
+
(r'[!/]+', Operator),
|
| 53 |
+
(r';', Punctuation),
|
| 54 |
+
(r'\d+', Number),
|
| 55 |
+
(r'\}', Punctuation, '#pop'),
|
| 56 |
+
],
|
| 57 |
+
'backend': [
|
| 58 |
+
include('whitespace'),
|
| 59 |
+
(r'(\.probe)(\s*=\s*)(\w+)(;)',
|
| 60 |
+
bygroups(Name.Attribute, Operator, Name.Variable.Global, Punctuation)),
|
| 61 |
+
(r'(\.probe)(\s*=\s*)(\{)',
|
| 62 |
+
bygroups(Name.Attribute, Operator, Punctuation), 'probe'),
|
| 63 |
+
(r'(\.\w+\b)(\s*=\s*)([^;\s]*)(\s*;)',
|
| 64 |
+
bygroups(Name.Attribute, Operator, using(this), Punctuation)),
|
| 65 |
+
(r'\{', Punctuation, '#push'),
|
| 66 |
+
(r'\}', Punctuation, '#pop'),
|
| 67 |
+
],
|
| 68 |
+
'statements': [
|
| 69 |
+
(r'(\d\.)?\d+[sdwhmy]', Literal.Date),
|
| 70 |
+
(r'(\d\.)?\d+ms', Literal.Date),
|
| 71 |
+
(r'(vcl_pass|vcl_hash|vcl_hit|vcl_init|vcl_backend_fetch|vcl_pipe|'
|
| 72 |
+
r'vcl_backend_response|vcl_synth|vcl_deliver|vcl_backend_error|'
|
| 73 |
+
r'vcl_fini|vcl_recv|vcl_purge|vcl_miss)\b', Name.Function),
|
| 74 |
+
(r'(pipe|retry|hash|synth|deliver|purge|abandon|lookup|pass|fail|ok|'
|
| 75 |
+
r'miss|fetch|restart)\b', Name.Constant),
|
| 76 |
+
(r'(beresp|obj|resp|req|req_top|bereq)\.http\.[a-zA-Z_-]+\b', Name.Variable),
|
| 77 |
+
(words((
|
| 78 |
+
'obj.status', 'req.hash_always_miss', 'beresp.backend', 'req.esi_level',
|
| 79 |
+
'req.can_gzip', 'beresp.ttl', 'obj.uncacheable', 'req.ttl', 'obj.hits',
|
| 80 |
+
'client.identity', 'req.hash_ignore_busy', 'obj.reason', 'req.xid',
|
| 81 |
+
'req_top.proto', 'beresp.age', 'obj.proto', 'obj.age', 'local.ip',
|
| 82 |
+
'beresp.uncacheable', 'req.method', 'beresp.backend.ip', 'now',
|
| 83 |
+
'obj.grace', 'req.restarts', 'beresp.keep', 'req.proto', 'resp.proto',
|
| 84 |
+
'bereq.xid', 'bereq.between_bytes_timeout', 'req.esi',
|
| 85 |
+
'bereq.first_byte_timeout', 'bereq.method', 'bereq.connect_timeout',
|
| 86 |
+
'beresp.do_gzip', 'resp.status', 'beresp.do_gunzip',
|
| 87 |
+
'beresp.storage_hint', 'resp.is_streaming', 'beresp.do_stream',
|
| 88 |
+
'req_top.method', 'bereq.backend', 'beresp.backend.name', 'beresp.status',
|
| 89 |
+
'req.url', 'obj.keep', 'obj.ttl', 'beresp.reason', 'bereq.retries',
|
| 90 |
+
'resp.reason', 'bereq.url', 'beresp.do_esi', 'beresp.proto', 'client.ip',
|
| 91 |
+
'bereq.proto', 'server.hostname', 'remote.ip', 'req.backend_hint',
|
| 92 |
+
'server.identity', 'req_top.url', 'beresp.grace', 'beresp.was_304',
|
| 93 |
+
'server.ip', 'bereq.uncacheable'), suffix=r'\b'),
|
| 94 |
+
Name.Variable),
|
| 95 |
+
(r'[!%&+*\-,/<.}{>=|~]+', Operator),
|
| 96 |
+
(r'[();]', Punctuation),
|
| 97 |
+
|
| 98 |
+
(r'[,]+', Punctuation),
|
| 99 |
+
(words(('hash_data', 'regsub', 'regsuball', 'if', 'else',
|
| 100 |
+
'elsif', 'elif', 'synth', 'synthetic', 'ban',
|
| 101 |
+
'return', 'set', 'unset', 'import', 'include', 'new',
|
| 102 |
+
'rollback', 'call'), suffix=r'\b'),
|
| 103 |
+
Keyword),
|
| 104 |
+
(r'storage\.\w+\.\w+\b', Name.Variable),
|
| 105 |
+
(words(('true', 'false')), Name.Builtin),
|
| 106 |
+
(r'\d+\b', Number),
|
| 107 |
+
(r'(backend)(\s+\w+)(\s*\{)',
|
| 108 |
+
bygroups(Keyword, Name.Variable.Global, Punctuation), 'backend'),
|
| 109 |
+
(r'(probe\s)(\s*\w+\s)(\{)',
|
| 110 |
+
bygroups(Keyword, Name.Variable.Global, Punctuation), 'probe'),
|
| 111 |
+
(r'(acl\s)(\s*\w+\s)(\{)',
|
| 112 |
+
bygroups(Keyword, Name.Variable.Global, Punctuation), 'acl'),
|
| 113 |
+
(r'(vcl )(4.0)(;)$',
|
| 114 |
+
bygroups(Keyword.Reserved, Name.Constant, Punctuation)),
|
| 115 |
+
(r'(sub\s+)([a-zA-Z]\w*)(\s*\{)',
|
| 116 |
+
bygroups(Keyword, Name.Function, Punctuation)),
|
| 117 |
+
(r'([a-zA-Z_]\w*)'
|
| 118 |
+
r'(\.)'
|
| 119 |
+
r'([a-zA-Z_]\w*)'
|
| 120 |
+
r'(\s*\(.*\))',
|
| 121 |
+
bygroups(Name.Function, Punctuation, Name.Function, using(this))),
|
| 122 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 123 |
+
],
|
| 124 |
+
'comment': [
|
| 125 |
+
(r'[^*/]+', Comment.Multiline),
|
| 126 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 127 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 128 |
+
(r'[*/]', Comment.Multiline),
|
| 129 |
+
],
|
| 130 |
+
'comments': [
|
| 131 |
+
(r'#.*$', Comment),
|
| 132 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 133 |
+
(r'//.*$', Comment),
|
| 134 |
+
],
|
| 135 |
+
'string': [
|
| 136 |
+
(r'"', String, '#pop'),
|
| 137 |
+
(r'[^"\n]+', String), # all other characters
|
| 138 |
+
],
|
| 139 |
+
'multistring': [
|
| 140 |
+
(r'[^"}]', String),
|
| 141 |
+
(r'"\}', String, '#pop'),
|
| 142 |
+
(r'["}]', String),
|
| 143 |
+
],
|
| 144 |
+
'whitespace': [
|
| 145 |
+
(r'L?"', String, 'string'),
|
| 146 |
+
(r'\{"', String, 'multistring'),
|
| 147 |
+
(r'\n', Whitespace),
|
| 148 |
+
(r'\s+', Whitespace),
|
| 149 |
+
(r'\\\n', Text), # line continuation
|
| 150 |
+
],
|
| 151 |
+
'root': [
|
| 152 |
+
include('whitespace'),
|
| 153 |
+
include('comments'),
|
| 154 |
+
include('statements'),
|
| 155 |
+
(r'\s+', Whitespace),
|
| 156 |
+
],
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
class VCLSnippetLexer(VCLLexer):
|
| 161 |
+
"""
|
| 162 |
+
For Varnish Configuration Language snippets.
|
| 163 |
+
"""
|
| 164 |
+
name = 'VCLSnippets'
|
| 165 |
+
aliases = ['vclsnippets', 'vclsnippet']
|
| 166 |
+
mimetypes = ['text/x-vclsnippet']
|
| 167 |
+
filenames = []
|
| 168 |
+
url = 'https://www.varnish-software.com/developers/tutorials/varnish-configuration-language-vcl'
|
| 169 |
+
version_added = '2.2'
|
| 170 |
+
|
| 171 |
+
def analyse_text(text):
|
| 172 |
+
# override method inherited from VCLLexer
|
| 173 |
+
return 0
|
| 174 |
+
|
| 175 |
+
tokens = {
|
| 176 |
+
'snippetspre': [
|
| 177 |
+
(r'\.\.\.+', Comment),
|
| 178 |
+
(r'(bereq|req|req_top|resp|beresp|obj|client|server|local|remote|'
|
| 179 |
+
r'storage)($|\.\*)', Name.Variable),
|
| 180 |
+
],
|
| 181 |
+
'snippetspost': [
|
| 182 |
+
(r'(backend)\b', Keyword.Reserved),
|
| 183 |
+
],
|
| 184 |
+
'root': [
|
| 185 |
+
include('snippetspre'),
|
| 186 |
+
inherit,
|
| 187 |
+
include('snippetspost'),
|
| 188 |
+
],
|
| 189 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/verification.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.verification
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Intermediate Verification Languages (IVLs).
|
| 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
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, Number, \
|
| 13 |
+
Punctuation, Text, Generic
|
| 14 |
+
|
| 15 |
+
__all__ = ['BoogieLexer', 'SilverLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class BoogieLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Boogie source code.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Boogie'
|
| 23 |
+
url = 'https://boogie-docs.readthedocs.io/en/latest/'
|
| 24 |
+
aliases = ['boogie']
|
| 25 |
+
filenames = ['*.bpl']
|
| 26 |
+
version_added = '2.1'
|
| 27 |
+
|
| 28 |
+
tokens = {
|
| 29 |
+
'root': [
|
| 30 |
+
# Whitespace and Comments
|
| 31 |
+
(r'\n', Text),
|
| 32 |
+
(r'\s+', Text),
|
| 33 |
+
(r'\\\n', Text), # line continuation
|
| 34 |
+
(r'//[/!](.*?)\n', Comment.Doc),
|
| 35 |
+
(r'//(.*?)\n', Comment.Single),
|
| 36 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 37 |
+
|
| 38 |
+
(words((
|
| 39 |
+
'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function',
|
| 40 |
+
'forall', 'if', 'invariant', 'modifies', 'procedure', 'requires',
|
| 41 |
+
'then', 'var', 'while'),
|
| 42 |
+
suffix=r'\b'), Keyword),
|
| 43 |
+
(words(('const',), suffix=r'\b'), Keyword.Reserved),
|
| 44 |
+
|
| 45 |
+
(words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type),
|
| 46 |
+
include('numbers'),
|
| 47 |
+
(r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator),
|
| 48 |
+
(r'\{.*?\}', Generic.Emph), #triggers
|
| 49 |
+
(r"([{}():;,.])", Punctuation),
|
| 50 |
+
# Identifier
|
| 51 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 52 |
+
],
|
| 53 |
+
'comment': [
|
| 54 |
+
(r'[^*/]+', Comment.Multiline),
|
| 55 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 56 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 57 |
+
(r'[*/]', Comment.Multiline),
|
| 58 |
+
],
|
| 59 |
+
'numbers': [
|
| 60 |
+
(r'[0-9]+', Number.Integer),
|
| 61 |
+
],
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class SilverLexer(RegexLexer):
|
| 66 |
+
"""
|
| 67 |
+
For Silver source code.
|
| 68 |
+
"""
|
| 69 |
+
name = 'Silver'
|
| 70 |
+
aliases = ['silver']
|
| 71 |
+
filenames = ['*.sil', '*.vpr']
|
| 72 |
+
url = 'https://github.com/viperproject/silver'
|
| 73 |
+
version_added = '2.2'
|
| 74 |
+
|
| 75 |
+
tokens = {
|
| 76 |
+
'root': [
|
| 77 |
+
# Whitespace and Comments
|
| 78 |
+
(r'\n', Text),
|
| 79 |
+
(r'\s+', Text),
|
| 80 |
+
(r'\\\n', Text), # line continuation
|
| 81 |
+
(r'//[/!](.*?)\n', Comment.Doc),
|
| 82 |
+
(r'//(.*?)\n', Comment.Single),
|
| 83 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 84 |
+
|
| 85 |
+
(words((
|
| 86 |
+
'result', 'true', 'false', 'null', 'method', 'function',
|
| 87 |
+
'predicate', 'program', 'domain', 'axiom', 'var', 'returns',
|
| 88 |
+
'field', 'define', 'fold', 'unfold', 'inhale', 'exhale', 'new', 'assert',
|
| 89 |
+
'assume', 'goto', 'while', 'if', 'elseif', 'else', 'fresh',
|
| 90 |
+
'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection',
|
| 91 |
+
'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists',
|
| 92 |
+
'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique',
|
| 93 |
+
'apply', 'package', 'folding', 'label', 'forperm'),
|
| 94 |
+
suffix=r'\b'), Keyword),
|
| 95 |
+
(words(('requires', 'ensures', 'invariant'), suffix=r'\b'), Name.Decorator),
|
| 96 |
+
(words(('Int', 'Perm', 'Bool', 'Ref', 'Rational'), suffix=r'\b'), Keyword.Type),
|
| 97 |
+
include('numbers'),
|
| 98 |
+
(r'[!%&*+=|?:<>/\-\[\]]', Operator),
|
| 99 |
+
(r'\{.*?\}', Generic.Emph), #triggers
|
| 100 |
+
(r'([{}():;,.])', Punctuation),
|
| 101 |
+
# Identifier
|
| 102 |
+
(r'[\w$]\w*', Name),
|
| 103 |
+
],
|
| 104 |
+
'comment': [
|
| 105 |
+
(r'[^*/]+', Comment.Multiline),
|
| 106 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 107 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 108 |
+
(r'[*/]', Comment.Multiline),
|
| 109 |
+
],
|
| 110 |
+
'numbers': [
|
| 111 |
+
(r'[0-9]+', Number.Integer),
|
| 112 |
+
],
|
| 113 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/verifpal.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.verifpal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Verifpal 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, words, bygroups, default
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, String, Punctuation, \
|
| 13 |
+
Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['VerifpalLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class VerifpalLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Verifpal code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Verifpal'
|
| 24 |
+
aliases = ['verifpal']
|
| 25 |
+
filenames = ['*.vp']
|
| 26 |
+
mimetypes = ['text/x-verifpal']
|
| 27 |
+
url = 'https://verifpal.com'
|
| 28 |
+
version_added = '2.16'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'//.*$', Comment.Single),
|
| 33 |
+
(r'(principal)( +)(\w+)( *)(\[)(.*)$', bygroups(Name.Builtin, Whitespace, String, Whitespace, Punctuation, Whitespace)),
|
| 34 |
+
(r'(attacker)( *)(\[)( *)(passive|active)( *)(\])( *)$', bygroups(Name.Builtin, Whitespace, Punctuation, Whitespace, String, Whitespace, Punctuation, Whitespace)),
|
| 35 |
+
(r'(knows)( +)(private|public)( +)', bygroups(Name.Builtin, Whitespace, Keyword.Constant, Whitespace), 'shared'),
|
| 36 |
+
(r'(queries)( +)(\[)', bygroups(Name.Builtin, Whitespace, Punctuation), 'queries'),
|
| 37 |
+
(r'(\w+)( +)(->|→)( *)(\w+)( *)(\:)', bygroups(String, Whitespace, Punctuation, Whitespace, String, Whitespace, Punctuation), 'shared'),
|
| 38 |
+
(words(('generates', 'leaks'), suffix=r'\b'), Name.Builtin, 'shared'),
|
| 39 |
+
(words(( 'phase', 'precondition',), suffix=r'\b'), Name.Builtin),
|
| 40 |
+
(r'[\[\(\)\]\?:=→^,]', Punctuation),
|
| 41 |
+
(r'->', Punctuation),
|
| 42 |
+
(words(('password',), suffix=r'\b'), Keyword.Constant),
|
| 43 |
+
(words(('AEAD_DEC', 'AEAD_ENC', 'ASSERT', 'BLIND', 'CONCAT',
|
| 44 |
+
'DEC', 'ENC', 'G', 'HASH', 'HKDF', 'MAC', 'PKE_DEC',
|
| 45 |
+
'PKE_ENC', 'PW_HASH', 'RINGSIGN', 'RINGSIGNVERIF',
|
| 46 |
+
'SHAMIR_JOIN', 'SHAMIR_SPLIT', 'SIGN', 'SIGNVERIF',
|
| 47 |
+
'SPLIT', 'UNBLIND', '_', 'nil'), suffix=r'\b'),
|
| 48 |
+
Name.Function),
|
| 49 |
+
(r'\s+', Whitespace),
|
| 50 |
+
(r'\w+', Name.Variable),
|
| 51 |
+
],
|
| 52 |
+
'shared': [
|
| 53 |
+
(r'[\^\[\],]', Punctuation),
|
| 54 |
+
(r' +', Whitespace),
|
| 55 |
+
(r'\w+', Name.Variable),
|
| 56 |
+
default('#pop')
|
| 57 |
+
],
|
| 58 |
+
'queries': [
|
| 59 |
+
(r'\s+', Name.Variable),
|
| 60 |
+
(words(('confidentiality?', 'authentication?', 'freshness?',
|
| 61 |
+
'unlinkability?', 'equivalence?'), suffix='( )'),
|
| 62 |
+
bygroups(Keyword.Pseudo, Whitespace), 'shared'),
|
| 63 |
+
default('#pop')
|
| 64 |
+
]
|
| 65 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/vip.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|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yright 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, inherit, words, include
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['VisualPrologLexer', 'VisualPrologGrammarLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class VisualPrologBaseLexer(RegexLexer):
|
| 21 |
+
minorendkw = ('try', 'foreach', 'if')
|
| 22 |
+
minorkwexp = ('and', 'catch', 'do', 'else', 'elseif', 'erroneous', 'externally', 'failure', 'finally', 'foreach', 'if', 'or', 'orelse', 'otherwise', 'then',
|
| 23 |
+
'try', 'div', 'mod', 'rem', 'quot')
|
| 24 |
+
dockw = ('short', 'detail', 'end', 'withdomain')
|
| 25 |
+
tokens = {
|
| 26 |
+
'root': [
|
| 27 |
+
(r'\s+', Whitespace),
|
| 28 |
+
(words(minorendkw, prefix=r'\bend\s+', suffix=r'\b'), Keyword.Minor),
|
| 29 |
+
(r'end', Keyword),
|
| 30 |
+
(words(minorkwexp, suffix=r'\b'), Keyword.Minor),
|
| 31 |
+
(r'0[xo][\da-fA-F_]+', Number),
|
| 32 |
+
(r'((\d[\d_]*)?\.)?\d[\d_]*([eE][\-+]?\d+)?', Number),
|
| 33 |
+
(r'_\w*', Name.Variable.Anonymous),
|
| 34 |
+
(r'[A-Z]\w*', Name.Variable),
|
| 35 |
+
(r'@\w+', Name.Variable),
|
| 36 |
+
(r'[a-z]\w*', Name),
|
| 37 |
+
(r'/\*', Comment, 'comment'),
|
| 38 |
+
(r'\%', Comment, 'commentline'),
|
| 39 |
+
(r'"', String.Symbol, 'string'),
|
| 40 |
+
(r'\'', String.Symbol, 'stringsingle'),
|
| 41 |
+
(r'@"', String.Symbol, 'atstring'),
|
| 42 |
+
(r'[\-+*^/!?<>=~:]+', Operator),
|
| 43 |
+
(r'[$,.[\]|(){}\\]+', Punctuation),
|
| 44 |
+
(r'.', Text),
|
| 45 |
+
],
|
| 46 |
+
'commentdoc': [
|
| 47 |
+
(words(dockw, prefix=r'@', suffix=r'\b'), Comment.Preproc),
|
| 48 |
+
(r'@', Comment),
|
| 49 |
+
],
|
| 50 |
+
'commentline': [
|
| 51 |
+
include('commentdoc'),
|
| 52 |
+
(r'[^@\n]+', Comment),
|
| 53 |
+
(r'$', Comment, '#pop'),
|
| 54 |
+
],
|
| 55 |
+
'comment': [
|
| 56 |
+
include('commentdoc'),
|
| 57 |
+
(r'[^@*/]+', Comment),
|
| 58 |
+
(r'/\*', Comment, '#push'),
|
| 59 |
+
(r'\*/', Comment, '#pop'),
|
| 60 |
+
(r'[*/]', Comment),
|
| 61 |
+
],
|
| 62 |
+
'stringescape': [
|
| 63 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 64 |
+
(r'\\[\'"ntr\\]', String.Escape),
|
| 65 |
+
],
|
| 66 |
+
'stringsingle': [
|
| 67 |
+
include('stringescape'),
|
| 68 |
+
(r'\'', String.Symbol, '#pop'),
|
| 69 |
+
(r'[^\'\\\n]+', String),
|
| 70 |
+
(r'\n', String.Escape.Error, '#pop'),
|
| 71 |
+
],
|
| 72 |
+
'string': [
|
| 73 |
+
include('stringescape'),
|
| 74 |
+
(r'"', String.Symbol, '#pop'),
|
| 75 |
+
(r'[^"\\\n]+', String),
|
| 76 |
+
(r'\n', String.Escape.Error, '#pop'),
|
| 77 |
+
],
|
| 78 |
+
'atstring': [
|
| 79 |
+
(r'""', String.Escape),
|
| 80 |
+
(r'"', String.Symbol, '#pop'),
|
| 81 |
+
(r'[^"]+', String),
|
| 82 |
+
]
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class VisualPrologLexer(VisualPrologBaseLexer):
|
| 87 |
+
"""Lexer for VisualProlog
|
| 88 |
+
"""
|
| 89 |
+
name = 'Visual Prolog'
|
| 90 |
+
url = 'https://www.visual-prolog.com/'
|
| 91 |
+
aliases = ['visualprolog']
|
| 92 |
+
filenames = ['*.pro', '*.cl', '*.i', '*.pack', '*.ph']
|
| 93 |
+
version_added = '2.17'
|
| 94 |
+
|
| 95 |
+
majorkw = ('goal', 'namespace', 'interface', 'class', 'implement', 'where', 'open', 'inherits', 'supports', 'resolve',
|
| 96 |
+
'delegate', 'monitor', 'constants', 'domains', 'predicates', 'constructors', 'properties', 'clauses', 'facts')
|
| 97 |
+
minorkw = ('align', 'anyflow', 'as', 'bitsize', 'determ', 'digits', 'erroneous', 'externally', 'failure', 'from',
|
| 98 |
+
'guard', 'multi', 'nondeterm', 'or', 'orelse', 'otherwise', 'procedure', 'resolve', 'single', 'suspending')
|
| 99 |
+
directivekw = ('bininclude', 'else', 'elseif', 'endif', 'error', 'export', 'externally', 'from', 'grammargenerate',
|
| 100 |
+
'grammarinclude', 'if', 'include', 'message', 'options', 'orrequires', 'requires', 'stringinclude', 'then')
|
| 101 |
+
tokens = {
|
| 102 |
+
'root': [
|
| 103 |
+
(words(minorkw, suffix=r'\b'), Keyword.Minor),
|
| 104 |
+
(words(majorkw, suffix=r'\b'), Keyword),
|
| 105 |
+
(words(directivekw, prefix='#', suffix=r'\b'), Keyword.Directive),
|
| 106 |
+
inherit
|
| 107 |
+
]
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
def analyse_text(text):
|
| 111 |
+
"""Competes with IDL and Prolog on *.pro; div. lisps on*.cl and SwigLexer on *.i"""
|
| 112 |
+
# These are *really* good indicators (and not conflicting with the other languages)
|
| 113 |
+
# end-scope first on line e.g. 'end implement'
|
| 114 |
+
# section keyword alone on line e.g. 'clauses'
|
| 115 |
+
if re.search(r'^\s*(end\s+(interface|class|implement)|(clauses|predicates|domains|facts|constants|properties)\s*$)', text):
|
| 116 |
+
return 0.98
|
| 117 |
+
else:
|
| 118 |
+
return 0
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class VisualPrologGrammarLexer(VisualPrologBaseLexer):
|
| 122 |
+
"""Lexer for VisualProlog grammar
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
name = 'Visual Prolog Grammar'
|
| 126 |
+
url = 'https://www.visual-prolog.com/'
|
| 127 |
+
aliases = ['visualprologgrammar']
|
| 128 |
+
filenames = ['*.vipgrm']
|
| 129 |
+
version_added = '2.17'
|
| 130 |
+
|
| 131 |
+
majorkw = ('open', 'namespace', 'grammar', 'nonterminals',
|
| 132 |
+
'startsymbols', 'terminals', 'rules', 'precedence')
|
| 133 |
+
directivekw = ('bininclude', 'stringinclude')
|
| 134 |
+
tokens = {
|
| 135 |
+
'root': [
|
| 136 |
+
(words(majorkw, suffix=r'\b'), Keyword),
|
| 137 |
+
(words(directivekw, prefix='#', suffix=r'\b'), Keyword.Directive),
|
| 138 |
+
inherit
|
| 139 |
+
]
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
def analyse_text(text):
|
| 143 |
+
"""No competditors (currently)"""
|
| 144 |
+
# These are *really* good indicators
|
| 145 |
+
# end-scope first on line e.g. 'end grammar'
|
| 146 |
+
# section keyword alone on line e.g. 'rules'
|
| 147 |
+
if re.search(r'^\s*(end\s+grammar|(nonterminals|startsymbols|terminals|rules|precedence)\s*$)', text):
|
| 148 |
+
return 0.98
|
| 149 |
+
else:
|
| 150 |
+
return 0
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/vyper.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.vyper
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Vyper Smart Contract 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 (Comment, String, Name, Keyword, Number,
|
| 13 |
+
Operator, Punctuation, Text, Whitespace)
|
| 14 |
+
|
| 15 |
+
__all__ = ['VyperLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class VyperLexer(RegexLexer):
|
| 19 |
+
"""For the Vyper smart contract language.
|
| 20 |
+
"""
|
| 21 |
+
name = 'Vyper'
|
| 22 |
+
aliases = ['vyper']
|
| 23 |
+
filenames = ['*.vy']
|
| 24 |
+
url = "https://vyper.readthedocs.io"
|
| 25 |
+
version_added = '2.17'
|
| 26 |
+
|
| 27 |
+
tokens = {
|
| 28 |
+
'root': [
|
| 29 |
+
# Whitespace
|
| 30 |
+
(r'\s+', Whitespace),
|
| 31 |
+
|
| 32 |
+
# Line continuations
|
| 33 |
+
(r'(\\)(\n|\r\n|\r)', bygroups(Text, Whitespace)),
|
| 34 |
+
|
| 35 |
+
# Comments - inline and multiline
|
| 36 |
+
(r'#.*$', Comment.Single),
|
| 37 |
+
(r'\"\"\"', Comment.Multiline, 'multiline-comment'),
|
| 38 |
+
|
| 39 |
+
# Strings - single and double
|
| 40 |
+
(r"'", String.Single, 'single-string'),
|
| 41 |
+
(r'"', String.Double, 'double-string'),
|
| 42 |
+
|
| 43 |
+
# Functions (working)
|
| 44 |
+
(r'(def)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
|
| 45 |
+
bygroups(Keyword, Whitespace, Name.Function)),
|
| 46 |
+
|
| 47 |
+
# Event and Struct
|
| 48 |
+
(r'(event|struct|interface|log)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
|
| 49 |
+
bygroups(Keyword, Whitespace, Name.Class)),
|
| 50 |
+
|
| 51 |
+
# Imports
|
| 52 |
+
(r'(from)(\s+)(vyper\.\w+)(\s+)(import)(\s+)(\w+)',
|
| 53 |
+
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
|
| 54 |
+
Keyword, Whitespace, Name.Class)),
|
| 55 |
+
|
| 56 |
+
# Numeric Literals
|
| 57 |
+
(r'\b0x[0-9a-fA-F]+\b', Number.Hex),
|
| 58 |
+
(r'\b(\d{1,3}(?:_\d{3})*|\d+)\b', Number.Integer),
|
| 59 |
+
(r'\b\d+\.\d*\b', Number.Float),
|
| 60 |
+
|
| 61 |
+
# Keywords
|
| 62 |
+
(words(('def', 'event', 'pass', 'return', 'for', 'while', 'if', 'elif',
|
| 63 |
+
'else', 'assert', 'raise', 'import', 'in', 'struct', 'implements',
|
| 64 |
+
'interface', 'from', 'indexed', 'log', 'extcall', 'staticcall'),
|
| 65 |
+
prefix=r'\b', suffix=r'\b'), Keyword),
|
| 66 |
+
|
| 67 |
+
# Visibility and State Mutability
|
| 68 |
+
(words(('public', 'private', 'view', 'pure', 'constant',
|
| 69 |
+
'immutable', 'nonpayable'), prefix=r'\b', suffix=r'\b'),
|
| 70 |
+
Keyword.Declaration),
|
| 71 |
+
|
| 72 |
+
# Built-in Functions
|
| 73 |
+
(words(('bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'shift',
|
| 74 |
+
'create_minimal_proxy_to', 'create_copy_of', 'create_from_blueprint',
|
| 75 |
+
'ecadd', 'ecmul', 'ecrecover', 'keccak256', 'sha256', 'concat', 'convert',
|
| 76 |
+
'uint2str', 'extract32', 'slice', 'abs', 'ceil', 'floor', 'max', 'max_value',
|
| 77 |
+
'min', 'min_value', 'pow_mod256', 'sqrt', 'isqrt', 'uint256_addmod',
|
| 78 |
+
'uint256_mulmod', 'unsafe_add', 'unsafe_sub', 'unsafe_mul', 'unsafe_div',
|
| 79 |
+
'as_wei_value', 'blockhash', 'empty', 'len', 'method_id', '_abi_encode',
|
| 80 |
+
'_abi_decode', 'print', 'range'), prefix=r'\b', suffix=r'\b'),
|
| 81 |
+
Name.Builtin),
|
| 82 |
+
|
| 83 |
+
# Built-in Variables and Attributes
|
| 84 |
+
(words(('msg.sender', 'msg.value', 'block.timestamp', 'block.number', 'msg.gas'),
|
| 85 |
+
prefix=r'\b', suffix=r'\b'),
|
| 86 |
+
Name.Builtin.Pseudo),
|
| 87 |
+
|
| 88 |
+
(words(('uint', 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',
|
| 89 |
+
'int', 'int8', 'int16', 'int32', 'int64', 'int128', 'int256', 'bool',
|
| 90 |
+
'decimal', 'bytes', 'bytes1', 'bytes2', 'bytes3', 'bytes4', 'bytes5',
|
| 91 |
+
'bytes6', 'bytes7', 'bytes8', 'bytes9', 'bytes10', 'bytes11',
|
| 92 |
+
'bytes12', 'bytes13', 'bytes14', 'bytes15', 'bytes16', 'bytes17',
|
| 93 |
+
'bytes18', 'bytes19', 'bytes20', 'bytes21', 'bytes22', 'bytes23',
|
| 94 |
+
'bytes24', 'bytes25', 'bytes26', 'bytes27', 'bytes28', 'bytes29',
|
| 95 |
+
'bytes30', 'bytes31', 'bytes32', 'string', 'String', 'address',
|
| 96 |
+
'enum', 'struct'), prefix=r'\b', suffix=r'\b'),
|
| 97 |
+
Keyword.Type),
|
| 98 |
+
|
| 99 |
+
# indexed keywords
|
| 100 |
+
(r'\b(indexed)\b(\s*)(\()(\s*)(\w+)(\s*)(\))',
|
| 101 |
+
bygroups(Keyword, Whitespace, Punctuation, Whitespace,
|
| 102 |
+
Keyword.Type, Punctuation)),
|
| 103 |
+
|
| 104 |
+
# Operators and Punctuation
|
| 105 |
+
(r'(\+|\-|\*|\/|<=?|>=?|==|!=|=|\||&|%)', Operator),
|
| 106 |
+
(r'[.,:;()\[\]{}]', Punctuation),
|
| 107 |
+
|
| 108 |
+
# Other variable names and types
|
| 109 |
+
(r'@[\w.]+', Name.Decorator),
|
| 110 |
+
(r'__\w+__', Name.Magic), # Matches double underscores followed by word characters
|
| 111 |
+
(r'EMPTY_BYTES32', Name.Constant),
|
| 112 |
+
(r'\bERC20\b', Name.Class),
|
| 113 |
+
(r'\bself\b', Name.Attribute),
|
| 114 |
+
|
| 115 |
+
(r'Bytes\[\d+\]', Keyword.Type),
|
| 116 |
+
|
| 117 |
+
# Generic names and variables
|
| 118 |
+
(r'\b[a-zA-Z_]\w*\b:', Name.Variable),
|
| 119 |
+
(r'\b[a-zA-Z_]\w*\b', Name),
|
| 120 |
+
|
| 121 |
+
],
|
| 122 |
+
|
| 123 |
+
'multiline-comment': [
|
| 124 |
+
(r'\"\"\"', Comment.Multiline, '#pop'),
|
| 125 |
+
(r'[^"]+', Comment.Multiline),
|
| 126 |
+
(r'\"', Comment.Multiline)
|
| 127 |
+
],
|
| 128 |
+
|
| 129 |
+
'single-string': [
|
| 130 |
+
(r"[^\\']+", String.Single),
|
| 131 |
+
(r"'", String.Single, '#pop'),
|
| 132 |
+
(r'\\.', String.Escape),
|
| 133 |
+
],
|
| 134 |
+
|
| 135 |
+
'double-string': [
|
| 136 |
+
(r'[^\\"]+', String.Double),
|
| 137 |
+
(r'"', String.Double, '#pop'),
|
| 138 |
+
(r'\\.', String.Escape),
|
| 139 |
+
]
|
| 140 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/web.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.web
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Just export previously exported lexers.
|
| 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.html import HtmlLexer, DtdLexer, XmlLexer, XsltLexer, \
|
| 13 |
+
HamlLexer, ScamlLexer, JadeLexer
|
| 14 |
+
from pygments.lexers.css import CssLexer, SassLexer, ScssLexer
|
| 15 |
+
from pygments.lexers.javascript import JavascriptLexer, LiveScriptLexer, \
|
| 16 |
+
DartLexer, TypeScriptLexer, LassoLexer, ObjectiveJLexer, CoffeeScriptLexer
|
| 17 |
+
from pygments.lexers.actionscript import ActionScriptLexer, \
|
| 18 |
+
ActionScript3Lexer, MxmlLexer
|
| 19 |
+
from pygments.lexers.php import PhpLexer
|
| 20 |
+
from pygments.lexers.webmisc import DuelLexer, XQueryLexer, SlimLexer, QmlLexer
|
| 21 |
+
from pygments.lexers.data import JsonLexer
|
| 22 |
+
JSONLexer = JsonLexer # for backwards compatibility with Pygments 1.5
|
| 23 |
+
|
| 24 |
+
__all__ = []
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webassembly.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.webassembly
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the WebAssembly text format.
|
| 6 |
+
|
| 7 |
+
The grammar can be found at https://github.com/WebAssembly/spec/blob/master/interpreter/README.md
|
| 8 |
+
and https://webassembly.github.io/spec/core/text/.
|
| 9 |
+
|
| 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, words, bygroups, default
|
| 16 |
+
from pygments.token import Text, Comment, Operator, Keyword, String, Number, Punctuation, Name
|
| 17 |
+
|
| 18 |
+
__all__ = ['WatLexer']
|
| 19 |
+
|
| 20 |
+
keywords = (
|
| 21 |
+
'module', 'import', 'func', 'funcref', 'start', 'param', 'local', 'type',
|
| 22 |
+
'result', 'export', 'memory', 'global', 'mut', 'data', 'table', 'elem',
|
| 23 |
+
'if', 'then', 'else', 'end', 'block', 'loop'
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
builtins = (
|
| 27 |
+
'unreachable', 'nop', 'block', 'loop', 'if', 'else', 'end', 'br', 'br_if',
|
| 28 |
+
'br_table', 'return', 'call', 'call_indirect', 'drop', 'select',
|
| 29 |
+
'local.get', 'local.set', 'local.tee', 'global.get', 'global.set',
|
| 30 |
+
'i32.load', 'i64.load', 'f32.load', 'f64.load', 'i32.load8_s',
|
| 31 |
+
'i32.load8_u', 'i32.load16_s', 'i32.load16_u', 'i64.load8_s',
|
| 32 |
+
'i64.load8_u', 'i64.load16_s', 'i64.load16_u', 'i64.load32_s',
|
| 33 |
+
'i64.load32_u', 'i32.store', 'i64.store', 'f32.store', 'f64.store',
|
| 34 |
+
'i32.store8', 'i32.store16', 'i64.store8', 'i64.store16', 'i64.store32',
|
| 35 |
+
'memory.size', 'memory.grow', 'i32.const', 'i64.const', 'f32.const',
|
| 36 |
+
'f64.const', 'i32.eqz', 'i32.eq', 'i32.ne', 'i32.lt_s', 'i32.lt_u',
|
| 37 |
+
'i32.gt_s', 'i32.gt_u', 'i32.le_s', 'i32.le_u', 'i32.ge_s', 'i32.ge_u',
|
| 38 |
+
'i64.eqz', 'i64.eq', 'i64.ne', 'i64.lt_s', 'i64.lt_u', 'i64.gt_s',
|
| 39 |
+
'i64.gt_u', 'i64.le_s', 'i64.le_u', 'i64.ge_s', 'i64.ge_u', 'f32.eq',
|
| 40 |
+
'f32.ne', 'f32.lt', 'f32.gt', 'f32.le', 'f32.ge', 'f64.eq', 'f64.ne',
|
| 41 |
+
'f64.lt', 'f64.gt', 'f64.le', 'f64.ge', 'i32.clz', 'i32.ctz', 'i32.popcnt',
|
| 42 |
+
'i32.add', 'i32.sub', 'i32.mul', 'i32.div_s', 'i32.div_u', 'i32.rem_s',
|
| 43 |
+
'i32.rem_u', 'i32.and', 'i32.or', 'i32.xor', 'i32.shl', 'i32.shr_s',
|
| 44 |
+
'i32.shr_u', 'i32.rotl', 'i32.rotr', 'i64.clz', 'i64.ctz', 'i64.popcnt',
|
| 45 |
+
'i64.add', 'i64.sub', 'i64.mul', 'i64.div_s', 'i64.div_u', 'i64.rem_s',
|
| 46 |
+
'i64.rem_u', 'i64.and', 'i64.or', 'i64.xor', 'i64.shl', 'i64.shr_s',
|
| 47 |
+
'i64.shr_u', 'i64.rotl', 'i64.rotr', 'f32.abs', 'f32.neg', 'f32.ceil',
|
| 48 |
+
'f32.floor', 'f32.trunc', 'f32.nearest', 'f32.sqrt', 'f32.add', 'f32.sub',
|
| 49 |
+
'f32.mul', 'f32.div', 'f32.min', 'f32.max', 'f32.copysign', 'f64.abs',
|
| 50 |
+
'f64.neg', 'f64.ceil', 'f64.floor', 'f64.trunc', 'f64.nearest', 'f64.sqrt',
|
| 51 |
+
'f64.add', 'f64.sub', 'f64.mul', 'f64.div', 'f64.min', 'f64.max',
|
| 52 |
+
'f64.copysign', 'i32.wrap_i64', 'i32.trunc_f32_s', 'i32.trunc_f32_u',
|
| 53 |
+
'i32.trunc_f64_s', 'i32.trunc_f64_u', 'i64.extend_i32_s',
|
| 54 |
+
'i64.extend_i32_u', 'i64.trunc_f32_s', 'i64.trunc_f32_u',
|
| 55 |
+
'i64.trunc_f64_s', 'i64.trunc_f64_u', 'f32.convert_i32_s',
|
| 56 |
+
'f32.convert_i32_u', 'f32.convert_i64_s', 'f32.convert_i64_u',
|
| 57 |
+
'f32.demote_f64', 'f64.convert_i32_s', 'f64.convert_i32_u',
|
| 58 |
+
'f64.convert_i64_s', 'f64.convert_i64_u', 'f64.promote_f32',
|
| 59 |
+
'i32.reinterpret_f32', 'i64.reinterpret_f64', 'f32.reinterpret_i32',
|
| 60 |
+
'f64.reinterpret_i64',
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class WatLexer(RegexLexer):
|
| 65 |
+
"""Lexer for the WebAssembly text format.
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
name = 'WebAssembly'
|
| 69 |
+
url = 'https://webassembly.org/'
|
| 70 |
+
aliases = ['wast', 'wat']
|
| 71 |
+
filenames = ['*.wat', '*.wast']
|
| 72 |
+
version_added = '2.9'
|
| 73 |
+
|
| 74 |
+
tokens = {
|
| 75 |
+
'root': [
|
| 76 |
+
(words(keywords, suffix=r'(?=[^a-z_\.])'), Keyword),
|
| 77 |
+
(words(builtins), Name.Builtin, 'arguments'),
|
| 78 |
+
(words(['i32', 'i64', 'f32', 'f64']), Keyword.Type),
|
| 79 |
+
(r'\$[A-Za-z0-9!#$%&\'*+./:<=>?@\\^_`|~-]+', Name.Variable), # yes, all of the are valid in identifiers
|
| 80 |
+
(r';;.*?$', Comment.Single),
|
| 81 |
+
(r'\(;', Comment.Multiline, 'nesting_comment'),
|
| 82 |
+
(r'[+-]?0x[\dA-Fa-f](_?[\dA-Fa-f])*(.([\dA-Fa-f](_?[\dA-Fa-f])*)?)?([pP][+-]?[\dA-Fa-f](_?[\dA-Fa-f])*)?', Number.Float),
|
| 83 |
+
(r'[+-]?\d.\d(_?\d)*[eE][+-]?\d(_?\d)*', Number.Float),
|
| 84 |
+
(r'[+-]?\d.\d(_?\d)*', Number.Float),
|
| 85 |
+
(r'[+-]?\d.[eE][+-]?\d(_?\d)*', Number.Float),
|
| 86 |
+
(r'[+-]?(inf|nan:0x[\dA-Fa-f](_?[\dA-Fa-f])*|nan)', Number.Float),
|
| 87 |
+
(r'[+-]?0x[\dA-Fa-f](_?[\dA-Fa-f])*', Number.Hex),
|
| 88 |
+
(r'[+-]?\d(_?\d)*', Number.Integer),
|
| 89 |
+
(r'[\(\)]', Punctuation),
|
| 90 |
+
(r'"', String.Double, 'string'),
|
| 91 |
+
(r'\s+', Text),
|
| 92 |
+
],
|
| 93 |
+
'nesting_comment': [
|
| 94 |
+
(r'\(;', Comment.Multiline, '#push'),
|
| 95 |
+
(r';\)', Comment.Multiline, '#pop'),
|
| 96 |
+
(r'[^;(]+', Comment.Multiline),
|
| 97 |
+
(r'[;(]', Comment.Multiline),
|
| 98 |
+
],
|
| 99 |
+
'string': [
|
| 100 |
+
(r'\\[\dA-Fa-f][\dA-Fa-f]', String.Escape), # must have exactly two hex digits
|
| 101 |
+
(r'\\t', String.Escape),
|
| 102 |
+
(r'\\n', String.Escape),
|
| 103 |
+
(r'\\r', String.Escape),
|
| 104 |
+
(r'\\"', String.Escape),
|
| 105 |
+
(r"\\'", String.Escape),
|
| 106 |
+
(r'\\u\{[\dA-Fa-f](_?[\dA-Fa-f])*\}', String.Escape),
|
| 107 |
+
(r'\\\\', String.Escape),
|
| 108 |
+
(r'"', String.Double, '#pop'),
|
| 109 |
+
(r'[^"\\]+', String.Double),
|
| 110 |
+
],
|
| 111 |
+
'arguments': [
|
| 112 |
+
(r'\s+', Text),
|
| 113 |
+
(r'(offset)(=)(0x[\dA-Fa-f](_?[\dA-Fa-f])*)', bygroups(Keyword, Operator, Number.Hex)),
|
| 114 |
+
(r'(offset)(=)(\d(_?\d)*)', bygroups(Keyword, Operator, Number.Integer)),
|
| 115 |
+
(r'(align)(=)(0x[\dA-Fa-f](_?[\dA-Fa-f])*)', bygroups(Keyword, Operator, Number.Hex)),
|
| 116 |
+
(r'(align)(=)(\d(_?\d)*)', bygroups(Keyword, Operator, Number.Integer)),
|
| 117 |
+
default('#pop'),
|
| 118 |
+
]
|
| 119 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webidl.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.webidl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Web IDL, including some extensions.
|
| 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, include, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Punctuation, \
|
| 13 |
+
String, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['WebIDLLexer']
|
| 16 |
+
|
| 17 |
+
_builtin_types = (
|
| 18 |
+
# primitive types
|
| 19 |
+
'byte', 'octet', 'boolean',
|
| 20 |
+
r'(?:unsigned\s+)?(?:short|long(?:\s+long)?)',
|
| 21 |
+
r'(?:unrestricted\s+)?(?:float|double)',
|
| 22 |
+
# string types
|
| 23 |
+
'DOMString', 'ByteString', 'USVString',
|
| 24 |
+
# exception types
|
| 25 |
+
'Error', 'DOMException',
|
| 26 |
+
# typed array types
|
| 27 |
+
'Uint8Array', 'Uint16Array', 'Uint32Array', 'Uint8ClampedArray',
|
| 28 |
+
'Float32Array', 'Float64Array',
|
| 29 |
+
# buffer source types
|
| 30 |
+
'ArrayBuffer', 'DataView', 'Int8Array', 'Int16Array', 'Int32Array',
|
| 31 |
+
# other
|
| 32 |
+
'any', 'void', 'object', 'RegExp',
|
| 33 |
+
)
|
| 34 |
+
_identifier = r'_?[A-Za-z][a-zA-Z0-9_-]*'
|
| 35 |
+
_keyword_suffix = r'(?![\w-])'
|
| 36 |
+
_string = r'"[^"]*"'
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class WebIDLLexer(RegexLexer):
|
| 40 |
+
"""
|
| 41 |
+
For Web IDL.
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
name = 'Web IDL'
|
| 45 |
+
url = 'https://www.w3.org/wiki/Web_IDL'
|
| 46 |
+
aliases = ['webidl']
|
| 47 |
+
filenames = ['*.webidl']
|
| 48 |
+
version_added = '2.6'
|
| 49 |
+
|
| 50 |
+
tokens = {
|
| 51 |
+
'common': [
|
| 52 |
+
(r'\s+', Text),
|
| 53 |
+
(r'(?s)/\*.*?\*/', Comment.Multiline),
|
| 54 |
+
(r'//.*', Comment.Single),
|
| 55 |
+
(r'^#.*', Comment.Preproc),
|
| 56 |
+
],
|
| 57 |
+
'root': [
|
| 58 |
+
include('common'),
|
| 59 |
+
(r'\[', Punctuation, 'extended_attributes'),
|
| 60 |
+
(r'partial' + _keyword_suffix, Keyword),
|
| 61 |
+
(r'typedef' + _keyword_suffix, Keyword, ('typedef', 'type')),
|
| 62 |
+
(r'interface' + _keyword_suffix, Keyword, 'interface_rest'),
|
| 63 |
+
(r'enum' + _keyword_suffix, Keyword, 'enum_rest'),
|
| 64 |
+
(r'callback' + _keyword_suffix, Keyword, 'callback_rest'),
|
| 65 |
+
(r'dictionary' + _keyword_suffix, Keyword, 'dictionary_rest'),
|
| 66 |
+
(r'namespace' + _keyword_suffix, Keyword, 'namespace_rest'),
|
| 67 |
+
(_identifier, Name.Class, 'implements_rest'),
|
| 68 |
+
],
|
| 69 |
+
'extended_attributes': [
|
| 70 |
+
include('common'),
|
| 71 |
+
(r',', Punctuation),
|
| 72 |
+
(_identifier, Name.Decorator),
|
| 73 |
+
(r'=', Punctuation, 'extended_attribute_rest'),
|
| 74 |
+
(r'\(', Punctuation, 'argument_list'),
|
| 75 |
+
(r'\]', Punctuation, '#pop'),
|
| 76 |
+
],
|
| 77 |
+
'extended_attribute_rest': [
|
| 78 |
+
include('common'),
|
| 79 |
+
(_identifier, Name, 'extended_attribute_named_rest'),
|
| 80 |
+
(_string, String),
|
| 81 |
+
(r'\(', Punctuation, 'identifier_list'),
|
| 82 |
+
default('#pop'),
|
| 83 |
+
],
|
| 84 |
+
'extended_attribute_named_rest': [
|
| 85 |
+
include('common'),
|
| 86 |
+
(r'\(', Punctuation, 'argument_list'),
|
| 87 |
+
default('#pop'),
|
| 88 |
+
],
|
| 89 |
+
'argument_list': [
|
| 90 |
+
include('common'),
|
| 91 |
+
(r'\)', Punctuation, '#pop'),
|
| 92 |
+
default('argument'),
|
| 93 |
+
],
|
| 94 |
+
'argument': [
|
| 95 |
+
include('common'),
|
| 96 |
+
(r'optional' + _keyword_suffix, Keyword),
|
| 97 |
+
(r'\[', Punctuation, 'extended_attributes'),
|
| 98 |
+
(r',', Punctuation, '#pop'),
|
| 99 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 100 |
+
default(('argument_rest', 'type'))
|
| 101 |
+
],
|
| 102 |
+
'argument_rest': [
|
| 103 |
+
include('common'),
|
| 104 |
+
(_identifier, Name.Variable),
|
| 105 |
+
(r'\.\.\.', Punctuation),
|
| 106 |
+
(r'=', Punctuation, 'default_value'),
|
| 107 |
+
default('#pop'),
|
| 108 |
+
],
|
| 109 |
+
'identifier_list': [
|
| 110 |
+
include('common'),
|
| 111 |
+
(_identifier, Name.Class),
|
| 112 |
+
(r',', Punctuation),
|
| 113 |
+
(r'\)', Punctuation, '#pop'),
|
| 114 |
+
],
|
| 115 |
+
'type': [
|
| 116 |
+
include('common'),
|
| 117 |
+
(r'(?:' + r'|'.join(_builtin_types) + r')' + _keyword_suffix,
|
| 118 |
+
Keyword.Type, 'type_null'),
|
| 119 |
+
(words(('sequence', 'Promise', 'FrozenArray'),
|
| 120 |
+
suffix=_keyword_suffix), Keyword.Type, 'type_identifier'),
|
| 121 |
+
(_identifier, Name.Class, 'type_identifier'),
|
| 122 |
+
(r'\(', Punctuation, 'union_type'),
|
| 123 |
+
],
|
| 124 |
+
'union_type': [
|
| 125 |
+
include('common'),
|
| 126 |
+
(r'or' + _keyword_suffix, Keyword),
|
| 127 |
+
(r'\)', Punctuation, ('#pop', 'type_null')),
|
| 128 |
+
default('type'),
|
| 129 |
+
],
|
| 130 |
+
'type_identifier': [
|
| 131 |
+
(r'<', Punctuation, 'type_list'),
|
| 132 |
+
default(('#pop', 'type_null'))
|
| 133 |
+
],
|
| 134 |
+
'type_null': [
|
| 135 |
+
(r'\?', Punctuation),
|
| 136 |
+
default('#pop:2'),
|
| 137 |
+
],
|
| 138 |
+
'default_value': [
|
| 139 |
+
include('common'),
|
| 140 |
+
include('const_value'),
|
| 141 |
+
(_string, String, '#pop'),
|
| 142 |
+
(r'\[\s*\]', Punctuation, '#pop'),
|
| 143 |
+
],
|
| 144 |
+
'const_value': [
|
| 145 |
+
include('common'),
|
| 146 |
+
(words(('true', 'false', '-Infinity', 'Infinity', 'NaN', 'null'),
|
| 147 |
+
suffix=_keyword_suffix), Keyword.Constant, '#pop'),
|
| 148 |
+
(r'-?(?:(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:[Ee][+-]?[0-9]+)?' +
|
| 149 |
+
r'|[0-9]+[Ee][+-]?[0-9]+)', Number.Float, '#pop'),
|
| 150 |
+
(r'-?[1-9][0-9]*', Number.Integer, '#pop'),
|
| 151 |
+
(r'-?0[Xx][0-9A-Fa-f]+', Number.Hex, '#pop'),
|
| 152 |
+
(r'-?0[0-7]*', Number.Oct, '#pop'),
|
| 153 |
+
],
|
| 154 |
+
'typedef': [
|
| 155 |
+
include('common'),
|
| 156 |
+
(_identifier, Name.Class),
|
| 157 |
+
(r';', Punctuation, '#pop'),
|
| 158 |
+
],
|
| 159 |
+
'namespace_rest': [
|
| 160 |
+
include('common'),
|
| 161 |
+
(_identifier, Name.Namespace),
|
| 162 |
+
(r'\{', Punctuation, 'namespace_body'),
|
| 163 |
+
(r';', Punctuation, '#pop'),
|
| 164 |
+
],
|
| 165 |
+
'namespace_body': [
|
| 166 |
+
include('common'),
|
| 167 |
+
(r'\[', Punctuation, 'extended_attributes'),
|
| 168 |
+
(r'readonly' + _keyword_suffix, Keyword),
|
| 169 |
+
(r'attribute' + _keyword_suffix,
|
| 170 |
+
Keyword, ('attribute_rest', 'type')),
|
| 171 |
+
(r'const' + _keyword_suffix, Keyword, ('const_rest', 'type')),
|
| 172 |
+
(r'\}', Punctuation, '#pop'),
|
| 173 |
+
default(('operation_rest', 'type')),
|
| 174 |
+
],
|
| 175 |
+
'interface_rest': [
|
| 176 |
+
include('common'),
|
| 177 |
+
(_identifier, Name.Class),
|
| 178 |
+
(r':', Punctuation),
|
| 179 |
+
(r'\{', Punctuation, 'interface_body'),
|
| 180 |
+
(r';', Punctuation, '#pop'),
|
| 181 |
+
],
|
| 182 |
+
'interface_body': [
|
| 183 |
+
(words(('iterable', 'maplike', 'setlike'), suffix=_keyword_suffix),
|
| 184 |
+
Keyword, 'iterable_maplike_setlike_rest'),
|
| 185 |
+
(words(('setter', 'getter', 'creator', 'deleter', 'legacycaller',
|
| 186 |
+
'inherit', 'static', 'stringifier', 'jsonifier'),
|
| 187 |
+
suffix=_keyword_suffix), Keyword),
|
| 188 |
+
(r'serializer' + _keyword_suffix, Keyword, 'serializer_rest'),
|
| 189 |
+
(r';', Punctuation),
|
| 190 |
+
include('namespace_body'),
|
| 191 |
+
],
|
| 192 |
+
'attribute_rest': [
|
| 193 |
+
include('common'),
|
| 194 |
+
(_identifier, Name.Variable),
|
| 195 |
+
(r';', Punctuation, '#pop'),
|
| 196 |
+
],
|
| 197 |
+
'const_rest': [
|
| 198 |
+
include('common'),
|
| 199 |
+
(_identifier, Name.Constant),
|
| 200 |
+
(r'=', Punctuation, 'const_value'),
|
| 201 |
+
(r';', Punctuation, '#pop'),
|
| 202 |
+
],
|
| 203 |
+
'operation_rest': [
|
| 204 |
+
include('common'),
|
| 205 |
+
(r';', Punctuation, '#pop'),
|
| 206 |
+
default('operation'),
|
| 207 |
+
],
|
| 208 |
+
'operation': [
|
| 209 |
+
include('common'),
|
| 210 |
+
(_identifier, Name.Function),
|
| 211 |
+
(r'\(', Punctuation, 'argument_list'),
|
| 212 |
+
(r';', Punctuation, '#pop:2'),
|
| 213 |
+
],
|
| 214 |
+
'iterable_maplike_setlike_rest': [
|
| 215 |
+
include('common'),
|
| 216 |
+
(r'<', Punctuation, 'type_list'),
|
| 217 |
+
(r';', Punctuation, '#pop'),
|
| 218 |
+
],
|
| 219 |
+
'type_list': [
|
| 220 |
+
include('common'),
|
| 221 |
+
(r',', Punctuation),
|
| 222 |
+
(r'>', Punctuation, '#pop'),
|
| 223 |
+
default('type'),
|
| 224 |
+
],
|
| 225 |
+
'serializer_rest': [
|
| 226 |
+
include('common'),
|
| 227 |
+
(r'=', Punctuation, 'serialization_pattern'),
|
| 228 |
+
(r';', Punctuation, '#pop'),
|
| 229 |
+
default('operation'),
|
| 230 |
+
],
|
| 231 |
+
'serialization_pattern': [
|
| 232 |
+
include('common'),
|
| 233 |
+
(_identifier, Name.Variable, '#pop'),
|
| 234 |
+
(r'\{', Punctuation, 'serialization_pattern_map'),
|
| 235 |
+
(r'\[', Punctuation, 'serialization_pattern_list'),
|
| 236 |
+
],
|
| 237 |
+
'serialization_pattern_map': [
|
| 238 |
+
include('common'),
|
| 239 |
+
(words(('getter', 'inherit', 'attribute'),
|
| 240 |
+
suffix=_keyword_suffix), Keyword),
|
| 241 |
+
(r',', Punctuation),
|
| 242 |
+
(_identifier, Name.Variable),
|
| 243 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 244 |
+
],
|
| 245 |
+
'serialization_pattern_list': [
|
| 246 |
+
include('common'),
|
| 247 |
+
(words(('getter', 'attribute'), suffix=_keyword_suffix), Keyword),
|
| 248 |
+
(r',', Punctuation),
|
| 249 |
+
(_identifier, Name.Variable),
|
| 250 |
+
(r']', Punctuation, '#pop:2'),
|
| 251 |
+
],
|
| 252 |
+
'enum_rest': [
|
| 253 |
+
include('common'),
|
| 254 |
+
(_identifier, Name.Class),
|
| 255 |
+
(r'\{', Punctuation, 'enum_body'),
|
| 256 |
+
(r';', Punctuation, '#pop'),
|
| 257 |
+
],
|
| 258 |
+
'enum_body': [
|
| 259 |
+
include('common'),
|
| 260 |
+
(_string, String),
|
| 261 |
+
(r',', Punctuation),
|
| 262 |
+
(r'\}', Punctuation, '#pop'),
|
| 263 |
+
],
|
| 264 |
+
'callback_rest': [
|
| 265 |
+
include('common'),
|
| 266 |
+
(r'interface' + _keyword_suffix,
|
| 267 |
+
Keyword, ('#pop', 'interface_rest')),
|
| 268 |
+
(_identifier, Name.Class),
|
| 269 |
+
(r'=', Punctuation, ('operation', 'type')),
|
| 270 |
+
(r';', Punctuation, '#pop'),
|
| 271 |
+
],
|
| 272 |
+
'dictionary_rest': [
|
| 273 |
+
include('common'),
|
| 274 |
+
(_identifier, Name.Class),
|
| 275 |
+
(r':', Punctuation),
|
| 276 |
+
(r'\{', Punctuation, 'dictionary_body'),
|
| 277 |
+
(r';', Punctuation, '#pop'),
|
| 278 |
+
],
|
| 279 |
+
'dictionary_body': [
|
| 280 |
+
include('common'),
|
| 281 |
+
(r'\[', Punctuation, 'extended_attributes'),
|
| 282 |
+
(r'required' + _keyword_suffix, Keyword),
|
| 283 |
+
(r'\}', Punctuation, '#pop'),
|
| 284 |
+
default(('dictionary_item', 'type')),
|
| 285 |
+
],
|
| 286 |
+
'dictionary_item': [
|
| 287 |
+
include('common'),
|
| 288 |
+
(_identifier, Name.Variable),
|
| 289 |
+
(r'=', Punctuation, 'default_value'),
|
| 290 |
+
(r';', Punctuation, '#pop'),
|
| 291 |
+
],
|
| 292 |
+
'implements_rest': [
|
| 293 |
+
include('common'),
|
| 294 |
+
(r'implements' + _keyword_suffix, Keyword),
|
| 295 |
+
(_identifier, Name.Class),
|
| 296 |
+
(r';', Punctuation, '#pop'),
|
| 297 |
+
],
|
| 298 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/webmisc.py
ADDED
|
@@ -0,0 +1,1006 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.webmisc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for misc. web stuff.
|
| 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, bygroups, \
|
| 14 |
+
default, using
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Literal, Whitespace
|
| 17 |
+
|
| 18 |
+
from pygments.lexers.css import _indentation, _starts_block
|
| 19 |
+
from pygments.lexers.html import HtmlLexer
|
| 20 |
+
from pygments.lexers.javascript import JavascriptLexer
|
| 21 |
+
from pygments.lexers.ruby import RubyLexer
|
| 22 |
+
|
| 23 |
+
__all__ = ['DuelLexer', 'SlimLexer', 'XQueryLexer', 'QmlLexer', 'CirruLexer']
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class DuelLexer(RegexLexer):
|
| 27 |
+
"""
|
| 28 |
+
Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
name = 'Duel'
|
| 32 |
+
url = 'http://duelengine.org/'
|
| 33 |
+
aliases = ['duel', 'jbst', 'jsonml+bst']
|
| 34 |
+
filenames = ['*.duel', '*.jbst']
|
| 35 |
+
mimetypes = ['text/x-duel', 'text/x-jbst']
|
| 36 |
+
version_added = '1.4'
|
| 37 |
+
|
| 38 |
+
flags = re.DOTALL
|
| 39 |
+
|
| 40 |
+
tokens = {
|
| 41 |
+
'root': [
|
| 42 |
+
(r'(<%[@=#!:]?)(.*?)(%>)',
|
| 43 |
+
bygroups(Name.Tag, using(JavascriptLexer), Name.Tag)),
|
| 44 |
+
(r'(<%\$)(.*?)(:)(.*?)(%>)',
|
| 45 |
+
bygroups(Name.Tag, Name.Function, Punctuation, String, Name.Tag)),
|
| 46 |
+
(r'(<%--)(.*?)(--%>)',
|
| 47 |
+
bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
|
| 48 |
+
(r'(<script.*?>)(.*?)(</script>)',
|
| 49 |
+
bygroups(using(HtmlLexer),
|
| 50 |
+
using(JavascriptLexer), using(HtmlLexer))),
|
| 51 |
+
(r'(.+?)(?=<)', using(HtmlLexer)),
|
| 52 |
+
(r'.+', using(HtmlLexer)),
|
| 53 |
+
],
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class XQueryLexer(ExtendedRegexLexer):
|
| 58 |
+
"""
|
| 59 |
+
An XQuery lexer, parsing a stream and outputting the tokens needed to
|
| 60 |
+
highlight xquery code.
|
| 61 |
+
"""
|
| 62 |
+
name = 'XQuery'
|
| 63 |
+
url = 'https://www.w3.org/XML/Query/'
|
| 64 |
+
aliases = ['xquery', 'xqy', 'xq', 'xql', 'xqm']
|
| 65 |
+
filenames = ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm']
|
| 66 |
+
mimetypes = ['text/xquery', 'application/xquery']
|
| 67 |
+
version_added = '1.4'
|
| 68 |
+
|
| 69 |
+
xquery_parse_state = []
|
| 70 |
+
|
| 71 |
+
# FIX UNICODE LATER
|
| 72 |
+
# ncnamestartchar = (
|
| 73 |
+
# r"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|"
|
| 74 |
+
# r"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|"
|
| 75 |
+
# r"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|"
|
| 76 |
+
# r"[\u10000-\uEFFFF]"
|
| 77 |
+
# )
|
| 78 |
+
ncnamestartchar = r"(?:[A-Z]|_|[a-z])"
|
| 79 |
+
# FIX UNICODE LATER
|
| 80 |
+
# ncnamechar = ncnamestartchar + (r"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|"
|
| 81 |
+
# r"[\u203F-\u2040]")
|
| 82 |
+
ncnamechar = r"(?:" + ncnamestartchar + r"|-|\.|[0-9])"
|
| 83 |
+
ncname = f"(?:{ncnamestartchar}+{ncnamechar}*)"
|
| 84 |
+
pitarget_namestartchar = r"(?:[A-KN-WYZ]|_|:|[a-kn-wyz])"
|
| 85 |
+
pitarget_namechar = r"(?:" + pitarget_namestartchar + r"|-|\.|[0-9])"
|
| 86 |
+
pitarget = f"{pitarget_namestartchar}+{pitarget_namechar}*"
|
| 87 |
+
prefixedname = f"{ncname}:{ncname}"
|
| 88 |
+
unprefixedname = ncname
|
| 89 |
+
qname = f"(?:{prefixedname}|{unprefixedname})"
|
| 90 |
+
|
| 91 |
+
entityref = r'(?:&(?:lt|gt|amp|quot|apos|nbsp);)'
|
| 92 |
+
charref = r'(?:&#[0-9]+;|&#x[0-9a-fA-F]+;)'
|
| 93 |
+
|
| 94 |
+
stringdouble = r'(?:"(?:' + entityref + r'|' + charref + r'|""|[^&"])*")'
|
| 95 |
+
stringsingle = r"(?:'(?:" + entityref + r"|" + charref + r"|''|[^&'])*')"
|
| 96 |
+
|
| 97 |
+
# FIX UNICODE LATER
|
| 98 |
+
# elementcontentchar = (r'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
| 99 |
+
# r'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
| 100 |
+
elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%()*+,\-./:;=?@\[\\\]^_\'`|~]'
|
| 101 |
+
# quotattrcontentchar = (r'\t|\r|\n|[\u0020-\u0021]|[\u0023-\u0025]|'
|
| 102 |
+
# r'[\u0027-\u003b]|[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
| 103 |
+
quotattrcontentchar = r'[A-Za-z]|\s|\d|[!#$%()*+,\-./:;=?@\[\\\]^_\'`|~]'
|
| 104 |
+
# aposattrcontentchar = (r'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
|
| 105 |
+
# r'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
|
| 106 |
+
aposattrcontentchar = r'[A-Za-z]|\s|\d|[!"#$%()*+,\-./:;=?@\[\\\]^_`|~]'
|
| 107 |
+
|
| 108 |
+
# CHAR elements - fix the above elementcontentchar, quotattrcontentchar,
|
| 109 |
+
# aposattrcontentchar
|
| 110 |
+
# x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
| 111 |
+
|
| 112 |
+
flags = re.DOTALL | re.MULTILINE
|
| 113 |
+
|
| 114 |
+
def punctuation_root_callback(lexer, match, ctx):
|
| 115 |
+
yield match.start(), Punctuation, match.group(1)
|
| 116 |
+
# transition to root always - don't pop off stack
|
| 117 |
+
ctx.stack = ['root']
|
| 118 |
+
ctx.pos = match.end()
|
| 119 |
+
|
| 120 |
+
def operator_root_callback(lexer, match, ctx):
|
| 121 |
+
yield match.start(), Operator, match.group(1)
|
| 122 |
+
# transition to root always - don't pop off stack
|
| 123 |
+
ctx.stack = ['root']
|
| 124 |
+
ctx.pos = match.end()
|
| 125 |
+
|
| 126 |
+
def popstate_tag_callback(lexer, match, ctx):
|
| 127 |
+
yield match.start(), Name.Tag, match.group(1)
|
| 128 |
+
if lexer.xquery_parse_state:
|
| 129 |
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
| 130 |
+
ctx.pos = match.end()
|
| 131 |
+
|
| 132 |
+
def popstate_xmlcomment_callback(lexer, match, ctx):
|
| 133 |
+
yield match.start(), String.Doc, match.group(1)
|
| 134 |
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
| 135 |
+
ctx.pos = match.end()
|
| 136 |
+
|
| 137 |
+
def popstate_kindtest_callback(lexer, match, ctx):
|
| 138 |
+
yield match.start(), Punctuation, match.group(1)
|
| 139 |
+
next_state = lexer.xquery_parse_state.pop()
|
| 140 |
+
if next_state == 'occurrenceindicator':
|
| 141 |
+
if re.match("[?*+]+", match.group(2)):
|
| 142 |
+
yield match.start(), Punctuation, match.group(2)
|
| 143 |
+
ctx.stack.append('operator')
|
| 144 |
+
ctx.pos = match.end()
|
| 145 |
+
else:
|
| 146 |
+
ctx.stack.append('operator')
|
| 147 |
+
ctx.pos = match.end(1)
|
| 148 |
+
else:
|
| 149 |
+
ctx.stack.append(next_state)
|
| 150 |
+
ctx.pos = match.end(1)
|
| 151 |
+
|
| 152 |
+
def popstate_callback(lexer, match, ctx):
|
| 153 |
+
yield match.start(), Punctuation, match.group(1)
|
| 154 |
+
# if we have run out of our state stack, pop whatever is on the pygments
|
| 155 |
+
# state stack
|
| 156 |
+
if len(lexer.xquery_parse_state) == 0:
|
| 157 |
+
ctx.stack.pop()
|
| 158 |
+
if not ctx.stack:
|
| 159 |
+
# make sure we have at least the root state on invalid inputs
|
| 160 |
+
ctx.stack = ['root']
|
| 161 |
+
elif len(ctx.stack) > 1:
|
| 162 |
+
ctx.stack.append(lexer.xquery_parse_state.pop())
|
| 163 |
+
else:
|
| 164 |
+
# i don't know if i'll need this, but in case, default back to root
|
| 165 |
+
ctx.stack = ['root']
|
| 166 |
+
ctx.pos = match.end()
|
| 167 |
+
|
| 168 |
+
def pushstate_element_content_starttag_callback(lexer, match, ctx):
|
| 169 |
+
yield match.start(), Name.Tag, match.group(1)
|
| 170 |
+
lexer.xquery_parse_state.append('element_content')
|
| 171 |
+
ctx.stack.append('start_tag')
|
| 172 |
+
ctx.pos = match.end()
|
| 173 |
+
|
| 174 |
+
def pushstate_cdata_section_callback(lexer, match, ctx):
|
| 175 |
+
yield match.start(), String.Doc, match.group(1)
|
| 176 |
+
ctx.stack.append('cdata_section')
|
| 177 |
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
| 178 |
+
ctx.pos = match.end()
|
| 179 |
+
|
| 180 |
+
def pushstate_starttag_callback(lexer, match, ctx):
|
| 181 |
+
yield match.start(), Name.Tag, match.group(1)
|
| 182 |
+
lexer.xquery_parse_state.append(ctx.state.pop)
|
| 183 |
+
ctx.stack.append('start_tag')
|
| 184 |
+
ctx.pos = match.end()
|
| 185 |
+
|
| 186 |
+
def pushstate_operator_order_callback(lexer, match, ctx):
|
| 187 |
+
yield match.start(), Keyword, match.group(1)
|
| 188 |
+
yield match.start(), Whitespace, match.group(2)
|
| 189 |
+
yield match.start(), Punctuation, match.group(3)
|
| 190 |
+
ctx.stack = ['root']
|
| 191 |
+
lexer.xquery_parse_state.append('operator')
|
| 192 |
+
ctx.pos = match.end()
|
| 193 |
+
|
| 194 |
+
def pushstate_operator_map_callback(lexer, match, ctx):
|
| 195 |
+
yield match.start(), Keyword, match.group(1)
|
| 196 |
+
yield match.start(), Whitespace, match.group(2)
|
| 197 |
+
yield match.start(), Punctuation, match.group(3)
|
| 198 |
+
ctx.stack = ['root']
|
| 199 |
+
lexer.xquery_parse_state.append('operator')
|
| 200 |
+
ctx.pos = match.end()
|
| 201 |
+
|
| 202 |
+
def pushstate_operator_root_validate(lexer, match, ctx):
|
| 203 |
+
yield match.start(), Keyword, match.group(1)
|
| 204 |
+
yield match.start(), Whitespace, match.group(2)
|
| 205 |
+
yield match.start(), Punctuation, match.group(3)
|
| 206 |
+
ctx.stack = ['root']
|
| 207 |
+
lexer.xquery_parse_state.append('operator')
|
| 208 |
+
ctx.pos = match.end()
|
| 209 |
+
|
| 210 |
+
def pushstate_operator_root_validate_withmode(lexer, match, ctx):
|
| 211 |
+
yield match.start(), Keyword, match.group(1)
|
| 212 |
+
yield match.start(), Whitespace, match.group(2)
|
| 213 |
+
yield match.start(), Keyword, match.group(3)
|
| 214 |
+
ctx.stack = ['root']
|
| 215 |
+
lexer.xquery_parse_state.append('operator')
|
| 216 |
+
ctx.pos = match.end()
|
| 217 |
+
|
| 218 |
+
def pushstate_operator_processing_instruction_callback(lexer, match, ctx):
|
| 219 |
+
yield match.start(), String.Doc, match.group(1)
|
| 220 |
+
ctx.stack.append('processing_instruction')
|
| 221 |
+
lexer.xquery_parse_state.append('operator')
|
| 222 |
+
ctx.pos = match.end()
|
| 223 |
+
|
| 224 |
+
def pushstate_element_content_processing_instruction_callback(lexer, match, ctx):
|
| 225 |
+
yield match.start(), String.Doc, match.group(1)
|
| 226 |
+
ctx.stack.append('processing_instruction')
|
| 227 |
+
lexer.xquery_parse_state.append('element_content')
|
| 228 |
+
ctx.pos = match.end()
|
| 229 |
+
|
| 230 |
+
def pushstate_element_content_cdata_section_callback(lexer, match, ctx):
|
| 231 |
+
yield match.start(), String.Doc, match.group(1)
|
| 232 |
+
ctx.stack.append('cdata_section')
|
| 233 |
+
lexer.xquery_parse_state.append('element_content')
|
| 234 |
+
ctx.pos = match.end()
|
| 235 |
+
|
| 236 |
+
def pushstate_operator_cdata_section_callback(lexer, match, ctx):
|
| 237 |
+
yield match.start(), String.Doc, match.group(1)
|
| 238 |
+
ctx.stack.append('cdata_section')
|
| 239 |
+
lexer.xquery_parse_state.append('operator')
|
| 240 |
+
ctx.pos = match.end()
|
| 241 |
+
|
| 242 |
+
def pushstate_element_content_xmlcomment_callback(lexer, match, ctx):
|
| 243 |
+
yield match.start(), String.Doc, match.group(1)
|
| 244 |
+
ctx.stack.append('xml_comment')
|
| 245 |
+
lexer.xquery_parse_state.append('element_content')
|
| 246 |
+
ctx.pos = match.end()
|
| 247 |
+
|
| 248 |
+
def pushstate_operator_xmlcomment_callback(lexer, match, ctx):
|
| 249 |
+
yield match.start(), String.Doc, match.group(1)
|
| 250 |
+
ctx.stack.append('xml_comment')
|
| 251 |
+
lexer.xquery_parse_state.append('operator')
|
| 252 |
+
ctx.pos = match.end()
|
| 253 |
+
|
| 254 |
+
def pushstate_kindtest_callback(lexer, match, ctx):
|
| 255 |
+
yield match.start(), Keyword, match.group(1)
|
| 256 |
+
yield match.start(), Whitespace, match.group(2)
|
| 257 |
+
yield match.start(), Punctuation, match.group(3)
|
| 258 |
+
lexer.xquery_parse_state.append('kindtest')
|
| 259 |
+
ctx.stack.append('kindtest')
|
| 260 |
+
ctx.pos = match.end()
|
| 261 |
+
|
| 262 |
+
def pushstate_operator_kindtestforpi_callback(lexer, match, ctx):
|
| 263 |
+
yield match.start(), Keyword, match.group(1)
|
| 264 |
+
yield match.start(), Whitespace, match.group(2)
|
| 265 |
+
yield match.start(), Punctuation, match.group(3)
|
| 266 |
+
lexer.xquery_parse_state.append('operator')
|
| 267 |
+
ctx.stack.append('kindtestforpi')
|
| 268 |
+
ctx.pos = match.end()
|
| 269 |
+
|
| 270 |
+
def pushstate_operator_kindtest_callback(lexer, match, ctx):
|
| 271 |
+
yield match.start(), Keyword, match.group(1)
|
| 272 |
+
yield match.start(), Whitespace, match.group(2)
|
| 273 |
+
yield match.start(), Punctuation, match.group(3)
|
| 274 |
+
lexer.xquery_parse_state.append('operator')
|
| 275 |
+
ctx.stack.append('kindtest')
|
| 276 |
+
ctx.pos = match.end()
|
| 277 |
+
|
| 278 |
+
def pushstate_occurrenceindicator_kindtest_callback(lexer, match, ctx):
|
| 279 |
+
yield match.start(), Name.Tag, match.group(1)
|
| 280 |
+
yield match.start(), Whitespace, match.group(2)
|
| 281 |
+
yield match.start(), Punctuation, match.group(3)
|
| 282 |
+
lexer.xquery_parse_state.append('occurrenceindicator')
|
| 283 |
+
ctx.stack.append('kindtest')
|
| 284 |
+
ctx.pos = match.end()
|
| 285 |
+
|
| 286 |
+
def pushstate_operator_starttag_callback(lexer, match, ctx):
|
| 287 |
+
yield match.start(), Name.Tag, match.group(1)
|
| 288 |
+
lexer.xquery_parse_state.append('operator')
|
| 289 |
+
ctx.stack.append('start_tag')
|
| 290 |
+
ctx.pos = match.end()
|
| 291 |
+
|
| 292 |
+
def pushstate_operator_root_callback(lexer, match, ctx):
|
| 293 |
+
yield match.start(), Punctuation, match.group(1)
|
| 294 |
+
lexer.xquery_parse_state.append('operator')
|
| 295 |
+
ctx.stack = ['root']
|
| 296 |
+
ctx.pos = match.end()
|
| 297 |
+
|
| 298 |
+
def pushstate_operator_root_construct_callback(lexer, match, ctx):
|
| 299 |
+
yield match.start(), Keyword, match.group(1)
|
| 300 |
+
yield match.start(), Whitespace, match.group(2)
|
| 301 |
+
yield match.start(), Punctuation, match.group(3)
|
| 302 |
+
lexer.xquery_parse_state.append('operator')
|
| 303 |
+
ctx.stack = ['root']
|
| 304 |
+
ctx.pos = match.end()
|
| 305 |
+
|
| 306 |
+
def pushstate_root_callback(lexer, match, ctx):
|
| 307 |
+
yield match.start(), Punctuation, match.group(1)
|
| 308 |
+
cur_state = ctx.stack.pop()
|
| 309 |
+
lexer.xquery_parse_state.append(cur_state)
|
| 310 |
+
ctx.stack = ['root']
|
| 311 |
+
ctx.pos = match.end()
|
| 312 |
+
|
| 313 |
+
def pushstate_operator_attribute_callback(lexer, match, ctx):
|
| 314 |
+
yield match.start(), Name.Attribute, match.group(1)
|
| 315 |
+
ctx.stack.append('operator')
|
| 316 |
+
ctx.pos = match.end()
|
| 317 |
+
|
| 318 |
+
tokens = {
|
| 319 |
+
'comment': [
|
| 320 |
+
# xquery comments
|
| 321 |
+
(r'[^:()]+', Comment),
|
| 322 |
+
(r'\(:', Comment, '#push'),
|
| 323 |
+
(r':\)', Comment, '#pop'),
|
| 324 |
+
(r'[:()]', Comment),
|
| 325 |
+
],
|
| 326 |
+
'whitespace': [
|
| 327 |
+
(r'\s+', Whitespace),
|
| 328 |
+
],
|
| 329 |
+
'operator': [
|
| 330 |
+
include('whitespace'),
|
| 331 |
+
(r'(\})', popstate_callback),
|
| 332 |
+
(r'\(:', Comment, 'comment'),
|
| 333 |
+
|
| 334 |
+
(r'(\{)', pushstate_root_callback),
|
| 335 |
+
(r'then|else|external|at|div|except', Keyword, 'root'),
|
| 336 |
+
(r'order by', Keyword, 'root'),
|
| 337 |
+
(r'group by', Keyword, 'root'),
|
| 338 |
+
(r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
|
| 339 |
+
(r'and|or', Operator.Word, 'root'),
|
| 340 |
+
(r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
|
| 341 |
+
Operator.Word, 'root'),
|
| 342 |
+
(r'return|satisfies|to|union|where|count|preserve\s+strip',
|
| 343 |
+
Keyword, 'root'),
|
| 344 |
+
(r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\|\||\||:=|=|!)',
|
| 345 |
+
operator_root_callback),
|
| 346 |
+
(r'(::|:|;|\[|//|/|,)',
|
| 347 |
+
punctuation_root_callback),
|
| 348 |
+
(r'(castable|cast)(\s+)(as)\b',
|
| 349 |
+
bygroups(Keyword, Whitespace, Keyword), 'singletype'),
|
| 350 |
+
(r'(instance)(\s+)(of)\b',
|
| 351 |
+
bygroups(Keyword, Whitespace, Keyword), 'itemtype'),
|
| 352 |
+
(r'(treat)(\s+)(as)\b',
|
| 353 |
+
bygroups(Keyword, Whitespace, Keyword), 'itemtype'),
|
| 354 |
+
(r'(case)(\s+)(' + stringdouble + ')',
|
| 355 |
+
bygroups(Keyword, Whitespace, String.Double), 'itemtype'),
|
| 356 |
+
(r'(case)(\s+)(' + stringsingle + ')',
|
| 357 |
+
bygroups(Keyword, Whitespace, String.Single), 'itemtype'),
|
| 358 |
+
(r'(case|as)\b', Keyword, 'itemtype'),
|
| 359 |
+
(r'(\))(\s*)(as)',
|
| 360 |
+
bygroups(Punctuation, Whitespace, Keyword), 'itemtype'),
|
| 361 |
+
(r'\$', Name.Variable, 'varname'),
|
| 362 |
+
(r'(for|let|previous|next)(\s+)(\$)',
|
| 363 |
+
bygroups(Keyword, Whitespace, Name.Variable), 'varname'),
|
| 364 |
+
(r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
|
| 365 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword,
|
| 366 |
+
Whitespace, Name.Variable),
|
| 367 |
+
'varname'),
|
| 368 |
+
# (r'\)|\?|\]', Punctuation, '#push'),
|
| 369 |
+
(r'\)|\?|\]', Punctuation),
|
| 370 |
+
(r'(empty)(\s+)(greatest|least)',
|
| 371 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 372 |
+
(r'ascending|descending|default', Keyword, '#push'),
|
| 373 |
+
(r'(allowing)(\s+)(empty)',
|
| 374 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 375 |
+
(r'external', Keyword),
|
| 376 |
+
(r'(start|when|end)', Keyword, 'root'),
|
| 377 |
+
(r'(only)(\s+)(end)', bygroups(Keyword, Whitespace, Keyword),
|
| 378 |
+
'root'),
|
| 379 |
+
(r'collation', Keyword, 'uritooperator'),
|
| 380 |
+
|
| 381 |
+
# eXist specific XQUF
|
| 382 |
+
(r'(into|following|preceding|with)', Keyword, 'root'),
|
| 383 |
+
|
| 384 |
+
# support for current context on rhs of Simple Map Operator
|
| 385 |
+
(r'\.', Operator),
|
| 386 |
+
|
| 387 |
+
# finally catch all string literals and stay in operator state
|
| 388 |
+
(stringdouble, String.Double),
|
| 389 |
+
(stringsingle, String.Single),
|
| 390 |
+
|
| 391 |
+
(r'(catch)(\s*)', bygroups(Keyword, Whitespace), 'root'),
|
| 392 |
+
],
|
| 393 |
+
'uritooperator': [
|
| 394 |
+
(stringdouble, String.Double, '#pop'),
|
| 395 |
+
(stringsingle, String.Single, '#pop'),
|
| 396 |
+
],
|
| 397 |
+
'namespacedecl': [
|
| 398 |
+
include('whitespace'),
|
| 399 |
+
(r'\(:', Comment, 'comment'),
|
| 400 |
+
(r'(at)(\s+)('+stringdouble+')',
|
| 401 |
+
bygroups(Keyword, Whitespace, String.Double)),
|
| 402 |
+
(r"(at)(\s+)("+stringsingle+')',
|
| 403 |
+
bygroups(Keyword, Whitespace, String.Single)),
|
| 404 |
+
(stringdouble, String.Double),
|
| 405 |
+
(stringsingle, String.Single),
|
| 406 |
+
(r',', Punctuation),
|
| 407 |
+
(r'=', Operator),
|
| 408 |
+
(r';', Punctuation, 'root'),
|
| 409 |
+
(ncname, Name.Namespace),
|
| 410 |
+
],
|
| 411 |
+
'namespacekeyword': [
|
| 412 |
+
include('whitespace'),
|
| 413 |
+
(r'\(:', Comment, 'comment'),
|
| 414 |
+
(stringdouble, String.Double, 'namespacedecl'),
|
| 415 |
+
(stringsingle, String.Single, 'namespacedecl'),
|
| 416 |
+
(r'inherit|no-inherit', Keyword, 'root'),
|
| 417 |
+
(r'namespace', Keyword, 'namespacedecl'),
|
| 418 |
+
(r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)),
|
| 419 |
+
(r'preserve|no-preserve', Keyword),
|
| 420 |
+
(r',', Punctuation),
|
| 421 |
+
],
|
| 422 |
+
'annotationname': [
|
| 423 |
+
(r'\(:', Comment, 'comment'),
|
| 424 |
+
(qname, Name.Decorator),
|
| 425 |
+
(r'(\()(' + stringdouble + ')', bygroups(Punctuation, String.Double)),
|
| 426 |
+
(r'(\()(' + stringsingle + ')', bygroups(Punctuation, String.Single)),
|
| 427 |
+
(r'(\,)(\s+)(' + stringdouble + ')',
|
| 428 |
+
bygroups(Punctuation, Text, String.Double)),
|
| 429 |
+
(r'(\,)(\s+)(' + stringsingle + ')',
|
| 430 |
+
bygroups(Punctuation, Text, String.Single)),
|
| 431 |
+
(r'\)', Punctuation),
|
| 432 |
+
(r'(\s+)(\%)', bygroups(Text, Name.Decorator), 'annotationname'),
|
| 433 |
+
(r'(\s+)(variable)(\s+)(\$)',
|
| 434 |
+
bygroups(Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
|
| 435 |
+
(r'(\s+)(function)(\s+)',
|
| 436 |
+
bygroups(Text, Keyword.Declaration, Text), 'root')
|
| 437 |
+
],
|
| 438 |
+
'varname': [
|
| 439 |
+
(r'\(:', Comment, 'comment'),
|
| 440 |
+
(r'(' + qname + r')(\()?', bygroups(Name, Punctuation), 'operator'),
|
| 441 |
+
],
|
| 442 |
+
'singletype': [
|
| 443 |
+
include('whitespace'),
|
| 444 |
+
(r'\(:', Comment, 'comment'),
|
| 445 |
+
(ncname + r'(:\*)', Name.Variable, 'operator'),
|
| 446 |
+
(qname, Name.Variable, 'operator'),
|
| 447 |
+
],
|
| 448 |
+
'itemtype': [
|
| 449 |
+
include('whitespace'),
|
| 450 |
+
(r'\(:', Comment, 'comment'),
|
| 451 |
+
(r'\$', Name.Variable, 'varname'),
|
| 452 |
+
(r'(void)(\s*)(\()(\s*)(\))',
|
| 453 |
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'),
|
| 454 |
+
(r'(element|attribute|schema-element|schema-attribute|comment|text|'
|
| 455 |
+
r'node|binary|document-node|empty-sequence)(\s*)(\()',
|
| 456 |
+
pushstate_occurrenceindicator_kindtest_callback),
|
| 457 |
+
# Marklogic specific type?
|
| 458 |
+
(r'(processing-instruction)(\s*)(\()',
|
| 459 |
+
bygroups(Keyword, Text, Punctuation),
|
| 460 |
+
('occurrenceindicator', 'kindtestforpi')),
|
| 461 |
+
(r'(item)(\s*)(\()(\s*)(\))(?=[*+?])',
|
| 462 |
+
bygroups(Keyword, Text, Punctuation, Text, Punctuation),
|
| 463 |
+
'occurrenceindicator'),
|
| 464 |
+
(r'(\(\#)(\s*)', bygroups(Punctuation, Text), 'pragma'),
|
| 465 |
+
(r';', Punctuation, '#pop'),
|
| 466 |
+
(r'then|else', Keyword, '#pop'),
|
| 467 |
+
(r'(at)(\s+)(' + stringdouble + ')',
|
| 468 |
+
bygroups(Keyword, Text, String.Double), 'namespacedecl'),
|
| 469 |
+
(r'(at)(\s+)(' + stringsingle + ')',
|
| 470 |
+
bygroups(Keyword, Text, String.Single), 'namespacedecl'),
|
| 471 |
+
(r'except|intersect|in|is|return|satisfies|to|union|where|count',
|
| 472 |
+
Keyword, 'root'),
|
| 473 |
+
(r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
|
| 474 |
+
(r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|\||\|', Operator, 'root'),
|
| 475 |
+
(r'external|at', Keyword, 'root'),
|
| 476 |
+
(r'(stable)(\s+)(order)(\s+)(by)',
|
| 477 |
+
bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
|
| 478 |
+
(r'(castable|cast)(\s+)(as)',
|
| 479 |
+
bygroups(Keyword, Text, Keyword), 'singletype'),
|
| 480 |
+
(r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
|
| 481 |
+
(r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
|
| 482 |
+
(r'(case)(\s+)(' + stringdouble + ')',
|
| 483 |
+
bygroups(Keyword, Text, String.Double), 'itemtype'),
|
| 484 |
+
(r'(case)(\s+)(' + stringsingle + ')',
|
| 485 |
+
bygroups(Keyword, Text, String.Single), 'itemtype'),
|
| 486 |
+
(r'case|as', Keyword, 'itemtype'),
|
| 487 |
+
(r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
|
| 488 |
+
(ncname + r':\*', Keyword.Type, 'operator'),
|
| 489 |
+
(r'(function|map|array)(\()', bygroups(Keyword.Type, Punctuation)),
|
| 490 |
+
(qname, Keyword.Type, 'occurrenceindicator'),
|
| 491 |
+
],
|
| 492 |
+
'kindtest': [
|
| 493 |
+
(r'\(:', Comment, 'comment'),
|
| 494 |
+
(r'\{', Punctuation, 'root'),
|
| 495 |
+
(r'(\))([*+?]?)', popstate_kindtest_callback),
|
| 496 |
+
(r'\*', Name, 'closekindtest'),
|
| 497 |
+
(qname, Name, 'closekindtest'),
|
| 498 |
+
(r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback),
|
| 499 |
+
],
|
| 500 |
+
'kindtestforpi': [
|
| 501 |
+
(r'\(:', Comment, 'comment'),
|
| 502 |
+
(r'\)', Punctuation, '#pop'),
|
| 503 |
+
(ncname, Name.Variable),
|
| 504 |
+
(stringdouble, String.Double),
|
| 505 |
+
(stringsingle, String.Single),
|
| 506 |
+
],
|
| 507 |
+
'closekindtest': [
|
| 508 |
+
(r'\(:', Comment, 'comment'),
|
| 509 |
+
(r'(\))', popstate_callback),
|
| 510 |
+
(r',', Punctuation),
|
| 511 |
+
(r'(\{)', pushstate_operator_root_callback),
|
| 512 |
+
(r'\?', Punctuation),
|
| 513 |
+
],
|
| 514 |
+
'xml_comment': [
|
| 515 |
+
(r'(-->)', popstate_xmlcomment_callback),
|
| 516 |
+
(r'[^-]{1,2}', Literal),
|
| 517 |
+
(r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|[\U00010000-\U0010FFFF]',
|
| 518 |
+
Literal),
|
| 519 |
+
],
|
| 520 |
+
'processing_instruction': [
|
| 521 |
+
(r'\s+', Text, 'processing_instruction_content'),
|
| 522 |
+
(r'\?>', String.Doc, '#pop'),
|
| 523 |
+
(pitarget, Name),
|
| 524 |
+
],
|
| 525 |
+
'processing_instruction_content': [
|
| 526 |
+
(r'\?>', String.Doc, '#pop'),
|
| 527 |
+
(r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|[\U00010000-\U0010FFFF]',
|
| 528 |
+
Literal),
|
| 529 |
+
],
|
| 530 |
+
'cdata_section': [
|
| 531 |
+
(r']]>', String.Doc, '#pop'),
|
| 532 |
+
(r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|[\U00010000-\U0010FFFF]',
|
| 533 |
+
Literal),
|
| 534 |
+
],
|
| 535 |
+
'start_tag': [
|
| 536 |
+
include('whitespace'),
|
| 537 |
+
(r'(/>)', popstate_tag_callback),
|
| 538 |
+
(r'>', Name.Tag, 'element_content'),
|
| 539 |
+
(r'"', Punctuation, 'quot_attribute_content'),
|
| 540 |
+
(r"'", Punctuation, 'apos_attribute_content'),
|
| 541 |
+
(r'=', Operator),
|
| 542 |
+
(qname, Name.Tag),
|
| 543 |
+
],
|
| 544 |
+
'quot_attribute_content': [
|
| 545 |
+
(r'"', Punctuation, 'start_tag'),
|
| 546 |
+
(r'(\{)', pushstate_root_callback),
|
| 547 |
+
(r'""', Name.Attribute),
|
| 548 |
+
(quotattrcontentchar, Name.Attribute),
|
| 549 |
+
(entityref, Name.Attribute),
|
| 550 |
+
(charref, Name.Attribute),
|
| 551 |
+
(r'\{\{|\}\}', Name.Attribute),
|
| 552 |
+
],
|
| 553 |
+
'apos_attribute_content': [
|
| 554 |
+
(r"'", Punctuation, 'start_tag'),
|
| 555 |
+
(r'\{', Punctuation, 'root'),
|
| 556 |
+
(r"''", Name.Attribute),
|
| 557 |
+
(aposattrcontentchar, Name.Attribute),
|
| 558 |
+
(entityref, Name.Attribute),
|
| 559 |
+
(charref, Name.Attribute),
|
| 560 |
+
(r'\{\{|\}\}', Name.Attribute),
|
| 561 |
+
],
|
| 562 |
+
'element_content': [
|
| 563 |
+
(r'</', Name.Tag, 'end_tag'),
|
| 564 |
+
(r'(\{)', pushstate_root_callback),
|
| 565 |
+
(r'(<!--)', pushstate_element_content_xmlcomment_callback),
|
| 566 |
+
(r'(<\?)', pushstate_element_content_processing_instruction_callback),
|
| 567 |
+
(r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback),
|
| 568 |
+
(r'(<)', pushstate_element_content_starttag_callback),
|
| 569 |
+
(elementcontentchar, Literal),
|
| 570 |
+
(entityref, Literal),
|
| 571 |
+
(charref, Literal),
|
| 572 |
+
(r'\{\{|\}\}', Literal),
|
| 573 |
+
],
|
| 574 |
+
'end_tag': [
|
| 575 |
+
include('whitespace'),
|
| 576 |
+
(r'(>)', popstate_tag_callback),
|
| 577 |
+
(qname, Name.Tag),
|
| 578 |
+
],
|
| 579 |
+
'xmlspace_decl': [
|
| 580 |
+
include('whitespace'),
|
| 581 |
+
(r'\(:', Comment, 'comment'),
|
| 582 |
+
(r'preserve|strip', Keyword, '#pop'),
|
| 583 |
+
],
|
| 584 |
+
'declareordering': [
|
| 585 |
+
(r'\(:', Comment, 'comment'),
|
| 586 |
+
include('whitespace'),
|
| 587 |
+
(r'ordered|unordered', Keyword, '#pop'),
|
| 588 |
+
],
|
| 589 |
+
'xqueryversion': [
|
| 590 |
+
include('whitespace'),
|
| 591 |
+
(r'\(:', Comment, 'comment'),
|
| 592 |
+
(stringdouble, String.Double),
|
| 593 |
+
(stringsingle, String.Single),
|
| 594 |
+
(r'encoding', Keyword),
|
| 595 |
+
(r';', Punctuation, '#pop'),
|
| 596 |
+
],
|
| 597 |
+
'pragma': [
|
| 598 |
+
(qname, Name.Variable, 'pragmacontents'),
|
| 599 |
+
],
|
| 600 |
+
'pragmacontents': [
|
| 601 |
+
(r'#\)', Punctuation, 'operator'),
|
| 602 |
+
(r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|[\U00010000-\U0010FFFF]',
|
| 603 |
+
Literal),
|
| 604 |
+
(r'(\s+)', Whitespace),
|
| 605 |
+
],
|
| 606 |
+
'occurrenceindicator': [
|
| 607 |
+
include('whitespace'),
|
| 608 |
+
(r'\(:', Comment, 'comment'),
|
| 609 |
+
(r'\*|\?|\+', Operator, 'operator'),
|
| 610 |
+
(r':=', Operator, 'root'),
|
| 611 |
+
default('operator'),
|
| 612 |
+
],
|
| 613 |
+
'option': [
|
| 614 |
+
include('whitespace'),
|
| 615 |
+
(qname, Name.Variable, '#pop'),
|
| 616 |
+
],
|
| 617 |
+
'qname_braren': [
|
| 618 |
+
include('whitespace'),
|
| 619 |
+
(r'(\{)', pushstate_operator_root_callback),
|
| 620 |
+
(r'(\()', Punctuation, 'root'),
|
| 621 |
+
],
|
| 622 |
+
'element_qname': [
|
| 623 |
+
(qname, Name.Variable, 'root'),
|
| 624 |
+
],
|
| 625 |
+
'attribute_qname': [
|
| 626 |
+
(qname, Name.Variable, 'root'),
|
| 627 |
+
],
|
| 628 |
+
'root': [
|
| 629 |
+
include('whitespace'),
|
| 630 |
+
(r'\(:', Comment, 'comment'),
|
| 631 |
+
|
| 632 |
+
# handle operator state
|
| 633 |
+
# order on numbers matters - handle most complex first
|
| 634 |
+
(r'\d+(\.\d*)?[eE][+-]?\d+', Number.Float, 'operator'),
|
| 635 |
+
(r'(\.\d+)[eE][+-]?\d+', Number.Float, 'operator'),
|
| 636 |
+
(r'(\.\d+|\d+\.\d*)', Number.Float, 'operator'),
|
| 637 |
+
(r'(\d+)', Number.Integer, 'operator'),
|
| 638 |
+
(r'(\.\.|\.|\))', Punctuation, 'operator'),
|
| 639 |
+
(r'(declare)(\s+)(construction)',
|
| 640 |
+
bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
|
| 641 |
+
(r'(declare)(\s+)(default)(\s+)(order)',
|
| 642 |
+
bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
|
| 643 |
+
(r'(declare)(\s+)(context)(\s+)(item)',
|
| 644 |
+
bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
|
| 645 |
+
(ncname + r':\*', Name, 'operator'),
|
| 646 |
+
(r'\*:'+ncname, Name.Tag, 'operator'),
|
| 647 |
+
(r'\*', Name.Tag, 'operator'),
|
| 648 |
+
(stringdouble, String.Double, 'operator'),
|
| 649 |
+
(stringsingle, String.Single, 'operator'),
|
| 650 |
+
|
| 651 |
+
(r'(\}|\])', popstate_callback),
|
| 652 |
+
|
| 653 |
+
# NAMESPACE DECL
|
| 654 |
+
(r'(declare)(\s+)(default)(\s+)(collation)',
|
| 655 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration,
|
| 656 |
+
Whitespace, Keyword.Declaration)),
|
| 657 |
+
(r'(module|declare)(\s+)(namespace)',
|
| 658 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration),
|
| 659 |
+
'namespacedecl'),
|
| 660 |
+
(r'(declare)(\s+)(base-uri)',
|
| 661 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration),
|
| 662 |
+
'namespacedecl'),
|
| 663 |
+
|
| 664 |
+
# NAMESPACE KEYWORD
|
| 665 |
+
(r'(declare)(\s+)(default)(\s+)(element|function)',
|
| 666 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration,
|
| 667 |
+
Whitespace, Keyword.Declaration),
|
| 668 |
+
'namespacekeyword'),
|
| 669 |
+
(r'(import)(\s+)(schema|module)',
|
| 670 |
+
bygroups(Keyword.Pseudo, Whitespace, Keyword.Pseudo),
|
| 671 |
+
'namespacekeyword'),
|
| 672 |
+
(r'(declare)(\s+)(copy-namespaces)',
|
| 673 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration),
|
| 674 |
+
'namespacekeyword'),
|
| 675 |
+
|
| 676 |
+
# VARNAMEs
|
| 677 |
+
(r'(for|let|some|every)(\s+)(\$)',
|
| 678 |
+
bygroups(Keyword, Whitespace, Name.Variable), 'varname'),
|
| 679 |
+
(r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
|
| 680 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword,
|
| 681 |
+
Whitespace, Name.Variable),
|
| 682 |
+
'varname'),
|
| 683 |
+
(r'\$', Name.Variable, 'varname'),
|
| 684 |
+
(r'(declare)(\s+)(variable)(\s+)(\$)',
|
| 685 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration,
|
| 686 |
+
Whitespace, Name.Variable),
|
| 687 |
+
'varname'),
|
| 688 |
+
|
| 689 |
+
# ANNOTATED GLOBAL VARIABLES AND FUNCTIONS
|
| 690 |
+
(r'(declare)(\s+)(\%)', bygroups(Keyword.Declaration, Whitespace,
|
| 691 |
+
Name.Decorator),
|
| 692 |
+
'annotationname'),
|
| 693 |
+
|
| 694 |
+
# ITEMTYPE
|
| 695 |
+
(r'(\))(\s+)(as)', bygroups(Operator, Whitespace, Keyword),
|
| 696 |
+
'itemtype'),
|
| 697 |
+
|
| 698 |
+
(r'(element|attribute|schema-element|schema-attribute|comment|'
|
| 699 |
+
r'text|node|document-node|empty-sequence)(\s+)(\()',
|
| 700 |
+
pushstate_operator_kindtest_callback),
|
| 701 |
+
|
| 702 |
+
(r'(processing-instruction)(\s+)(\()',
|
| 703 |
+
pushstate_operator_kindtestforpi_callback),
|
| 704 |
+
|
| 705 |
+
(r'(<!--)', pushstate_operator_xmlcomment_callback),
|
| 706 |
+
|
| 707 |
+
(r'(<\?)', pushstate_operator_processing_instruction_callback),
|
| 708 |
+
|
| 709 |
+
(r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback),
|
| 710 |
+
|
| 711 |
+
# (r'</', Name.Tag, 'end_tag'),
|
| 712 |
+
(r'(<)', pushstate_operator_starttag_callback),
|
| 713 |
+
|
| 714 |
+
(r'(declare)(\s+)(boundary-space)',
|
| 715 |
+
bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'xmlspace_decl'),
|
| 716 |
+
|
| 717 |
+
(r'(validate)(\s+)(lax|strict)',
|
| 718 |
+
pushstate_operator_root_validate_withmode),
|
| 719 |
+
(r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
|
| 720 |
+
(r'(typeswitch)(\s*)(\()', bygroups(Keyword, Whitespace,
|
| 721 |
+
Punctuation)),
|
| 722 |
+
(r'(switch)(\s*)(\()', bygroups(Keyword, Whitespace, Punctuation)),
|
| 723 |
+
(r'(element|attribute|namespace)(\s*)(\{)',
|
| 724 |
+
pushstate_operator_root_construct_callback),
|
| 725 |
+
|
| 726 |
+
(r'(document|text|processing-instruction|comment)(\s*)(\{)',
|
| 727 |
+
pushstate_operator_root_construct_callback),
|
| 728 |
+
# ATTRIBUTE
|
| 729 |
+
(r'(attribute)(\s+)(?=' + qname + r')',
|
| 730 |
+
bygroups(Keyword, Whitespace), 'attribute_qname'),
|
| 731 |
+
# ELEMENT
|
| 732 |
+
(r'(element)(\s+)(?=' + qname + r')',
|
| 733 |
+
bygroups(Keyword, Whitespace), 'element_qname'),
|
| 734 |
+
# PROCESSING_INSTRUCTION
|
| 735 |
+
(r'(processing-instruction|namespace)(\s+)(' + ncname + r')(\s*)(\{)',
|
| 736 |
+
bygroups(Keyword, Whitespace, Name.Variable, Whitespace,
|
| 737 |
+
Punctuation),
|
| 738 |
+
'operator'),
|
| 739 |
+
|
| 740 |
+
(r'(declare|define)(\s+)(function)',
|
| 741 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration)),
|
| 742 |
+
|
| 743 |
+
(r'(\{|\[)', pushstate_operator_root_callback),
|
| 744 |
+
|
| 745 |
+
(r'(unordered|ordered)(\s*)(\{)',
|
| 746 |
+
pushstate_operator_order_callback),
|
| 747 |
+
|
| 748 |
+
(r'(map|array)(\s*)(\{)',
|
| 749 |
+
pushstate_operator_map_callback),
|
| 750 |
+
|
| 751 |
+
(r'(declare)(\s+)(ordering)',
|
| 752 |
+
bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration),
|
| 753 |
+
'declareordering'),
|
| 754 |
+
|
| 755 |
+
(r'(xquery)(\s+)(version)',
|
| 756 |
+
bygroups(Keyword.Pseudo, Whitespace, Keyword.Pseudo),
|
| 757 |
+
'xqueryversion'),
|
| 758 |
+
|
| 759 |
+
(r'(\(#)(\s*)', bygroups(Punctuation, Whitespace), 'pragma'),
|
| 760 |
+
|
| 761 |
+
# sometimes return can occur in root state
|
| 762 |
+
(r'return', Keyword),
|
| 763 |
+
|
| 764 |
+
(r'(declare)(\s+)(option)', bygroups(Keyword.Declaration,
|
| 765 |
+
Whitespace,
|
| 766 |
+
Keyword.Declaration),
|
| 767 |
+
'option'),
|
| 768 |
+
|
| 769 |
+
# URI LITERALS - single and double quoted
|
| 770 |
+
(r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'),
|
| 771 |
+
(r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'),
|
| 772 |
+
|
| 773 |
+
(r'(ancestor-or-self|ancestor|attribute|child|descendant-or-self)(::)',
|
| 774 |
+
bygroups(Keyword, Punctuation)),
|
| 775 |
+
(r'(descendant|following-sibling|following|parent|preceding-sibling'
|
| 776 |
+
r'|preceding|self)(::)', bygroups(Keyword, Punctuation)),
|
| 777 |
+
|
| 778 |
+
(r'(if)(\s*)(\()', bygroups(Keyword, Whitespace, Punctuation)),
|
| 779 |
+
|
| 780 |
+
(r'then|else', Keyword),
|
| 781 |
+
|
| 782 |
+
# eXist specific XQUF
|
| 783 |
+
(r'(update)(\s*)(insert|delete|replace|value|rename)',
|
| 784 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 785 |
+
(r'(into|following|preceding|with)', Keyword),
|
| 786 |
+
|
| 787 |
+
# Marklogic specific
|
| 788 |
+
(r'(try)(\s*)', bygroups(Keyword, Whitespace), 'root'),
|
| 789 |
+
(r'(catch)(\s*)(\()(\$)',
|
| 790 |
+
bygroups(Keyword, Whitespace, Punctuation, Name.Variable),
|
| 791 |
+
'varname'),
|
| 792 |
+
|
| 793 |
+
|
| 794 |
+
(r'(@'+qname+')', Name.Attribute, 'operator'),
|
| 795 |
+
(r'(@'+ncname+')', Name.Attribute, 'operator'),
|
| 796 |
+
(r'@\*:'+ncname, Name.Attribute, 'operator'),
|
| 797 |
+
(r'@\*', Name.Attribute, 'operator'),
|
| 798 |
+
(r'(@)', Name.Attribute, 'operator'),
|
| 799 |
+
|
| 800 |
+
(r'//|/|\+|-|;|,|\(|\)', Punctuation),
|
| 801 |
+
|
| 802 |
+
# STANDALONE QNAMES
|
| 803 |
+
(qname + r'(?=\s*\{)', Name.Tag, 'qname_braren'),
|
| 804 |
+
(qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'),
|
| 805 |
+
(r'(' + qname + ')(#)([0-9]+)', bygroups(Name.Function, Keyword.Type, Number.Integer)),
|
| 806 |
+
(qname, Name.Tag, 'operator'),
|
| 807 |
+
]
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
|
| 811 |
+
class QmlLexer(RegexLexer):
|
| 812 |
+
"""
|
| 813 |
+
For QML files.
|
| 814 |
+
"""
|
| 815 |
+
|
| 816 |
+
# QML is based on javascript, so much of this is taken from the
|
| 817 |
+
# JavascriptLexer above.
|
| 818 |
+
|
| 819 |
+
name = 'QML'
|
| 820 |
+
url = 'https://doc.qt.io/qt-6/qmlapplications.html'
|
| 821 |
+
aliases = ['qml', 'qbs']
|
| 822 |
+
filenames = ['*.qml', '*.qbs']
|
| 823 |
+
mimetypes = ['application/x-qml', 'application/x-qt.qbs+qml']
|
| 824 |
+
version_added = '1.6'
|
| 825 |
+
|
| 826 |
+
# pasted from JavascriptLexer, with some additions
|
| 827 |
+
flags = re.DOTALL | re.MULTILINE
|
| 828 |
+
|
| 829 |
+
tokens = {
|
| 830 |
+
'commentsandwhitespace': [
|
| 831 |
+
(r'\s+', Text),
|
| 832 |
+
(r'<!--', Comment),
|
| 833 |
+
(r'//.*?\n', Comment.Single),
|
| 834 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 835 |
+
],
|
| 836 |
+
'slashstartsregex': [
|
| 837 |
+
include('commentsandwhitespace'),
|
| 838 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 839 |
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
| 840 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 841 |
+
default('#pop')
|
| 842 |
+
],
|
| 843 |
+
'badregex': [
|
| 844 |
+
(r'\n', Text, '#pop')
|
| 845 |
+
],
|
| 846 |
+
'root': [
|
| 847 |
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
| 848 |
+
include('commentsandwhitespace'),
|
| 849 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
| 850 |
+
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
| 851 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 852 |
+
(r'[})\].]', Punctuation),
|
| 853 |
+
|
| 854 |
+
# QML insertions
|
| 855 |
+
(r'\bid\s*:\s*[A-Za-z][\w.]*', Keyword.Declaration,
|
| 856 |
+
'slashstartsregex'),
|
| 857 |
+
(r'\b[A-Za-z][\w.]*\s*:', Keyword, 'slashstartsregex'),
|
| 858 |
+
|
| 859 |
+
# the rest from JavascriptLexer
|
| 860 |
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
| 861 |
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
| 862 |
+
r'this)\b', Keyword, 'slashstartsregex'),
|
| 863 |
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 864 |
+
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
| 865 |
+
r'extends|final|float|goto|implements|import|int|interface|long|native|'
|
| 866 |
+
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
| 867 |
+
r'transient|volatile)\b', Keyword.Reserved),
|
| 868 |
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
| 869 |
+
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
| 870 |
+
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
| 871 |
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
| 872 |
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
| 873 |
+
r'window)\b', Name.Builtin),
|
| 874 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 875 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 876 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 877 |
+
(r'[0-9]+', Number.Integer),
|
| 878 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 879 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 880 |
+
]
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
|
| 884 |
+
class CirruLexer(RegexLexer):
|
| 885 |
+
r"""
|
| 886 |
+
* using ``()`` for expressions, but restricted in a same line
|
| 887 |
+
* using ``""`` for strings, with ``\`` for escaping chars
|
| 888 |
+
* using ``$`` as folding operator
|
| 889 |
+
* using ``,`` as unfolding operator
|
| 890 |
+
* using indentations for nested blocks
|
| 891 |
+
"""
|
| 892 |
+
|
| 893 |
+
name = 'Cirru'
|
| 894 |
+
url = 'http://cirru.org/'
|
| 895 |
+
aliases = ['cirru']
|
| 896 |
+
filenames = ['*.cirru']
|
| 897 |
+
mimetypes = ['text/x-cirru']
|
| 898 |
+
version_added = '2.0'
|
| 899 |
+
flags = re.MULTILINE
|
| 900 |
+
|
| 901 |
+
tokens = {
|
| 902 |
+
'string': [
|
| 903 |
+
(r'[^"\\\n]+', String),
|
| 904 |
+
(r'\\', String.Escape, 'escape'),
|
| 905 |
+
(r'"', String, '#pop'),
|
| 906 |
+
],
|
| 907 |
+
'escape': [
|
| 908 |
+
(r'.', String.Escape, '#pop'),
|
| 909 |
+
],
|
| 910 |
+
'function': [
|
| 911 |
+
(r'\,', Operator, '#pop'),
|
| 912 |
+
(r'[^\s"()]+', Name.Function, '#pop'),
|
| 913 |
+
(r'\)', Operator, '#pop'),
|
| 914 |
+
(r'(?=\n)', Text, '#pop'),
|
| 915 |
+
(r'\(', Operator, '#push'),
|
| 916 |
+
(r'"', String, ('#pop', 'string')),
|
| 917 |
+
(r'[ ]+', Text.Whitespace),
|
| 918 |
+
],
|
| 919 |
+
'line': [
|
| 920 |
+
(r'(?<!\w)\$(?!\w)', Operator, 'function'),
|
| 921 |
+
(r'\(', Operator, 'function'),
|
| 922 |
+
(r'\)', Operator),
|
| 923 |
+
(r'\n', Text, '#pop'),
|
| 924 |
+
(r'"', String, 'string'),
|
| 925 |
+
(r'[ ]+', Text.Whitespace),
|
| 926 |
+
(r'[+-]?[\d.]+\b', Number),
|
| 927 |
+
(r'[^\s"()]+', Name.Variable)
|
| 928 |
+
],
|
| 929 |
+
'root': [
|
| 930 |
+
(r'^\n+', Text.Whitespace),
|
| 931 |
+
default(('line', 'function')),
|
| 932 |
+
]
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
|
| 936 |
+
class SlimLexer(ExtendedRegexLexer):
|
| 937 |
+
"""
|
| 938 |
+
For Slim markup.
|
| 939 |
+
"""
|
| 940 |
+
|
| 941 |
+
name = 'Slim'
|
| 942 |
+
aliases = ['slim']
|
| 943 |
+
filenames = ['*.slim']
|
| 944 |
+
mimetypes = ['text/x-slim']
|
| 945 |
+
url = 'https://slim-template.github.io'
|
| 946 |
+
version_added = '2.0'
|
| 947 |
+
|
| 948 |
+
flags = re.IGNORECASE
|
| 949 |
+
_dot = r'(?: \|\n(?=.* \|)|.)'
|
| 950 |
+
tokens = {
|
| 951 |
+
'root': [
|
| 952 |
+
(r'[ \t]*\n', Text),
|
| 953 |
+
(r'[ \t]*', _indentation),
|
| 954 |
+
],
|
| 955 |
+
|
| 956 |
+
'css': [
|
| 957 |
+
(r'\.[\w:-]+', Name.Class, 'tag'),
|
| 958 |
+
(r'\#[\w:-]+', Name.Function, 'tag'),
|
| 959 |
+
],
|
| 960 |
+
|
| 961 |
+
'eval-or-plain': [
|
| 962 |
+
(r'([ \t]*==?)(.*\n)',
|
| 963 |
+
bygroups(Punctuation, using(RubyLexer)),
|
| 964 |
+
'root'),
|
| 965 |
+
(r'[ \t]+[\w:-]+(?==)', Name.Attribute, 'html-attributes'),
|
| 966 |
+
default('plain'),
|
| 967 |
+
],
|
| 968 |
+
|
| 969 |
+
'content': [
|
| 970 |
+
include('css'),
|
| 971 |
+
(r'[\w:-]+:[ \t]*\n', Text, 'plain'),
|
| 972 |
+
(r'(-)(.*\n)',
|
| 973 |
+
bygroups(Punctuation, using(RubyLexer)),
|
| 974 |
+
'#pop'),
|
| 975 |
+
(r'\|' + _dot + r'*\n', _starts_block(Text, 'plain'), '#pop'),
|
| 976 |
+
(r'/' + _dot + r'*\n', _starts_block(Comment.Preproc, 'slim-comment-block'), '#pop'),
|
| 977 |
+
(r'[\w:-]+', Name.Tag, 'tag'),
|
| 978 |
+
include('eval-or-plain'),
|
| 979 |
+
],
|
| 980 |
+
|
| 981 |
+
'tag': [
|
| 982 |
+
include('css'),
|
| 983 |
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
| 984 |
+
(r'[ \t]+\n', Punctuation, '#pop:2'),
|
| 985 |
+
include('eval-or-plain'),
|
| 986 |
+
],
|
| 987 |
+
|
| 988 |
+
'plain': [
|
| 989 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
| 990 |
+
(r'(#\{)(.*?)(\})',
|
| 991 |
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
| 992 |
+
(r'\n', Text, 'root'),
|
| 993 |
+
],
|
| 994 |
+
|
| 995 |
+
'html-attributes': [
|
| 996 |
+
(r'=', Punctuation),
|
| 997 |
+
(r'"[^"]+"', using(RubyLexer), 'tag'),
|
| 998 |
+
(r'\'[^\']+\'', using(RubyLexer), 'tag'),
|
| 999 |
+
(r'\w+', Text, 'tag'),
|
| 1000 |
+
],
|
| 1001 |
+
|
| 1002 |
+
'slim-comment-block': [
|
| 1003 |
+
(_dot + '+', Comment.Preproc),
|
| 1004 |
+
(r'\n', Text, 'root'),
|
| 1005 |
+
],
|
| 1006 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wgsl.py
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.wgsl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the WebGPU Shading 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, default
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
from pygments import unistring as uni
|
| 15 |
+
|
| 16 |
+
__all__ = ['WgslLexer']
|
| 17 |
+
|
| 18 |
+
LF = '\\u000a'
|
| 19 |
+
VT = '\\u000b'
|
| 20 |
+
FF = '\\u000c'
|
| 21 |
+
CR = '\\u000d'
|
| 22 |
+
NextLine = '\\u0085'
|
| 23 |
+
LineSep = '\\u2028'
|
| 24 |
+
ParaSep = '\\u2029'
|
| 25 |
+
LineEndCodePoints = [LF,VT,FF,CR,NextLine,LineSep,ParaSep]
|
| 26 |
+
NotLineEndRE = '[^' + "".join(LineEndCodePoints) + ']'
|
| 27 |
+
LineEndRE = '[' + "".join(LineEndCodePoints) + ']'
|
| 28 |
+
|
| 29 |
+
# https://www.w3.org/TR/WGSL/#syntax-ident_pattern_token
|
| 30 |
+
ident_pattern_token = f'([{uni.xid_start}][{uni.xid_continue}]+)|[{uni.xid_start}]'
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class WgslLexer(RegexLexer):
|
| 34 |
+
"""
|
| 35 |
+
Lexer for the WebGPU Shading Language.
|
| 36 |
+
"""
|
| 37 |
+
name = 'WebGPU Shading Language'
|
| 38 |
+
url = 'https://www.w3.org/TR/WGSL/'
|
| 39 |
+
aliases = ['wgsl']
|
| 40 |
+
filenames = ['*.wgsl']
|
| 41 |
+
mimetypes = ['text/wgsl']
|
| 42 |
+
version_added = '2.15'
|
| 43 |
+
|
| 44 |
+
# https://www.w3.org/TR/WGSL/#var-and-value
|
| 45 |
+
keyword_decl = (words('var let const override'.split(),suffix=r'\b'), Keyword.Declaration)
|
| 46 |
+
# https://www.w3.org/TR/WGSL/#keyword-summary
|
| 47 |
+
keywords = (words("""
|
| 48 |
+
alias
|
| 49 |
+
break
|
| 50 |
+
case
|
| 51 |
+
const_assert
|
| 52 |
+
continue
|
| 53 |
+
continuing
|
| 54 |
+
default
|
| 55 |
+
diagnostic
|
| 56 |
+
discard
|
| 57 |
+
else
|
| 58 |
+
enable
|
| 59 |
+
false
|
| 60 |
+
fn
|
| 61 |
+
for
|
| 62 |
+
if
|
| 63 |
+
loop
|
| 64 |
+
requires
|
| 65 |
+
return
|
| 66 |
+
struct
|
| 67 |
+
switch
|
| 68 |
+
true
|
| 69 |
+
while
|
| 70 |
+
""".split(), suffix=r'\b'), Keyword)
|
| 71 |
+
|
| 72 |
+
# https://www.w3.org/TR/WGSL/#reserved-words
|
| 73 |
+
keyword_reserved = (words("""
|
| 74 |
+
NULL
|
| 75 |
+
Self
|
| 76 |
+
abstract
|
| 77 |
+
active
|
| 78 |
+
alignas
|
| 79 |
+
alignof
|
| 80 |
+
as
|
| 81 |
+
asm
|
| 82 |
+
asm_fragment
|
| 83 |
+
async
|
| 84 |
+
attribute
|
| 85 |
+
auto
|
| 86 |
+
await
|
| 87 |
+
become
|
| 88 |
+
binding_array
|
| 89 |
+
cast
|
| 90 |
+
catch
|
| 91 |
+
class
|
| 92 |
+
co_await
|
| 93 |
+
co_return
|
| 94 |
+
co_yield
|
| 95 |
+
coherent
|
| 96 |
+
column_major
|
| 97 |
+
common
|
| 98 |
+
compile
|
| 99 |
+
compile_fragment
|
| 100 |
+
concept
|
| 101 |
+
const_cast
|
| 102 |
+
consteval
|
| 103 |
+
constexpr
|
| 104 |
+
constinit
|
| 105 |
+
crate
|
| 106 |
+
debugger
|
| 107 |
+
decltype
|
| 108 |
+
delete
|
| 109 |
+
demote
|
| 110 |
+
demote_to_helper
|
| 111 |
+
do
|
| 112 |
+
dynamic_cast
|
| 113 |
+
enum
|
| 114 |
+
explicit
|
| 115 |
+
export
|
| 116 |
+
extends
|
| 117 |
+
extern
|
| 118 |
+
external
|
| 119 |
+
fallthrough
|
| 120 |
+
filter
|
| 121 |
+
final
|
| 122 |
+
finally
|
| 123 |
+
friend
|
| 124 |
+
from
|
| 125 |
+
fxgroup
|
| 126 |
+
get
|
| 127 |
+
goto
|
| 128 |
+
groupshared
|
| 129 |
+
highp
|
| 130 |
+
impl
|
| 131 |
+
implements
|
| 132 |
+
import
|
| 133 |
+
inline
|
| 134 |
+
instanceof
|
| 135 |
+
interface
|
| 136 |
+
layout
|
| 137 |
+
lowp
|
| 138 |
+
macro
|
| 139 |
+
macro_rules
|
| 140 |
+
match
|
| 141 |
+
mediump
|
| 142 |
+
meta
|
| 143 |
+
mod
|
| 144 |
+
module
|
| 145 |
+
move
|
| 146 |
+
mut
|
| 147 |
+
mutable
|
| 148 |
+
namespace
|
| 149 |
+
new
|
| 150 |
+
nil
|
| 151 |
+
noexcept
|
| 152 |
+
noinline
|
| 153 |
+
nointerpolation
|
| 154 |
+
noperspective
|
| 155 |
+
null
|
| 156 |
+
nullptr
|
| 157 |
+
of
|
| 158 |
+
operator
|
| 159 |
+
package
|
| 160 |
+
packoffset
|
| 161 |
+
partition
|
| 162 |
+
pass
|
| 163 |
+
patch
|
| 164 |
+
pixelfragment
|
| 165 |
+
precise
|
| 166 |
+
precision
|
| 167 |
+
premerge
|
| 168 |
+
priv
|
| 169 |
+
protected
|
| 170 |
+
pub
|
| 171 |
+
public
|
| 172 |
+
readonly
|
| 173 |
+
ref
|
| 174 |
+
regardless
|
| 175 |
+
register
|
| 176 |
+
reinterpret_cast
|
| 177 |
+
require
|
| 178 |
+
resource
|
| 179 |
+
restrict
|
| 180 |
+
self
|
| 181 |
+
set
|
| 182 |
+
shared
|
| 183 |
+
sizeof
|
| 184 |
+
smooth
|
| 185 |
+
snorm
|
| 186 |
+
static
|
| 187 |
+
static_assert
|
| 188 |
+
static_cast
|
| 189 |
+
std
|
| 190 |
+
subroutine
|
| 191 |
+
super
|
| 192 |
+
target
|
| 193 |
+
template
|
| 194 |
+
this
|
| 195 |
+
thread_local
|
| 196 |
+
throw
|
| 197 |
+
trait
|
| 198 |
+
try
|
| 199 |
+
type
|
| 200 |
+
typedef
|
| 201 |
+
typeid
|
| 202 |
+
typename
|
| 203 |
+
typeof
|
| 204 |
+
union
|
| 205 |
+
unless
|
| 206 |
+
unorm
|
| 207 |
+
unsafe
|
| 208 |
+
unsized
|
| 209 |
+
use
|
| 210 |
+
using
|
| 211 |
+
varying
|
| 212 |
+
virtual
|
| 213 |
+
volatile
|
| 214 |
+
wgsl
|
| 215 |
+
where
|
| 216 |
+
with
|
| 217 |
+
writeonly
|
| 218 |
+
yield
|
| 219 |
+
""".split(), suffix=r'\b'), Keyword.Reserved)
|
| 220 |
+
|
| 221 |
+
# https://www.w3.org/TR/WGSL/#predeclared-enumerants
|
| 222 |
+
predeclared_enums = (words("""
|
| 223 |
+
read write read_write
|
| 224 |
+
function private workgroup uniform storage
|
| 225 |
+
perspective linear flat
|
| 226 |
+
center centroid sample
|
| 227 |
+
vertex_index instance_index position front_facing frag_depth
|
| 228 |
+
local_invocation_id local_invocation_index
|
| 229 |
+
global_invocation_id workgroup_id num_workgroups
|
| 230 |
+
sample_index sample_mask
|
| 231 |
+
rgba8unorm
|
| 232 |
+
rgba8snorm
|
| 233 |
+
rgba8uint
|
| 234 |
+
rgba8sint
|
| 235 |
+
rgba16uint
|
| 236 |
+
rgba16sint
|
| 237 |
+
rgba16float
|
| 238 |
+
r32uint
|
| 239 |
+
r32sint
|
| 240 |
+
r32float
|
| 241 |
+
rg32uint
|
| 242 |
+
rg32sint
|
| 243 |
+
rg32float
|
| 244 |
+
rgba32uint
|
| 245 |
+
rgba32sint
|
| 246 |
+
rgba32float
|
| 247 |
+
bgra8unorm
|
| 248 |
+
""".split(), suffix=r'\b'), Name.Builtin)
|
| 249 |
+
|
| 250 |
+
# https://www.w3.org/TR/WGSL/#predeclared-types
|
| 251 |
+
predeclared_types = (words("""
|
| 252 |
+
bool
|
| 253 |
+
f16
|
| 254 |
+
f32
|
| 255 |
+
i32
|
| 256 |
+
sampler sampler_comparison
|
| 257 |
+
texture_depth_2d
|
| 258 |
+
texture_depth_2d_array
|
| 259 |
+
texture_depth_cube
|
| 260 |
+
texture_depth_cube_array
|
| 261 |
+
texture_depth_multisampled_2d
|
| 262 |
+
texture_external
|
| 263 |
+
texture_external
|
| 264 |
+
u32
|
| 265 |
+
""".split(), suffix=r'\b'), Name.Builtin)
|
| 266 |
+
|
| 267 |
+
# https://www.w3.org/TR/WGSL/#predeclared-types
|
| 268 |
+
predeclared_type_generators = (words("""
|
| 269 |
+
array
|
| 270 |
+
atomic
|
| 271 |
+
mat2x2
|
| 272 |
+
mat2x3
|
| 273 |
+
mat2x4
|
| 274 |
+
mat3x2
|
| 275 |
+
mat3x3
|
| 276 |
+
mat3x4
|
| 277 |
+
mat4x2
|
| 278 |
+
mat4x3
|
| 279 |
+
mat4x4
|
| 280 |
+
ptr
|
| 281 |
+
texture_1d
|
| 282 |
+
texture_2d
|
| 283 |
+
texture_2d_array
|
| 284 |
+
texture_3d
|
| 285 |
+
texture_cube
|
| 286 |
+
texture_cube_array
|
| 287 |
+
texture_multisampled_2d
|
| 288 |
+
texture_storage_1d
|
| 289 |
+
texture_storage_2d
|
| 290 |
+
texture_storage_2d_array
|
| 291 |
+
texture_storage_3d
|
| 292 |
+
vec2
|
| 293 |
+
vec3
|
| 294 |
+
vec4
|
| 295 |
+
""".split(), suffix=r'\b'), Name.Builtin)
|
| 296 |
+
|
| 297 |
+
# Predeclared type aliases for vectors
|
| 298 |
+
# https://www.w3.org/TR/WGSL/#vector-types
|
| 299 |
+
predeclared_type_alias_vectors = (words("""
|
| 300 |
+
vec2i vec3i vec4i
|
| 301 |
+
vec2u vec3u vec4u
|
| 302 |
+
vec2f vec3f vec4f
|
| 303 |
+
vec2h vec3h vec4h
|
| 304 |
+
""".split(), suffix=r'\b'), Name.Builtin)
|
| 305 |
+
|
| 306 |
+
# Predeclared type aliases for matrices
|
| 307 |
+
# https://www.w3.org/TR/WGSL/#matrix-types
|
| 308 |
+
predeclared_type_alias_matrices = (words("""
|
| 309 |
+
mat2x2f mat2x3f mat2x4f
|
| 310 |
+
mat3x2f mat3x3f mat3x4f
|
| 311 |
+
mat4x2f mat4x3f mat4x4f
|
| 312 |
+
mat2x2h mat2x3h mat2x4h
|
| 313 |
+
mat3x2h mat3x3h mat3x4h
|
| 314 |
+
mat4x2h mat4x3h mat4x4h
|
| 315 |
+
""".split(), suffix=r'\b'), Name.Builtin)
|
| 316 |
+
|
| 317 |
+
tokens = {
|
| 318 |
+
'blankspace': [
|
| 319 |
+
# https://www.w3.org/TR/WGSL/#blankspace
|
| 320 |
+
(r'[\u0020\u0009\u000a\u000b\u000c\u000d\u0085\u200e\u200f\u2028\u2029]+', Whitespace),
|
| 321 |
+
],
|
| 322 |
+
'comments': [
|
| 323 |
+
# Line ending comments
|
| 324 |
+
# Match up CR/LF pair first.
|
| 325 |
+
(rf'//{NotLineEndRE}*{CR}{LF}', Comment.Single),
|
| 326 |
+
(rf'//{NotLineEndRE}*{LineEndRE}', Comment.Single),
|
| 327 |
+
(r'/\*', Comment.Multiline, 'block_comment'),
|
| 328 |
+
],
|
| 329 |
+
'attribute': [
|
| 330 |
+
include('blankspace'),
|
| 331 |
+
include('comments'),
|
| 332 |
+
(ident_pattern_token, Name.Decorator,'#pop'),
|
| 333 |
+
default('#pop'),
|
| 334 |
+
],
|
| 335 |
+
'root': [
|
| 336 |
+
include('blankspace'),
|
| 337 |
+
include('comments'),
|
| 338 |
+
|
| 339 |
+
# Attributes.
|
| 340 |
+
# https://www.w3.org/TR/WGSL/#attributes
|
| 341 |
+
# Mark the '@' and the attribute name as a decorator.
|
| 342 |
+
(r'@', Name.Decorator, 'attribute'),
|
| 343 |
+
|
| 344 |
+
# Keywords
|
| 345 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 346 |
+
keyword_decl,
|
| 347 |
+
keywords,
|
| 348 |
+
keyword_reserved,
|
| 349 |
+
|
| 350 |
+
# Predeclared
|
| 351 |
+
predeclared_enums,
|
| 352 |
+
predeclared_types,
|
| 353 |
+
predeclared_type_generators,
|
| 354 |
+
predeclared_type_alias_vectors,
|
| 355 |
+
predeclared_type_alias_matrices,
|
| 356 |
+
|
| 357 |
+
# Decimal float literals
|
| 358 |
+
# https://www.w3.org/TR/WGSL/#syntax-decimal_float_literal
|
| 359 |
+
# 0, with type-specifying suffix.
|
| 360 |
+
(r'0[fh]', Number.Float),
|
| 361 |
+
# Other decimal integer, with type-specifying suffix.
|
| 362 |
+
(r'[1-9][0-9]*[fh]', Number.Float),
|
| 363 |
+
# Has decimal point, at least one digit after decimal.
|
| 364 |
+
(r'[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[fh]?', Number.Float),
|
| 365 |
+
# Has decimal point, at least one digit before decimal.
|
| 366 |
+
(r'[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?[fh]?', Number.Float),
|
| 367 |
+
# Has at least one digit, and has an exponent.
|
| 368 |
+
(r'[0-9]+[eE][+-]?[0-9]+[fh]?', Number.Float),
|
| 369 |
+
|
| 370 |
+
# Hex float literals
|
| 371 |
+
# https://www.w3.org/TR/WGSL/#syntax-hex_float_literal
|
| 372 |
+
(r'0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+([pP][+-]?[0-9]+[fh]?)?', Number.Float),
|
| 373 |
+
(r'0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*([pP][+-]?[0-9]+[fh]?)?', Number.Float),
|
| 374 |
+
(r'0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?', Number.Float),
|
| 375 |
+
|
| 376 |
+
# Hexadecimal integer literals
|
| 377 |
+
# https://www.w3.org/TR/WGSL/#syntax-hex_int_literal
|
| 378 |
+
(r'0[xX][0-9a-fA-F]+[iu]?', Number.Hex),
|
| 379 |
+
# Decimal integer literals
|
| 380 |
+
# https://www.w3.org/TR/WGSL/#syntax-decimal_int_literal
|
| 381 |
+
# We need two rules here because 01 is not valid.
|
| 382 |
+
(r'[1-9][0-9]*[iu]?', Number.Integer),
|
| 383 |
+
(r'0[iu]?', Number.Integer), # Must match last.
|
| 384 |
+
|
| 385 |
+
# Operators and Punctuation
|
| 386 |
+
(r'[{}()\[\],\.;:]', Punctuation),
|
| 387 |
+
(r'->', Punctuation), # Return-type arrow
|
| 388 |
+
(r'[+\-*/%&|<>^!~=]', Operator),
|
| 389 |
+
|
| 390 |
+
# TODO: Treat context-depedendent names specially
|
| 391 |
+
# https://www.w3.org/TR/WGSL/#context-dependent-name
|
| 392 |
+
|
| 393 |
+
# Identifiers
|
| 394 |
+
(ident_pattern_token, Name),
|
| 395 |
+
|
| 396 |
+
# TODO: templates start and end tokens.
|
| 397 |
+
# https://www.w3.org/TR/WGSL/#template-lists-sec
|
| 398 |
+
],
|
| 399 |
+
'block_comment': [
|
| 400 |
+
# https://www.w3.org/TR/WGSL/#block-comment
|
| 401 |
+
(r'[^*/]+', Comment.Multiline),
|
| 402 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 403 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 404 |
+
(r'[*/]', Comment.Multiline),
|
| 405 |
+
],
|
| 406 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/whiley.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.whiley
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Whiley 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 Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['WhileyLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class WhileyLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the Whiley programming language.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Whiley'
|
| 23 |
+
url = 'http://whiley.org/'
|
| 24 |
+
filenames = ['*.whiley']
|
| 25 |
+
aliases = ['whiley']
|
| 26 |
+
mimetypes = ['text/x-whiley']
|
| 27 |
+
version_added = '2.2'
|
| 28 |
+
|
| 29 |
+
# See the language specification:
|
| 30 |
+
# http://whiley.org/download/WhileyLanguageSpec.pdf
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
# Whitespace
|
| 35 |
+
(r'\s+', Text),
|
| 36 |
+
|
| 37 |
+
# Comments
|
| 38 |
+
(r'//.*', Comment.Single),
|
| 39 |
+
# don't parse empty comment as doc comment
|
| 40 |
+
(r'/\*\*/', Comment.Multiline),
|
| 41 |
+
(r'(?s)/\*\*.*?\*/', String.Doc),
|
| 42 |
+
(r'(?s)/\*.*?\*/', Comment.Multiline),
|
| 43 |
+
|
| 44 |
+
# Keywords
|
| 45 |
+
(words((
|
| 46 |
+
'if', 'else', 'while', 'for', 'do', 'return',
|
| 47 |
+
'switch', 'case', 'default', 'break', 'continue',
|
| 48 |
+
'requires', 'ensures', 'where', 'assert', 'assume',
|
| 49 |
+
'all', 'no', 'some', 'in', 'is', 'new',
|
| 50 |
+
'throw', 'try', 'catch', 'debug', 'skip', 'fail',
|
| 51 |
+
'finite', 'total'), suffix=r'\b'), Keyword.Reserved),
|
| 52 |
+
(words((
|
| 53 |
+
'function', 'method', 'public', 'private', 'protected',
|
| 54 |
+
'export', 'native'), suffix=r'\b'), Keyword.Declaration),
|
| 55 |
+
# "constant" & "type" are not keywords unless used in declarations
|
| 56 |
+
(r'(constant|type)(\s+)([a-zA-Z_]\w*)(\s+)(is)\b',
|
| 57 |
+
bygroups(Keyword.Declaration, Text, Name, Text, Keyword.Reserved)),
|
| 58 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 59 |
+
(r'(bool|byte|int|real|any|void)\b', Keyword.Type),
|
| 60 |
+
# "from" is not a keyword unless used with import
|
| 61 |
+
(r'(import)(\s+)(\*)([^\S\n]+)(from)\b',
|
| 62 |
+
bygroups(Keyword.Namespace, Text, Punctuation, Text, Keyword.Namespace)),
|
| 63 |
+
(r'(import)(\s+)([a-zA-Z_]\w*)([^\S\n]+)(from)\b',
|
| 64 |
+
bygroups(Keyword.Namespace, Text, Name, Text, Keyword.Namespace)),
|
| 65 |
+
(r'(package|import)\b', Keyword.Namespace),
|
| 66 |
+
|
| 67 |
+
# standard library: https://github.com/Whiley/WhileyLibs/
|
| 68 |
+
(words((
|
| 69 |
+
# types defined in whiley.lang.Int
|
| 70 |
+
'i8', 'i16', 'i32', 'i64',
|
| 71 |
+
'u8', 'u16', 'u32', 'u64',
|
| 72 |
+
'uint', 'nat',
|
| 73 |
+
|
| 74 |
+
# whiley.lang.Any
|
| 75 |
+
'toString'), suffix=r'\b'), Name.Builtin),
|
| 76 |
+
|
| 77 |
+
# byte literal
|
| 78 |
+
(r'[01]+b', Number.Bin),
|
| 79 |
+
|
| 80 |
+
# decimal literal
|
| 81 |
+
(r'[0-9]+\.[0-9]+', Number.Float),
|
| 82 |
+
# match "1." but not ranges like "3..5"
|
| 83 |
+
(r'[0-9]+\.(?!\.)', Number.Float),
|
| 84 |
+
|
| 85 |
+
# integer literal
|
| 86 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 87 |
+
(r'[0-9]+', Number.Integer),
|
| 88 |
+
|
| 89 |
+
# character literal
|
| 90 |
+
(r"""'[^\\]'""", String.Char),
|
| 91 |
+
(r"""(')(\\['"\\btnfr])(')""",
|
| 92 |
+
bygroups(String.Char, String.Escape, String.Char)),
|
| 93 |
+
|
| 94 |
+
# string literal
|
| 95 |
+
(r'"', String, 'string'),
|
| 96 |
+
|
| 97 |
+
# operators and punctuation
|
| 98 |
+
(r'[{}()\[\],.;]', Punctuation),
|
| 99 |
+
(r'[+\-*/%&|<>^!~@=:?'
|
| 100 |
+
# unicode operators
|
| 101 |
+
r'\u2200\u2203\u2205\u2282\u2286\u2283\u2287'
|
| 102 |
+
r'\u222A\u2229\u2264\u2265\u2208\u2227\u2228'
|
| 103 |
+
r']', Operator),
|
| 104 |
+
|
| 105 |
+
# identifier
|
| 106 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 107 |
+
],
|
| 108 |
+
'string': [
|
| 109 |
+
(r'"', String, '#pop'),
|
| 110 |
+
(r'\\[btnfr]', String.Escape),
|
| 111 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 112 |
+
(r'\\.', String),
|
| 113 |
+
(r'[^\\"]+', String),
|
| 114 |
+
],
|
| 115 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wowtoc.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.wowtoc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for World of Warcraft TOC files
|
| 6 |
+
|
| 7 |
+
TOC files describe game addons.
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import re
|
| 14 |
+
|
| 15 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 16 |
+
from pygments.token import Comment, Name, Text, Punctuation, String, Keyword
|
| 17 |
+
|
| 18 |
+
__all__ = ["WoWTocLexer"]
|
| 19 |
+
|
| 20 |
+
def _create_tag_line_pattern(inner_pattern, ignore_case=False):
|
| 21 |
+
return ((r"(?i)" if ignore_case else r"")
|
| 22 |
+
+ r"^(##)( *)" # groups 1, 2
|
| 23 |
+
+ inner_pattern # group 3
|
| 24 |
+
+ r"( *)(:)( *)(.*?)( *)$") # groups 4, 5, 6, 7, 8
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _create_tag_line_token(inner_pattern, inner_token, ignore_case=False):
|
| 28 |
+
# this function template-izes the tag line for a specific type of tag, which will
|
| 29 |
+
# have a different pattern and different token. otherwise, everything about a tag
|
| 30 |
+
# line is the same
|
| 31 |
+
return (
|
| 32 |
+
_create_tag_line_pattern(inner_pattern, ignore_case=ignore_case),
|
| 33 |
+
bygroups(
|
| 34 |
+
Keyword.Declaration,
|
| 35 |
+
Text.Whitespace,
|
| 36 |
+
inner_token,
|
| 37 |
+
Text.Whitespace,
|
| 38 |
+
Punctuation,
|
| 39 |
+
Text.Whitespace,
|
| 40 |
+
String,
|
| 41 |
+
Text.Whitespace,
|
| 42 |
+
),
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class WoWTocLexer(RegexLexer):
|
| 47 |
+
"""
|
| 48 |
+
Lexer for World of Warcraft TOC files.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
name = "World of Warcraft TOC"
|
| 52 |
+
aliases = ["wowtoc"]
|
| 53 |
+
filenames = ["*.toc"]
|
| 54 |
+
url = 'https://wowpedia.fandom.com/wiki/TOC_format'
|
| 55 |
+
version_added = '2.14'
|
| 56 |
+
|
| 57 |
+
tokens = {
|
| 58 |
+
"root": [
|
| 59 |
+
# official localized tags, Notes and Title
|
| 60 |
+
# (normal part is insensitive, locale part is sensitive)
|
| 61 |
+
_create_tag_line_token(
|
| 62 |
+
r"((?:[nN][oO][tT][eE][sS]|[tT][iI][tT][lL][eE])-(?:ptBR|zhCN|"
|
| 63 |
+
r"enCN|frFR|deDE|itIT|esMX|ptPT|koKR|ruRU|esES|zhTW|enTW|enGB|enUS))",
|
| 64 |
+
Name.Builtin,
|
| 65 |
+
),
|
| 66 |
+
# other official tags
|
| 67 |
+
_create_tag_line_token(
|
| 68 |
+
r"(Interface|Title|Notes|RequiredDeps|Dep[^: ]*|OptionalDeps|"
|
| 69 |
+
r"LoadOnDemand|LoadWith|LoadManagers|SavedVariablesPerCharacter|"
|
| 70 |
+
r"SavedVariables|DefaultState|Secure|Author|Version)",
|
| 71 |
+
Name.Builtin,
|
| 72 |
+
ignore_case=True,
|
| 73 |
+
),
|
| 74 |
+
# user-defined tags
|
| 75 |
+
_create_tag_line_token(
|
| 76 |
+
r"(X-[^: ]*)",
|
| 77 |
+
Name.Variable,
|
| 78 |
+
ignore_case=True,
|
| 79 |
+
),
|
| 80 |
+
# non-conforming tags, but still valid
|
| 81 |
+
_create_tag_line_token(
|
| 82 |
+
r"([^: ]*)",
|
| 83 |
+
Name.Other,
|
| 84 |
+
),
|
| 85 |
+
|
| 86 |
+
# Comments
|
| 87 |
+
(r"^#.*$", Comment),
|
| 88 |
+
|
| 89 |
+
# Addon Files
|
| 90 |
+
(r"^.+$", Name),
|
| 91 |
+
]
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
def analyse_text(text):
|
| 95 |
+
# at time of writing, this file suffix conflict's with one of Tex's in
|
| 96 |
+
# markup.py. Tex's anaylse_text() appears to be definitive (binary) and does not
|
| 97 |
+
# share any likeness to WoW TOCs, which means we wont have to compete with it by
|
| 98 |
+
# abitrary increments in score.
|
| 99 |
+
|
| 100 |
+
result = 0
|
| 101 |
+
|
| 102 |
+
# while not required, an almost certain marker of WoW TOC's is the interface tag
|
| 103 |
+
# if this tag is omitted, players will need to opt-in to loading the addon with
|
| 104 |
+
# an options change ("Load out of date addons"). the value is also standardized:
|
| 105 |
+
# `<major><minor><patch>`, with minor and patch being two-digit zero-padded.
|
| 106 |
+
interface_pattern = _create_tag_line_pattern(r"(Interface)", ignore_case=True)
|
| 107 |
+
match = re.search(interface_pattern, text)
|
| 108 |
+
if match and re.match(r"(\d+)(\d{2})(\d{2})", match.group(7)):
|
| 109 |
+
result += 0.8
|
| 110 |
+
|
| 111 |
+
casefolded = text.casefold()
|
| 112 |
+
# Lua file listing is good marker too, but probably conflicts with many other
|
| 113 |
+
# lexers
|
| 114 |
+
if ".lua" in casefolded:
|
| 115 |
+
result += 0.1
|
| 116 |
+
# ditto for XML files, but they're less used in WoW TOCs
|
| 117 |
+
if ".xml" in casefolded:
|
| 118 |
+
result += 0.05
|
| 119 |
+
|
| 120 |
+
return result
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/wren.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.wren
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Wren.
|
| 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 include, RegexLexer, words
|
| 14 |
+
from pygments.token import Whitespace, Punctuation, Keyword, Name, Comment, \
|
| 15 |
+
Operator, Number, String
|
| 16 |
+
|
| 17 |
+
__all__ = ['WrenLexer']
|
| 18 |
+
|
| 19 |
+
class WrenLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For Wren source code, version 0.4.0.
|
| 22 |
+
"""
|
| 23 |
+
name = 'Wren'
|
| 24 |
+
url = 'https://wren.io'
|
| 25 |
+
aliases = ['wren']
|
| 26 |
+
filenames = ['*.wren']
|
| 27 |
+
version_added = '2.14'
|
| 28 |
+
|
| 29 |
+
flags = re.MULTILINE | re.DOTALL
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
# Whitespace.
|
| 34 |
+
(r'\s+', Whitespace),
|
| 35 |
+
(r'[,\\\[\]{}]', Punctuation),
|
| 36 |
+
|
| 37 |
+
# Really 'root', not '#push': in 'interpolation',
|
| 38 |
+
# parentheses inside the interpolation expression are
|
| 39 |
+
# Punctuation, not String.Interpol.
|
| 40 |
+
(r'\(', Punctuation, 'root'),
|
| 41 |
+
(r'\)', Punctuation, '#pop'),
|
| 42 |
+
|
| 43 |
+
# Keywords.
|
| 44 |
+
(words((
|
| 45 |
+
'as', 'break', 'class', 'construct', 'continue', 'else',
|
| 46 |
+
'for', 'foreign', 'if', 'import', 'return', 'static', 'super',
|
| 47 |
+
'this', 'var', 'while'), prefix = r'(?<!\.)',
|
| 48 |
+
suffix = r'\b'), Keyword),
|
| 49 |
+
|
| 50 |
+
(words((
|
| 51 |
+
'true', 'false', 'null'), prefix = r'(?<!\.)',
|
| 52 |
+
suffix = r'\b'), Keyword.Constant),
|
| 53 |
+
|
| 54 |
+
(words((
|
| 55 |
+
'in', 'is'), prefix = r'(?<!\.)',
|
| 56 |
+
suffix = r'\b'), Operator.Word),
|
| 57 |
+
|
| 58 |
+
# Comments.
|
| 59 |
+
(r'/\*', Comment.Multiline, 'comment'), # Multiline, can nest.
|
| 60 |
+
(r'//.*?$', Comment.Single), # Single line.
|
| 61 |
+
(r'#.*?(\(.*?\))?$', Comment.Special), # Attribute or shebang.
|
| 62 |
+
|
| 63 |
+
# Names and operators.
|
| 64 |
+
(r'[!%&*+\-./:<=>?\\^|~]+', Operator),
|
| 65 |
+
(r'[a-z][a-zA-Z_0-9]*', Name),
|
| 66 |
+
(r'[A-Z][a-zA-Z_0-9]*', Name.Class),
|
| 67 |
+
(r'__[a-zA-Z_0-9]*', Name.Variable.Class),
|
| 68 |
+
(r'_[a-zA-Z_0-9]*', Name.Variable.Instance),
|
| 69 |
+
|
| 70 |
+
# Numbers.
|
| 71 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 72 |
+
(r'\d+(\.\d+)?([eE][-+]?\d+)?', Number.Float),
|
| 73 |
+
|
| 74 |
+
# Strings.
|
| 75 |
+
(r'""".*?"""', String), # Raw string
|
| 76 |
+
(r'"', String, 'string'), # Other string
|
| 77 |
+
],
|
| 78 |
+
'comment': [
|
| 79 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 80 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 81 |
+
(r'([^*/]|\*(?!/)|/(?!\*))+', Comment.Multiline),
|
| 82 |
+
],
|
| 83 |
+
'string': [
|
| 84 |
+
(r'"', String, '#pop'),
|
| 85 |
+
(r'\\[\\%"0abefnrtv]', String.Escape), # Escape.
|
| 86 |
+
(r'\\x[a-fA-F0-9]{2}', String.Escape), # Byte escape.
|
| 87 |
+
(r'\\u[a-fA-F0-9]{4}', String.Escape), # Unicode escape.
|
| 88 |
+
(r'\\U[a-fA-F0-9]{8}', String.Escape), # Long Unicode escape.
|
| 89 |
+
|
| 90 |
+
(r'%\(', String.Interpol, 'interpolation'),
|
| 91 |
+
(r'[^\\"%]+', String), # All remaining characters.
|
| 92 |
+
],
|
| 93 |
+
'interpolation': [
|
| 94 |
+
# redefine closing paren to be String.Interpol
|
| 95 |
+
(r'\)', String.Interpol, '#pop'),
|
| 96 |
+
include('root'),
|
| 97 |
+
],
|
| 98 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/x10.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.x10
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the X10 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
|
| 12 |
+
from pygments.token import Text, Comment, Keyword, String
|
| 13 |
+
|
| 14 |
+
__all__ = ['X10Lexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class X10Lexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For the X10 language.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
name = 'X10'
|
| 23 |
+
url = 'http://x10-lang.org/'
|
| 24 |
+
aliases = ['x10', 'xten']
|
| 25 |
+
filenames = ['*.x10']
|
| 26 |
+
mimetypes = ['text/x-x10']
|
| 27 |
+
version_added = '2.2'
|
| 28 |
+
|
| 29 |
+
keywords = (
|
| 30 |
+
'as', 'assert', 'async', 'at', 'athome', 'ateach', 'atomic',
|
| 31 |
+
'break', 'case', 'catch', 'class', 'clocked', 'continue',
|
| 32 |
+
'def', 'default', 'do', 'else', 'final', 'finally', 'finish',
|
| 33 |
+
'for', 'goto', 'haszero', 'here', 'if', 'import', 'in',
|
| 34 |
+
'instanceof', 'interface', 'isref', 'new', 'offer',
|
| 35 |
+
'operator', 'package', 'return', 'struct', 'switch', 'throw',
|
| 36 |
+
'try', 'type', 'val', 'var', 'when', 'while'
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
types = (
|
| 40 |
+
'void'
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
values = (
|
| 44 |
+
'false', 'null', 'self', 'super', 'this', 'true'
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
modifiers = (
|
| 48 |
+
'abstract', 'extends', 'implements', 'native', 'offers',
|
| 49 |
+
'private', 'property', 'protected', 'public', 'static',
|
| 50 |
+
'throws', 'transient'
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
tokens = {
|
| 54 |
+
'root': [
|
| 55 |
+
(r'[^\S\n]+', Text),
|
| 56 |
+
(r'//.*?\n', Comment.Single),
|
| 57 |
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
| 58 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 59 |
+
(r'\b({})\b'.format('|'.join(types)), Keyword.Type),
|
| 60 |
+
(r'\b({})\b'.format('|'.join(values)), Keyword.Constant),
|
| 61 |
+
(r'\b({})\b'.format('|'.join(modifiers)), Keyword.Declaration),
|
| 62 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 63 |
+
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
|
| 64 |
+
(r'.', Text)
|
| 65 |
+
],
|
| 66 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/xorg.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.xorg
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Xorg configs.
|
| 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
|
| 12 |
+
from pygments.token import Comment, String, Name, Text
|
| 13 |
+
|
| 14 |
+
__all__ = ['XorgLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class XorgLexer(RegexLexer):
|
| 18 |
+
"""Lexer for xorg.conf files."""
|
| 19 |
+
name = 'Xorg'
|
| 20 |
+
url = 'https://www.x.org/wiki/'
|
| 21 |
+
aliases = ['xorg.conf']
|
| 22 |
+
filenames = ['xorg.conf']
|
| 23 |
+
mimetypes = []
|
| 24 |
+
version_added = ''
|
| 25 |
+
|
| 26 |
+
tokens = {
|
| 27 |
+
'root': [
|
| 28 |
+
(r'\s+', Text),
|
| 29 |
+
(r'#.*$', Comment),
|
| 30 |
+
|
| 31 |
+
(r'((?:Sub)?Section)(\s+)("\w+")',
|
| 32 |
+
bygroups(String.Escape, Text, String.Escape)),
|
| 33 |
+
(r'(End(?:Sub)?Section)', String.Escape),
|
| 34 |
+
|
| 35 |
+
(r'(\w+)(\s+)([^\n#]+)',
|
| 36 |
+
bygroups(Name.Builtin, Text, Name.Constant)),
|
| 37 |
+
],
|
| 38 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/yang.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.yang
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the YANG 1.1 modeling language. See :rfc:`7950`.
|
| 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, Token, Name, String, Comment, Number
|
| 13 |
+
|
| 14 |
+
__all__ = ['YangLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class YangLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
Lexer for YANG, based on RFC7950.
|
| 20 |
+
"""
|
| 21 |
+
name = 'YANG'
|
| 22 |
+
url = 'https://tools.ietf.org/html/rfc7950/'
|
| 23 |
+
aliases = ['yang']
|
| 24 |
+
filenames = ['*.yang']
|
| 25 |
+
mimetypes = ['application/yang']
|
| 26 |
+
version_added = '2.7'
|
| 27 |
+
|
| 28 |
+
#Keywords from RFC7950 ; oriented at BNF style
|
| 29 |
+
TOP_STMTS_KEYWORDS = ("module", "submodule")
|
| 30 |
+
MODULE_HEADER_STMT_KEYWORDS = ("belongs-to", "namespace", "prefix", "yang-version")
|
| 31 |
+
META_STMT_KEYWORDS = ("contact", "description", "organization",
|
| 32 |
+
"reference", "revision")
|
| 33 |
+
LINKAGE_STMTS_KEYWORDS = ("import", "include", "revision-date")
|
| 34 |
+
BODY_STMT_KEYWORDS = ("action", "argument", "augment", "deviation",
|
| 35 |
+
"extension", "feature", "grouping", "identity",
|
| 36 |
+
"if-feature", "input", "notification", "output",
|
| 37 |
+
"rpc", "typedef")
|
| 38 |
+
DATA_DEF_STMT_KEYWORDS = ("anydata", "anyxml", "case", "choice",
|
| 39 |
+
"config", "container", "deviate", "leaf",
|
| 40 |
+
"leaf-list", "list", "must", "presence",
|
| 41 |
+
"refine", "uses", "when")
|
| 42 |
+
TYPE_STMT_KEYWORDS = ("base", "bit", "default", "enum", "error-app-tag",
|
| 43 |
+
"error-message", "fraction-digits", "length",
|
| 44 |
+
"max-elements", "min-elements", "modifier",
|
| 45 |
+
"ordered-by", "path", "pattern", "position",
|
| 46 |
+
"range", "require-instance", "status", "type",
|
| 47 |
+
"units", "value", "yin-element")
|
| 48 |
+
LIST_STMT_KEYWORDS = ("key", "mandatory", "unique")
|
| 49 |
+
|
| 50 |
+
#RFC7950 other keywords
|
| 51 |
+
CONSTANTS_KEYWORDS = ("add", "current", "delete", "deprecated", "false",
|
| 52 |
+
"invert-match", "max", "min", "not-supported",
|
| 53 |
+
"obsolete", "replace", "true", "unbounded", "user")
|
| 54 |
+
|
| 55 |
+
#RFC7950 Built-In Types
|
| 56 |
+
TYPES = ("binary", "bits", "boolean", "decimal64", "empty", "enumeration",
|
| 57 |
+
"identityref", "instance-identifier", "int16", "int32", "int64",
|
| 58 |
+
"int8", "leafref", "string", "uint16", "uint32", "uint64",
|
| 59 |
+
"uint8", "union")
|
| 60 |
+
|
| 61 |
+
suffix_re_pattern = r'(?=[^\w\-:])'
|
| 62 |
+
|
| 63 |
+
tokens = {
|
| 64 |
+
'comments': [
|
| 65 |
+
(r'[^*/]', Comment),
|
| 66 |
+
(r'/\*', Comment, '#push'),
|
| 67 |
+
(r'\*/', Comment, '#pop'),
|
| 68 |
+
(r'[*/]', Comment),
|
| 69 |
+
],
|
| 70 |
+
"root": [
|
| 71 |
+
(r'\s+', Text.Whitespace),
|
| 72 |
+
(r'[{};]+', Token.Punctuation),
|
| 73 |
+
(r'(?<![\-\w])(and|or|not|\+|\.)(?![\-\w])', Token.Operator),
|
| 74 |
+
|
| 75 |
+
(r'"(?:\\"|[^"])*?"', String.Double),
|
| 76 |
+
(r"'(?:\\'|[^'])*?'", String.Single),
|
| 77 |
+
|
| 78 |
+
(r'/\*', Comment, 'comments'),
|
| 79 |
+
(r'//.*?$', Comment),
|
| 80 |
+
|
| 81 |
+
#match BNF stmt for `node-identifier` with [ prefix ":"]
|
| 82 |
+
(r'(?:^|(?<=[\s{};]))([\w.-]+)(:)([\w.-]+)(?=[\s{};])',
|
| 83 |
+
bygroups(Name.Namespace, Token.Punctuation, Name.Variable)),
|
| 84 |
+
|
| 85 |
+
#match BNF stmt `date-arg-str`
|
| 86 |
+
(r'([0-9]{4}\-[0-9]{2}\-[0-9]{2})(?=[\s{};])', Name.Label),
|
| 87 |
+
(r'([0-9]+\.[0-9]+)(?=[\s{};])', Number.Float),
|
| 88 |
+
(r'([0-9]+)(?=[\s{};])', Number.Integer),
|
| 89 |
+
|
| 90 |
+
(words(TOP_STMTS_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 91 |
+
(words(MODULE_HEADER_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 92 |
+
(words(META_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 93 |
+
(words(LINKAGE_STMTS_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 94 |
+
(words(BODY_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 95 |
+
(words(DATA_DEF_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 96 |
+
(words(TYPE_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 97 |
+
(words(LIST_STMT_KEYWORDS, suffix=suffix_re_pattern), Token.Keyword),
|
| 98 |
+
(words(TYPES, suffix=suffix_re_pattern), Name.Class),
|
| 99 |
+
(words(CONSTANTS_KEYWORDS, suffix=suffix_re_pattern), Name.Class),
|
| 100 |
+
|
| 101 |
+
(r'[^;{}\s\'"]+', Name.Variable),
|
| 102 |
+
]
|
| 103 |
+
}
|
.cache/uv/archive-v0/dv8pcwxW1Ib13dL5cHO1m/pygments/lexers/yara.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.yara
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for YARA.
|
| 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, String, Name, Text, Punctuation, \
|
| 13 |
+
Operator, Keyword, Whitespace, Number
|
| 14 |
+
|
| 15 |
+
__all__ = ['YaraLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class YaraLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For YARA rules
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'YARA'
|
| 24 |
+
url = 'https://virustotal.github.io/yara/'
|
| 25 |
+
aliases = ['yara', 'yar']
|
| 26 |
+
filenames = ['*.yar']
|
| 27 |
+
mimetypes = ['text/x-yara']
|
| 28 |
+
version_added = '2.16'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'\s+', Whitespace),
|
| 33 |
+
(r'//.*?$', Comment.Single),
|
| 34 |
+
(r'\#.*?$', Comment.Single),
|
| 35 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 36 |
+
(words(('rule', 'private', 'global', 'import', 'include'),
|
| 37 |
+
prefix=r'\b', suffix=r'\b'),
|
| 38 |
+
Keyword.Declaration),
|
| 39 |
+
(words(('strings', 'condition', 'meta'), prefix=r'\b', suffix=r'\b'),
|
| 40 |
+
Keyword),
|
| 41 |
+
(words(('ascii', 'at', 'base64', 'base64wide', 'condition',
|
| 42 |
+
'contains', 'endswith', 'entrypoint', 'filesize', 'for',
|
| 43 |
+
'fullword', 'icontains', 'iendswith', 'iequals', 'in',
|
| 44 |
+
'include', 'int16', 'int16be', 'int32', 'int32be', 'int8',
|
| 45 |
+
'int8be', 'istartswith', 'matches', 'meta', 'nocase',
|
| 46 |
+
'none', 'of', 'startswith', 'strings', 'them', 'uint16',
|
| 47 |
+
'uint16be', 'uint32', 'uint32be', 'uint8', 'uint8be',
|
| 48 |
+
'wide', 'xor', 'defined'),
|
| 49 |
+
prefix=r'\b', suffix=r'\b'),
|
| 50 |
+
Name.Builtin),
|
| 51 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 52 |
+
(r'(and|or|not|any|all)\b', Operator.Word),
|
| 53 |
+
(r'(\$\w+)', Name.Variable),
|
| 54 |
+
(r'"[^"]*"', String.Double),
|
| 55 |
+
(r'\'[^\']*\'', String.Single),
|
| 56 |
+
(r'\{.*?\}$', Number.Hex),
|
| 57 |
+
(r'(/.*?/)', String.Regex),
|
| 58 |
+
(r'[a-z_]\w*', Name),
|
| 59 |
+
(r'[$(){}[\].?+*|]', Punctuation),
|
| 60 |
+
(r'[:=,;]', Punctuation),
|
| 61 |
+
(r'.', Text)
|
| 62 |
+
],
|
| 63 |
+
'comment': [
|
| 64 |
+
(r'[^*/]+', Comment.Multiline),
|
| 65 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 66 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 67 |
+
(r'[*/]', Comment.Multiline)
|
| 68 |
+
]
|
| 69 |
+
}
|