Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .cache/pip/http-v2/a/1/9/5/3/a19537d3cf37c122db841d6fe4cd322bc10d1a558bb00d146b85cb9aAdded
- .cache/pip/http-v2/a/1/9/5/3/a19537d3cf37c122db841d6fe4cd322bc10d1a558bb00d146b85cb9a.bodyAdded
- .cache/pip/http-v2/a/3/2/7/2/a3272be75c47d40339fd3bd21ed3327aebabd76954c68f902bf35782Added
- .cache/pip/http-v2/a/3/2/7/2/a3272be75c47d40339fd3bd21ed3327aebabd76954c68f902bf35782.bodyAdded+134
- .cache/pip/http-v2/a/f/2/9/f/af29feb3d93cb03190397ce919a96d795669e4f05d0c1e5af7d6405cAdded
- .cache/pip/http-v2/a/f/5/3/d/af53d10b2a0401eb083b4e24ccf3518cc83ed2a451d87928b17de49aAdded
- .cache/pip/http-v2/a/f/5/3/d/af53d10b2a0401eb083b4e24ccf3518cc83ed2a451d87928b17de49a.bodyAdded
- .cache/pip/http-v2/d/d/2/0/6/dd206ee8d449d4bec512242e8f8ebadb5a808c682766018f3921f62b.bodyAdded+51
- .cache/pip/http-v2/e/5/8/5/b/e585bbf94bc6bd5f1a310aa9356bdd33cf1860b5d9f831257a0a9cfe.bodyAdded+408
- .cache/pip/http-v2/e/7/5/e/3/e75e3a72ec5ffce867a4e738b4b84c7a8477fb04f819b70bfe837470Added
- .cache/pip/http-v2/e/d/e/d/1/eded1062df3a835b1d654db11016327d0de7276866caf329f6f27b1c.bodyAdded+94
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/formatters/bbcode.pyAdded+108
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/formatters/rtf.pyAdded+349
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/_mapping.pyAdded+603
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bare.pyAdded+101
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/basic.pyAdded+656
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bdd.pyAdded+57
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/berry.pyAdded+99
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bibtex.pyAdded+159
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/blueprint.pyAdded+173
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/boa.pyAdded+97
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bqn.pyAdded+112
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/business.pyAdded+625
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/c_cpp.pyAdded+415
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/c_like.pyAdded+738
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/capnproto.pyAdded+74
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/carbon.pyAdded+95
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/cddl.pyAdded+172
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/chapel.pyAdded+139
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/clean.pyAdded+180
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/codeql.pyAdded+80
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/comal.pyAdded+81
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/compiled.pyAdded+35
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/configs.pyAdded+1433
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/console.pyAdded+114
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/cplint.pyAdded+43
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/crystal.pyAdded+364
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/csound.pyAdded+466
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/css.pyAdded+632
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/d.pyAdded+259
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dalvik.pyAdded+126
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/data.pyAdded+763
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dax.pyAdded+135
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/devicetree.pyAdded+120
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/diff.pyAdded+169
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dns.pyAdded+109
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dotnet.pyAdded+873
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dsls.pyAdded+970
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dylan.pyAdded+279
- .cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/ecl.pyAdded+144
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134Metadata-Version: 2.4Name: safetensorsVersion: 0.8.0Classifier: Development Status :: 5 - Production/StableClassifier: Intended Audience :: DevelopersClassifier: Intended Audience :: EducationClassifier: Intended Audience :: Science/ResearchClassifier: License :: OSI Approved :: Apache Software LicenseClassifier: Operating System :: OS IndependentClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3.14Classifier: Topic :: Scientific/Engineering :: Artificial IntelligenceClassifier: Typing :: TypedRequires-Dist: safetensors[torch] ; extra == 'all'Requires-Dist: safetensors[numpy] ; extra == 'all'Requires-Dist: safetensors[jax] ; extra == 'all'Requires-Dist: safetensors[paddlepaddle] ; extra == 'all'Requires-Dist: safetensors[convert] ; extra == 'all'Requires-Dist: safetensors[quality] ; extra == 'all'Requires-Dist: safetensors[testing] ; extra == 'all'Requires-Dist: safetensors[torch] ; extra == 'convert'Requires-Dist: huggingface-hub>=1.4 ; extra == 'convert'Requires-Dist: safetensors[all] ; extra == 'dev'Requires-Dist: safetensors[pinned-tf] ; extra == 'dev'Requires-Dist: safetensors[numpy] ; extra == 'jax'Requires-Dist: flax>=0.6.3 ; extra == 'jax'Requires-Dist: jax>=0.3.25 ; extra == 'jax'Requires-Dist: jaxlib>=0.3.25 ; extra == 'jax'Requires-Dist: mlx>=0.0.9 ; extra == 'mlx'Requires-Dist: numpy>=1.24.6 ; extra == 'numpy'Requires-Dist: safetensors[numpy] ; extra == 'paddlepaddle'Requires-Dist: paddlepaddle>=2.4.1 ; extra == 'paddlepaddle'Requires-Dist: safetensors[numpy] ; extra == 'pinned-tf'Requires-Dist: tensorflow==2.18.0 ; extra == 'pinned-tf'Requires-Dist: ruff ; extra == 'quality'Requires-Dist: safetensors[numpy] ; extra == 'tensorflow'Requires-Dist: tensorflow>=2.11.0 ; extra == 'tensorflow'Requires-Dist: safetensors[numpy] ; extra == 'testing'Requires-Dist: h5py>=3.7.0 ; extra == 'testing'Requires-Dist: setuptools-rust>=1.12.0 ; extra == 'testing'Requires-Dist: pytest>=9.0 ; extra == 'testing'Requires-Dist: pytest-benchmark>=5.2 ; extra == 'testing'Requires-Dist: hypothesis>=6.70.2 ; extra == 'testing'Requires-Dist: fsspec>=2024.6.0 ; extra == 'testing'Requires-Dist: s3fs>=2024.6.0 ; extra == 'testing'Requires-Dist: safetensors[numpy] ; extra == 'tf-nightly'Requires-Dist: tf-nightly ; extra == 'tf-nightly'Requires-Dist: safetensors[numpy] ; extra == 'torch'Requires-Dist: torch>=2.4 ; extra == 'torch'Provides-Extra: allProvides-Extra: convertProvides-Extra: devProvides-Extra: jaxProvides-Extra: mlxProvides-Extra: numpyProvides-Extra: paddlepaddleProvides-Extra: pinned-tfProvides-Extra: qualityProvides-Extra: tensorflowProvides-Extra: testingProvides-Extra: tf-nightlyProvides-Extra: torchLicense-File: LICENSEAuthor-email: Nicolas Patry <patry.nicolas@protonmail.com>, Luc Georges <luc@huggingface.co>, Daniël De Kok <daniel.dekok@huggingface.co>Requires-Python: >=3.10Description-Content-Type: text/markdown; charset=UTF-8; variant=GFMProject-URL: Homepage, https://github.com/huggingface/safetensorsProject-URL: Source, https://github.com/huggingface/safetensors
## Installation
```pip install safetensors```
## Usage
### Numpy
```pythonfrom safetensors.numpy import save_file, load_fileimport numpy as np
tensors = { "a": np.zeros((2, 2)), "b": np.zeros((2, 3), dtype=np.uint8)}
save_file(tensors, "./model.safetensors")
# Now loadingloaded = load_file("./model.safetensors")```
### Torch
```pythonfrom safetensors.torch import save_file, load_fileimport torch
tensors = { "a": torch.zeros((2, 2)), "b": torch.zeros((2, 3), dtype=torch.uint8)}
save_file(tensors, "./model.safetensors")
# Now loadingloaded = load_file("./model.safetensors")```
### Developing
```# inside ./safetensors/bindings/pythonpip install .[dev]```Should be enough to install this library locally.
### Testing
```# inside ./safetensors/bindings/pythonpip install .[dev]pytest -sv tests/```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051Metadata-Version: 2.1Name: et_xmlfileVersion: 2.0.0Summary: An implementation of lxml.xmlfile for the standard libraryHome-page: https://foss.heptapod.net/openpyxl/et_xmlfileAuthor: See AUTHORS.txtAuthor-email: charlie.clark@clark-consulting.euLicense: MITProject-URL: Documentation, https://openpyxl.pages.heptapod.net/et_xmlfile/Project-URL: Source, https://foss.heptapod.net/openpyxl/et_xmlfileProject-URL: Tracker, https://foss.heptapod.net/openpyxl/et_xmfile/-/issuesClassifier: Development Status :: 5 - Production/StableClassifier: Operating System :: MacOS :: MacOS XClassifier: Operating System :: Microsoft :: WindowsClassifier: Operating System :: POSIXClassifier: License :: OSI Approved :: MIT LicenseClassifier: Programming Language :: PythonClassifier: Programming Language :: Python :: 3.8Classifier: Programming Language :: Python :: 3.9Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Requires-Python: >=3.8License-File: LICENCE.pythonLicense-File: LICENCE.rstLicense-File: AUTHORS.txt
.. image:: https://foss.heptapod.net/openpyxl/et_xmlfile/badges/branch/default/coverage.svg :target: https://coveralls.io/bitbucket/openpyxl/et_xmlfile?branch=default :alt: coverage status
et_xmfile=========
XML can use lots of memory, and et_xmlfile is a low memory library for creating large XML filesAnd, although the standard library already includes an incremental parser, `iterparse` it has no equivalent when writing XML. Once an element has been added to the tree, it is written tothe file or stream and the memory is then cleared.
This module is based upon the `xmlfile module from lxml <http://lxml.de/api.html#incremental-xml-generation>`_ with the aim of allowing code to be developed that will work with both libraries.It was developed initially for the openpyxl project, but is now a standalone module.
The code was written by Elias Rabel as part of the `Python Düsseldorf <http://pyddf.de>`_ openpyxl sprint in September 2014.
Proper support for incremental writing was provided by Daniel Hillier in 2024
Note on performance-------------------
The code was not developed with performance in mind, but turned out to be faster than the existing SAX-based implementation but is generally slower than lxml's xmlfile.There is one area where an optimisation for lxml may negatively affect the performance of et_xmfile and that is when using the `.element()` method on the xmlfile context manager. It is, therefore, recommended simply to create Elements write these directly, as in the sample code.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408Metadata-Version: 2.4Name: typerVersion: 0.25.1Summary: Typer, build great CLIs. Easy to code. Based on Python type hints.Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>License-Expression: MITLicense-File: LICENSEClassifier: Intended Audience :: Information TechnologyClassifier: Intended Audience :: System AdministratorsClassifier: Operating System :: OS IndependentClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: PythonClassifier: Topic :: Software Development :: Libraries :: Application FrameworksClassifier: Topic :: Software Development :: Libraries :: Python ModulesClassifier: Topic :: Software Development :: LibrariesClassifier: Topic :: Software DevelopmentClassifier: Typing :: TypedClassifier: Development Status :: 4 - BetaClassifier: Intended Audience :: DevelopersClassifier: Programming Language :: Python :: 3 :: OnlyClassifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3.14Project-URL: Homepage, https://github.com/fastapi/typerProject-URL: Documentation, https://typer.tiangolo.comProject-URL: Repository, https://github.com/fastapi/typerProject-URL: Issues, https://github.com/fastapi/typer/issuesProject-URL: Changelog, https://typer.tiangolo.com/release-notes/Requires-Python: >=3.10Requires-Dist: click>=8.2.1Requires-Dist: shellingham>=1.3.0Requires-Dist: rich>=13.8.0Requires-Dist: annotated-doc>=0.0.2Description-Content-Type: text/markdown
<p align="center"> <a href="https://typer.tiangolo.com"><img src="https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg#only-light" alt="Typer"></a>
</p><p align="center"> <em>Typer, build great CLIs. Easy to code. Based on Python type hints.</em></p><p align="center"><a href="https://github.com/fastapi/typer/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster" target="_blank"> <img src="https://github.com/fastapi/typer/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Test"></a><a href="https://github.com/fastapi/typer/actions?query=workflow%3APublish" target="_blank"> <img src="https://github.com/fastapi/typer/workflows/Publish/badge.svg" alt="Publish"></a><a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/typer" target="_blank"> <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/typer.svg" alt="Coverage"><a href="https://pypi.org/project/typer" target="_blank"> <img src="https://img.shields.io/pypi/v/typer?color=%2334D058&label=pypi%20package" alt="Package version"></a></p>
---
**Documentation**: <a href="https://typer.tiangolo.com" target="_blank">https://typer.tiangolo.com</a>
**Source Code**: <a href="https://github.com/fastapi/typer" target="_blank">https://github.com/fastapi/typer</a>
---
Typer is a library for building <abbr title="command line interface, programs executed from a terminal">CLI</abbr> applications that users will **love using** and developers will **love creating**. Based on Python type hints.
It's also a command line tool to run scripts, automatically converting them to CLI applications.
The key features are:
* **Intuitive to write**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.* **Easy to use**: It's easy to use for the final users. Automatic help, and automatic completion for all shells.* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.* **Start simple**: The simplest example adds only 2 lines of code to your app: **1 import, 1 function call**.* **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups of subcommands, with options and arguments.* **Run scripts**: Typer includes a `typer` command/program that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally.
## FastAPI of CLIs
**Typer** is <a href="https://fastapi.tiangolo.com" class="external-link" target="_blank">FastAPI</a>'s little sibling, it's the FastAPI of CLIs.
## Installation
Create and activate a <a href="https://typer.tiangolo.com/virtual-environments/" class="external-link" target="_blank">virtual environment</a> and then install **Typer**:
<div class="termy">
```console$ pip install typer---> 100%Successfully installed typer rich shellingham```
</div>
## Example
### The absolute minimum
* Create a file `main.py` with:
```Pythondef main(name: str): print(f"Hello {name}")```
This script doesn't even use Typer internally. But you can use the `typer` command to run it as a CLI application.
### Run it
Run your application with the `typer` command:
<div class="termy">
```console// Run your application$ typer main.py run
// You get a nice error, you are missing NAMEUsage: typer [PATH_OR_MODULE] run [OPTIONS] NAMETry 'typer [PATH_OR_MODULE] run --help' for help.╭─ Error ───────────────────────────────────────────╮│ Missing argument 'NAME'. │╰───────────────────────────────────────────────────╯
// You get a --help for free$ typer main.py run --help
Usage: typer [PATH_OR_MODULE] run [OPTIONS] NAME
Run the provided Typer app.
╭─ Arguments ───────────────────────────────────────╮│ * name TEXT [default: None] [required] |╰───────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────╮│ --help Show this message and exit. │╰───────────────────────────────────────────────────╯
// Now pass the NAME argument$ typer main.py run Camila
Hello Camila
// It works! 🎉```
</div>
This is the simplest use case, not even using Typer internally, but it can already be quite useful for simple scripts.
**Note**: auto-completion works when you create a Python package and run it with `--install-completion` or when you use the `typer` command.
## Use Typer in your code
Now let's start using Typer in your own code, update `main.py` with:
```Pythonimport typer
def main(name: str): print(f"Hello {name}")
if __name__ == "__main__": typer.run(main)```
Now you could run it with Python directly:
<div class="termy">
```console// Run your application$ python main.py
// You get a nice error, you are missing NAMEUsage: main.py [OPTIONS] NAMETry 'main.py --help' for help.╭─ Error ───────────────────────────────────────────╮│ Missing argument 'NAME'. │╰───────────────────────────────────────────────────╯
// You get a --help for free$ python main.py --help
Usage: main.py [OPTIONS] NAME
╭─ Arguments ───────────────────────────────────────╮│ * name TEXT [default: None] [required] |╰───────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────╮│ --help Show this message and exit. │╰───────────────────────────────────────────────────╯
// Now pass the NAME argument$ python main.py Camila
Hello Camila
// It works! 🎉```
</div>
**Note**: you can also call this same script with the `typer` command, but you don't need to.
## Example upgrade
This was the simplest example possible.
Now let's see one a bit more complex.
### An example with two subcommands
Modify the file `main.py`.
Create a `typer.Typer()` app, and create two subcommands with their parameters.
```Python hl_lines="3 6 11 20"import typer
app = typer.Typer()
@app.command()def hello(name: str): print(f"Hello {name}")
@app.command()def goodbye(name: str, formal: bool = False): if formal: print(f"Goodbye Ms. {name}. Have a good day.") else: print(f"Bye {name}!")
if __name__ == "__main__": app()```
And that will:
* Explicitly create a `typer.Typer` app. * The previous `typer.run` actually creates one implicitly for you.* Add two subcommands with `@app.command()`.* Execute the `app()` itself, as if it was a function (instead of `typer.run`).
### Run the upgraded example
Check the new help:
<div class="termy">
```console$ python main.py --help
Usage: main.py [OPTIONS] COMMAND [ARGS]...
╭─ Options ─────────────────────────────────────────╮│ --install-completion Install completion ││ for the current ││ shell. ││ --show-completion Show completion for ││ the current shell, ││ to copy it or ││ customize the ││ installation. ││ --help Show this message ││ and exit. │╰───────────────────────────────────────────────────╯╭─ Commands ────────────────────────────────────────╮│ goodbye ││ hello │╰───────────────────────────────────────────────────╯
// When you create a package you get ✨ auto-completion ✨ for free, installed with --install-completion
// You have 2 subcommands (the 2 functions): goodbye and hello```
</div>
Now check the help for the `hello` command:
<div class="termy">
```console$ python main.py hello --help
Usage: main.py hello [OPTIONS] NAME
╭─ Arguments ───────────────────────────────────────╮│ * name TEXT [default: None] [required] │╰───────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────╮│ --help Show this message and exit. │╰───────────────────────────────────────────────────╯```
</div>
And now check the help for the `goodbye` command:
<div class="termy">
```console$ python main.py goodbye --help
Usage: main.py goodbye [OPTIONS] NAME
╭─ Arguments ───────────────────────────────────────╮│ * name TEXT [default: None] [required] │╰───────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────╮│ --formal --no-formal [default: no-formal] ││ --help Show this message ││ and exit. │╰───────────────────────────────────────────────────╯
// Automatic --formal and --no-formal for the bool option 🎉```
</div>
Now you can try out the new command line application:
<div class="termy">
```console// Use it with the hello command
$ python main.py hello Camila
Hello Camila
// And with the goodbye command
$ python main.py goodbye Camila
Bye Camila!
// And with --formal
$ python main.py goodbye --formal Camila
Goodbye Ms. Camila. Have a good day.```
</div>
**Note**: If your app only has one command, by default the command name is **omitted** in usage: `python main.py Camila`. However, when there are multiple commands, you must **explicitly include the command name**: `python main.py hello Camila`. See [One or Multiple Commands](https://typer.tiangolo.com/tutorial/commands/one-or-multiple/) for more details.
### Recap
In summary, you declare **once** the types of parameters (*CLI arguments* and *CLI options*) as function parameters.
You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python**.
For example, for an `int`:
```Pythontotal: int```
or for a `bool` flag:
```Pythonforce: bool```
And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of subcommands**, add metadata, extra **validation**, etc.
**You get**: great editor support, including **completion** and **type checks** everywhere.
**Your users get**: automatic **`--help`**, **auto-completion** in their terminal (Bash, Zsh, Fish, PowerShell) when they install your package or when using the `typer` command.
For a more complete example including more features, see the <a href="https://typer.tiangolo.com/tutorial/">Tutorial - User Guide</a>.
## Dependencies
**Typer** stands on the shoulders of giants. It has three required dependencies:
* <a href="https://click.palletsprojects.com/" class="external-link" target="_blank">Click</a>: a popular tool for building CLIs in Python. Typer is based on it.* <a href="https://rich.readthedocs.io/en/stable/index.html" class="external-link" target="_blank"><code>rich</code></a>: to show nicely formatted errors automatically.* <a href="https://github.com/sarugaku/shellingham" class="external-link" target="_blank"><code>shellingham</code></a>: to automatically detect the current shell when installing completion.
### `typer-slim`
There used to be a slimmed-down version of Typer called `typer-slim`, which didn't include the dependencies `rich` and `shellingham`, nor the `typer` command.
However, since version 0.22.0, we have stopped supporting this, and `typer-slim` now simply installs (all of) Typer.
If you want to disable Rich globally, you can set an environmental variable `TYPER_USE_RICH` to `False` or `0`.
## License
This project is licensed under the terms of the MIT license.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394Metadata-Version: 2.1Name: contourpyVersion: 1.3.3Summary: Python library for calculating contours of 2D quadrilateral gridsAuthor-Email: Ian Thomas <ianthomas23@gmail.com>License: BSD 3-Clause License Copyright (c) 2021-2025, ContourPy Developers. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Classifier: Development Status :: 5 - Production/StableClassifier: Intended Audience :: DevelopersClassifier: Intended Audience :: Science/ResearchClassifier: License :: OSI Approved :: BSD LicenseClassifier: Programming Language :: C++Classifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3.14Classifier: Topic :: Scientific/Engineering :: Information AnalysisClassifier: Topic :: Scientific/Engineering :: MathematicsClassifier: Topic :: Scientific/Engineering :: VisualizationProject-URL: Homepage, https://github.com/contourpy/contourpyProject-URL: Changelog, https://contourpy.readthedocs.io/en/latest/changelog.htmlProject-URL: Documentation, https://contourpy.readthedocs.ioProject-URL: Repository, https://github.com/contourpy/contourpyRequires-Python: >=3.11Requires-Dist: numpy>=1.25Provides-Extra: docsRequires-Dist: furo; extra == "docs"Requires-Dist: sphinx>=7.2; extra == "docs"Requires-Dist: sphinx-copybutton; extra == "docs"Provides-Extra: bokehRequires-Dist: bokeh; extra == "bokeh"Requires-Dist: selenium; extra == "bokeh"Provides-Extra: mypyRequires-Dist: contourpy[bokeh,docs]; extra == "mypy"Requires-Dist: bokeh; extra == "mypy"Requires-Dist: docutils-stubs; extra == "mypy"Requires-Dist: mypy==1.17.0; extra == "mypy"Requires-Dist: types-Pillow; extra == "mypy"Provides-Extra: testRequires-Dist: contourpy[test-no-images]; extra == "test"Requires-Dist: matplotlib; extra == "test"Requires-Dist: Pillow; extra == "test"Provides-Extra: test-no-imagesRequires-Dist: pytest; extra == "test-no-images"Requires-Dist: pytest-cov; extra == "test-no-images"Requires-Dist: pytest-rerunfailures; extra == "test-no-images"Requires-Dist: pytest-xdist; extra == "test-no-images"Requires-Dist: wurlitzer; extra == "test-no-images"Description-Content-Type: text/markdown
<img alt="ContourPy" src="https://raw.githubusercontent.com/contourpy/contourpy/main/docs/_static/contourpy_logo_horiz.svg" height="90">
ContourPy is a Python library for calculating contours of 2D quadrilateral grids. It is written in C++11 and wrapped using pybind11.
It contains the 2005 and 2014 algorithms used in Matplotlib as well as a newer algorithm that includes more features and is available in both serial and multithreaded versions. It provides an easy way for Python libraries to use contouring algorithms without having to include Matplotlib as a dependency.
* **Documentation**: https://contourpy.readthedocs.io * **Source code**: https://github.com/contourpy/contourpy
| | || --- | --- || Latest release | [](https://pypi.python.org/pypi/contourpy) [](https://anaconda.org/conda-forge/contourpy) || Downloads | [](https://pepy.tech/project/contourpy) || Python version | [](https://pypi.org/project/contourpy/) || Coverage | [](https://app.codecov.io/gh/contourpy/contourpy) |123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108""" pygments.formatters.bbcode ~~~~~~~~~~~~~~~~~~~~~~~~~~
BBcode formatter.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.formatter import Formatterfrom pygments.util import get_bool_opt
__all__ = ['BBCodeFormatter']
class BBCodeFormatter(Formatter): """ Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.
This formatter has no support for background colors and borders, as there are no common BBcode tags for that.
Some board systems (e.g. phpBB) don't support colors in their [code] tag, so you can't use the highlighting together with that tag. Text in a [code] tag usually is shown with a monospace font (which this formatter can do with the ``monofont`` option) and no spaces (which you need for indentation) are removed.
Additional options accepted:
`style` The style to use, can be a string or a Style subclass (default: ``'default'``).
`codetag` If set to true, put the output into ``[code]`` tags (default: ``false``)
`monofont` If set to true, add a tag to show the code with a monospace font (default: ``false``). """ name = 'BBCode' aliases = ['bbcode', 'bb'] filenames = []
def __init__(self, **options): Formatter.__init__(self, **options) self._code = get_bool_opt(options, 'codetag', False) self._mono = get_bool_opt(options, 'monofont', False)
self.styles = {} self._make_styles()
def _make_styles(self): for ttype, ndef in self.style: start = end = '' if ndef['color']: start += '[color=#{}]'.format(ndef['color']) end = '[/color]' + end if ndef['bold']: start += '[b]' end = '[/b]' + end if ndef['italic']: start += '[i]' end = '[/i]' + end if ndef['underline']: start += '[u]' end = '[/u]' + end # there are no common BBcodes for background-color and border
self.styles[ttype] = start, end
def format_unencoded(self, tokensource, outfile): if self._code: outfile.write('[code]') if self._mono: outfile.write('[font=monospace]')
lastval = '' lasttype = None
for ttype, value in tokensource: while ttype not in self.styles: ttype = ttype.parent if ttype == lasttype: lastval += value else: if lastval: start, end = self.styles[lasttype] outfile.write(''.join((start, lastval, end))) lastval = value lasttype = ttype
if lastval: start, end = self.styles[lasttype] outfile.write(''.join((start, lastval, end)))
if self._mono: outfile.write('[/font]') if self._code: outfile.write('[/code]') if self._code or self._mono: outfile.write('\n')123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349""" pygments.formatters.rtf ~~~~~~~~~~~~~~~~~~~~~~~
A formatter that generates RTF files.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from collections import OrderedDictfrom pygments.formatter import Formatterfrom pygments.style import _ansimapfrom pygments.util import get_bool_opt, get_int_opt, get_list_opt, surrogatepair
__all__ = ['RtfFormatter']
class RtfFormatter(Formatter): """ Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft(R) Word(R) documents.
Please note that ``encoding`` and ``outencoding`` options are ignored. The RTF format is ASCII natively, but handles unicode characters correctly thanks to escape sequences.
.. versionadded:: 0.6
Additional options accepted:
`style` The style to use, can be a string or a Style subclass (default: ``'default'``).
`fontface` The used font family, for example ``Bitstream Vera Sans``. Defaults to some generic font which is supposed to have fixed width.
`fontsize` Size of the font used. Size is specified in half points. The default is 24 half-points, giving a size 12 font.
.. versionadded:: 2.0
`linenos` Turn on line numbering (default: ``False``).
.. versionadded:: 2.18
`lineno_fontsize` Font size for line numbers. Size is specified in half points (default: `fontsize`).
.. versionadded:: 2.18
`lineno_padding` Number of spaces between the (inline) line numbers and the source code (default: ``2``).
.. versionadded:: 2.18
`linenostart` The line number for the first line (default: ``1``).
.. versionadded:: 2.18
`linenostep` If set to a number n > 1, only every nth line number is printed.
.. versionadded:: 2.18
`lineno_color` Color for line numbers specified as a hex triplet, e.g. ``'5e5e5e'``. Defaults to the style's line number color if it is a hex triplet, otherwise ansi bright black.
.. versionadded:: 2.18
`hl_lines` Specify a list of lines to be highlighted, as line numbers separated by spaces, e.g. ``'3 7 8'``. The line numbers are relative to the input (i.e. the first line is line 1) unless `hl_linenostart` is set.
.. versionadded:: 2.18
`hl_color` Color for highlighting the lines specified in `hl_lines`, specified as a hex triplet (default: style's `highlight_color`).
.. versionadded:: 2.18
`hl_linenostart` If set to ``True`` line numbers in `hl_lines` are specified relative to `linenostart` (default ``False``).
.. versionadded:: 2.18 """ name = 'RTF' aliases = ['rtf'] filenames = ['*.rtf']
def __init__(self, **options): r""" Additional options accepted:
``fontface`` Name of the font used. Could for example be ``'Courier New'`` to further specify the default which is ``'\fmodern'``. The RTF specification claims that ``\fmodern`` are "Fixed-pitch serif and sans serif fonts". Hope every RTF implementation thinks the same about modern...
""" Formatter.__init__(self, **options) self.fontface = options.get('fontface') or '' self.fontsize = get_int_opt(options, 'fontsize', 0) self.linenos = get_bool_opt(options, 'linenos', False) self.lineno_fontsize = get_int_opt(options, 'lineno_fontsize', self.fontsize) self.lineno_padding = get_int_opt(options, 'lineno_padding', 2) self.linenostart = abs(get_int_opt(options, 'linenostart', 1)) self.linenostep = abs(get_int_opt(options, 'linenostep', 1)) self.hl_linenostart = get_bool_opt(options, 'hl_linenostart', False)
self.hl_color = options.get('hl_color', '') if not self.hl_color: self.hl_color = self.style.highlight_color
self.hl_lines = [] for lineno in get_list_opt(options, 'hl_lines', []): try: lineno = int(lineno) if self.hl_linenostart: lineno = lineno - self.linenostart + 1 self.hl_lines.append(lineno) except ValueError: pass
self.lineno_color = options.get('lineno_color', '') if not self.lineno_color: if self.style.line_number_color == 'inherit': # style color is the css value 'inherit' # default to ansi bright-black self.lineno_color = _ansimap['ansibrightblack'] else: # style color is assumed to be a hex triplet as other # colors in pygments/style.py self.lineno_color = self.style.line_number_color
self.color_mapping = self._create_color_mapping()
def _escape(self, text): return text.replace('\\', '\\\\') \ .replace('{', '\\{') \ .replace('}', '\\}')
def _escape_text(self, text): # empty strings, should give a small performance improvement if not text: return ''
# escape text text = self._escape(text)
buf = [] for c in text: cn = ord(c) if cn < (2**7): # ASCII character buf.append(str(c)) elif (2**7) <= cn < (2**16): # single unicode escape sequence buf.append('{\\u%d}' % cn) elif (2**16) <= cn: # RTF limits unicode to 16 bits. # Force surrogate pairs buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
return ''.join(buf).replace('\n', '\\par')
@staticmethod def hex_to_rtf_color(hex_color): if hex_color[0] == "#": hex_color = hex_color[1:]
return '\\red%d\\green%d\\blue%d;' % ( int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16) )
def _split_tokens_on_newlines(self, tokensource): """ Split tokens containing newline characters into multiple token each representing a line of the input file. Needed for numbering lines of e.g. multiline comments. """ for ttype, value in tokensource: if value == '\n': yield (ttype, value) elif "\n" in value: lines = value.split("\n") for line in lines[:-1]: yield (ttype, line+"\n") if lines[-1]: yield (ttype, lines[-1]) else: yield (ttype, value)
def _create_color_mapping(self): """ Create a mapping of style hex colors to index/offset in the RTF color table. """ color_mapping = OrderedDict() offset = 1
if self.linenos: color_mapping[self.lineno_color] = offset offset += 1
if self.hl_lines: color_mapping[self.hl_color] = offset offset += 1
for _, style in self.style: for color in style['color'], style['bgcolor'], style['border']: if color and color not in color_mapping: color_mapping[color] = offset offset += 1
return color_mapping
@property def _lineno_template(self): if self.lineno_fontsize != self.fontsize: return '{{\\fs{} \\cf{} %s{}}}'.format(self.lineno_fontsize, self.color_mapping[self.lineno_color], " " * self.lineno_padding)
return '{{\\cf{} %s{}}}'.format(self.color_mapping[self.lineno_color], " " * self.lineno_padding)
@property def _hl_open_str(self): return rf'{{\highlight{self.color_mapping[self.hl_color]} '
@property def _rtf_header(self): lines = [] # rtf 1.8 header lines.append('{\\rtf1\\ansi\\uc0\\deff0' '{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}' % (self.fontface and ' ' + self._escape(self.fontface) or ''))
# color table lines.append('{\\colortbl;') for color, _ in self.color_mapping.items(): lines.append(self.hex_to_rtf_color(color)) lines.append('}')
# font and fontsize lines.append('\\f0\\sa0') if self.fontsize: lines.append('\\fs%d' % self.fontsize)
# ensure Libre Office Writer imports and renders consecutive # space characters the same width, needed for line numbering. # https://bugs.documentfoundation.org/show_bug.cgi?id=144050 lines.append('\\dntblnsbdb')
return lines
def format_unencoded(self, tokensource, outfile): for line in self._rtf_header: outfile.write(line + "\n")
tokensource = self._split_tokens_on_newlines(tokensource)
# first pass of tokens to count lines, needed for line numbering if self.linenos: line_count = 0 tokens = [] # for copying the token source generator for ttype, value in tokensource: tokens.append((ttype, value)) if value.endswith("\n"): line_count += 1
# width of line number strings (for padding with spaces) linenos_width = len(str(line_count+self.linenostart-1))
tokensource = tokens
# highlight stream lineno = 1 start_new_line = True for ttype, value in tokensource: if start_new_line and lineno in self.hl_lines: outfile.write(self._hl_open_str)
if start_new_line and self.linenos: if (lineno-self.linenostart+1)%self.linenostep == 0: current_lineno = lineno + self.linenostart - 1 lineno_str = str(current_lineno).rjust(linenos_width) else: lineno_str = "".rjust(linenos_width) outfile.write(self._lineno_template % lineno_str)
while not self.style.styles_token(ttype) and ttype.parent: ttype = ttype.parent style = self.style.style_for_token(ttype) buf = [] if style['bgcolor']: buf.append('\\cb%d' % self.color_mapping[style['bgcolor']]) if style['color']: buf.append('\\cf%d' % self.color_mapping[style['color']]) if style['bold']: buf.append('\\b') if style['italic']: buf.append('\\i') if style['underline']: buf.append('\\ul') if style['border']: buf.append('\\chbrdr\\chcfpat%d' % self.color_mapping[style['border']]) start = ''.join(buf) if start: outfile.write(f'{{{start} ') outfile.write(self._escape_text(value)) if start: outfile.write('}') start_new_line = False
# complete line of input if value.endswith("\n"): # close line highlighting if lineno in self.hl_lines: outfile.write('}') # newline in RTF file after closing } outfile.write("\n")
start_new_line = True lineno += 1
outfile.write('}\n')123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603# Automatically generated by scripts/gen_mapfiles.py.# DO NOT EDIT BY HAND; run `tox -e mapfiles` instead.
LEXERS = { 'ABAPLexer': ('pygments.lexers.business', 'ABAP', ('abap',), ('*.abap', '*.ABAP'), ('text/x-abap',)), 'AMDGPULexer': ('pygments.lexers.amdgpu', 'AMDGPU', ('amdgpu',), ('*.isa',), ()), 'APLLexer': ('pygments.lexers.apl', 'APL', ('apl',), ('*.apl', '*.aplf', '*.aplo', '*.apln', '*.aplc', '*.apli', '*.dyalog'), ()), 'AbnfLexer': ('pygments.lexers.grammar_notation', 'ABNF', ('abnf',), ('*.abnf',), ('text/x-abnf',)), 'ActionScript3Lexer': ('pygments.lexers.actionscript', 'ActionScript 3', ('actionscript3', 'as3'), ('*.as',), ('application/x-actionscript3', 'text/x-actionscript3', 'text/actionscript3')), 'ActionScriptLexer': ('pygments.lexers.actionscript', 'ActionScript', ('actionscript', 'as'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')), 'AdaLexer': ('pygments.lexers.ada', 'Ada', ('ada', 'ada95', 'ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)), 'AdlLexer': ('pygments.lexers.archetype', 'ADL', ('adl',), ('*.adl', '*.adls', '*.adlf', '*.adlx'), ()), 'AgdaLexer': ('pygments.lexers.haskell', 'Agda', ('agda',), ('*.agda',), ('text/x-agda',)), 'AheuiLexer': ('pygments.lexers.esoteric', 'Aheui', ('aheui',), ('*.aheui',), ()), 'AlloyLexer': ('pygments.lexers.dsls', 'Alloy', ('alloy',), ('*.als',), ('text/x-alloy',)), 'AmbientTalkLexer': ('pygments.lexers.ambient', 'AmbientTalk', ('ambienttalk', 'ambienttalk/2', 'at'), ('*.at',), ('text/x-ambienttalk',)), 'AmplLexer': ('pygments.lexers.ampl', 'Ampl', ('ampl',), ('*.run',), ()), 'Angular2HtmlLexer': ('pygments.lexers.templates', 'HTML + Angular2', ('html+ng2',), ('*.ng2',), ()), 'Angular2Lexer': ('pygments.lexers.templates', 'Angular2', ('ng2',), (), ()), 'AntlrActionScriptLexer': ('pygments.lexers.parsers', 'ANTLR With ActionScript Target', ('antlr-actionscript', 'antlr-as'), ('*.G', '*.g'), ()), 'AntlrCSharpLexer': ('pygments.lexers.parsers', 'ANTLR With C# Target', ('antlr-csharp', 'antlr-c#'), ('*.G', '*.g'), ()), 'AntlrCppLexer': ('pygments.lexers.parsers', 'ANTLR With CPP Target', ('antlr-cpp',), ('*.G', '*.g'), ()), 'AntlrJavaLexer': ('pygments.lexers.parsers', 'ANTLR With Java Target', ('antlr-java',), ('*.G', '*.g'), ()), 'AntlrLexer': ('pygments.lexers.parsers', 'ANTLR', ('antlr',), (), ()), 'AntlrObjectiveCLexer': ('pygments.lexers.parsers', 'ANTLR With ObjectiveC Target', ('antlr-objc',), ('*.G', '*.g'), ()), 'AntlrPerlLexer': ('pygments.lexers.parsers', 'ANTLR With Perl Target', ('antlr-perl',), ('*.G', '*.g'), ()), 'AntlrPythonLexer': ('pygments.lexers.parsers', 'ANTLR With Python Target', ('antlr-python',), ('*.G', '*.g'), ()), 'AntlrRubyLexer': ('pygments.lexers.parsers', 'ANTLR With Ruby Target', ('antlr-ruby', 'antlr-rb'), ('*.G', '*.g'), ()), 'ApacheConfLexer': ('pygments.lexers.configs', 'ApacheConf', ('apacheconf', 'aconf', 'apache'), ('.htaccess', 'apache.conf', 'apache2.conf'), ('text/x-apacheconf',)), 'AppleScriptLexer': ('pygments.lexers.scripting', 'AppleScript', ('applescript',), ('*.applescript',), ()), 'ArduinoLexer': ('pygments.lexers.c_like', 'Arduino', ('arduino',), ('*.ino',), ('text/x-arduino',)), 'ArrowLexer': ('pygments.lexers.arrow', 'Arrow', ('arrow',), ('*.arw',), ()), 'ArturoLexer': ('pygments.lexers.arturo', 'Arturo', ('arturo', 'art'), ('*.art',), ()), 'AscLexer': ('pygments.lexers.asc', 'ASCII armored', ('asc', 'pem'), ('*.asc', '*.pem', 'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk', 'id_rsa'), ('application/pgp-keys', 'application/pgp-encrypted', 'application/pgp-signature', 'application/pem-certificate-chain')), 'Asn1Lexer': ('pygments.lexers.asn1', 'ASN.1', ('asn1',), ('*.asn1',), ()), 'AspectJLexer': ('pygments.lexers.jvm', 'AspectJ', ('aspectj',), ('*.aj',), ('text/x-aspectj',)), 'AsymptoteLexer': ('pygments.lexers.graphics', 'Asymptote', ('asymptote', 'asy'), ('*.asy',), ('text/x-asymptote',)), 'AugeasLexer': ('pygments.lexers.configs', 'Augeas', ('augeas',), ('*.aug',), ()), 'AutoItLexer': ('pygments.lexers.automation', 'AutoIt', ('autoit',), ('*.au3',), ('text/x-autoit',)), 'AutohotkeyLexer': ('pygments.lexers.automation', 'autohotkey', ('autohotkey', 'ahk'), ('*.ahk', '*.ahkl'), ('text/x-autohotkey',)), 'AwkLexer': ('pygments.lexers.textedit', 'Awk', ('awk', 'gawk', 'mawk', 'nawk'), ('*.awk',), ('application/x-awk',)), 'BBCBasicLexer': ('pygments.lexers.basic', 'BBC Basic', ('bbcbasic',), ('*.bbc',), ()), 'BBCodeLexer': ('pygments.lexers.markup', 'BBCode', ('bbcode',), (), ('text/x-bbcode',)), 'BCLexer': ('pygments.lexers.algebra', 'BC', ('bc',), ('*.bc',), ()), 'BQNLexer': ('pygments.lexers.bqn', 'BQN', ('bqn',), ('*.bqn',), ()), 'BSTLexer': ('pygments.lexers.bibtex', 'BST', ('bst', 'bst-pybtex'), ('*.bst',), ()), 'BareLexer': ('pygments.lexers.bare', 'BARE', ('bare',), ('*.bare',), ()), 'BaseMakefileLexer': ('pygments.lexers.make', 'Base Makefile', ('basemake',), (), ()), 'BashLexer': ('pygments.lexers.shell', 'Bash', ('bash', 'sh', 'ksh', 'zsh', 'shell', 'openrc'), ('*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '*.exheres-0', '*.exlib', '*.zsh', '.bashrc', 'bashrc', '.bash_*', 'bash_*', 'zshrc', '.zshrc', '.kshrc', 'kshrc', 'PKGBUILD'), ('application/x-sh', 'application/x-shellscript', 'text/x-shellscript')), 'BashSessionLexer': ('pygments.lexers.shell', 'Bash Session', ('console', 'shell-session'), ('*.sh-session', '*.shell-session'), ('application/x-shell-session', 'application/x-sh-session')), 'BatchLexer': ('pygments.lexers.shell', 'Batchfile', ('batch', 'bat', 'dosbatch', 'winbatch'), ('*.bat', '*.cmd'), ('application/x-dos-batch',)), 'BddLexer': ('pygments.lexers.bdd', 'Bdd', ('bdd',), ('*.feature',), ('text/x-bdd',)), 'BefungeLexer': ('pygments.lexers.esoteric', 'Befunge', ('befunge',), ('*.befunge',), ('application/x-befunge',)), 'BerryLexer': ('pygments.lexers.berry', 'Berry', ('berry', 'be'), ('*.be',), ('text/x-berry', 'application/x-berry')), 'BibTeXLexer': ('pygments.lexers.bibtex', 'BibTeX', ('bibtex', 'bib'), ('*.bib',), ('text/x-bibtex',)), 'BlitzBasicLexer': ('pygments.lexers.basic', 'BlitzBasic', ('blitzbasic', 'b3d', 'bplus'), ('*.bb', '*.decls'), ('text/x-bb',)), 'BlitzMaxLexer': ('pygments.lexers.basic', 'BlitzMax', ('blitzmax', 'bmax'), ('*.bmx',), ('text/x-bmx',)), 'BlueprintLexer': ('pygments.lexers.blueprint', 'Blueprint', ('blueprint',), ('*.blp',), ('text/x-blueprint',)), 'BnfLexer': ('pygments.lexers.grammar_notation', 'BNF', ('bnf',), ('*.bnf',), ('text/x-bnf',)), 'BoaLexer': ('pygments.lexers.boa', 'Boa', ('boa',), ('*.boa',), ()), 'BooLexer': ('pygments.lexers.dotnet', 'Boo', ('boo',), ('*.boo',), ('text/x-boo',)), 'BoogieLexer': ('pygments.lexers.verification', 'Boogie', ('boogie',), ('*.bpl',), ()), 'BrainfuckLexer': ('pygments.lexers.esoteric', 'Brainfuck', ('brainfuck', 'bf'), ('*.bf', '*.b'), ('application/x-brainfuck',)), 'BugsLexer': ('pygments.lexers.modeling', 'BUGS', ('bugs', 'winbugs', 'openbugs'), ('*.bug',), ()), 'CAmkESLexer': ('pygments.lexers.esoteric', 'CAmkES', ('camkes', 'idl4'), ('*.camkes', '*.idl4'), ()), 'CLexer': ('pygments.lexers.c_cpp', 'C', ('c',), ('*.c', '*.h', '*.idc', '*.x[bp]m'), ('text/x-chdr', 'text/x-csrc', 'image/x-xbitmap', 'image/x-xpixmap')), 'CMakeLexer': ('pygments.lexers.make', 'CMake', ('cmake',), ('*.cmake', 'CMakeLists.txt'), ('text/x-cmake',)), 'CObjdumpLexer': ('pygments.lexers.asm', 'c-objdump', ('c-objdump',), ('*.c-objdump',), ('text/x-c-objdump',)), 'CPSALexer': ('pygments.lexers.lisp', 'CPSA', ('cpsa',), ('*.cpsa',), ()), 'CSSUL4Lexer': ('pygments.lexers.ul4', 'CSS+UL4', ('css+ul4',), ('*.cssul4',), ()), 'CSharpAspxLexer': ('pygments.lexers.dotnet', 'aspx-cs', ('aspx-cs',), ('*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'), ()), 'CSharpLexer': ('pygments.lexers.dotnet', 'C#', ('csharp', 'c#', 'cs'), ('*.cs',), ('text/x-csharp',)), 'Ca65Lexer': ('pygments.lexers.asm', 'ca65 assembler', ('ca65',), ('*.s',), ()), 'CadlLexer': ('pygments.lexers.archetype', 'cADL', ('cadl',), ('*.cadl',), ()), 'CapDLLexer': ('pygments.lexers.esoteric', 'CapDL', ('capdl',), ('*.cdl',), ()), 'CapnProtoLexer': ('pygments.lexers.capnproto', "Cap'n Proto", ('capnp',), ('*.capnp',), ()), 'CarbonLexer': ('pygments.lexers.carbon', 'Carbon', ('carbon',), ('*.carbon',), ('text/x-carbon',)), 'CbmBasicV2Lexer': ('pygments.lexers.basic', 'CBM BASIC V2', ('cbmbas',), ('*.bas',), ()), 'CddlLexer': ('pygments.lexers.cddl', 'CDDL', ('cddl',), ('*.cddl',), ('text/x-cddl',)), 'CeylonLexer': ('pygments.lexers.jvm', 'Ceylon', ('ceylon',), ('*.ceylon',), ('text/x-ceylon',)), 'Cfengine3Lexer': ('pygments.lexers.configs', 'CFEngine3', ('cfengine3', 'cf3'), ('*.cf',), ()), 'ChaiscriptLexer': ('pygments.lexers.scripting', 'ChaiScript', ('chaiscript', 'chai'), ('*.chai',), ('text/x-chaiscript', 'application/x-chaiscript')), 'ChapelLexer': ('pygments.lexers.chapel', 'Chapel', ('chapel', 'chpl'), ('*.chpl',), ()), 'CharmciLexer': ('pygments.lexers.c_like', 'Charmci', ('charmci',), ('*.ci',), ()), 'CheetahHtmlLexer': ('pygments.lexers.templates', 'HTML+Cheetah', ('html+cheetah', 'html+spitfire', 'htmlcheetah'), (), ('text/html+cheetah', 'text/html+spitfire')), 'CheetahJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Cheetah', ('javascript+cheetah', 'js+cheetah', 'javascript+spitfire', 'js+spitfire'), (), ('application/x-javascript+cheetah', 'text/x-javascript+cheetah', 'text/javascript+cheetah', 'application/x-javascript+spitfire', 'text/x-javascript+spitfire', 'text/javascript+spitfire')), 'CheetahLexer': ('pygments.lexers.templates', 'Cheetah', ('cheetah', 'spitfire'), ('*.tmpl', '*.spt'), ('application/x-cheetah', 'application/x-spitfire')), 'CheetahXmlLexer': ('pygments.lexers.templates', 'XML+Cheetah', ('xml+cheetah', 'xml+spitfire'), (), ('application/xml+cheetah', 'application/xml+spitfire')), 'CirruLexer': ('pygments.lexers.webmisc', 'Cirru', ('cirru',), ('*.cirru',), ('text/x-cirru',)), 'ClayLexer': ('pygments.lexers.c_like', 'Clay', ('clay',), ('*.clay',), ('text/x-clay',)), 'CleanLexer': ('pygments.lexers.clean', 'Clean', ('clean',), ('*.icl', '*.dcl'), ()), 'ClojureLexer': ('pygments.lexers.jvm', 'Clojure', ('clojure', 'clj'), ('*.clj', '*.cljc'), ('text/x-clojure', 'application/x-clojure')), 'ClojureScriptLexer': ('pygments.lexers.jvm', 'ClojureScript', ('clojurescript', 'cljs'), ('*.cljs',), ('text/x-clojurescript', 'application/x-clojurescript')), 'CobolFreeformatLexer': ('pygments.lexers.business', 'COBOLFree', ('cobolfree',), ('*.cbl', '*.CBL'), ()), 'CobolLexer': ('pygments.lexers.business', 'COBOL', ('cobol',), ('*.cob', '*.COB', '*.cpy', '*.CPY'), ('text/x-cobol',)), 'CodeQLLexer': ('pygments.lexers.codeql', 'CodeQL', ('codeql', 'ql'), ('*.ql', '*.qll'), ()), 'CoffeeScriptLexer': ('pygments.lexers.javascript', 'CoffeeScript', ('coffeescript', 'coffee-script', 'coffee'), ('*.coffee',), ('text/coffeescript',)), 'ColdfusionCFCLexer': ('pygments.lexers.templates', 'Coldfusion CFC', ('cfc',), ('*.cfc',), ()), 'ColdfusionHtmlLexer': ('pygments.lexers.templates', 'Coldfusion HTML', ('cfm',), ('*.cfm', '*.cfml'), ('application/x-coldfusion',)), 'ColdfusionLexer': ('pygments.lexers.templates', 'cfstatement', ('cfs',), (), ()), 'Comal80Lexer': ('pygments.lexers.comal', 'COMAL-80', ('comal', 'comal80'), ('*.cml', '*.comal'), ()), 'CommonLispLexer': ('pygments.lexers.lisp', 'Common Lisp', ('common-lisp', 'cl', 'lisp'), ('*.cl', '*.lisp'), ('text/x-common-lisp',)), 'ComponentPascalLexer': ('pygments.lexers.oberon', 'Component Pascal', ('componentpascal', 'cp'), ('*.cp', '*.cps'), ('text/x-component-pascal',)), 'CplintLexer': ('pygments.lexers.cplint', 'cplint', ('cplint',), ('*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl'), ('text/x-cplint',)), 'CppLexer': ('pygments.lexers.c_cpp', 'C++', ('cpp', 'c++'), ('*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp', '*.CPP', '*.tpp', '*.cppm', '*.ixx', '*.mxx'), ('text/x-c++hdr', 'text/x-c++src')), 'CppObjdumpLexer': ('pygments.lexers.asm', 'cpp-objdump', ('cpp-objdump', 'c++-objdumb', 'cxx-objdump'), ('*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'), ('text/x-cpp-objdump',)), 'CrmshLexer': ('pygments.lexers.dsls', 'Crmsh', ('crmsh', 'pcmk'), ('*.crmsh', '*.pcmk'), ()), 'CrocLexer': ('pygments.lexers.d', 'Croc', ('croc',), ('*.croc',), ('text/x-crocsrc',)), 'CryptolLexer': ('pygments.lexers.haskell', 'Cryptol', ('cryptol', 'cry'), ('*.cry',), ('text/x-cryptol',)), 'CrystalLexer': ('pygments.lexers.crystal', 'Crystal', ('cr', 'crystal'), ('*.cr',), ('text/x-crystal',)), 'CsoundDocumentLexer': ('pygments.lexers.csound', 'Csound Document', ('csound-document', 'csound-csd'), ('*.csd',), ()), 'CsoundOrchestraLexer': ('pygments.lexers.csound', 'Csound Orchestra', ('csound', 'csound-orc'), ('*.orc', '*.udo'), ()), 'CsoundScoreLexer': ('pygments.lexers.csound', 'Csound Score', ('csound-score', 'csound-sco'), ('*.sco',), ()), 'CssDjangoLexer': ('pygments.lexers.templates', 'CSS+Django/Jinja', ('css+django', 'css+jinja'), ('*.css.j2', '*.css.jinja2'), ('text/css+django', 'text/css+jinja')), 'CssErbLexer': ('pygments.lexers.templates', 'CSS+Ruby', ('css+ruby', 'css+erb'), (), ('text/css+ruby',)), 'CssGenshiLexer': ('pygments.lexers.templates', 'CSS+Genshi Text', ('css+genshitext', 'css+genshi'), (), ('text/css+genshi',)), 'CssLexer': ('pygments.lexers.css', 'CSS', ('css',), ('*.css',), ('text/css',)), 'CssPhpLexer': ('pygments.lexers.templates', 'CSS+PHP', ('css+php',), (), ('text/css+php',)), 'CssSmartyLexer': ('pygments.lexers.templates', 'CSS+Smarty', ('css+smarty',), (), ('text/css+smarty',)), 'CudaLexer': ('pygments.lexers.c_like', 'CUDA', ('cuda', 'cu'), ('*.cu', '*.cuh'), ('text/x-cuda',)), 'CypherLexer': ('pygments.lexers.graph', 'Cypher', ('cypher',), ('*.cyp', '*.cypher'), ()), 'CythonLexer': ('pygments.lexers.python', 'Cython', ('cython', 'pyx', 'pyrex'), ('*.pyx', '*.pxd', '*.pxi'), ('text/x-cython', 'application/x-cython')), 'DLexer': ('pygments.lexers.d', 'D', ('d',), ('*.d', '*.di'), ('text/x-dsrc',)), 'DObjdumpLexer': ('pygments.lexers.asm', 'd-objdump', ('d-objdump',), ('*.d-objdump',), ('text/x-d-objdump',)), 'DarcsPatchLexer': ('pygments.lexers.diff', 'Darcs Patch', ('dpatch',), ('*.dpatch', '*.darcspatch'), ()), 'DartLexer': ('pygments.lexers.javascript', 'Dart', ('dart',), ('*.dart',), ('text/x-dart',)), 'Dasm16Lexer': ('pygments.lexers.asm', 'DASM16', ('dasm16',), ('*.dasm16', '*.dasm'), ('text/x-dasm16',)), 'DaxLexer': ('pygments.lexers.dax', 'Dax', ('dax',), ('*.dax',), ()), 'DebianControlLexer': ('pygments.lexers.installers', 'Debian Control file', ('debcontrol', 'control'), ('control',), ()), 'DebianSourcesLexer': ('pygments.lexers.installers', 'Debian Sources file', ('debian.sources',), ('*.sources',), ()), 'DelphiLexer': ('pygments.lexers.pascal', 'Delphi', ('delphi', 'pas', 'pascal', 'objectpascal'), ('*.pas', '*.dpr'), ('text/x-pascal',)), 'DesktopLexer': ('pygments.lexers.configs', 'Desktop file', ('desktop',), ('*.desktop',), ('application/x-desktop',)), 'DevicetreeLexer': ('pygments.lexers.devicetree', 'Devicetree', ('devicetree', 'dts'), ('*.dts', '*.dtsi'), ('text/x-c',)), 'DgLexer': ('pygments.lexers.python', 'dg', ('dg',), ('*.dg',), ('text/x-dg',)), 'DiffLexer': ('pygments.lexers.diff', 'Diff', ('diff', 'udiff'), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch')), 'DjangoLexer': ('pygments.lexers.templates', 'Django/Jinja', ('django', 'jinja'), (), ('application/x-django-templating', 'application/x-jinja')), 'DnsZoneLexer': ('pygments.lexers.dns', 'Zone', ('zone',), ('*.zone',), ('text/dns',)), 'DockerLexer': ('pygments.lexers.configs', 'Docker', ('docker', 'dockerfile'), ('Dockerfile', '*.docker'), ('text/x-dockerfile-config',)), 'DtdLexer': ('pygments.lexers.html', 'DTD', ('dtd',), ('*.dtd',), ('application/xml-dtd',)), 'DuelLexer': ('pygments.lexers.webmisc', 'Duel', ('duel', 'jbst', 'jsonml+bst'), ('*.duel', '*.jbst'), ('text/x-duel', 'text/x-jbst')), 'DylanConsoleLexer': ('pygments.lexers.dylan', 'Dylan session', ('dylan-console', 'dylan-repl'), ('*.dylan-console',), ('text/x-dylan-console',)), 'DylanLexer': ('pygments.lexers.dylan', 'Dylan', ('dylan',), ('*.dylan', '*.dyl', '*.intr'), ('text/x-dylan',)), 'DylanLidLexer': ('pygments.lexers.dylan', 'DylanLID', ('dylan-lid', 'lid'), ('*.lid', '*.hdp'), ('text/x-dylan-lid',)), 'ECLLexer': ('pygments.lexers.ecl', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)), 'ECLexer': ('pygments.lexers.c_like', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')), 'EarlGreyLexer': ('pygments.lexers.javascript', 'Earl Grey', ('earl-grey', 'earlgrey', 'eg'), ('*.eg',), ('text/x-earl-grey',)), 'EasytrieveLexer': ('pygments.lexers.scripting', 'Easytrieve', ('easytrieve',), ('*.ezt', '*.mac'), ('text/x-easytrieve',)), 'EbnfLexer': ('pygments.lexers.parsers', 'EBNF', ('ebnf',), ('*.ebnf',), ('text/x-ebnf',)), 'EiffelLexer': ('pygments.lexers.eiffel', 'Eiffel', ('eiffel',), ('*.e',), ('text/x-eiffel',)), 'ElixirConsoleLexer': ('pygments.lexers.erlang', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)), 'ElixirLexer': ('pygments.lexers.erlang', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.eex', '*.exs', '*.leex'), ('text/x-elixir',)), 'ElmLexer': ('pygments.lexers.elm', 'Elm', ('elm',), ('*.elm',), ('text/x-elm',)), 'ElpiLexer': ('pygments.lexers.elpi', 'Elpi', ('elpi',), ('*.elpi',), ('text/x-elpi',)), 'EmacsLispLexer': ('pygments.lexers.lisp', 'EmacsLisp', ('emacs-lisp', 'elisp', 'emacs'), ('*.el',), ('text/x-elisp', 'application/x-elisp')), 'EmailLexer': ('pygments.lexers.email', 'E-mail', ('email', 'eml'), ('*.eml',), ('message/rfc822',)), 'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)), 'ErlangLexer': ('pygments.lexers.erlang', 'Erlang', ('erlang',), ('*.erl', '*.hrl', '*.es', '*.escript'), ('text/x-erlang',)), 'ErlangShellLexer': ('pygments.lexers.erlang', 'Erlang erl session', ('erl',), ('*.erl-sh',), ('text/x-erl-shellsession',)), 'EvoqueHtmlLexer': ('pygments.lexers.templates', 'HTML+Evoque', ('html+evoque',), (), ('text/html+evoque',)), 'EvoqueLexer': ('pygments.lexers.templates', 'Evoque', ('evoque',), ('*.evoque',), ('application/x-evoque',)), 'EvoqueXmlLexer': ('pygments.lexers.templates', 'XML+Evoque', ('xml+evoque',), (), ('application/xml+evoque',)), 'ExeclineLexer': ('pygments.lexers.shell', 'execline', ('execline',), ('*.exec',), ()), 'EzhilLexer': ('pygments.lexers.ezhil', 'Ezhil', ('ezhil',), ('*.n',), ('text/x-ezhil',)), 'FSharpLexer': ('pygments.lexers.dotnet', 'F#', ('fsharp', 'f#'), ('*.fs', '*.fsi', '*.fsx'), ('text/x-fsharp',)), 'FStarLexer': ('pygments.lexers.ml', 'FStar', ('fstar',), ('*.fst', '*.fsti'), ('text/x-fstar',)), 'FactorLexer': ('pygments.lexers.factor', 'Factor', ('factor',), ('*.factor',), ('text/x-factor',)), 'FancyLexer': ('pygments.lexers.ruby', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.fantom', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), 'FelixLexer': ('pygments.lexers.felix', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)), 'FennelLexer': ('pygments.lexers.lisp', 'Fennel', ('fennel', 'fnl'), ('*.fnl', '*.fnlm'), ('text/x-fennel',)), 'FiftLexer': ('pygments.lexers.fift', 'Fift', ('fift', 'fif'), ('*.fif',), ()), 'FishShellLexer': ('pygments.lexers.shell', 'Fish', ('fish', 'fishshell'), ('*.fish', '*.load'), ('application/x-fish',)), 'FlatlineLexer': ('pygments.lexers.dsls', 'Flatline', ('flatline',), (), ('text/x-flatline',)), 'FloScriptLexer': ('pygments.lexers.floscript', 'FloScript', ('floscript', 'flo'), ('*.flo',), ()), 'ForthLexer': ('pygments.lexers.forth', 'Forth', ('forth',), ('*.frt', '*.fs'), ('application/x-forth',)), 'FortranFixedLexer': ('pygments.lexers.fortran', 'FortranFixed', ('fortranfixed',), ('*.f', '*.F'), ()), 'FortranLexer': ('pygments.lexers.fortran', 'Fortran', ('fortran', 'f90'), ('*.f03', '*.f90', '*.F03', '*.F90'), ('text/x-fortran',)), 'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('foxpro', 'vfp', 'clipper', 'xbase'), ('*.PRG', '*.prg'), ()), 'FreeFemLexer': ('pygments.lexers.freefem', 'Freefem', ('freefem',), ('*.edp',), ('text/x-freefem',)), 'FuncLexer': ('pygments.lexers.func', 'FunC', ('func', 'fc'), ('*.fc', '*.func'), ()), 'FutharkLexer': ('pygments.lexers.futhark', 'Futhark', ('futhark',), ('*.fut',), ('text/x-futhark',)), 'GAPConsoleLexer': ('pygments.lexers.algebra', 'GAP session', ('gap-console', 'gap-repl'), ('*.tst',), ()), 'GAPLexer': ('pygments.lexers.algebra', 'GAP', ('gap',), ('*.g', '*.gd', '*.gi', '*.gap'), ()), 'GDScriptLexer': ('pygments.lexers.gdscript', 'GDScript', ('gdscript', 'gd'), ('*.gd',), ('text/x-gdscript', 'application/x-gdscript')), 'GLShaderLexer': ('pygments.lexers.graphics', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)), 'GSQLLexer': ('pygments.lexers.gsql', 'GSQL', ('gsql',), ('*.gsql',), ()), 'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas', 'asm'), ('*.s', '*.S'), ('text/x-gas',)), 'GcodeLexer': ('pygments.lexers.gcodelexer', 'g-code', ('gcode',), ('*.gcode',), ()), 'GenshiLexer': ('pygments.lexers.templates', 'Genshi', ('genshi', 'kid', 'xml+genshi', 'xml+kid'), ('*.kid',), ('application/x-genshi', 'application/x-kid')), 'GenshiTextLexer': ('pygments.lexers.templates', 'Genshi Text', ('genshitext',), (), ('application/x-genshi-text', 'text/x-genshi')), 'GettextLexer': ('pygments.lexers.textfmts', 'Gettext Catalog', ('pot', 'po'), ('*.pot', '*.po'), ('application/x-gettext', 'text/x-gettext', 'text/gettext')), 'GherkinLexer': ('pygments.lexers.testing', 'Gherkin', ('gherkin', 'cucumber'), ('*.feature',), ('text/x-gherkin',)), 'GleamLexer': ('pygments.lexers.gleam', 'Gleam', ('gleam',), ('*.gleam',), ('text/x-gleam',)), 'GnuplotLexer': ('pygments.lexers.graphics', 'Gnuplot', ('gnuplot',), ('*.plot', '*.plt'), ('text/x-gnuplot',)), 'GoLexer': ('pygments.lexers.go', 'Go', ('go', 'golang'), ('*.go',), ('text/x-gosrc',)), 'GoloLexer': ('pygments.lexers.jvm', 'Golo', ('golo',), ('*.golo',), ()), 'GoodDataCLLexer': ('pygments.lexers.business', 'GoodData-CL', ('gooddata-cl',), ('*.gdc',), ('text/x-gooddata-cl',)), 'GoogleSqlLexer': ('pygments.lexers.sql', 'GoogleSQL', ('googlesql', 'zetasql'), ('*.googlesql', '*.googlesql.sql'), ('text/x-google-sql', 'text/x-google-sql-aux')), 'GosuLexer': ('pygments.lexers.jvm', 'Gosu', ('gosu',), ('*.gs', '*.gsx', '*.gsp', '*.vark'), ('text/x-gosu',)), 'GosuTemplateLexer': ('pygments.lexers.jvm', 'Gosu Template', ('gst',), ('*.gst',), ('text/x-gosu-template',)), 'GraphQLLexer': ('pygments.lexers.graphql', 'GraphQL', ('graphql',), ('*.graphql',), ()), 'GraphvizLexer': ('pygments.lexers.graphviz', 'Graphviz', ('graphviz', 'dot'), ('*.gv', '*.dot'), ('text/x-graphviz', 'text/vnd.graphviz')), 'GroffLexer': ('pygments.lexers.markup', 'Groff', ('groff', 'nroff', 'man'), ('*.[1-9]', '*.man', '*.1p', '*.3pm'), ('application/x-troff', 'text/troff')), 'GroovyLexer': ('pygments.lexers.jvm', 'Groovy', ('groovy',), ('*.groovy', '*.gradle'), ('text/x-groovy',)), 'HLSLShaderLexer': ('pygments.lexers.graphics', 'HLSL', ('hlsl',), ('*.hlsl', '*.hlsli'), ('text/x-hlsl',)), 'HTMLUL4Lexer': ('pygments.lexers.ul4', 'HTML+UL4', ('html+ul4',), ('*.htmlul4',), ()), 'HamlLexer': ('pygments.lexers.html', 'Haml', ('haml',), ('*.haml',), ('text/x-haml',)), 'HandlebarsHtmlLexer': ('pygments.lexers.templates', 'HTML+Handlebars', ('html+handlebars',), ('*.handlebars', '*.hbs'), ('text/html+handlebars', 'text/x-handlebars-template')), 'HandlebarsLexer': ('pygments.lexers.templates', 'Handlebars', ('handlebars',), (), ()), 'HareLexer': ('pygments.lexers.hare', 'Hare', ('hare',), ('*.ha',), ('text/x-hare',)), 'HaskellLexer': ('pygments.lexers.haskell', 'Haskell', ('haskell', 'hs'), ('*.hs',), ('text/x-haskell',)), 'HaxeLexer': ('pygments.lexers.haxe', 'Haxe', ('haxe', 'hxsl', 'hx'), ('*.hx', '*.hxsl'), ('text/haxe', 'text/x-haxe', 'text/x-hx')), 'HexdumpLexer': ('pygments.lexers.hexdump', 'Hexdump', ('hexdump',), (), ()), 'HsailLexer': ('pygments.lexers.asm', 'HSAIL', ('hsail', 'hsa'), ('*.hsail',), ('text/x-hsail',)), 'HspecLexer': ('pygments.lexers.haskell', 'Hspec', ('hspec',), ('*Spec.hs',), ()), 'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja', 'htmldjango'), ('*.html.j2', '*.htm.j2', '*.xhtml.j2', '*.html.jinja2', '*.htm.jinja2', '*.xhtml.jinja2'), ('text/html+django', 'text/html+jinja')), 'HtmlGenshiLexer': ('pygments.lexers.templates', 'HTML+Genshi', ('html+genshi', 'html+kid'), (), ('text/html+genshi',)), 'HtmlLexer': ('pygments.lexers.html', 'HTML', ('html',), ('*.html', '*.htm', '*.xhtml', '*.xslt'), ('text/html', 'application/xhtml+xml')), 'HtmlPhpLexer': ('pygments.lexers.templates', 'HTML+PHP', ('html+php',), ('*.phtml',), ('application/x-php', 'application/x-httpd-php', 'application/x-httpd-php3', 'application/x-httpd-php4', 'application/x-httpd-php5')), 'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)), 'HttpLexer': ('pygments.lexers.textfmts', 'HTTP', ('http',), (), ()), 'HxmlLexer': ('pygments.lexers.haxe', 'Hxml', ('haxeml', 'hxml'), ('*.hxml',), ()), 'HyLexer': ('pygments.lexers.lisp', 'Hy', ('hylang', 'hy'), ('*.hy',), ('text/x-hy', 'application/x-hy')), 'HybrisLexer': ('pygments.lexers.scripting', 'Hybris', ('hybris',), ('*.hyb',), ('text/x-hybris', 'application/x-hybris')), 'IDLLexer': ('pygments.lexers.idl', 'IDL', ('idl',), ('*.pro',), ('text/idl',)), 'IconLexer': ('pygments.lexers.unicon', 'Icon', ('icon',), ('*.icon', '*.ICON'), ()), 'IdrisLexer': ('pygments.lexers.haskell', 'Idris', ('idris', 'idr'), ('*.idr',), ('text/x-idris',)), 'IgorLexer': ('pygments.lexers.igor', 'Igor', ('igor', 'igorpro'), ('*.ipf',), ('text/ipf',)), 'Inform6Lexer': ('pygments.lexers.int_fiction', 'Inform 6', ('inform6', 'i6'), ('*.inf',), ()), 'Inform6TemplateLexer': ('pygments.lexers.int_fiction', 'Inform 6 template', ('i6t',), ('*.i6t',), ()), 'Inform7Lexer': ('pygments.lexers.int_fiction', 'Inform 7', ('inform7', 'i7'), ('*.ni', '*.i7x'), ()), 'IniLexer': ('pygments.lexers.configs', 'INI', ('ini', 'cfg', 'dosini'), ('*.ini', '*.cfg', '*.inf', '.editorconfig'), ('text/x-ini', 'text/inf')), 'IoLexer': ('pygments.lexers.iolang', 'Io', ('io',), ('*.io',), ('text/x-iosrc',)), 'IokeLexer': ('pygments.lexers.jvm', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)), 'IrcLogsLexer': ('pygments.lexers.textfmts', 'IRC logs', ('irc',), ('*.weechatlog',), ('text/x-irclog',)), 'IsabelleLexer': ('pygments.lexers.theorem', 'Isabelle', ('isabelle',), ('*.thy',), ('text/x-isabelle',)), 'JLexer': ('pygments.lexers.j', 'J', ('j',), ('*.ijs',), ('text/x-j',)), 'JMESPathLexer': ('pygments.lexers.jmespath', 'JMESPath', ('jmespath', 'jp'), ('*.jp',), ()), 'JSLTLexer': ('pygments.lexers.jslt', 'JSLT', ('jslt',), ('*.jslt',), ('text/x-jslt',)), 'JagsLexer': ('pygments.lexers.modeling', 'JAGS', ('jags',), ('*.jag', '*.bug'), ()), 'JanetLexer': ('pygments.lexers.lisp', 'Janet', ('janet',), ('*.janet', '*.jdn'), ('text/x-janet', 'application/x-janet')), 'JasminLexer': ('pygments.lexers.jvm', 'Jasmin', ('jasmin', 'jasminxt'), ('*.j',), ()), 'JavaLexer': ('pygments.lexers.jvm', 'Java', ('java',), ('*.java',), ('text/x-java',)), 'JavascriptDjangoLexer': ('pygments.lexers.templates', 'JavaScript+Django/Jinja', ('javascript+django', 'js+django', 'javascript+jinja', 'js+jinja'), ('*.js.j2', '*.js.jinja2'), ('application/x-javascript+django', 'application/x-javascript+jinja', 'text/x-javascript+django', 'text/x-javascript+jinja', 'text/javascript+django', 'text/javascript+jinja')), 'JavascriptErbLexer': ('pygments.lexers.templates', 'JavaScript+Ruby', ('javascript+ruby', 'js+ruby', 'javascript+erb', 'js+erb'), (), ('application/x-javascript+ruby', 'text/x-javascript+ruby', 'text/javascript+ruby')), 'JavascriptGenshiLexer': ('pygments.lexers.templates', 'JavaScript+Genshi Text', ('js+genshitext', 'js+genshi', 'javascript+genshitext', 'javascript+genshi'), (), ('application/x-javascript+genshi', 'text/x-javascript+genshi', 'text/javascript+genshi')), 'JavascriptLexer': ('pygments.lexers.javascript', 'JavaScript', ('javascript', 'js'), ('*.js', '*.jsm', '*.mjs', '*.cjs'), ('application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript')), 'JavascriptPhpLexer': ('pygments.lexers.templates', 'JavaScript+PHP', ('javascript+php', 'js+php'), (), ('application/x-javascript+php', 'text/x-javascript+php', 'text/javascript+php')), 'JavascriptSmartyLexer': ('pygments.lexers.templates', 'JavaScript+Smarty', ('javascript+smarty', 'js+smarty'), (), ('application/x-javascript+smarty', 'text/x-javascript+smarty', 'text/javascript+smarty')), 'JavascriptUL4Lexer': ('pygments.lexers.ul4', 'Javascript+UL4', ('js+ul4',), ('*.jsul4',), ()), 'JclLexer': ('pygments.lexers.scripting', 'JCL', ('jcl',), ('*.jcl',), ('text/x-jcl',)), 'JsgfLexer': ('pygments.lexers.grammar_notation', 'JSGF', ('jsgf',), ('*.jsgf',), ('application/jsgf', 'application/x-jsgf', 'text/jsgf')), 'Json5Lexer': ('pygments.lexers.json5', 'JSON5', ('json5',), ('*.json5',), ()), 'JsonBareObjectLexer': ('pygments.lexers.data', 'JSONBareObject', (), (), ()), 'JsonLdLexer': ('pygments.lexers.data', 'JSON-LD', ('jsonld', 'json-ld'), ('*.jsonld',), ('application/ld+json',)), 'JsonLexer': ('pygments.lexers.data', 'JSON', ('json', 'json-object'), ('*.json', '*.jsonl', '*.ndjson', 'Pipfile.lock', '*.module', '*.xc'), ('application/json', 'application/json-object', 'application/x-ndjson', 'application/jsonl', 'application/json-seq')), 'JsonnetLexer': ('pygments.lexers.jsonnet', 'Jsonnet', ('jsonnet',), ('*.jsonnet', '*.libsonnet'), ()), 'JspLexer': ('pygments.lexers.templates', 'Java Server Page', ('jsp',), ('*.jsp',), ('application/x-jsp',)), 'JsxLexer': ('pygments.lexers.jsx', 'JSX', ('jsx', 'react'), ('*.jsx', '*.react'), ('text/jsx', 'text/typescript-jsx')), 'JuliaConsoleLexer': ('pygments.lexers.julia', 'Julia console', ('jlcon', 'julia-repl'), (), ()), 'JuliaLexer': ('pygments.lexers.julia', 'Julia', ('julia', 'jl'), ('*.jl',), ('text/x-julia', 'application/x-julia')), 'JuttleLexer': ('pygments.lexers.javascript', 'Juttle', ('juttle',), ('*.juttle',), ('application/juttle', 'application/x-juttle', 'text/x-juttle', 'text/juttle')), 'KLexer': ('pygments.lexers.q', 'K', ('k',), ('*.k',), ()), 'KalLexer': ('pygments.lexers.javascript', 'Kal', ('kal',), ('*.kal',), ('text/kal', 'application/kal')), 'KconfigLexer': ('pygments.lexers.configs', 'Kconfig', ('kconfig', 'menuconfig', 'linux-config', 'kernel-config'), ('Kconfig*', '*Config.in*', 'external.in*', 'standard-modules.in'), ('text/x-kconfig',)), 'KernelLogLexer': ('pygments.lexers.textfmts', 'Kernel log', ('kmsg', 'dmesg'), ('*.kmsg', '*.dmesg'), ()), 'KokaLexer': ('pygments.lexers.haskell', 'Koka', ('koka',), ('*.kk', '*.kki'), ('text/x-koka',)), 'KotlinLexer': ('pygments.lexers.jvm', 'Kotlin', ('kotlin',), ('*.kt', '*.kts'), ('text/x-kotlin',)), 'KuinLexer': ('pygments.lexers.kuin', 'Kuin', ('kuin',), ('*.kn',), ()), 'KustoLexer': ('pygments.lexers.kusto', 'Kusto', ('kql', 'kusto'), ('*.kql', '*.kusto', '.csl'), ()), 'LSLLexer': ('pygments.lexers.scripting', 'LSL', ('lsl',), ('*.lsl',), ('text/x-lsl',)), 'LassoCssLexer': ('pygments.lexers.templates', 'CSS+Lasso', ('css+lasso',), (), ('text/css+lasso',)), 'LassoHtmlLexer': ('pygments.lexers.templates', 'HTML+Lasso', ('html+lasso',), (), ('text/html+lasso', 'application/x-httpd-lasso', 'application/x-httpd-lasso[89]')), 'LassoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Lasso', ('javascript+lasso', 'js+lasso'), (), ('application/x-javascript+lasso', 'text/x-javascript+lasso', 'text/javascript+lasso')), 'LassoLexer': ('pygments.lexers.javascript', 'Lasso', ('lasso', 'lassoscript'), ('*.lasso', '*.lasso[89]'), ('text/x-lasso',)), 'LassoXmlLexer': ('pygments.lexers.templates', 'XML+Lasso', ('xml+lasso',), (), ('application/xml+lasso',)), 'LdaprcLexer': ('pygments.lexers.ldap', 'LDAP configuration file', ('ldapconf', 'ldaprc'), ('.ldaprc', 'ldaprc', 'ldap.conf'), ('text/x-ldapconf',)), 'LdifLexer': ('pygments.lexers.ldap', 'LDIF', ('ldif',), ('*.ldif',), ('text/x-ldif',)), 'Lean3Lexer': ('pygments.lexers.lean', 'Lean', ('lean', 'lean3'), ('*.lean',), ('text/x-lean', 'text/x-lean3')), 'Lean4Lexer': ('pygments.lexers.lean', 'Lean4', ('lean4',), ('*.lean',), ('text/x-lean4',)), 'LessCssLexer': ('pygments.lexers.css', 'LessCss', ('less',), ('*.less',), ('text/x-less-css',)), 'LighttpdConfLexer': ('pygments.lexers.configs', 'Lighttpd configuration file', ('lighttpd', 'lighty'), ('lighttpd.conf',), ('text/x-lighttpd-conf',)), 'LilyPondLexer': ('pygments.lexers.lilypond', 'LilyPond', ('lilypond',), ('*.ly',), ()), 'LimboLexer': ('pygments.lexers.inferno', 'Limbo', ('limbo',), ('*.b',), ('text/limbo',)), 'LiquidLexer': ('pygments.lexers.templates', 'liquid', ('liquid',), ('*.liquid',), ()), 'LiterateAgdaLexer': ('pygments.lexers.haskell', 'Literate Agda', ('literate-agda', 'lagda'), ('*.lagda',), ('text/x-literate-agda',)), 'LiterateCryptolLexer': ('pygments.lexers.haskell', 'Literate Cryptol', ('literate-cryptol', 'lcryptol', 'lcry'), ('*.lcry',), ('text/x-literate-cryptol',)), 'LiterateHaskellLexer': ('pygments.lexers.haskell', 'Literate Haskell', ('literate-haskell', 'lhaskell', 'lhs'), ('*.lhs',), ('text/x-literate-haskell',)), 'LiterateIdrisLexer': ('pygments.lexers.haskell', 'Literate Idris', ('literate-idris', 'lidris', 'lidr'), ('*.lidr',), ('text/x-literate-idris',)), 'LiveScriptLexer': ('pygments.lexers.javascript', 'LiveScript', ('livescript', 'live-script'), ('*.ls',), ('text/livescript',)), 'LlvmLexer': ('pygments.lexers.asm', 'LLVM', ('llvm',), ('*.ll',), ('text/x-llvm',)), 'LlvmMirBodyLexer': ('pygments.lexers.asm', 'LLVM-MIR Body', ('llvm-mir-body',), (), ()), 'LlvmMirLexer': ('pygments.lexers.asm', 'LLVM-MIR', ('llvm-mir',), ('*.mir',), ()), 'LogosLexer': ('pygments.lexers.objective', 'Logos', ('logos',), ('*.x', '*.xi', '*.xm', '*.xmi'), ('text/x-logos',)), 'LogtalkLexer': ('pygments.lexers.prolog', 'Logtalk', ('logtalk',), ('*.lgt', '*.logtalk'), ('text/x-logtalk',)), 'LuaLexer': ('pygments.lexers.scripting', 'Lua', ('lua',), ('*.lua', '*.wlua'), ('text/x-lua', 'application/x-lua')), 'LuauLexer': ('pygments.lexers.scripting', 'Luau', ('luau',), ('*.luau',), ()), 'MCFunctionLexer': ('pygments.lexers.minecraft', 'MCFunction', ('mcfunction', 'mcf'), ('*.mcfunction',), ('text/mcfunction',)), 'MCSchemaLexer': ('pygments.lexers.minecraft', 'MCSchema', ('mcschema',), ('*.mcschema',), ('text/mcschema',)), 'MIMELexer': ('pygments.lexers.mime', 'MIME', ('mime',), (), ('multipart/mixed', 'multipart/related', 'multipart/alternative')), 'MIPSLexer': ('pygments.lexers.mips', 'MIPS', ('mips',), ('*.mips', '*.MIPS'), ()), 'MOOCodeLexer': ('pygments.lexers.scripting', 'MOOCode', ('moocode', 'moo'), ('*.moo',), ('text/x-moocode',)), 'MSDOSSessionLexer': ('pygments.lexers.shell', 'MSDOS Session', ('doscon',), (), ()), 'Macaulay2Lexer': ('pygments.lexers.macaulay2', 'Macaulay2', ('macaulay2',), ('*.m2',), ()), 'MakefileLexer': ('pygments.lexers.make', 'Makefile', ('make', 'makefile', 'mf', 'bsdmake'), ('*.mak', '*.mk', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'), ('text/x-makefile',)), 'MakoCssLexer': ('pygments.lexers.templates', 'CSS+Mako', ('css+mako',), (), ('text/css+mako',)), 'MakoHtmlLexer': ('pygments.lexers.templates', 'HTML+Mako', ('html+mako',), (), ('text/html+mako',)), 'MakoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Mako', ('javascript+mako', 'js+mako'), (), ('application/x-javascript+mako', 'text/x-javascript+mako', 'text/javascript+mako')), 'MakoLexer': ('pygments.lexers.templates', 'Mako', ('mako',), ('*.mao',), ('application/x-mako',)), 'MakoXmlLexer': ('pygments.lexers.templates', 'XML+Mako', ('xml+mako',), (), ('application/xml+mako',)), 'MapleLexer': ('pygments.lexers.maple', 'Maple', ('maple',), ('*.mpl', '*.mi', '*.mm'), ('text/x-maple',)), 'MaqlLexer': ('pygments.lexers.business', 'MAQL', ('maql',), ('*.maql',), ('text/x-gooddata-maql', 'application/x-gooddata-maql')), 'MarkdownLexer': ('pygments.lexers.markup', 'Markdown', ('markdown', 'md'), ('*.md', '*.markdown'), ('text/x-markdown',)), 'MaskLexer': ('pygments.lexers.javascript', 'Mask', ('mask',), ('*.mask',), ('text/x-mask',)), 'MasonLexer': ('pygments.lexers.templates', 'Mason', ('mason',), ('*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler'), ('application/x-mason',)), 'MathematicaLexer': ('pygments.lexers.algebra', 'Mathematica', ('mathematica', 'mma', 'nb', 'wl', 'wolfram'), ('*.nb', '*.cdf', '*.nbp', '*.ma', '*.wl', '*.wls'), ('application/mathematica', 'application/vnd.wolfram.mathematica', 'application/vnd.wolfram.mathematica.package', 'application/vnd.wolfram.cdf', 'application/vnd.wolfram.wl')), 'MatlabLexer': ('pygments.lexers.matlab', 'Matlab', ('matlab',), ('*.m',), ('text/matlab',)), 'MatlabSessionLexer': ('pygments.lexers.matlab', 'Matlab session', ('matlabsession',), (), ()), 'MaximaLexer': ('pygments.lexers.maxima', 'Maxima', ('maxima', 'macsyma'), ('*.mac', '*.max'), ()), 'MesonLexer': ('pygments.lexers.meson', 'Meson', ('meson', 'meson.build'), ('meson.build', 'meson.options', 'meson_options.txt'), ('text/x-meson',)), 'MiniDLexer': ('pygments.lexers.d', 'MiniD', ('minid',), (), ('text/x-minidsrc',)), 'MiniScriptLexer': ('pygments.lexers.scripting', 'MiniScript', ('miniscript', 'ms'), ('*.ms',), ('text/x-minicript', 'application/x-miniscript')), 'ModelicaLexer': ('pygments.lexers.modeling', 'Modelica', ('modelica',), ('*.mo',), ('text/x-modelica',)), 'Modula2Lexer': ('pygments.lexers.modula2', 'Modula-2', ('modula2', 'm2'), ('*.def', '*.mod'), ('text/x-modula2',)), 'MoinWikiLexer': ('pygments.lexers.markup', 'MoinMoin/Trac Wiki markup', ('trac-wiki', 'moin'), (), ('text/x-trac-wiki',)), 'MojoLexer': ('pygments.lexers.mojo', 'Mojo', ('mojo', '🔥'), ('*.mojo', '*.🔥'), ('text/x-mojo', 'application/x-mojo')), 'MonkeyLexer': ('pygments.lexers.basic', 'Monkey', ('monkey',), ('*.monkey',), ('text/x-monkey',)), 'MonteLexer': ('pygments.lexers.monte', 'Monte', ('monte',), ('*.mt',), ()), 'MoonScriptLexer': ('pygments.lexers.scripting', 'MoonScript', ('moonscript', 'moon'), ('*.moon',), ('text/x-moonscript', 'application/x-moonscript')), 'MoselLexer': ('pygments.lexers.mosel', 'Mosel', ('mosel',), ('*.mos',), ()), 'MozPreprocCssLexer': ('pygments.lexers.markup', 'CSS+mozpreproc', ('css+mozpreproc',), ('*.css.in',), ()), 'MozPreprocHashLexer': ('pygments.lexers.markup', 'mozhashpreproc', ('mozhashpreproc',), (), ()), 'MozPreprocJavascriptLexer': ('pygments.lexers.markup', 'Javascript+mozpreproc', ('javascript+mozpreproc',), ('*.js.in',), ()), 'MozPreprocPercentLexer': ('pygments.lexers.markup', 'mozpercentpreproc', ('mozpercentpreproc',), (), ()), 'MozPreprocXulLexer': ('pygments.lexers.markup', 'XUL+mozpreproc', ('xul+mozpreproc',), ('*.xul.in',), ()), 'MqlLexer': ('pygments.lexers.c_like', 'MQL', ('mql', 'mq4', 'mq5', 'mql4', 'mql5'), ('*.mq4', '*.mq5', '*.mqh'), ('text/x-mql',)), 'MscgenLexer': ('pygments.lexers.dsls', 'Mscgen', ('mscgen', 'msc'), ('*.msc',), ()), 'MuPADLexer': ('pygments.lexers.algebra', 'MuPAD', ('mupad',), ('*.mu',), ()), 'MxmlLexer': ('pygments.lexers.actionscript', 'MXML', ('mxml',), ('*.mxml',), ()), 'MySqlLexer': ('pygments.lexers.sql', 'MySQL', ('mysql',), (), ('text/x-mysql',)), 'MyghtyCssLexer': ('pygments.lexers.templates', 'CSS+Myghty', ('css+myghty',), (), ('text/css+myghty',)), 'MyghtyHtmlLexer': ('pygments.lexers.templates', 'HTML+Myghty', ('html+myghty',), (), ('text/html+myghty',)), 'MyghtyJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Myghty', ('javascript+myghty', 'js+myghty'), (), ('application/x-javascript+myghty', 'text/x-javascript+myghty', 'text/javascript+mygthy')), 'MyghtyLexer': ('pygments.lexers.templates', 'Myghty', ('myghty',), ('*.myt', 'autodelegate'), ('application/x-myghty',)), 'MyghtyXmlLexer': ('pygments.lexers.templates', 'XML+Myghty', ('xml+myghty',), (), ('application/xml+myghty',)), 'NCLLexer': ('pygments.lexers.ncl', 'NCL', ('ncl',), ('*.ncl',), ('text/ncl',)), 'NSISLexer': ('pygments.lexers.installers', 'NSIS', ('nsis', 'nsi', 'nsh'), ('*.nsi', '*.nsh'), ('text/x-nsis',)), 'NasmLexer': ('pygments.lexers.asm', 'NASM', ('nasm',), ('*.asm', '*.ASM', '*.nasm'), ('text/x-nasm',)), 'NasmObjdumpLexer': ('pygments.lexers.asm', 'objdump-nasm', ('objdump-nasm',), ('*.objdump-intel',), ('text/x-nasm-objdump',)), 'NemerleLexer': ('pygments.lexers.dotnet', 'Nemerle', ('nemerle',), ('*.n',), ('text/x-nemerle',)), 'NesCLexer': ('pygments.lexers.c_like', 'nesC', ('nesc',), ('*.nc',), ('text/x-nescsrc',)), 'NestedTextLexer': ('pygments.lexers.configs', 'NestedText', ('nestedtext', 'nt'), ('*.nt',), ()), 'NewLispLexer': ('pygments.lexers.lisp', 'NewLisp', ('newlisp',), ('*.lsp', '*.nl', '*.kif'), ('text/x-newlisp', 'application/x-newlisp')), 'NewspeakLexer': ('pygments.lexers.smalltalk', 'Newspeak', ('newspeak',), ('*.ns2',), ('text/x-newspeak',)), 'NginxConfLexer': ('pygments.lexers.configs', 'Nginx configuration file', ('nginx',), ('nginx.conf',), ('text/x-nginx-conf',)), 'NimrodLexer': ('pygments.lexers.nimrod', 'Nimrod', ('nimrod', 'nim'), ('*.nim', '*.nimrod'), ('text/x-nim',)), 'NitLexer': ('pygments.lexers.nit', 'Nit', ('nit',), ('*.nit',), ()), 'NixLexer': ('pygments.lexers.nix', 'Nix', ('nixos', 'nix'), ('*.nix',), ('text/x-nix',)), 'NodeConsoleLexer': ('pygments.lexers.javascript', 'Node.js REPL console session', ('nodejsrepl',), (), ('text/x-nodejsrepl',)), 'NotmuchLexer': ('pygments.lexers.textfmts', 'Notmuch', ('notmuch',), (), ()), 'NuSMVLexer': ('pygments.lexers.smv', 'NuSMV', ('nusmv',), ('*.smv',), ()), 'NumPyLexer': ('pygments.lexers.python', 'NumPy', ('numpy',), (), ()), 'NumbaIRLexer': ('pygments.lexers.numbair', 'Numba_IR', ('numba_ir', 'numbair'), ('*.numba_ir',), ('text/x-numba_ir', 'text/x-numbair')), 'ObjdumpLexer': ('pygments.lexers.asm', 'objdump', ('objdump',), ('*.objdump',), ('text/x-objdump',)), 'ObjectiveCLexer': ('pygments.lexers.objective', 'Objective-C', ('objective-c', 'objectivec', 'obj-c', 'objc'), ('*.m', '*.h'), ('text/x-objective-c',)), 'ObjectiveCppLexer': ('pygments.lexers.objective', 'Objective-C++', ('objective-c++', 'objectivec++', 'obj-c++', 'objc++'), ('*.mm', '*.hh'), ('text/x-objective-c++',)), 'ObjectiveJLexer': ('pygments.lexers.javascript', 'Objective-J', ('objective-j', 'objectivej', 'obj-j', 'objj'), ('*.j',), ('text/x-objective-j',)), 'OcamlLexer': ('pygments.lexers.ml', 'OCaml', ('ocaml',), ('*.ml', '*.mli', '*.mll', '*.mly'), ('text/x-ocaml',)), 'OctaveLexer': ('pygments.lexers.matlab', 'Octave', ('octave',), ('*.m',), ('text/octave',)), 'OdinLexer': ('pygments.lexers.archetype', 'ODIN', ('odin',), ('*.odin',), ('text/odin',)), 'OmgIdlLexer': ('pygments.lexers.c_like', 'OMG Interface Definition Language', ('omg-idl',), ('*.idl', '*.pidl'), ()), 'OocLexer': ('pygments.lexers.ooc', 'Ooc', ('ooc',), ('*.ooc',), ('text/x-ooc',)), 'OpaLexer': ('pygments.lexers.ml', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)), 'OpenEdgeLexer': ('pygments.lexers.business', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')), 'OpenScadLexer': ('pygments.lexers.openscad', 'OpenSCAD', ('openscad',), ('*.scad',), ('application/x-openscad',)), 'OrgLexer': ('pygments.lexers.markup', 'Org Mode', ('org', 'orgmode', 'org-mode'), ('*.org',), ('text/org',)), 'OutputLexer': ('pygments.lexers.special', 'Text output', ('output',), (), ()), 'PacmanConfLexer': ('pygments.lexers.configs', 'PacmanConf', ('pacmanconf',), ('pacman.conf',), ()), 'PanLexer': ('pygments.lexers.dsls', 'Pan', ('pan',), ('*.pan',), ()), 'ParaSailLexer': ('pygments.lexers.parasail', 'ParaSail', ('parasail',), ('*.psi', '*.psl'), ('text/x-parasail',)), 'PawnLexer': ('pygments.lexers.pawn', 'Pawn', ('pawn',), ('*.p', '*.pwn', '*.inc'), ('text/x-pawn',)), 'PddlLexer': ('pygments.lexers.pddl', 'PDDL', ('pddl',), ('*.pddl',), ()), 'PegLexer': ('pygments.lexers.grammar_notation', 'PEG', ('peg',), ('*.peg',), ('text/x-peg',)), 'Perl6Lexer': ('pygments.lexers.perl', 'Perl6', ('perl6', 'pl6', 'raku'), ('*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6', '*.6pm', '*.p6m', '*.pm6', '*.t', '*.raku', '*.rakumod', '*.rakutest', '*.rakudoc'), ('text/x-perl6', 'application/x-perl6')), 'PerlLexer': ('pygments.lexers.perl', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm', '*.t', '*.perl'), ('text/x-perl', 'application/x-perl')), 'PhixLexer': ('pygments.lexers.phix', 'Phix', ('phix',), ('*.exw',), ('text/x-phix',)), 'PhpLexer': ('pygments.lexers.php', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]', '*.inc'), ('text/x-php',)), 'PigLexer': ('pygments.lexers.jvm', 'Pig', ('pig',), ('*.pig',), ('text/x-pig',)), 'PikeLexer': ('pygments.lexers.c_like', 'Pike', ('pike',), ('*.pike', '*.pmod'), ('text/x-pike',)), 'PkgConfigLexer': ('pygments.lexers.configs', 'PkgConfig', ('pkgconfig',), ('*.pc',), ()), 'PlPgsqlLexer': ('pygments.lexers.sql', 'PL/pgSQL', ('plpgsql',), (), ('text/x-plpgsql',)), 'PointlessLexer': ('pygments.lexers.pointless', 'Pointless', ('pointless',), ('*.ptls',), ()), 'PonyLexer': ('pygments.lexers.pony', 'Pony', ('pony',), ('*.pony',), ()), 'PortugolLexer': ('pygments.lexers.pascal', 'Portugol', ('portugol',), ('*.alg', '*.portugol'), ()), 'PostScriptLexer': ('pygments.lexers.graphics', 'PostScript', ('postscript', 'postscr'), ('*.ps', '*.eps'), ('application/postscript',)), 'PostgresConsoleLexer': ('pygments.lexers.sql', 'PostgreSQL console (psql)', ('psql', 'postgresql-console', 'postgres-console'), (), ('text/x-postgresql-psql',)), 'PostgresExplainLexer': ('pygments.lexers.sql', 'PostgreSQL EXPLAIN dialect', ('postgres-explain',), ('*.explain',), ('text/x-postgresql-explain',)), 'PostgresLexer': ('pygments.lexers.sql', 'PostgreSQL SQL dialect', ('postgresql', 'postgres'), (), ('text/x-postgresql',)), 'PovrayLexer': ('pygments.lexers.graphics', 'POVRay', ('pov',), ('*.pov', '*.inc'), ('text/x-povray',)), 'PowerShellLexer': ('pygments.lexers.shell', 'PowerShell', ('powershell', 'pwsh', 'posh', 'ps1', 'psm1'), ('*.ps1', '*.psm1'), ('text/x-powershell',)), 'PowerShellSessionLexer': ('pygments.lexers.shell', 'PowerShell Session', ('pwsh-session', 'ps1con'), (), ()), 'PraatLexer': ('pygments.lexers.praat', 'Praat', ('praat',), ('*.praat', '*.proc', '*.psc'), ()), 'ProcfileLexer': ('pygments.lexers.procfile', 'Procfile', ('procfile',), ('Procfile',), ()), 'PrologLexer': ('pygments.lexers.prolog', 'Prolog', ('prolog',), ('*.ecl', '*.prolog', '*.pro', '*.pl'), ('text/x-prolog',)), 'PromQLLexer': ('pygments.lexers.promql', 'PromQL', ('promql',), ('*.promql',), ()), 'PromelaLexer': ('pygments.lexers.c_like', 'Promela', ('promela',), ('*.pml', '*.prom', '*.prm', '*.promela', '*.pr', '*.pm'), ('text/x-promela',)), 'PropertiesLexer': ('pygments.lexers.configs', 'Properties', ('properties', 'jproperties'), ('*.properties',), ('text/x-java-properties',)), 'ProtoBufLexer': ('pygments.lexers.dsls', 'Protocol Buffer', ('protobuf', 'proto'), ('*.proto',), ()), 'PrqlLexer': ('pygments.lexers.prql', 'PRQL', ('prql',), ('*.prql',), ('application/prql', 'application/x-prql')), 'PsyshConsoleLexer': ('pygments.lexers.php', 'PsySH console session for PHP', ('psysh',), (), ()), 'PtxLexer': ('pygments.lexers.ptx', 'PTX', ('ptx',), ('*.ptx',), ('text/x-ptx',)), 'PugLexer': ('pygments.lexers.html', 'Pug', ('pug', 'jade'), ('*.pug', '*.jade'), ('text/x-pug', 'text/x-jade')), 'PuppetLexer': ('pygments.lexers.dsls', 'Puppet', ('puppet',), ('*.pp',), ()), 'PyPyLogLexer': ('pygments.lexers.console', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ('application/x-pypylog',)), 'Python2Lexer': ('pygments.lexers.python', 'Python 2.x', ('python2', 'py2'), (), ('text/x-python2', 'application/x-python2')), 'Python2TracebackLexer': ('pygments.lexers.python', 'Python 2.x Traceback', ('py2tb',), ('*.py2tb',), ('text/x-python2-traceback',)), 'PythonConsoleLexer': ('pygments.lexers.python', 'Python console session', ('pycon', 'python-console'), (), ('text/x-python-doctest',)), 'PythonLexer': ('pygments.lexers.python', 'Python', ('python', 'py', 'sage', 'python3', 'py3', 'bazel', 'starlark', 'pyi'), ('*.py', '*.pyw', '*.pyi', '*.jy', '*.sage', '*.sc', 'SConstruct', 'SConscript', '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE', '*.tac', '*.pye'), ('text/x-python', 'application/x-python', 'text/x-python3', 'application/x-python3')), 'PythonTracebackLexer': ('pygments.lexers.python', 'Python Traceback', ('pytb', 'py3tb'), ('*.pytb', '*.py3tb'), ('text/x-python-traceback', 'text/x-python3-traceback')), 'PythonUL4Lexer': ('pygments.lexers.ul4', 'Python+UL4', ('py+ul4',), ('*.pyul4',), ()), 'QBasicLexer': ('pygments.lexers.basic', 'QBasic', ('qbasic', 'basic'), ('*.BAS', '*.bas'), ('text/basic',)), 'QLexer': ('pygments.lexers.q', 'Q', ('q',), ('*.q',), ()), 'QVToLexer': ('pygments.lexers.qvt', 'QVTO', ('qvto', 'qvt'), ('*.qvto',), ()), 'QlikLexer': ('pygments.lexers.qlik', 'Qlik', ('qlik', 'qlikview', 'qliksense', 'qlikscript'), ('*.qvs', '*.qvw'), ()), 'QmlLexer': ('pygments.lexers.webmisc', 'QML', ('qml', 'qbs'), ('*.qml', '*.qbs'), ('application/x-qml', 'application/x-qt.qbs+qml')), 'RConsoleLexer': ('pygments.lexers.r', 'RConsole', ('rconsole', 'rout'), ('*.Rout',), ()), 'RNCCompactLexer': ('pygments.lexers.rnc', 'Relax-NG Compact', ('rng-compact', 'rnc'), ('*.rnc',), ()), 'RPMSpecLexer': ('pygments.lexers.installers', 'RPMSpec', ('spec',), ('*.spec',), ('text/x-rpm-spec',)), 'RacketLexer': ('pygments.lexers.lisp', 'Racket', ('racket', 'rkt'), ('*.rkt', '*.rktd', '*.rktl'), ('text/x-racket', 'application/x-racket')), 'RagelCLexer': ('pygments.lexers.parsers', 'Ragel in C Host', ('ragel-c',), ('*.rl',), ()), 'RagelCppLexer': ('pygments.lexers.parsers', 'Ragel in CPP Host', ('ragel-cpp',), ('*.rl',), ()), 'RagelDLexer': ('pygments.lexers.parsers', 'Ragel in D Host', ('ragel-d',), ('*.rl',), ()), 'RagelEmbeddedLexer': ('pygments.lexers.parsers', 'Embedded Ragel', ('ragel-em',), ('*.rl',), ()), 'RagelJavaLexer': ('pygments.lexers.parsers', 'Ragel in Java Host', ('ragel-java',), ('*.rl',), ()), 'RagelLexer': ('pygments.lexers.parsers', 'Ragel', ('ragel',), (), ()), 'RagelObjectiveCLexer': ('pygments.lexers.parsers', 'Ragel in Objective C Host', ('ragel-objc',), ('*.rl',), ()), 'RagelRubyLexer': ('pygments.lexers.parsers', 'Ragel in Ruby Host', ('ragel-ruby', 'ragel-rb'), ('*.rl',), ()), 'RawTokenLexer': ('pygments.lexers.special', 'Raw token data', (), (), ('application/x-pygments-tokens',)), 'RdLexer': ('pygments.lexers.r', 'Rd', ('rd',), ('*.Rd',), ('text/x-r-doc',)), 'ReasonLexer': ('pygments.lexers.ml', 'ReasonML', ('reasonml', 'reason'), ('*.re', '*.rei'), ('text/x-reasonml',)), 'RebolLexer': ('pygments.lexers.rebol', 'REBOL', ('rebol',), ('*.r', '*.r3', '*.reb'), ('text/x-rebol',)), 'RedLexer': ('pygments.lexers.rebol', 'Red', ('red', 'red/system'), ('*.red', '*.reds'), ('text/x-red', 'text/x-red-system')), 'RedcodeLexer': ('pygments.lexers.esoteric', 'Redcode', ('redcode',), ('*.cw',), ()), 'RegeditLexer': ('pygments.lexers.configs', 'reg', ('registry',), ('*.reg',), ('text/x-windows-registry',)), 'RegoLexer': ('pygments.lexers.rego', 'Rego', ('rego',), ('*.rego',), ('text/x-rego',)), 'RellLexer': ('pygments.lexers.rell', 'Rell', ('rell',), ('*.rell',), ('text/x-rell',)), 'ResourceLexer': ('pygments.lexers.resource', 'ResourceBundle', ('resourcebundle', 'resource'), (), ()), 'RexxLexer': ('pygments.lexers.scripting', 'Rexx', ('rexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)), 'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)), 'RideLexer': ('pygments.lexers.ride', 'Ride', ('ride',), ('*.ride',), ('text/x-ride',)), 'RitaLexer': ('pygments.lexers.rita', 'Rita', ('rita',), ('*.rita',), ('text/rita',)), 'RoboconfGraphLexer': ('pygments.lexers.roboconf', 'Roboconf Graph', ('roboconf-graph',), ('*.graph',), ()), 'RoboconfInstancesLexer': ('pygments.lexers.roboconf', 'Roboconf Instances', ('roboconf-instances',), ('*.instances',), ()), 'RobotFrameworkLexer': ('pygments.lexers.robotframework', 'RobotFramework', ('robotframework',), ('*.robot', '*.resource'), ('text/x-robotframework',)), 'RocqLexer': ('pygments.lexers.theorem', 'Rocq Prover', ('coq', 'rocq', 'rocq-prover'), ('*.v',), ('text/x-coq', 'text/x-rocq')), 'RqlLexer': ('pygments.lexers.sql', 'RQL', ('rql',), ('*.rql',), ('text/x-rql',)), 'RslLexer': ('pygments.lexers.dsls', 'RSL', ('rsl',), ('*.rsl',), ('text/rsl',)), 'RstLexer': ('pygments.lexers.markup', 'reStructuredText', ('restructuredtext', 'rst', 'rest'), ('*.rst', '*.rest'), ('text/x-rst', 'text/prs.fallenstein.rst')), 'RtsLexer': ('pygments.lexers.trafficscript', 'TrafficScript', ('trafficscript', 'rts'), ('*.rts',), ()), 'RubyConsoleLexer': ('pygments.lexers.ruby', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)), 'RubyLexer': ('pygments.lexers.ruby', 'Ruby', ('ruby', 'rb', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby', 'Gemfile', 'Vagrantfile'), ('text/x-ruby', 'application/x-ruby')), 'RustLexer': ('pygments.lexers.rust', 'Rust', ('rust', 'rs'), ('*.rs', '*.rs.in'), ('text/rust', 'text/x-rust')), 'SASLexer': ('pygments.lexers.sas', 'SAS', ('sas',), ('*.SAS', '*.sas'), ('text/x-sas', 'text/sas', 'application/x-sas')), 'SLexer': ('pygments.lexers.r', 'S', ('splus', 's', 'r'), ('*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron'), ('text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile')), 'SMLLexer': ('pygments.lexers.ml', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')), 'SNBTLexer': ('pygments.lexers.minecraft', 'SNBT', ('snbt',), ('*.snbt',), ('text/snbt',)), 'SarlLexer': ('pygments.lexers.jvm', 'SARL', ('sarl',), ('*.sarl',), ('text/x-sarl',)), 'SassLexer': ('pygments.lexers.css', 'Sass', ('sass',), ('*.sass',), ('text/x-sass',)), 'SaviLexer': ('pygments.lexers.savi', 'Savi', ('savi',), ('*.savi',), ()), 'ScalaLexer': ('pygments.lexers.jvm', 'Scala', ('scala',), ('*.scala',), ('text/x-scala',)), 'ScamlLexer': ('pygments.lexers.html', 'Scaml', ('scaml',), ('*.scaml',), ('text/x-scaml',)), 'ScdocLexer': ('pygments.lexers.scdoc', 'scdoc', ('scdoc', 'scd'), ('*.scd', '*.scdoc'), ()), 'SchemeLexer': ('pygments.lexers.lisp', 'Scheme', ('scheme', 'scm'), ('*.scm', '*.ss'), ('text/x-scheme', 'application/x-scheme')), 'ScilabLexer': ('pygments.lexers.matlab', 'Scilab', ('scilab',), ('*.sci', '*.sce', '*.tst'), ('text/scilab',)), 'ScssLexer': ('pygments.lexers.css', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)), 'SedLexer': ('pygments.lexers.textedit', 'Sed', ('sed', 'gsed', 'ssed'), ('*.sed', '*.[gs]sed'), ('text/x-sed',)), 'ShExCLexer': ('pygments.lexers.rdf', 'ShExC', ('shexc', 'shex'), ('*.shex',), ('text/shex',)), 'ShenLexer': ('pygments.lexers.lisp', 'Shen', ('shen',), ('*.shen',), ('text/x-shen', 'application/x-shen')), 'SieveLexer': ('pygments.lexers.sieve', 'Sieve', ('sieve',), ('*.siv', '*.sieve'), ()), 'SilverLexer': ('pygments.lexers.verification', 'Silver', ('silver',), ('*.sil', '*.vpr'), ()), 'SingularityLexer': ('pygments.lexers.configs', 'Singularity', ('singularity',), ('*.def', 'Singularity'), ()), 'SlashLexer': ('pygments.lexers.slash', 'Slash', ('slash',), ('*.sla',), ()), 'SlimLexer': ('pygments.lexers.webmisc', 'Slim', ('slim',), ('*.slim',), ('text/x-slim',)), 'SlurmBashLexer': ('pygments.lexers.shell', 'Slurm', ('slurm', 'sbatch'), ('*.sl',), ()), 'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)), 'SmalltalkLexer': ('pygments.lexers.smalltalk', 'Smalltalk', ('smalltalk', 'squeak', 'st'), ('*.st',), ('text/x-smalltalk',)), 'SmartGameFormatLexer': ('pygments.lexers.sgf', 'SmartGameFormat', ('sgf',), ('*.sgf',), ()), 'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)), 'SmithyLexer': ('pygments.lexers.smithy', 'Smithy', ('smithy',), ('*.smithy',), ()), 'SnobolLexer': ('pygments.lexers.snobol', 'Snobol', ('snobol',), ('*.snobol',), ('text/x-snobol',)), 'SnowballLexer': ('pygments.lexers.dsls', 'Snowball', ('snowball',), ('*.sbl',), ()), 'SolidityLexer': ('pygments.lexers.solidity', 'Solidity', ('solidity',), ('*.sol',), ()), 'SoongLexer': ('pygments.lexers.soong', 'Soong', ('androidbp', 'bp', 'soong'), ('Android.bp',), ()), 'SophiaLexer': ('pygments.lexers.sophia', 'Sophia', ('sophia',), ('*.aes',), ()), 'SourcePawnLexer': ('pygments.lexers.pawn', 'SourcePawn', ('sp',), ('*.sp',), ('text/x-sourcepawn',)), 'SourcesListLexer': ('pygments.lexers.installers', 'Debian Sourcelist', ('debsources', 'sourceslist', 'sources.list'), ('sources.list',), ()), 'SparqlLexer': ('pygments.lexers.rdf', 'SPARQL', ('sparql',), ('*.rq', '*.sparql'), ('application/sparql-query',)), 'SpiceLexer': ('pygments.lexers.spice', 'Spice', ('spice', 'spicelang'), ('*.spice',), ('text/x-spice',)), 'SqlJinjaLexer': ('pygments.lexers.templates', 'SQL+Jinja', ('sql+jinja',), ('*.sql', '*.sql.j2', '*.sql.jinja2'), ()), 'SqlLexer': ('pygments.lexers.sql', 'SQL', ('sql',), ('*.sql',), ('text/x-sql',)), 'SqliteConsoleLexer': ('pygments.lexers.sql', 'sqlite3con', ('sqlite3',), ('*.sqlite3-console',), ('text/x-sqlite3-console',)), 'SquidConfLexer': ('pygments.lexers.configs', 'SquidConf', ('squidconf', 'squid.conf', 'squid'), ('squid.conf',), ('text/x-squidconf',)), 'SrcinfoLexer': ('pygments.lexers.srcinfo', 'Srcinfo', ('srcinfo',), ('.SRCINFO',), ()), 'SspLexer': ('pygments.lexers.templates', 'Scalate Server Page', ('ssp',), ('*.ssp',), ('application/x-ssp',)), 'StanLexer': ('pygments.lexers.modeling', 'Stan', ('stan',), ('*.stan',), ()), 'StataLexer': ('pygments.lexers.stata', 'Stata', ('stata', 'do'), ('*.do', '*.ado'), ('text/x-stata', 'text/stata', 'application/x-stata')), 'SuperColliderLexer': ('pygments.lexers.supercollider', 'SuperCollider', ('supercollider', 'sc'), ('*.sc', '*.scd'), ('application/supercollider', 'text/supercollider')), 'SwiftLexer': ('pygments.lexers.objective', 'Swift', ('swift',), ('*.swift',), ('text/x-swift',)), 'SwigLexer': ('pygments.lexers.c_like', 'SWIG', ('swig',), ('*.swg', '*.i'), ('text/swig',)), 'SystemVerilogLexer': ('pygments.lexers.hdl', 'systemverilog', ('systemverilog', 'sv'), ('*.sv', '*.svh'), ('text/x-systemverilog',)), 'SystemdLexer': ('pygments.lexers.configs', 'Systemd', ('systemd',), ('*.service', '*.socket', '*.device', '*.mount', '*.automount', '*.swap', '*.target', '*.path', '*.timer', '*.slice', '*.scope'), ()), 'TAPLexer': ('pygments.lexers.testing', 'TAP', ('tap',), ('*.tap',), ()), 'TNTLexer': ('pygments.lexers.tnt', 'Typographic Number Theory', ('tnt',), ('*.tnt',), ()), 'TOMLLexer': ('pygments.lexers.configs', 'TOML', ('toml',), ('*.toml', 'Pipfile', 'poetry.lock'), ('application/toml',)), 'TableGenLexer': ('pygments.lexers.tablegen', 'TableGen', ('tablegen', 'td'), ('*.td',), ()), 'TactLexer': ('pygments.lexers.tact', 'Tact', ('tact',), ('*.tact',), ()), 'Tads3Lexer': ('pygments.lexers.int_fiction', 'TADS 3', ('tads3',), ('*.t',), ()), 'TalLexer': ('pygments.lexers.tal', 'Tal', ('tal', 'uxntal'), ('*.tal',), ('text/x-uxntal',)), 'TasmLexer': ('pygments.lexers.asm', 'TASM', ('tasm',), ('*.asm', '*.ASM', '*.tasm'), ('text/x-tasm',)), 'TclLexer': ('pygments.lexers.tcl', 'Tcl', ('tcl',), ('*.tcl', '*.rvt'), ('text/x-tcl', 'text/x-script.tcl', 'application/x-tcl')), 'TcshLexer': ('pygments.lexers.shell', 'Tcsh', ('tcsh', 'csh'), ('*.tcsh', '*.csh'), ('application/x-csh',)), 'TcshSessionLexer': ('pygments.lexers.shell', 'Tcsh Session', ('tcshcon',), (), ()), 'TeaTemplateLexer': ('pygments.lexers.templates', 'Tea', ('tea',), ('*.tea',), ('text/x-tea',)), 'TealLexer': ('pygments.lexers.teal', 'teal', ('teal',), ('*.teal',), ()), 'TeraTermLexer': ('pygments.lexers.teraterm', 'Tera Term macro', ('teratermmacro', 'teraterm', 'ttl'), ('*.ttl',), ('text/x-teratermmacro',)), 'TermcapLexer': ('pygments.lexers.configs', 'Termcap', ('termcap',), ('termcap', 'termcap.src'), ()), 'TerminfoLexer': ('pygments.lexers.configs', 'Terminfo', ('terminfo',), ('terminfo', 'terminfo.src'), ()), 'TerraformLexer': ('pygments.lexers.configs', 'Terraform', ('terraform', 'tf', 'hcl'), ('*.tf', '*.hcl'), ('application/x-tf', 'application/x-terraform')), 'TexLexer': ('pygments.lexers.markup', 'TeX', ('tex', 'latex'), ('*.tex', '*.aux', '*.toc'), ('text/x-tex', 'text/x-latex')), 'TextLexer': ('pygments.lexers.special', 'Text only', ('text',), ('*.txt',), ('text/plain',)), 'ThingsDBLexer': ('pygments.lexers.thingsdb', 'ThingsDB', ('ti', 'thingsdb'), ('*.ti',), ()), 'ThriftLexer': ('pygments.lexers.dsls', 'Thrift', ('thrift',), ('*.thrift',), ('application/x-thrift',)), 'TiddlyWiki5Lexer': ('pygments.lexers.markup', 'tiddler', ('tid',), ('*.tid',), ('text/vnd.tiddlywiki',)), 'TlbLexer': ('pygments.lexers.tlb', 'Tl-b', ('tlb',), ('*.tlb',), ()), 'TlsLexer': ('pygments.lexers.tls', 'TLS Presentation Language', ('tls',), (), ()), 'TodotxtLexer': ('pygments.lexers.textfmts', 'Todotxt', ('todotxt',), ('todo.txt', '*.todotxt'), ('text/x-todo',)), 'TransactSqlLexer': ('pygments.lexers.sql', 'Transact-SQL', ('tsql', 't-sql'), ('*.sql',), ('text/x-tsql',)), 'TreetopLexer': ('pygments.lexers.parsers', 'Treetop', ('treetop',), ('*.treetop', '*.tt'), ()), 'TsxLexer': ('pygments.lexers.jsx', 'TSX', ('tsx',), ('*.tsx',), ('text/typescript-tsx',)), 'TurtleLexer': ('pygments.lexers.rdf', 'Turtle', ('turtle',), ('*.ttl',), ('text/turtle', 'application/x-turtle')), 'TwigHtmlLexer': ('pygments.lexers.templates', 'HTML+Twig', ('html+twig',), ('*.twig',), ('text/html+twig',)), 'TwigLexer': ('pygments.lexers.templates', 'Twig', ('twig',), (), ('application/x-twig',)), 'TypeScriptLexer': ('pygments.lexers.javascript', 'TypeScript', ('typescript', 'ts'), ('*.ts',), ('application/x-typescript', 'text/x-typescript')), 'TypoScriptCssDataLexer': ('pygments.lexers.typoscript', 'TypoScriptCssData', ('typoscriptcssdata',), (), ()), 'TypoScriptHtmlDataLexer': ('pygments.lexers.typoscript', 'TypoScriptHtmlData', ('typoscripthtmldata',), (), ()), 'TypoScriptLexer': ('pygments.lexers.typoscript', 'TypoScript', ('typoscript',), ('*.typoscript',), ('text/x-typoscript',)), 'TypstLexer': ('pygments.lexers.typst', 'Typst', ('typst',), ('*.typ',), ('text/x-typst',)), 'UL4Lexer': ('pygments.lexers.ul4', 'UL4', ('ul4',), ('*.ul4',), ()), 'UcodeLexer': ('pygments.lexers.unicon', 'ucode', ('ucode',), ('*.u', '*.u1', '*.u2'), ()), 'UniconLexer': ('pygments.lexers.unicon', 'Unicon', ('unicon',), ('*.icn',), ('text/unicon',)), 'UnixConfigLexer': ('pygments.lexers.configs', 'Unix/Linux config files', ('unixconfig', 'linuxconfig'), (), ()), 'UrbiscriptLexer': ('pygments.lexers.urbi', 'UrbiScript', ('urbiscript',), ('*.u',), ('application/x-urbiscript',)), 'UrlEncodedLexer': ('pygments.lexers.html', 'urlencoded', ('urlencoded',), (), ('application/x-www-form-urlencoded',)), 'UsdLexer': ('pygments.lexers.usd', 'USD', ('usd', 'usda'), ('*.usd', '*.usda'), ()), 'VBScriptLexer': ('pygments.lexers.basic', 'VBScript', ('vbscript',), ('*.vbs', '*.VBS'), ()), 'VCLLexer': ('pygments.lexers.varnish', 'VCL', ('vcl',), ('*.vcl',), ('text/x-vclsrc',)), 'VCLSnippetLexer': ('pygments.lexers.varnish', 'VCLSnippets', ('vclsnippets', 'vclsnippet'), (), ('text/x-vclsnippet',)), 'VCTreeStatusLexer': ('pygments.lexers.console', 'VCTreeStatus', ('vctreestatus',), (), ()), 'VGLLexer': ('pygments.lexers.dsls', 'VGL', ('vgl',), ('*.rpf',), ()), 'ValaLexer': ('pygments.lexers.c_like', 'Vala', ('vala', 'vapi'), ('*.vala', '*.vapi'), ('text/x-vala',)), 'VbNetAspxLexer': ('pygments.lexers.dotnet', 'aspx-vb', ('aspx-vb',), ('*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'), ()), 'VbNetLexer': ('pygments.lexers.dotnet', 'VB.net', ('vb.net', 'vbnet', 'lobas', 'oobas', 'sobas', 'visual-basic', 'visualbasic'), ('*.vb', '*.bas'), ('text/x-vbnet', 'text/x-vba')), 'VelocityHtmlLexer': ('pygments.lexers.templates', 'HTML+Velocity', ('html+velocity',), (), ('text/html+velocity',)), 'VelocityLexer': ('pygments.lexers.templates', 'Velocity', ('velocity',), ('*.vm', '*.fhtml'), ()), 'VelocityXmlLexer': ('pygments.lexers.templates', 'XML+Velocity', ('xml+velocity',), (), ('application/xml+velocity',)), 'VerifpalLexer': ('pygments.lexers.verifpal', 'Verifpal', ('verifpal',), ('*.vp',), ('text/x-verifpal',)), 'VerilogLexer': ('pygments.lexers.hdl', 'verilog', ('verilog', 'v'), ('*.v',), ('text/x-verilog',)), 'VhdlLexer': ('pygments.lexers.hdl', 'vhdl', ('vhdl',), ('*.vhdl', '*.vhd'), ('text/x-vhdl',)), 'VimLexer': ('pygments.lexers.textedit', 'VimL', ('vim',), ('*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'), ('text/x-vim',)), 'VisualPrologGrammarLexer': ('pygments.lexers.vip', 'Visual Prolog Grammar', ('visualprologgrammar',), ('*.vipgrm',), ()), 'VisualPrologLexer': ('pygments.lexers.vip', 'Visual Prolog', ('visualprolog',), ('*.pro', '*.cl', '*.i', '*.pack', '*.ph'), ()), 'VueLexer': ('pygments.lexers.html', 'Vue', ('vue',), ('*.vue',), ()), 'VyperLexer': ('pygments.lexers.vyper', 'Vyper', ('vyper',), ('*.vy',), ()), 'WDiffLexer': ('pygments.lexers.diff', 'WDiff', ('wdiff',), ('*.wdiff',), ()), 'WatLexer': ('pygments.lexers.webassembly', 'WebAssembly', ('wast', 'wat'), ('*.wat', '*.wast'), ()), 'WebIDLLexer': ('pygments.lexers.webidl', 'Web IDL', ('webidl',), ('*.webidl',), ()), 'WgslLexer': ('pygments.lexers.wgsl', 'WebGPU Shading Language', ('wgsl',), ('*.wgsl',), ('text/wgsl',)), 'WhileyLexer': ('pygments.lexers.whiley', 'Whiley', ('whiley',), ('*.whiley',), ('text/x-whiley',)), 'WikitextLexer': ('pygments.lexers.markup', 'Wikitext', ('wikitext', 'mediawiki'), (), ('text/x-wiki',)), 'WoWTocLexer': ('pygments.lexers.wowtoc', 'World of Warcraft TOC', ('wowtoc',), ('*.toc',), ()), 'WrenLexer': ('pygments.lexers.wren', 'Wren', ('wren',), ('*.wren',), ()), 'X10Lexer': ('pygments.lexers.x10', 'X10', ('x10', 'xten'), ('*.x10',), ('text/x-x10',)), 'XMLUL4Lexer': ('pygments.lexers.ul4', 'XML+UL4', ('xml+ul4',), ('*.xmlul4',), ()), 'XQueryLexer': ('pygments.lexers.webmisc', 'XQuery', ('xquery', 'xqy', 'xq', 'xql', 'xqm'), ('*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'), ('text/xquery', 'application/xquery')), 'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), ('*.xml.j2', '*.xml.jinja2'), ('application/xml+django', 'application/xml+jinja')), 'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+ruby', 'xml+erb'), (), ('application/xml+ruby',)), 'XmlLexer': ('pygments.lexers.html', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl', '*.wsf', '*.xbrl', '*.pom'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml')), 'XmlPhpLexer': ('pygments.lexers.templates', 'XML+PHP', ('xml+php',), (), ('application/xml+php',)), 'XmlSmartyLexer': ('pygments.lexers.templates', 'XML+Smarty', ('xml+smarty',), (), ('application/xml+smarty',)), 'XorgLexer': ('pygments.lexers.xorg', 'Xorg', ('xorg.conf',), ('xorg.conf',), ()), 'XppLexer': ('pygments.lexers.dotnet', 'X++', ('xpp', 'x++'), ('*.xpp',), ()), 'XsltLexer': ('pygments.lexers.html', 'XSLT', ('xslt',), ('*.xsl', '*.xslt', '*.xpl'), ('application/xsl+xml', 'application/xslt+xml')), 'XtendLexer': ('pygments.lexers.jvm', 'Xtend', ('xtend',), ('*.xtend',), ('text/x-xtend',)), 'XtlangLexer': ('pygments.lexers.lisp', 'xtlang', ('extempore',), ('*.xtm',), ()), 'YamlJinjaLexer': ('pygments.lexers.templates', 'YAML+Jinja', ('yaml+jinja', 'salt', 'sls'), ('*.sls', '*.yaml.j2', '*.yml.j2', '*.yaml.jinja2', '*.yml.jinja2'), ('text/x-yaml+jinja', 'text/x-sls')), 'YamlLexer': ('pygments.lexers.data', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',)), 'YangLexer': ('pygments.lexers.yang', 'YANG', ('yang',), ('*.yang',), ('application/yang',)), 'YaraLexer': ('pygments.lexers.yara', 'YARA', ('yara', 'yar'), ('*.yar',), ('text/x-yara',)), 'ZeekLexer': ('pygments.lexers.dsls', 'Zeek', ('zeek', 'bro'), ('*.zeek', '*.bro'), ()), 'ZephirLexer': ('pygments.lexers.php', 'Zephir', ('zephir',), ('*.zep',), ()), 'ZigLexer': ('pygments.lexers.zig', 'Zig', ('zig',), ('*.zig',), ('text/zig',)), 'apdlexer': ('pygments.lexers.apdlexer', 'ANSYS parametric design language', ('ansys', 'apdl'), ('*.ans',), ()),}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101""" pygments.lexers.bare ~~~~~~~~~~~~~~~~~~~~
Lexer for the BARE schema.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, words, bygroupsfrom pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace
__all__ = ['BareLexer']
class BareLexer(RegexLexer): """ For BARE schema source. """ name = 'BARE' url = 'https://baremessages.org' filenames = ['*.bare'] aliases = ['bare'] version_added = '2.7'
keywords = [ 'type', 'enum', 'u8', 'u16', 'u32', 'u64', 'uint', 'i8', 'i16', 'i32', 'i64', 'int', 'f32', 'f64', 'bool', 'void', 'data', 'string', 'optional', 'map', ]
tokens = { 'root': [ (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\{)', bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'struct'), (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)(\()', bygroups(Keyword, Whitespace, Name.Class, Whitespace, Text), 'union'), (r'(type)(\s+)([A-Z][a-zA-Z0-9]+)(\s+)', bygroups(Keyword, Whitespace, Name, Whitespace), 'typedef'), (r'(enum)(\s+)([A-Z][a-zA-Z0-9]+)(\s+\{)', bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'enum'), (r'#.*?$', Comment), (r'\s+', Whitespace), ], 'struct': [ (r'\{', Text, '#push'), (r'\}', Text, '#pop'), (r'([a-zA-Z0-9]+)(:)(\s*)', bygroups(Name.Attribute, Text, Whitespace), 'typedef'), (r'\s+', Whitespace), ], 'union': [ (r'\)', Text, '#pop'), (r'(\s*)(\|)(\s*)', bygroups(Whitespace, Text, Whitespace)), (r'[A-Z][a-zA-Z0-9]+', Name.Class), (words(keywords), Keyword), (r'\s+', Whitespace), ], 'typedef': [ (r'\[\]', Text), (r'#.*?$', Comment, '#pop'), (r'(\[)(\d+)(\])', bygroups(Text, Literal, Text)), (r'<|>', Text), (r'\(', Text, 'union'), (r'(\[)([a-z][a-z-A-Z0-9]+)(\])', bygroups(Text, Keyword, Text)), (r'(\[)([A-Z][a-z-A-Z0-9]+)(\])', bygroups(Text, Name.Class, Text)), (r'([A-Z][a-z-A-Z0-9]+)', Name.Class), (words(keywords), Keyword), (r'\n', Text, '#pop'), (r'\{', Text, 'struct'), (r'\s+', Whitespace), (r'\d+', Literal), ], 'enum': [ (r'\{', Text, '#push'), (r'\}', Text, '#pop'), (r'([A-Z][A-Z0-9_]*)(\s*=\s*)(\d+)', bygroups(Name.Attribute, Text, Literal)), (r'([A-Z][A-Z0-9_]*)', bygroups(Name.Attribute)), (r'#.*?$', Comment), (r'\s+', Whitespace), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656""" pygments.lexers.basic ~~~~~~~~~~~~~~~~~~~~~
Lexers for BASIC like languages (other than VB.net).
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, bygroups, default, words, includefrom pygments.token import Comment, Error, Keyword, Name, Number, \ Punctuation, Operator, String, Text, Whitespacefrom pygments.lexers import _vbscript_builtins
__all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer', 'QBasicLexer', 'VBScriptLexer', 'BBCBasicLexer']
class BlitzMaxLexer(RegexLexer): """ For BlitzMax source code. """
name = 'BlitzMax' url = 'http://blitzbasic.com' aliases = ['blitzmax', 'bmax'] filenames = ['*.bmx'] mimetypes = ['text/x-bmx'] version_added = '1.4'
bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b' bmax_sktypes = r'@{1,2}|[!#$%]' bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b' bmax_name = r'[a-z_]\w*' bmax_var = (rf'({bmax_name})(?:(?:([ \t]*)({bmax_sktypes})|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)' rf'|([ \t]*)(:)([ \t]*)(?:{bmax_lktypes}|({bmax_name})))(?:([ \t]*)(Ptr))?)') bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
flags = re.MULTILINE | re.IGNORECASE tokens = { 'root': [ # Text (r'\s+', Whitespace), (r'(\.\.)(\n)', bygroups(Text, Whitespace)), # Line continuation # Comments (r"'.*?\n", Comment.Single), (r'([ \t]*)\bRem\n(\n|.)*?\s*\bEnd([ \t]*)Rem', Comment.Multiline), # Data types ('"', String.Double, 'string'), # Numbers (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), (r'\.[0-9]*(?!\.)', Number.Float), (r'[0-9]+', Number.Integer), (r'\$[0-9a-f]+', Number.Hex), (r'\%[10]+', Number.Bin), # Other (rf'(?:(?:(:)?([ \t]*)(:?{bmax_vopwords}|([+\-*/&|~]))|Or|And|Not|[=<>^]))', Operator), (r'[(),.:\[\]]', Punctuation), (r'(?:#[\w \t]*)', Name.Label), (r'(?:\?[\w \t]*)', Comment.Preproc), # Identifiers (rf'\b(New)\b([ \t]?)([(]?)({bmax_name})', bygroups(Keyword.Reserved, Whitespace, Punctuation, Name.Class)), (rf'\b(Import|Framework|Module)([ \t]+)({bmax_name}\.{bmax_name})', bygroups(Keyword.Reserved, Whitespace, Keyword.Namespace)), (bmax_func, bygroups(Name.Function, Whitespace, Keyword.Type, Operator, Whitespace, Punctuation, Whitespace, Keyword.Type, Name.Class, Whitespace, Keyword.Type, Whitespace, Punctuation)), (bmax_var, bygroups(Name.Variable, Whitespace, Keyword.Type, Operator, Whitespace, Punctuation, Whitespace, Keyword.Type, Name.Class, Whitespace, Keyword.Type)), (rf'\b(Type|Extends)([ \t]+)({bmax_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), # Keywords (r'\b(Ptr)\b', Keyword.Type), (r'\b(Pi|True|False|Null|Self|Super)\b', Keyword.Constant), (r'\b(Local|Global|Const|Field)\b', Keyword.Declaration), (words(( 'TNullMethodException', 'TNullFunctionException', 'TNullObjectException', 'TArrayBoundsException', 'TRuntimeException'), prefix=r'\b', suffix=r'\b'), Name.Exception), (words(( 'Strict', 'SuperStrict', 'Module', 'ModuleInfo', 'End', 'Return', 'Continue', 'Exit', 'Public', 'Private', 'Var', 'VarPtr', 'Chr', 'Len', 'Asc', 'SizeOf', 'Sgn', 'Abs', 'Min', 'Max', 'New', 'Release', 'Delete', 'Incbin', 'IncbinPtr', 'IncbinLen', 'Framework', 'Include', 'Import', 'Extern', 'EndExtern', 'Function', 'EndFunction', 'Type', 'EndType', 'Extends', 'Method', 'EndMethod', 'Abstract', 'Final', 'If', 'Then', 'Else', 'ElseIf', 'EndIf', 'For', 'To', 'Next', 'Step', 'EachIn', 'While', 'Wend', 'EndWhile', 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', 'EndSelect', 'Try', 'Catch', 'EndTry', 'Throw', 'Assert', 'Goto', 'DefData', 'ReadData', 'RestoreData'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), # Final resolve (for variable names and such) (rf'({bmax_name})', Name.Variable), ], 'string': [ (r'""', String.Double), (r'"C?', String.Double, '#pop'), (r'[^"]+', String.Double), ], }
class BlitzBasicLexer(RegexLexer): """ For BlitzBasic source code. """
name = 'BlitzBasic' url = 'http://blitzbasic.com' aliases = ['blitzbasic', 'b3d', 'bplus'] filenames = ['*.bb', '*.decls'] mimetypes = ['text/x-bb'] version_added = '2.0'
bb_sktypes = r'@{1,2}|[#$%]' bb_name = r'[a-z]\w*' bb_var = (rf'({bb_name})(?:([ \t]*)({bb_sktypes})|([ \t]*)([.])([ \t]*)(?:({bb_name})))?')
flags = re.MULTILINE | re.IGNORECASE tokens = { 'root': [ # Text (r'\s+', Whitespace), # Comments (r";.*?\n", Comment.Single), # Data types ('"', String.Double, 'string'), # Numbers (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), (r'\.[0-9]+(?!\.)', Number.Float), (r'[0-9]+', Number.Integer), (r'\$[0-9a-f]+', Number.Hex), (r'\%[10]+', Number.Bin), # Other (words(('Shl', 'Shr', 'Sar', 'Mod', 'Or', 'And', 'Not', 'Abs', 'Sgn', 'Handle', 'Int', 'Float', 'Str', 'First', 'Last', 'Before', 'After'), prefix=r'\b', suffix=r'\b'), Operator), (r'([+\-*/~=<>^])', Operator), (r'[(),:\[\]\\]', Punctuation), (rf'\.([ \t]*)({bb_name})', Name.Label), # Identifiers (rf'\b(New)\b([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), (rf'\b(Gosub|Goto)\b([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Label)), (rf'\b(Object)\b([ \t]*)([.])([ \t]*)({bb_name})\b', bygroups(Operator, Whitespace, Punctuation, Whitespace, Name.Class)), (rf'\b{bb_var}\b([ \t]*)(\()', bygroups(Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation, Whitespace, Name.Class, Whitespace, Punctuation)), (rf'\b(Function)\b([ \t]+){bb_var}', bygroups(Keyword.Reserved, Whitespace, Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation, Whitespace, Name.Class)), (rf'\b(Type)([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), # Keywords (r'\b(Pi|True|False|Null)\b', Keyword.Constant), (r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration), (words(( 'End', 'Return', 'Exit', 'Chr', 'Len', 'Asc', 'New', 'Delete', 'Insert', 'Include', 'Function', 'Type', 'If', 'Then', 'Else', 'ElseIf', 'EndIf', 'For', 'To', 'Next', 'Step', 'Each', 'While', 'Wend', 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', 'Goto', 'Gosub', 'Data', 'Read', 'Restore'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), # Final resolve (for variable names and such) # (r'(%s)' % (bb_name), Name.Variable), (bb_var, bygroups(Name.Variable, Whitespace, Keyword.Type, Whitespace, Punctuation, Whitespace, Name.Class)), ], 'string': [ (r'""', String.Double), (r'"C?', String.Double, '#pop'), (r'[^"\n]+', String.Double), ], }
class MonkeyLexer(RegexLexer): """ For Monkey source code. """
name = 'Monkey' aliases = ['monkey'] filenames = ['*.monkey'] mimetypes = ['text/x-monkey'] url = 'https://blitzresearch.itch.io/monkeyx' version_added = '1.6'
name_variable = r'[a-z_]\w*' name_function = r'[A-Z]\w*' name_constant = r'[A-Z_][A-Z0-9_]*' name_class = r'[A-Z]\w*' name_module = r'[a-z0-9_]*'
keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)' # ? == Bool // % == Int // # == Float // $ == String keyword_type_special = r'[?%#$]'
flags = re.MULTILINE
tokens = { 'root': [ # Text (r'\s+', Whitespace), # Comments (r"'.*", Comment), (r'(?i)^#rem\b', Comment.Multiline, 'comment'), # preprocessor directives (r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc), # preprocessor variable (any line starting with '#' that is not a directive) (r'^#', Comment.Preproc, 'variables'), # String ('"', String.Double, 'string'), # Numbers (r'[0-9]+\.[0-9]*(?!\.)', Number.Float), (r'\.[0-9]+(?!\.)', Number.Float), (r'[0-9]+', Number.Integer), (r'\$[0-9a-fA-Z]+', Number.Hex), (r'\%[10]+', Number.Bin), # Native data types (rf'\b{keyword_type}\b', Keyword.Type), # Exception handling (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved), (r'Throwable', Name.Exception), # Builtins (r'(?i)\b(?:Null|True|False)\b', Name.Builtin), (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo), (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant), # Keywords (r'(?i)^(Import)(\s+)(.*)(\n)', bygroups(Keyword.Namespace, Whitespace, Name.Namespace, Whitespace)), (r'(?i)^Strict\b.*\n', Keyword.Reserved), (r'(?i)(Const|Local|Global|Field)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'variables'), (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)', bygroups(Keyword.Reserved, Whitespace), 'classname'), (r'(?i)(Function|Method)(\s+)', bygroups(Keyword.Reserved, Whitespace), 'funcname'), (r'(?i)(?:End|Return|Public|Private|Extern|Property|' r'Final|Abstract)\b', Keyword.Reserved), # Flow Control stuff (r'(?i)(?:If|Then|Else|ElseIf|EndIf|' r'Select|Case|Default|' r'While|Wend|' r'Repeat|Until|Forever|' r'For|To|Until|Step|EachIn|Next|' r'Exit|Continue)(?=\s)', Keyword.Reserved), # not used yet (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved), # Array (r'[\[\]]', Punctuation), # Other (r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator), (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word), (r'[(){}!#,.:]', Punctuation), # catch the rest (rf'{name_constant}\b', Name.Constant), (rf'{name_function}\b', Name.Function), (rf'{name_variable}\b', Name.Variable), ], 'funcname': [ (rf'(?i){name_function}\b', Name.Function), (r':', Punctuation, 'classname'), (r'\s+', Whitespace), (r'\(', Punctuation, 'variables'), (r'\)', Punctuation, '#pop') ], 'classname': [ (rf'{name_module}\.', Name.Namespace), (rf'{keyword_type}\b', Keyword.Type), (rf'{name_class}\b', Name.Class), # array (of given size) (r'(\[)(\s*)(\d*)(\s*)(\])', bygroups(Punctuation, Whitespace, Number.Integer, Whitespace, Punctuation)), # generics (r'\s+(?!<)', Whitespace, '#pop'), (r'<', Punctuation, '#push'), (r'>', Punctuation, '#pop'), (r'\n', Whitespace, '#pop'), default('#pop') ], 'variables': [ (rf'{name_constant}\b', Name.Constant), (rf'{name_variable}\b', Name.Variable), (rf'{keyword_type_special}', Keyword.Type), (r'\s+', Whitespace), (r':', Punctuation, 'classname'), (r',', Punctuation, '#push'), default('#pop') ], 'string': [ (r'[^"~]+', String.Double), (r'~q|~n|~r|~t|~z|~~', String.Escape), (r'"', String.Double, '#pop'), ], 'comment': [ (r'(?i)^#rem.*?', Comment.Multiline, "#push"), (r'(?i)^#end.*?', Comment.Multiline, "#pop"), (r'\n', Comment.Multiline), (r'.+', Comment.Multiline), ], }
class CbmBasicV2Lexer(RegexLexer): """ For CBM BASIC V2 sources. """ name = 'CBM BASIC V2' aliases = ['cbmbas'] filenames = ['*.bas'] url = 'https://en.wikipedia.org/wiki/Commodore_BASIC' version_added = '1.6'
flags = re.IGNORECASE
tokens = { 'root': [ (r'rem.*\n', Comment.Single), (r'\s+', Whitespace), (r'new|run|end|for|to|next|step|go(to|sub)?|on|return|stop|cont' r'|if|then|input#?|read|wait|load|save|verify|poke|sys|print#?' r'|list|clr|cmd|open|close|get#?', Keyword.Reserved), (r'data|restore|dim|let|def|fn', Keyword.Declaration), (r'tab|spc|sgn|int|abs|usr|fre|pos|sqr|rnd|log|exp|cos|sin|tan|atn' r'|peek|len|val|asc|(str|chr|left|right|mid)\$', Name.Builtin), (r'[-+*/^<>=]', Operator), (r'not|and|or', Operator.Word), (r'"[^"\n]*.', String), (r'\d+|[-+]?\d*\.\d*(e[-+]?\d+)?', Number.Float), (r'[(),:;]', Punctuation), (r'\w+[$%]?', Name), ] }
def analyse_text(text): # if it starts with a line number, it shouldn't be a "modern" Basic # like VB.net if re.match(r'^\d+', text): return 0.2
class QBasicLexer(RegexLexer): """ For QBasic source code. """
name = 'QBasic' aliases = ['qbasic', 'basic'] filenames = ['*.BAS', '*.bas'] mimetypes = ['text/basic'] url = 'https://en.wikipedia.org/wiki/QBasic' version_added = '2.0'
declarations = ('DATA', 'LET')
functions = ( 'ABS', 'ASC', 'ATN', 'CDBL', 'CHR$', 'CINT', 'CLNG', 'COMMAND$', 'COS', 'CSNG', 'CSRLIN', 'CVD', 'CVDMBF', 'CVI', 'CVL', 'CVS', 'CVSMBF', 'DATE$', 'ENVIRON$', 'EOF', 'ERDEV', 'ERDEV$', 'ERL', 'ERR', 'EXP', 'FILEATTR', 'FIX', 'FRE', 'FREEFILE', 'HEX$', 'INKEY$', 'INP', 'INPUT$', 'INSTR', 'INT', 'IOCTL$', 'LBOUND', 'LCASE$', 'LEFT$', 'LEN', 'LOC', 'LOF', 'LOG', 'LPOS', 'LTRIM$', 'MID$', 'MKD$', 'MKDMBF$', 'MKI$', 'MKL$', 'MKS$', 'MKSMBF$', 'OCT$', 'PEEK', 'PEN', 'PLAY', 'PMAP', 'POINT', 'POS', 'RIGHT$', 'RND', 'RTRIM$', 'SADD', 'SCREEN', 'SEEK', 'SETMEM', 'SGN', 'SIN', 'SPACE$', 'SPC', 'SQR', 'STICK', 'STR$', 'STRIG', 'STRING$', 'TAB', 'TAN', 'TIME$', 'TIMER', 'UBOUND', 'UCASE$', 'VAL', 'VARPTR', 'VARPTR$', 'VARSEG' )
metacommands = ('$DYNAMIC', '$INCLUDE', '$STATIC')
operators = ('AND', 'EQV', 'IMP', 'NOT', 'OR', 'XOR')
statements = ( 'BEEP', 'BLOAD', 'BSAVE', 'CALL', 'CALL ABSOLUTE', 'CALL INTERRUPT', 'CALLS', 'CHAIN', 'CHDIR', 'CIRCLE', 'CLEAR', 'CLOSE', 'CLS', 'COLOR', 'COM', 'COMMON', 'CONST', 'DATA', 'DATE$', 'DECLARE', 'DEF FN', 'DEF SEG', 'DEFDBL', 'DEFINT', 'DEFLNG', 'DEFSNG', 'DEFSTR', 'DEF', 'DIM', 'DO', 'LOOP', 'DRAW', 'END', 'ENVIRON', 'ERASE', 'ERROR', 'EXIT', 'FIELD', 'FILES', 'FOR', 'NEXT', 'FUNCTION', 'GET', 'GOSUB', 'GOTO', 'IF', 'THEN', 'INPUT', 'INPUT #', 'IOCTL', 'KEY', 'KEY', 'KILL', 'LET', 'LINE', 'LINE INPUT', 'LINE INPUT #', 'LOCATE', 'LOCK', 'UNLOCK', 'LPRINT', 'LSET', 'MID$', 'MKDIR', 'NAME', 'ON COM', 'ON ERROR', 'ON KEY', 'ON PEN', 'ON PLAY', 'ON STRIG', 'ON TIMER', 'ON UEVENT', 'ON', 'OPEN', 'OPEN COM', 'OPTION BASE', 'OUT', 'PAINT', 'PALETTE', 'PCOPY', 'PEN', 'PLAY', 'POKE', 'PRESET', 'PRINT', 'PRINT #', 'PRINT USING', 'PSET', 'PUT', 'PUT', 'RANDOMIZE', 'READ', 'REDIM', 'REM', 'RESET', 'RESTORE', 'RESUME', 'RETURN', 'RMDIR', 'RSET', 'RUN', 'SCREEN', 'SEEK', 'SELECT CASE', 'SHARED', 'SHELL', 'SLEEP', 'SOUND', 'STATIC', 'STOP', 'STRIG', 'SUB', 'SWAP', 'SYSTEM', 'TIME$', 'TIMER', 'TROFF', 'TRON', 'TYPE', 'UEVENT', 'UNLOCK', 'VIEW', 'WAIT', 'WHILE', 'WEND', 'WIDTH', 'WINDOW', 'WRITE' )
keywords = ( 'ACCESS', 'ALIAS', 'ANY', 'APPEND', 'AS', 'BASE', 'BINARY', 'BYVAL', 'CASE', 'CDECL', 'DOUBLE', 'ELSE', 'ELSEIF', 'ENDIF', 'INTEGER', 'IS', 'LIST', 'LOCAL', 'LONG', 'LOOP', 'MOD', 'NEXT', 'OFF', 'ON', 'OUTPUT', 'RANDOM', 'SIGNAL', 'SINGLE', 'STEP', 'STRING', 'THEN', 'TO', 'UNTIL', 'USING', 'WEND' )
tokens = { 'root': [ (r'\n+', Text), (r'\s+', Text.Whitespace), (r'^(\s*)(\d*)(\s*)(REM .*)$', bygroups(Text.Whitespace, Name.Label, Text.Whitespace, Comment.Single)), (r'^(\s*)(\d+)(\s*)', bygroups(Text.Whitespace, Name.Label, Text.Whitespace)), (r'(?=[\s]*)(\w+)(?=[\s]*=)', Name.Variable.Global), (r'(?=[^"]*)\'.*$', Comment.Single), (r'"[^\n"]*"', String.Double), (r'(END)(\s+)(FUNCTION|IF|SELECT|SUB)', bygroups(Keyword.Reserved, Text.Whitespace, Keyword.Reserved)), (r'(DECLARE)(\s+)([A-Z]+)(\s+)(\S+)', bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable, Text.Whitespace, Name)), (r'(DIM)(\s+)(SHARED)(\s+)([^\s(]+)', bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable, Text.Whitespace, Name.Variable.Global)), (r'(DIM)(\s+)([^\s(]+)', bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable.Global)), (r'^(\s*)([a-zA-Z_]+)(\s*)(\=)', bygroups(Text.Whitespace, Name.Variable.Global, Text.Whitespace, Operator)), (r'(GOTO|GOSUB)(\s+)(\w+\:?)', bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)), (r'(SUB)(\s+)(\w+\:?)', bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)), include('declarations'), include('functions'), include('metacommands'), include('operators'), include('statements'), include('keywords'), (r'[a-zA-Z_]\w*[$@#&!]', Name.Variable.Global), (r'[a-zA-Z_]\w*\:', Name.Label), (r'\-?\d*\.\d+[@|#]?', Number.Float), (r'\-?\d+[@|#]', Number.Float), (r'\-?\d+#?', Number.Integer.Long), (r'\-?\d+#?', Number.Integer), (r'!=|==|:=|\.=|<<|>>|[-~+/\\*%=<>&^|?:!.]', Operator), (r'[\[\]{}(),;]', Punctuation), (r'[\w]+', Name.Variable.Global), ], # can't use regular \b because of X$() # XXX: use words() here 'declarations': [ (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, declarations))), Keyword.Declaration), ], 'functions': [ (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, functions))), Keyword.Reserved), ], 'metacommands': [ (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, metacommands))), Keyword.Constant), ], 'operators': [ (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, operators))), Operator.Word), ], 'statements': [ (r'\b({})\b'.format('|'.join(map(re.escape, statements))), Keyword.Reserved), ], 'keywords': [ (r'\b({})\b'.format('|'.join(keywords)), Keyword), ], }
def analyse_text(text): if '$DYNAMIC' in text or '$STATIC' in text: return 0.9
class VBScriptLexer(RegexLexer): """ VBScript is scripting language that is modeled on Visual Basic. """ name = 'VBScript' aliases = ['vbscript'] filenames = ['*.vbs', '*.VBS'] url = 'https://learn.microsoft.com/en-us/previous-versions/t0aew7h6(v=vs.85)' version_added = '2.4'
flags = re.IGNORECASE
tokens = { 'root': [ (r"'[^\n]*", Comment.Single), (r'\s+', Whitespace), ('"', String.Double, 'string'), ('&h[0-9a-f]+', Number.Hex), # Float variant 1, for example: 1., 1.e2, 1.2e3 (r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), (r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Float variant 2, for example: .1, .1e2 (r'[0-9]+e[+-]?[0-9]+', Number.Float), # Float variant 3, for example: 123e45 (r'[0-9]+', Number.Integer), ('#.+#', String), # date or time value (r'(dim)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Variable), 'dim_more'), (r'(function|sub)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Function)), (r'(class)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Class)), (r'(const)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Constant)), (r'(end)(\s+)(class|function|if|property|sub|with)', bygroups(Keyword, Whitespace, Keyword)), (r'(on)(\s+)(error)(\s+)(goto)(\s+)(0)', bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Number.Integer)), (r'(on)(\s+)(error)(\s+)(resume)(\s+)(next)', bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Keyword)), (r'(option)(\s+)(explicit)', bygroups(Keyword, Whitespace, Keyword)), (r'(property)(\s+)(get|let|set)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Property)), (r'rem\s.*[^\n]*', Comment.Single), (words(_vbscript_builtins.KEYWORDS, suffix=r'\b'), Keyword), (words(_vbscript_builtins.OPERATORS), Operator), (words(_vbscript_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word), (words(_vbscript_builtins.BUILTIN_CONSTANTS, suffix=r'\b'), Name.Constant), (words(_vbscript_builtins.BUILTIN_FUNCTIONS, suffix=r'\b'), Name.Builtin), (words(_vbscript_builtins.BUILTIN_VARIABLES, suffix=r'\b'), Name.Builtin), (r'[a-z_][a-z0-9_]*', Name), (r'\b_\n', Operator), (words(r'(),.:'), Punctuation), (r'.+(\n)?', Error) ], 'dim_more': [ (r'(\s*)(,)(\s*)([a-z_][a-z0-9]*)', bygroups(Whitespace, Punctuation, Whitespace, Name.Variable)), default('#pop'), ], 'string': [ (r'[^"\n]+', String.Double), (r'\"\"', String.Double), (r'"', String.Double, '#pop'), (r'\n', Error, '#pop'), # Unterminated string ], }
class BBCBasicLexer(RegexLexer): """ BBC Basic was supplied on the BBC Micro, and later Acorn RISC OS. It is also used by BBC Basic For Windows. """ base_keywords = ['OTHERWISE', 'AND', 'DIV', 'EOR', 'MOD', 'OR', 'ERROR', 'LINE', 'OFF', 'STEP', 'SPC', 'TAB', 'ELSE', 'THEN', 'OPENIN', 'PTR', 'PAGE', 'TIME', 'LOMEM', 'HIMEM', 'ABS', 'ACS', 'ADVAL', 'ASC', 'ASN', 'ATN', 'BGET', 'COS', 'COUNT', 'DEG', 'ERL', 'ERR', 'EVAL', 'EXP', 'EXT', 'FALSE', 'FN', 'GET', 'INKEY', 'INSTR', 'INT', 'LEN', 'LN', 'LOG', 'NOT', 'OPENUP', 'OPENOUT', 'PI', 'POINT', 'POS', 'RAD', 'RND', 'SGN', 'SIN', 'SQR', 'TAN', 'TO', 'TRUE', 'USR', 'VAL', 'VPOS', 'CHR$', 'GET$', 'INKEY$', 'LEFT$', 'MID$', 'RIGHT$', 'STR$', 'STRING$', 'EOF', 'PTR', 'PAGE', 'TIME', 'LOMEM', 'HIMEM', 'SOUND', 'BPUT', 'CALL', 'CHAIN', 'CLEAR', 'CLOSE', 'CLG', 'CLS', 'DATA', 'DEF', 'DIM', 'DRAW', 'END', 'ENDPROC', 'ENVELOPE', 'FOR', 'GOSUB', 'GOTO', 'GCOL', 'IF', 'INPUT', 'LET', 'LOCAL', 'MODE', 'MOVE', 'NEXT', 'ON', 'VDU', 'PLOT', 'PRINT', 'PROC', 'READ', 'REM', 'REPEAT', 'REPORT', 'RESTORE', 'RETURN', 'RUN', 'STOP', 'COLOUR', 'TRACE', 'UNTIL', 'WIDTH', 'OSCLI']
basic5_keywords = ['WHEN', 'OF', 'ENDCASE', 'ENDIF', 'ENDWHILE', 'CASE', 'CIRCLE', 'FILL', 'ORIGIN', 'POINT', 'RECTANGLE', 'SWAP', 'WHILE', 'WAIT', 'MOUSE', 'QUIT', 'SYS', 'INSTALL', 'LIBRARY', 'TINT', 'ELLIPSE', 'BEATS', 'TEMPO', 'VOICES', 'VOICE', 'STEREO', 'OVERLAY', 'APPEND', 'AUTO', 'CRUNCH', 'DELETE', 'EDIT', 'HELP', 'LIST', 'LOAD', 'LVAR', 'NEW', 'OLD', 'RENUMBER', 'SAVE', 'TEXTLOAD', 'TEXTSAVE', 'TWIN', 'TWINO', 'INSTALL', 'SUM', 'BEAT']
name = 'BBC Basic' aliases = ['bbcbasic'] filenames = ['*.bbc'] url = 'https://www.bbcbasic.co.uk/bbcbasic.html' version_added = '2.4'
tokens = { 'root': [ (r"[0-9]+", Name.Label), (r"(\*)([^\n]*)", bygroups(Keyword.Pseudo, Comment.Special)), default('code'), ],
'code': [ (r"(REM)([^\n]*)", bygroups(Keyword.Declaration, Comment.Single)), (r'\n', Whitespace, 'root'), (r'\s+', Whitespace), (r':', Comment.Preproc),
# Some special cases to make functions come out nicer (r'(DEF)(\s*)(FN|PROC)([A-Za-z_@][\w@]*)', bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Name.Function)), (r'(FN|PROC)([A-Za-z_@][\w@]*)', bygroups(Keyword, Name.Function)),
(r'(GOTO|GOSUB|THEN|RESTORE)(\s*)(\d+)', bygroups(Keyword, Whitespace, Name.Label)),
(r'(TRUE|FALSE)', Keyword.Constant), (r'(PAGE|LOMEM|HIMEM|TIME|WIDTH|ERL|ERR|REPORT\$|POS|VPOS|VOICES)', Keyword.Pseudo),
(words(base_keywords), Keyword), (words(basic5_keywords), Keyword),
('"', String.Double, 'string'),
('%[01]{1,32}', Number.Bin), ('&[0-9a-f]{1,8}', Number.Hex),
(r'[+-]?[0-9]+\.[0-9]*(E[+-]?[0-9]+)?', Number.Float), (r'[+-]?\.[0-9]+(E[+-]?[0-9]+)?', Number.Float), (r'[+-]?[0-9]+E[+-]?[0-9]+', Number.Float), (r'[+-]?\d+', Number.Integer),
(r'([A-Za-z_@][\w@]*[%$]?)', Name.Variable), (r'([+\-]=|[$!|?+\-*/%^=><();]|>=|<=|<>|<<|>>|>>>|,)', Operator), ], 'string': [ (r'[^"\n]+', String.Double), (r'"', String.Double, '#pop'), (r'\n', Error, 'root'), # Unterminated string ], }
def analyse_text(text): if text.startswith('10REM >') or text.startswith('REM >'): return 0.9123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657""" pygments.lexers.bdd ~~~~~~~~~~~~~~~~~~~
Lexer for BDD(Behavior-driven development).
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, includefrom pygments.token import Comment, Keyword, Name, String, Number, Text, \ Punctuation, Whitespace
__all__ = ['BddLexer']
class BddLexer(RegexLexer): """ Lexer for BDD(Behavior-driven development), which highlights not only keywords, but also comments, punctuations, strings, numbers, and variables. """
name = 'Bdd' aliases = ['bdd'] filenames = ['*.feature'] mimetypes = ['text/x-bdd'] url = 'https://en.wikipedia.org/wiki/Behavior-driven_development' version_added = '2.11'
step_keywords = (r'Given|When|Then|Add|And|Feature|Scenario Outline|' r'Scenario|Background|Examples|But')
tokens = { 'comments': [ (r'^\s*#.*$', Comment), ], 'miscellaneous': [ (r'(<|>|\[|\]|=|\||:|\(|\)|\{|\}|,|\.|;|-|_|\$)', Punctuation), (r'((?<=\<)[^\\>]+(?=\>))', Name.Variable), (r'"([^\"]*)"', String), (r'^@\S+', Name.Label), ], 'numbers': [ (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number), ], 'root': [ (r'\n|\s+', Whitespace), (step_keywords, Keyword), include('comments'), include('miscellaneous'), include('numbers'), (r'\S+', Text), ] }
def analyse_text(self, text): return123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899""" pygments.lexers.berry ~~~~~~~~~~~~~~~~~~~~~
Lexer for Berry.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, words, include, bygroupsfrom pygments.token import Comment, Whitespace, Operator, Keyword, Name, \ String, Number, Punctuation
__all__ = ['BerryLexer']
class BerryLexer(RegexLexer): """ For Berry source code. """ name = 'Berry' aliases = ['berry', 'be'] filenames = ['*.be'] mimetypes = ['text/x-berry', 'application/x-berry'] url = 'https://berry-lang.github.io' version_added = '2.12'
_name = r'\b[^\W\d]\w*'
tokens = { 'root': [ include('whitespace'), include('numbers'), include('keywords'), (rf'(def)(\s+)({_name})', bygroups(Keyword.Declaration, Whitespace, Name.Function)), (rf'\b(class)(\s+)({_name})', bygroups(Keyword.Declaration, Whitespace, Name.Class)), (rf'\b(import)(\s+)({_name})', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), include('expr') ], 'expr': [ (r'[^\S\n]+', Whitespace), (r'\.\.|[~!%^&*+=|?:<>/-]', Operator), (r'[(){}\[\],.;]', Punctuation), include('controls'), include('builtins'), include('funccall'), include('member'), include('name'), include('strings') ], 'whitespace': [ (r'\s+', Whitespace), (r'#-(.|\n)*?-#', Comment.Multiline), (r'#.*?$', Comment.Single) ], 'keywords': [ (words(( 'as', 'break', 'continue', 'import', 'static', 'self', 'super'), suffix=r'\b'), Keyword.Reserved), (r'(true|false|nil)\b', Keyword.Constant), (r'(var|def)\b', Keyword.Declaration) ], 'controls': [ (words(( 'if', 'elif', 'else', 'for', 'while', 'do', 'end', 'break', 'continue', 'return', 'try', 'except', 'raise'), suffix=r'\b'), Keyword) ], 'builtins': [ (words(( 'assert', 'bool', 'input', 'classname', 'classof', 'number', 'real', 'bytes', 'compile', 'map', 'list', 'int', 'isinstance', 'print', 'range', 'str', 'super', 'module', 'size', 'issubclass', 'open', 'file', 'type', 'call'), suffix=r'\b'), Name.Builtin) ], 'numbers': [ (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'-?\d+', Number.Integer), (r'(-?\d+\.?|\.\d)\d*([eE][+-]?\d+)?', Number.Float) ], 'name': [ (_name, Name) ], 'funccall': [ (rf'{_name}(?=\s*\()', Name.Function, '#pop') ], 'member': [ (rf'(?<=\.){_name}\b(?!\()', Name.Attribute, '#pop') ], 'strings': [ (r'"([^\\]|\\.)*?"', String.Double, '#pop'), (r'\'([^\\]|\\.)*?\'', String.Single, '#pop') ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159""" pygments.lexers.bibtex ~~~~~~~~~~~~~~~~~~~~~~
Lexers for BibTeX bibliography data and styles
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, default, \ wordsfrom pygments.token import Name, Comment, String, Error, Number, Keyword, \ Punctuation, Whitespace
__all__ = ['BibTeXLexer', 'BSTLexer']
class BibTeXLexer(ExtendedRegexLexer): """ A lexer for BibTeX bibliography data format. """
name = 'BibTeX' aliases = ['bibtex', 'bib'] filenames = ['*.bib'] mimetypes = ["text/x-bibtex"] version_added = '2.2' flags = re.IGNORECASE url = 'https://texfaq.org/FAQ-BibTeXing'
ALLOWED_CHARS = r'@!$&*+\-./:;<>?\[\\\]^`|~' IDENTIFIER = '[{}][{}]*'.format('a-z_' + ALLOWED_CHARS, r'\w' + ALLOWED_CHARS)
def open_brace_callback(self, match, ctx): opening_brace = match.group() ctx.opening_brace = opening_brace yield match.start(), Punctuation, opening_brace ctx.pos = match.end()
def close_brace_callback(self, match, ctx): closing_brace = match.group() if ( ctx.opening_brace == '{' and closing_brace != '}' or ctx.opening_brace == '(' and closing_brace != ')' ): yield match.start(), Error, closing_brace else: yield match.start(), Punctuation, closing_brace del ctx.opening_brace ctx.pos = match.end()
tokens = { 'root': [ include('whitespace'), (r'@comment(?!ary)', Comment), ('@preamble', Name.Class, ('closing-brace', 'value', 'opening-brace')), ('@string', Name.Class, ('closing-brace', 'field', 'opening-brace')), ('@' + IDENTIFIER, Name.Class, ('closing-brace', 'command-body', 'opening-brace')), ('.+', Comment), ], 'opening-brace': [ include('whitespace'), (r'[{(]', open_brace_callback, '#pop'), ], 'closing-brace': [ include('whitespace'), (r'[})]', close_brace_callback, '#pop'), ], 'command-body': [ include('whitespace'), (r'[^\s\,\}]+', Name.Label, ('#pop', 'fields')), ], 'fields': [ include('whitespace'), (',', Punctuation, 'field'), default('#pop'), ], 'field': [ include('whitespace'), (IDENTIFIER, Name.Attribute, ('value', '=')), default('#pop'), ], '=': [ include('whitespace'), ('=', Punctuation, '#pop'), ], 'value': [ include('whitespace'), (IDENTIFIER, Name.Variable), ('"', String, 'quoted-string'), (r'\{', String, 'braced-string'), (r'[\d]+', Number), ('#', Punctuation), default('#pop'), ], 'quoted-string': [ (r'\{', String, 'braced-string'), ('"', String, '#pop'), (r'[^\{\"]+', String), ], 'braced-string': [ (r'\{', String, '#push'), (r'\}', String, '#pop'), (r'[^\{\}]+', String), ], 'whitespace': [ (r'\s+', Whitespace), ], }
class BSTLexer(RegexLexer): """ A lexer for BibTeX bibliography styles. """
name = 'BST' aliases = ['bst', 'bst-pybtex'] filenames = ['*.bst'] version_added = '2.2' flags = re.IGNORECASE | re.MULTILINE url = 'https://texfaq.org/FAQ-BibTeXing'
tokens = { 'root': [ include('whitespace'), (words(['read', 'sort']), Keyword), (words(['execute', 'integers', 'iterate', 'reverse', 'strings']), Keyword, ('group')), (words(['function', 'macro']), Keyword, ('group', 'group')), (words(['entry']), Keyword, ('group', 'group', 'group')), ], 'group': [ include('whitespace'), (r'\{', Punctuation, ('#pop', 'group-end', 'body')), ], 'group-end': [ include('whitespace'), (r'\}', Punctuation, '#pop'), ], 'body': [ include('whitespace'), (r"\'[^#\"\{\}\s]+", Name.Function), (r'[^#\"\{\}\s]+\$', Name.Builtin), (r'[^#\"\{\}\s]+', Name.Variable), (r'"[^\"]*"', String), (r'#-?\d+', Number), (r'\{', Punctuation, ('group-end', 'body')), default('#pop'), ], 'whitespace': [ (r'\s+', Whitespace), ('%.*?$', Comment.Single), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173""" pygments.lexers.blueprint ~~~~~~~~~~~~~~~~~~~~~~~~~
Lexer for the Blueprint UI markup language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, wordsfrom pygments.token import ( Comment, Operator, Keyword, Name, String, Number, Punctuation, Whitespace,)
__all__ = ["BlueprintLexer"]
class BlueprintLexer(RegexLexer): """ For Blueprint UI markup. """
name = "Blueprint" aliases = ["blueprint"] filenames = ["*.blp"] mimetypes = ["text/x-blueprint"] url = "https://gitlab.gnome.org/jwestman/blueprint-compiler" version_added = '2.16'
flags = re.IGNORECASE tokens = { "root": [ include("block-content"), ], "type": [ (r"\$\s*[a-z_][a-z0-9_\-]*", Name.Class), (r"(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*)", bygroups(Name.Namespace, Whitespace, Punctuation, Whitespace, Name.Class)), ], "whitespace": [ (r"\s+", Whitespace), (r"//.*?\n", Comment.Single), (r"/\*", Comment.Multiline, "comment-multiline"), ], "comment-multiline": [ (r"\*/", Comment.Multiline, "#pop"), (r"[^*]+", Comment.Multiline), (r"\*", Comment.Multiline), ], "value": [ (r"(typeof)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"), (words(("true", "false", "null")), Keyword.Constant), (r"[a-z_][a-z0-9_\-]*", Name.Variable), (r"\|", Operator), (r'".*?"', String.Double), (r"\'.*?\'", String.Single), (r"0x[\d_]*", Number.Hex), (r"[0-9_]+", Number.Integer), (r"\d[\d\.a-z_]*", Number), ], "typeof": [ include("whitespace"), include("type"), (r">", Punctuation, "#pop"), ], "content": [ include("whitespace"), # Keywords (words(("after", "bidirectional", "bind-property", "bind", "default", "destructive", "disabled", "inverted", "no-sync-create", "suggested", "swapped", "sync-create", "template")), Keyword), # Translated strings (r"(C?_)(\s*)(\()", bygroups(Name.Function.Builtin, Whitespace, Punctuation), "paren-content"), # Cast expressions (r"(as)(\s*)(<)", bygroups(Keyword, Whitespace, Punctuation), "typeof"), # Closures (r"(\$?[a-z_][a-z0-9_\-]*)(\s*)(\()", bygroups(Name.Function, Whitespace, Punctuation), "paren-content"), # Objects (r"(?:(\$\s*[a-z_][a-z0-9_\-]+)|(?:([a-z_][a-z0-9_\-]*)(\s*)(\.)(\s*))?([a-z_][a-z0-9_\-]*))(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)", bygroups(Name.Class, Name.Namespace, Whitespace, Punctuation, Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation), "brace-block"), # Misc include("value"), (r",|\.", Punctuation), ], "block-content": [ # Import statements (r"(using)(\s+)([a-z_][a-z0-9_\-]*)(\s+)(\d[\d\.]*)(;)", bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, Name.Namespace, Punctuation)), # Menus (r"(menu|section|submenu)(?:(\s+)([a-z_][a-z0-9_\-]*))?(\s*)(\{)", bygroups(Keyword, Whitespace, Name.Variable, Whitespace, Punctuation), "brace-block"), (r"(item)(\s*)(\{)", bygroups(Keyword, Whitespace, Punctuation), "brace-block"), (r"(item)(\s*)(\()", bygroups(Keyword, Whitespace, Punctuation), "paren-block"), # Templates (r"template", Keyword.Declaration, "template"), # Nested blocks. When extensions are added, this is where they go. (r"(responses|items|mime-types|patterns|suffixes|marks|widgets|strings|styles)(\s*)(\[)", bygroups(Keyword, Whitespace, Punctuation), "bracket-block"), (r"(accessibility|setters|layout|item)(\s*)(\{)", bygroups(Keyword, Whitespace, Punctuation), "brace-block"), (r"(condition|mark|item)(\s*)(\()", bygroups(Keyword, Whitespace, Punctuation), "paren-content"), (r"\[", Punctuation, "child-type"), # Properties and signals (r"([a-z_][a-z0-9_\-]*(?:::[a-z0-9_]+)?)(\s*)(:|=>)", bygroups(Name.Property, Whitespace, Punctuation), "statement"), include("content"), ], "paren-block": [ include("block-content"), (r"\)", Punctuation, "#pop"), ], "paren-content": [ include("content"), (r"\)", Punctuation, "#pop"), ], "bracket-block": [ include("block-content"), (r"\]", Punctuation, "#pop"), ], "brace-block": [ include("block-content"), (r"\}", Punctuation, "#pop"), ], "statement": [ include("content"), (r";", Punctuation, "#pop"), ], "child-type": [ include("whitespace"), (r"(action)(\s+)(response)(\s*)(=)(\s*)", bygroups(Keyword, Whitespace, Name.Attribute, Whitespace, Punctuation, Whitespace)), (words(("default", "internal-child", "response")), Keyword), (r"[a-z_][a-z0-9_\-]*", Name.Decorator), include("value"), (r"=", Punctuation), (r"\]", Punctuation, "#pop"), ], "template": [ include("whitespace"), include("type"), (r":", Punctuation), (r"\{", Punctuation, ("#pop", "brace-block")), ], }12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697""" pygments.lexers.boa ~~~~~~~~~~~~~~~~~~~
Lexers for the Boa language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import String, Comment, Keyword, Name, Number, Operator, \ Punctuation, Whitespace
__all__ = ['BoaLexer']
class BoaLexer(RegexLexer): """ Lexer for the Boa language. """ name = 'Boa' aliases = ['boa'] filenames = ['*.boa'] url = 'https://boa.cs.iastate.edu/docs' version_added = '2.4'
reserved = words( ('input', 'output', 'of', 'weight', 'before', 'after', 'stop', 'ifall', 'foreach', 'exists', 'function', 'break', 'switch', 'case', 'visitor', 'default', 'return', 'visit', 'while', 'if', 'else'), suffix=r'\b', prefix=r'\b') keywords = words( ('bottom', 'collection', 'maximum', 'mean', 'minimum', 'set', 'sum', 'top', 'string', 'int', 'bool', 'float', 'time', 'false', 'true', 'array', 'map', 'stack', 'enum', 'type'), suffix=r'\b', prefix=r'\b') classes = words( ('Project', 'ForgeKind', 'CodeRepository', 'Revision', 'RepositoryKind', 'ChangedFile', 'FileKind', 'ASTRoot', 'Namespace', 'Declaration', 'Type', 'Method', 'Variable', 'Statement', 'Expression', 'Modifier', 'StatementKind', 'ExpressionKind', 'ModifierKind', 'Visibility', 'TypeKind', 'Person', 'ChangeKind'), suffix=r'\b', prefix=r'\b') operators = ('->', ':=', ':', '=', '<<', '!', '++', '||', '&&', '+', '-', '*', ">", "<") string_sep = ('`', '\"') built_in_functions = words( ( # Array functions 'new', 'sort', # Date & Time functions 'yearof', 'dayofyear', 'hourof', 'minuteof', 'secondof', 'now', 'addday', 'addmonth', 'addweek', 'addyear', 'dayofmonth', 'dayofweek', 'dayofyear', 'formattime', 'trunctoday', 'trunctohour', 'trunctominute', 'trunctomonth', 'trunctosecond', 'trunctoyear', # Map functions 'clear', 'haskey', 'keys', 'lookup', 'remove', 'values', # Math functions 'abs', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'cos', 'cosh', 'exp', 'floor', 'highbit', 'isfinite', 'isinf', 'isnan', 'isnormal', 'log', 'log10', 'max', 'min', 'nrand', 'pow', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc', # Other functions 'def', 'hash', 'len', # Set functions 'add', 'contains', 'remove', # String functions 'format', 'lowercase', 'match', 'matchposns', 'matchstrs', 'regex', 'split', 'splitall', 'splitn', 'strfind', 'strreplace', 'strrfind', 'substring', 'trim', 'uppercase', # Type Conversion functions 'bool', 'float', 'int', 'string', 'time', # Domain-Specific functions 'getast', 'getsnapshot', 'hasfiletype', 'isfixingrevision', 'iskind', 'isliteral', ), prefix=r'\b', suffix=r'\(')
tokens = { 'root': [ (r'#.*?$', Comment.Single), (r'/\*.*?\*/', Comment.Multiline), (reserved, Keyword.Reserved), (built_in_functions, Name.Function), (keywords, Keyword.Type), (classes, Name.Classes), (words(operators), Operator), (r'[][(),;{}\\.]', Punctuation), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"`(\\\\|\\[^\\]|[^`\\])*`", String.Backtick), (words(string_sep), String.Delimiter), (r'[a-zA-Z_]+', Name.Variable), (r'[0-9]+', Number.Integer), (r'\s+', Whitespace), # Whitespace ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112""" pygments.lexers.bqn ~~~~~~~~~~~~~~~~~~~
Lexer for BQN.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexerfrom pygments.token import Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['BQNLexer']
class BQNLexer(RegexLexer): """ A simple BQN lexer. """ name = 'BQN' url = 'https://mlochbaum.github.io/BQN/index.html' aliases = ['bqn'] filenames = ['*.bqn'] mimetypes = [] version_added = '2.16'
# An inter_word_char. Necessary because \w matches all alphanumeric # Unicode characters, including ones (e.g., 𝕊) that BQN treats special. _iwc = r'((?=[^𝕎𝕏𝔽𝔾𝕊𝕨𝕩𝕗𝕘𝕤𝕣])\w)'
tokens = { 'root': [ # Whitespace # ========== (r'\s+', Whitespace), # # Comment # ======= # '#' is a comment that continues to the end of the line (r'#.*$', Comment.Single), # # Strings # ======= (r'\'((\'\')|[^\'])*\'', String.Single), (r'"(("")|[^"])*"', String.Double), # # Null Character # ============== # Literal representation of the null character (r'@', String.Symbol), # # Punctuation # =========== # This token type is used for diamond, commas # and array and list brackets and strand syntax (r'[\.⋄,\[\]⟨⟩‿]', Punctuation), # # Expression Grouping # =================== # Since this token type is important in BQN, it is not included in # the punctuation token type but rather in the following one (r'[\(\)]', String.Regex), # # Numbers # ======= # Includes the numeric literals and the Nothing character (r'¯?[0-9](([0-9]|_)*\.?([0-9]|_)+|([0-9]|_)*)([Ee][¯]?([0-9]|_)+)?|¯|∞|π|·', Number), # # Variables # ========= (r'[a-z]' + _iwc + r'*', Name.Variable), # # 2-Modifiers # =========== # Needs to come before the 1-modifiers due to _𝕣 and _𝕣_ (r'[∘○⊸⟜⌾⊘◶⎉⚇⍟⎊]', Name.Property), (r'_(𝕣|[a-zA-Z0-9]+)_', Name.Property), # # 1-Modifiers # =========== (r'[˙˜˘¨⌜⁼´˝`𝕣]', Name.Attribute), (r'_(𝕣|[a-zA-Z0-9]+)', Name.Attribute), # # Functions # ========= # The monadic or dyadic function primitives and function # operands and arguments, along with function self-reference (r'[+\-×÷\⋆√⌊⌈∧∨¬|≤<>≥=≠≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!𝕎𝕏𝔽𝔾𝕊]', Operator), (r'[A-Z]' + _iwc + r'*|•' + _iwc + r'+', Operator), # # Constant # ======== (r'˙', Name.Constant), # # Define/Export/Change # ==================== (r'[←↩⇐]', Keyword.Declaration), # # Blocks # ====== (r'[{}]', Keyword.Type), # # Extra characters # ================ (r'[;:?𝕨𝕩𝕗𝕘𝕤]', Name.Entity), #
], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625""" pygments.lexers.business ~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for "business-oriented" languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, words, bygroupsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Error, Whitespace
from pygments.lexers._openedge_builtins import OPENEDGEKEYWORDS
__all__ = ['CobolLexer', 'CobolFreeformatLexer', 'ABAPLexer', 'OpenEdgeLexer', 'GoodDataCLLexer', 'MaqlLexer']
class CobolLexer(RegexLexer): """ Lexer for OpenCOBOL code. """ name = 'COBOL' aliases = ['cobol'] filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY'] mimetypes = ['text/x-cobol'] url = 'https://en.wikipedia.org/wiki/COBOL' version_added = '1.6'
flags = re.IGNORECASE | re.MULTILINE
# Data Types: by PICTURE and USAGE # Operators: **, *, +, -, /, <, >, <=, >=, =, <> # Logical (?): NOT, AND, OR
# Reserved words: # http://opencobol.add1tocobol.com/#reserved-words # Intrinsics: # http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
tokens = { 'root': [ include('comment'), include('strings'), include('core'), include('nums'), (r'[a-z0-9]([\w\-]*[a-z0-9]+)?', Name.Variable), # (r'[\s]+', Text), (r'[ \t]+', Whitespace), ], 'comment': [ (r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment), ], 'core': [ # Figurative constants (r'(^|(?<=[^\w\-]))(ALL\s+)?' r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)' r'\s*($|(?=[^\w\-]))', Name.Constant),
# Reserved words STATEMENTS and other bolds (words(( 'ACCEPT', 'ADD', 'ALLOCATE', 'CALL', 'CANCEL', 'CLOSE', 'COMPUTE', 'CONFIGURATION', 'CONTINUE', 'DATA', 'DELETE', 'DISPLAY', 'DIVIDE', 'DIVISION', 'ELSE', 'END', 'END-ACCEPT', 'END-ADD', 'END-CALL', 'END-COMPUTE', 'END-DELETE', 'END-DISPLAY', 'END-DIVIDE', 'END-EVALUATE', 'END-IF', 'END-MULTIPLY', 'END-OF-PAGE', 'END-PERFORM', 'END-READ', 'END-RETURN', 'END-REWRITE', 'END-SEARCH', 'END-START', 'END-STRING', 'END-SUBTRACT', 'END-UNSTRING', 'END-WRITE', 'ENVIRONMENT', 'EVALUATE', 'EXIT', 'FD', 'FILE', 'FILE-CONTROL', 'FOREVER', 'FREE', 'GENERATE', 'GO', 'GOBACK', 'IDENTIFICATION', 'IF', 'INITIALIZE', 'INITIATE', 'INPUT-OUTPUT', 'INSPECT', 'INVOKE', 'I-O-CONTROL', 'LINKAGE', 'LOCAL-STORAGE', 'MERGE', 'MOVE', 'MULTIPLY', 'OPEN', 'PERFORM', 'PROCEDURE', 'PROGRAM-ID', 'RAISE', 'READ', 'RELEASE', 'RESUME', 'RETURN', 'REWRITE', 'SCREEN', 'SD', 'SEARCH', 'SECTION', 'SET', 'SORT', 'START', 'STOP', 'STRING', 'SUBTRACT', 'SUPPRESS', 'TERMINATE', 'THEN', 'UNLOCK', 'UNSTRING', 'USE', 'VALIDATE', 'WORKING-STORAGE', 'WRITE'), prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'), Keyword.Reserved),
# Reserved words (words(( 'ACCESS', 'ADDRESS', 'ADVANCING', 'AFTER', 'ALL', 'ALPHABET', 'ALPHABETIC', 'ALPHABETIC-LOWER', 'ALPHABETIC-UPPER', 'ALPHANUMERIC', 'ALPHANUMERIC-EDITED', 'ALSO', 'ALTER', 'ALTERNATE' 'ANY', 'ARE', 'AREA', 'AREAS', 'ARGUMENT-NUMBER', 'ARGUMENT-VALUE', 'AS', 'ASCENDING', 'ASSIGN', 'AT', 'AUTO', 'AUTO-SKIP', 'AUTOMATIC', 'AUTOTERMINATE', 'BACKGROUND-COLOR', 'BASED', 'BEEP', 'BEFORE', 'BELL', 'BLANK', 'BLINK', 'BLOCK', 'BOTTOM', 'BY', 'BYTE-LENGTH', 'CHAINING', 'CHARACTER', 'CHARACTERS', 'CLASS', 'CODE', 'CODE-SET', 'COL', 'COLLATING', 'COLS', 'COLUMN', 'COLUMNS', 'COMMA', 'COMMAND-LINE', 'COMMIT', 'COMMON', 'CONSTANT', 'CONTAINS', 'CONTENT', 'CONTROL', 'CONTROLS', 'CONVERTING', 'COPY', 'CORR', 'CORRESPONDING', 'COUNT', 'CRT', 'CURRENCY', 'CURSOR', 'CYCLE', 'DATE', 'DAY', 'DAY-OF-WEEK', 'DE', 'DEBUGGING', 'DECIMAL-POINT', 'DECLARATIVES', 'DEFAULT', 'DELIMITED', 'DELIMITER', 'DEPENDING', 'DESCENDING', 'DETAIL', 'DISK', 'DOWN', 'DUPLICATES', 'DYNAMIC', 'EBCDIC', 'ENTRY', 'ENVIRONMENT-NAME', 'ENVIRONMENT-VALUE', 'EOL', 'EOP', 'EOS', 'ERASE', 'ERROR', 'ESCAPE', 'EXCEPTION', 'EXCLUSIVE', 'EXTEND', 'EXTERNAL', 'FILE-ID', 'FILLER', 'FINAL', 'FIRST', 'FIXED', 'FLOAT-LONG', 'FLOAT-SHORT', 'FOOTING', 'FOR', 'FOREGROUND-COLOR', 'FORMAT', 'FROM', 'FULL', 'FUNCTION', 'FUNCTION-ID', 'GIVING', 'GLOBAL', 'GROUP', 'HEADING', 'HIGHLIGHT', 'I-O', 'ID', 'IGNORE', 'IGNORING', 'IN', 'INDEX', 'INDEXED', 'INDICATE', 'INITIAL', 'INITIALIZED', 'INPUT', 'INTO', 'INTRINSIC', 'INVALID', 'IS', 'JUST', 'JUSTIFIED', 'KEY', 'LABEL', 'LAST', 'LEADING', 'LEFT', 'LENGTH', 'LIMIT', 'LIMITS', 'LINAGE', 'LINAGE-COUNTER', 'LINE', 'LINES', 'LOCALE', 'LOCK', 'LOWLIGHT', 'MANUAL', 'MEMORY', 'MINUS', 'MODE', 'MULTIPLE', 'NATIONAL', 'NATIONAL-EDITED', 'NATIVE', 'NEGATIVE', 'NEXT', 'NO', 'NULL', 'NULLS', 'NUMBER', 'NUMBERS', 'NUMERIC', 'NUMERIC-EDITED', 'OBJECT-COMPUTER', 'OCCURS', 'OF', 'OFF', 'OMITTED', 'ON', 'ONLY', 'OPTIONAL', 'ORDER', 'ORGANIZATION', 'OTHER', 'OUTPUT', 'OVERFLOW', 'OVERLINE', 'PACKED-DECIMAL', 'PADDING', 'PAGE', 'PARAGRAPH', 'PLUS', 'POINTER', 'POSITION', 'POSITIVE', 'PRESENT', 'PREVIOUS', 'PRINTER', 'PRINTING', 'PROCEDURE-POINTER', 'PROCEDURES', 'PROCEED', 'PROGRAM', 'PROGRAM-POINTER', 'PROMPT', 'QUOTE', 'QUOTES', 'RANDOM', 'RD', 'RECORD', 'RECORDING', 'RECORDS', 'RECURSIVE', 'REDEFINES', 'REEL', 'REFERENCE', 'RELATIVE', 'REMAINDER', 'REMOVAL', 'RENAMES', 'REPLACING', 'REPORT', 'REPORTING', 'REPORTS', 'REPOSITORY', 'REQUIRED', 'RESERVE', 'RETURNING', 'REVERSE-VIDEO', 'REWIND', 'RIGHT', 'ROLLBACK', 'ROUNDED', 'RUN', 'SAME', 'SCROLL', 'SECURE', 'SEGMENT-LIMIT', 'SELECT', 'SENTENCE', 'SEPARATE', 'SEQUENCE', 'SEQUENTIAL', 'SHARING', 'SIGN', 'SIGNED', 'SIGNED-INT', 'SIGNED-LONG', 'SIGNED-SHORT', 'SIZE', 'SORT-MERGE', 'SOURCE', 'SOURCE-COMPUTER', 'SPECIAL-NAMES', 'STANDARD', 'STANDARD-1', 'STANDARD-2', 'STATUS', 'SUBKEY', 'SUM', 'SYMBOLIC', 'SYNC', 'SYNCHRONIZED', 'TALLYING', 'TAPE', 'TEST', 'THROUGH', 'THRU', 'TIME', 'TIMES', 'TO', 'TOP', 'TRAILING', 'TRANSFORM', 'TYPE', 'UNDERLINE', 'UNIT', 'UNSIGNED', 'UNSIGNED-INT', 'UNSIGNED-LONG', 'UNSIGNED-SHORT', 'UNTIL', 'UP', 'UPDATE', 'UPON', 'USAGE', 'USING', 'VALUE', 'VALUES', 'VARYING', 'WAIT', 'WHEN', 'WITH', 'WORDS', 'YYYYDDD', 'YYYYMMDD'), prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'), Keyword.Pseudo),
# inactive reserved words (words(( 'ACTIVE-CLASS', 'ALIGNED', 'ANYCASE', 'ARITHMETIC', 'ATTRIBUTE', 'B-AND', 'B-NOT', 'B-OR', 'B-XOR', 'BIT', 'BOOLEAN', 'CD', 'CENTER', 'CF', 'CH', 'CHAIN', 'CLASS-ID', 'CLASSIFICATION', 'COMMUNICATION', 'CONDITION', 'DATA-POINTER', 'DESTINATION', 'DISABLE', 'EC', 'EGI', 'EMI', 'ENABLE', 'END-RECEIVE', 'ENTRY-CONVENTION', 'EO', 'ESI', 'EXCEPTION-OBJECT', 'EXPANDS', 'FACTORY', 'FLOAT-BINARY-16', 'FLOAT-BINARY-34', 'FLOAT-BINARY-7', 'FLOAT-DECIMAL-16', 'FLOAT-DECIMAL-34', 'FLOAT-EXTENDED', 'FORMAT', 'FUNCTION-POINTER', 'GET', 'GROUP-USAGE', 'IMPLEMENTS', 'INFINITY', 'INHERITS', 'INTERFACE', 'INTERFACE-ID', 'INVOKE', 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MESSAGES', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LINE-COUNTER', 'MESSAGE', 'METHOD', 'METHOD-ID', 'NESTED', 'NONE', 'NORMAL', 'OBJECT', 'OBJECT-REFERENCE', 'OPTIONS', 'OVERRIDE', 'PAGE-COUNTER', 'PF', 'PH', 'PROPERTY', 'PROTOTYPE', 'PURGE', 'QUEUE', 'RAISE', 'RAISING', 'RECEIVE', 'RELATION', 'REPLACE', 'REPRESENTS-NOT-A-NUMBER', 'RESET', 'RESUME', 'RETRY', 'RF', 'RH', 'SECONDS', 'SEGMENT', 'SELF', 'SEND', 'SOURCES', 'STATEMENT', 'STEP', 'STRONG', 'SUB-QUEUE-1', 'SUB-QUEUE-2', 'SUB-QUEUE-3', 'SUPER', 'SYMBOL', 'SYSTEM-DEFAULT', 'TABLE', 'TERMINAL', 'TEXT', 'TYPEDEF', 'UCS-4', 'UNIVERSAL', 'USER-DEFAULT', 'UTF-16', 'UTF-8', 'VAL-STATUS', 'VALID', 'VALIDATE', 'VALIDATE-STATUS'), prefix=r'(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))'), Error),
# Data Types (r'(^|(?<=[^\w\-]))' r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|' r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|' r'BINARY-C-LONG|' r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|' r'BINARY)\s*($|(?=[^\w\-]))', Keyword.Type),
# Operators (r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator),
# (r'(::)', Keyword.Declaration),
(r'([(),;:&%.])', Punctuation),
# Intrinsics (r'(^|(?<=[^\w\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|' r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|' r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|' r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|' r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|' r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG(?:10)?|' r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|' r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|' r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|' r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|' r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|' r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*' r'($|(?=[^\w\-]))', Name.Function),
# Booleans (r'(^|(?<=[^\w\-]))(true|false)\s*($|(?=[^\w\-]))', Name.Builtin), # Comparing Operators (r'(^|(?<=[^\w\-]))(equal|equals|ne|lt|le|gt|ge|' r'greater|less|than|not|and|or)\s*($|(?=[^\w\-]))', Operator.Word), ],
# \"[^\"\n]*\"|\'[^\'\n]*\' 'strings': [ # apparently strings can be delimited by EOL if they are continued # in the next line (r'"[^"\n]*("|\n)', String.Double), (r"'[^'\n]*('|\n)", String.Single), ],
'nums': [ (r'\d+(\s*|\.$|$)', Number.Integer), (r'[+-]?\d*\.\d+(E[-+]?\d+)?', Number.Float), (r'[+-]?\d+\.\d*(E[-+]?\d+)?', Number.Float), ], }
class CobolFreeformatLexer(CobolLexer): """ Lexer for Free format OpenCOBOL code. """ name = 'COBOLFree' aliases = ['cobolfree'] filenames = ['*.cbl', '*.CBL'] mimetypes = [] url = 'https://opencobol.add1tocobol.com' version_added = '1.6'
flags = re.IGNORECASE | re.MULTILINE
tokens = { 'comment': [ (r'(\*>.*\n|^\w*\*.*$)', Comment), ], }
class ABAPLexer(RegexLexer): """ Lexer for ABAP, SAP's integrated language. """ name = 'ABAP' aliases = ['abap'] filenames = ['*.abap', '*.ABAP'] mimetypes = ['text/x-abap'] url = 'https://community.sap.com/topics/abap' version_added = '1.1'
flags = re.IGNORECASE | re.MULTILINE
tokens = { 'common': [ (r'\s+', Whitespace), (r'^\*.*$', Comment.Single), (r'\".*?\n', Comment.Single), (r'##\w+', Comment.Special), ], 'variable-names': [ (r'<\S+>', Name.Variable), (r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable), ], 'root': [ include('common'), # function calls (r'CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION)', Keyword), (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|' r'TRANSACTION|TRANSFORMATION))\b', Keyword), (r'(FORM|PERFORM)(\s+)(\w+)', bygroups(Keyword, Whitespace, Name.Function)), (r'(PERFORM)(\s+)(\()(\w+)(\))', bygroups(Keyword, Whitespace, Punctuation, Name.Variable, Punctuation)), (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)', bygroups(Keyword, Whitespace, Name.Function, Whitespace, Keyword)),
# method implementation (r'(METHOD)(\s+)([\w~]+)', bygroups(Keyword, Whitespace, Name.Function)), # method calls (r'(\s+)([\w\-]+)([=\-]>)([\w\-~]+)', bygroups(Whitespace, Name.Variable, Operator, Name.Function)), # call methodnames returning style (r'(?<=(=|-)>)([\w\-~]+)(?=\()', Name.Function),
# text elements (r'(TEXT)(-)(\d{3})', bygroups(Keyword, Punctuation, Number.Integer)), (r'(TEXT)(-)(\w{3})', bygroups(Keyword, Punctuation, Name.Variable)),
# keywords with dashes in them. # these need to be first, because for instance the -ID part # of MESSAGE-ID wouldn't get highlighted if MESSAGE was # first in the list of keywords. (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|' r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|' r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|' r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|' r'FIELD-GROUPS|FIELD-SYMBOLS|FIELD-SYMBOL|FUNCTION-POOL|' r'INTERFACE-POOL|INVERTED-DATE|' r'LOAD-OF-PROGRAM|LOG-POINT|' r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|' r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|' r'OUTPUT-LENGTH|PRINT-CONTROL|' r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|' r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|' r'TYPE-POOL|TYPE-POOLS|NO-DISPLAY' r')\b', Keyword),
# keyword kombinations (r'(?<![-\>])(CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|' r'(PUBLIC|PRIVATE|PROTECTED)\s+SECTION|' r'(TYPE|LIKE)\s+((LINE\s+OF|REF\s+TO|' r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|' r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|' r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|' r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|' r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|' r'RUN\s+TIME|TIME\s+(STAMP)?)?|' r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|' r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|' r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|' r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|' r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|' r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|' r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|' r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|' r'DATABASE|SHARED\s+(MEMORY|BUFFER))|' r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|' r'FREE\s(MEMORY|OBJECT)?|' r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|' r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|' r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|' r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|' r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|' r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|' r'SCREEN)|COMMENT|FUNCTION\s+KEY|' r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|' r'SKIP|ULINE)|' r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|' r'TO LIST-PROCESSING|TO TRANSACTION)' r'(ENDING|STARTING)\s+AT|' r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|' r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|' r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|' r'(BEGIN|END)\s+OF|' r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|' r'COMPARING(\s+ALL\s+FIELDS)?|' r'(INSERT|APPEND)(\s+INITIAL\s+LINE\s+(IN)?TO|\s+LINES\s+OF)?|' r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|' r'END-OF-(DEFINITION|PAGE|SELECTION)|' r'WITH\s+FRAME(\s+TITLE)|' r'(REPLACE|FIND)\s+((FIRST|ALL)\s+OCCURRENCES?\s+OF\s+)?(SUBSTRING|REGEX)?|' r'MATCH\s+(LENGTH|COUNT|LINE|OFFSET)|' r'(RESPECTING|IGNORING)\s+CASE|' r'IN\s+UPDATE\s+TASK|' r'(SOURCE|RESULT)\s+(XML)?|' r'REFERENCE\s+INTO|'
# simple kombinations r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|' r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|' r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|' r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|' r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|' r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|' r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE|COMMON\s+PART)\b', Keyword),
# single word keywords. (r'(^|(?<=(\s|\.)))(ABBREVIATED|ABSTRACT|ADD|ALIASES|ALIGN|ALPHA|' r'ASSERT|AS|ASSIGN(ING)?|AT(\s+FIRST)?|' r'BACK|BLOCK|BREAK-POINT|' r'CASE|CAST|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|COND|CONV|' r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|' r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|COUNTRY|CURRENCY|' r'DATA|DATE|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|' r'DETAIL|DIRECTORY|DIVIDE|DO|DUMMY|' r'ELSE(IF)?|ENDAT|ENDCASE|ENDCATCH|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|' r'ENDIF|ENDINTERFACE|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|ENDWHILE|' r'ENHANCEMENT|EVENTS|EXACT|EXCEPTIONS?|EXIT|EXPONENT|EXPORT|EXPORTING|EXTRACT|' r'FETCH|FIELDS?|FOR|FORM|FORMAT|FREE|FROM|FUNCTION|' r'HIDE|' r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|' r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|' r'LANGUAGE|LEAVE|LENGTH|LINES|LOAD|LOCAL|' r'JOIN|' r'KEY|' r'NEW|NEXT|' r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFIER|MODIFY|MOVE|MULTIPLY|' r'NODES|NUMBER|' r'OBLIGATORY|OBJECT|OF|OFF|ON|OTHERS|OVERLAY|' r'PACK|PAD|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|PF\d\d|' r'RAISE|RAISING|RANGES?|READ|RECEIVE|REDEFINITION|REFRESH|REJECT|REPORT|RESERVE|' r'REF|RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|REPLACE|' r'SCROLL|SEARCH|SELECT|SHIFT|SIGN|SINGLE|SIZE|SKIP|SORT|SPLIT|STATICS|STOP|' r'STYLE|SUBMATCHES|SUBMIT|SUBTRACT|SUM(?!\()|SUMMARY|SUMMING|SUPPLY|SWITCH|' r'TABLE|TABLES|TIMESTAMP|TIMES?|TIMEZONE|TITLE|\??TO|' r'TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|' r'ULINE|UNDER|UNPACK|UPDATE|USING|' r'VALUE|VALUES|VIA|VARYING|VARY|' r'WAIT|WHEN|WHERE|WIDTH|WHILE|WITH|WINDOW|WRITE|XSD|ZERO)\b', Keyword),
# builtins (r'(abs|acos|asin|atan|' r'boolc|boolx|bit_set|' r'char_off|charlen|ceil|cmax|cmin|condense|contains|' r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|' r'count|count_any_of|count_any_not_of|' r'dbmaxlen|distance|' r'escape|exp|' r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|' r'insert|' r'lines|log|log10|' r'match|matches|' r'nmax|nmin|numofchar|' r'repeat|replace|rescale|reverse|round|' r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|' r'substring|substring_after|substring_from|substring_before|substring_to|' r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|' r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)),
(r'&[0-9]', Name), (r'[0-9]+', Number.Integer),
# operators which look like variable names before # parsing variable names. (r'(?<=(\s|.))(AND|OR|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|' r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|' r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator.Word),
include('variable-names'),
# standard operators after variable names, # because < and > are part of field symbols. (r'[?*<>=\-+&]', Operator), (r"'(''|[^'])*'", String.Single), (r"`([^`])*`", String.Single), (r"([|}])([^{}|]*?)([|{])", bygroups(Punctuation, String.Single, Punctuation)), (r'[/;:()\[\],.]', Punctuation), (r'(!)(\w+)', bygroups(Operator, Name)), ], }
class OpenEdgeLexer(RegexLexer): """ Lexer for OpenEdge ABL (formerly Progress) source code. """ name = 'OpenEdge ABL' aliases = ['openedge', 'abl', 'progress'] filenames = ['*.p', '*.cls'] mimetypes = ['text/x-openedge', 'application/x-openedge'] url = 'https://www.progress.com/openedge/features/abl' version_added = '1.5'
types = (r'(?i)(^|(?<=[^\w\-]))(CHARACTER|CHAR|CHARA|CHARAC|CHARACT|CHARACTE|' r'COM-HANDLE|DATE|DATETIME|DATETIME-TZ|' r'DECIMAL|DEC|DECI|DECIM|DECIMA|HANDLE|' r'INT64|INTEGER|INT|INTE|INTEG|INTEGE|' r'LOGICAL|LONGCHAR|MEMPTR|RAW|RECID|ROWID)\s*($|(?=[^\w\-]))')
keywords = words(OPENEDGEKEYWORDS, prefix=r'(?i)(^|(?<=[^\w\-]))', suffix=r'\s*($|(?=[^\w\-]))')
tokens = { 'root': [ (r'/\*', Comment.Multiline, 'comment'), (r'\{', Comment.Preproc, 'preprocessor'), (r'\s*&.*', Comment.Preproc), (r'0[xX][0-9a-fA-F]+[LlUu]*', Number.Hex), (r'(?i)(DEFINE|DEF|DEFI|DEFIN)\b', Keyword.Declaration), (types, Keyword.Type), (keywords, Name.Builtin), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'[0-9]+', Number.Integer), (r'\s+', Whitespace), (r'[+*/=-]', Operator), (r'[.:()]', Punctuation), (r'.', Name.Variable), # Lazy catch-all ], 'comment': [ (r'[^*/]', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline) ], 'preprocessor': [ (r'[^{}]', Comment.Preproc), (r'\{', Comment.Preproc, '#push'), (r'\}', Comment.Preproc, '#pop'), ], }
def analyse_text(text): """Try to identify OpenEdge ABL based on a few common constructs.""" result = 0
if 'END.' in text: result += 0.05
if 'END PROCEDURE.' in text: result += 0.05
if 'ELSE DO:' in text: result += 0.05
return result
class GoodDataCLLexer(RegexLexer): """ Lexer for GoodData-CL script files. """
name = 'GoodData-CL' aliases = ['gooddata-cl'] filenames = ['*.gdc'] mimetypes = ['text/x-gooddata-cl'] url = 'https://github.com/gooddata/GoodData-CL' version_added = '1.4'
flags = re.IGNORECASE
# Syntax: # https://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt tokens = { 'root': [ # Comments (r'#.*', Comment.Single), # Function call (r'[a-z]\w*', Name.Function), # Argument list (r'\(', Punctuation, 'args-list'), # Punctuation (r';', Punctuation), # Space is not significant (r'\s+', Text) ], 'args-list': [ (r'\)', Punctuation, '#pop'), (r',', Punctuation), (r'[a-z]\w*', Name.Variable), (r'=', Operator), (r'"', String, 'string-literal'), (r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number), # Space is not significant (r'\s', Whitespace) ], 'string-literal': [ (r'\\[tnrfbae"\\]', String.Escape), (r'"', String, '#pop'), (r'[^\\"]+', String) ] }
class MaqlLexer(RegexLexer): """ Lexer for GoodData MAQL scripts. """
name = 'MAQL' aliases = ['maql'] filenames = ['*.maql'] mimetypes = ['text/x-gooddata-maql', 'application/x-gooddata-maql'] url = 'https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/maql-analytical-query-language' version_added = '1.4'
flags = re.IGNORECASE tokens = { 'root': [ # IDENTITY (r'IDENTIFIER\b', Name.Builtin), # IDENTIFIER (r'\{[^}]+\}', Name.Variable), # NUMBER (r'[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]{1,3})?', Number), # STRING (r'"', String, 'string-literal'), # RELATION (r'\<\>|\!\=', Operator), (r'\=|\>\=|\>|\<\=|\<', Operator), # := (r'\:\=', Operator), # OBJECT (r'\[[^]]+\]', Name.Variable.Class), # keywords (words(( 'DIMENSION', 'DIMENSIONS', 'BOTTOM', 'METRIC', 'COUNT', 'OTHER', 'FACT', 'WITH', 'TOP', 'OR', 'ATTRIBUTE', 'CREATE', 'PARENT', 'FALSE', 'ROW', 'ROWS', 'FROM', 'ALL', 'AS', 'PF', 'COLUMN', 'COLUMNS', 'DEFINE', 'REPORT', 'LIMIT', 'TABLE', 'LIKE', 'AND', 'BY', 'BETWEEN', 'EXCEPT', 'SELECT', 'MATCH', 'WHERE', 'TRUE', 'FOR', 'IN', 'WITHOUT', 'FILTER', 'ALIAS', 'WHEN', 'NOT', 'ON', 'KEYS', 'KEY', 'FULLSET', 'PRIMARY', 'LABELS', 'LABEL', 'VISUAL', 'TITLE', 'DESCRIPTION', 'FOLDER', 'ALTER', 'DROP', 'ADD', 'DATASET', 'DATATYPE', 'INT', 'BIGINT', 'DOUBLE', 'DATE', 'VARCHAR', 'DECIMAL', 'SYNCHRONIZE', 'TYPE', 'DEFAULT', 'ORDER', 'ASC', 'DESC', 'HYPERLINK', 'INCLUDE', 'TEMPLATE', 'MODIFY'), suffix=r'\b'), Keyword), # FUNCNAME (r'[a-z]\w*\b', Name.Function), # Comments (r'#.*', Comment.Single), # Punctuation (r'[,;()]', Punctuation), # Space is not significant (r'\s+', Whitespace) ], 'string-literal': [ (r'\\[tnrfbae"\\]', String.Escape), (r'"', String, '#pop'), (r'[^\\"]+', String) ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415""" pygments.lexers.c_cpp ~~~~~~~~~~~~~~~~~~~~~
Lexers for C/C++ languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, using, \ this, inherit, default, wordsfrom pygments.util import get_bool_optfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['CLexer', 'CppLexer']
class CFamilyLexer(RegexLexer): """ For C family source code. This is used as a base class to avoid repetitious definitions. """
# The trailing ?, rather than *, avoids a geometric performance drop here. #: only one /* */ style comment _ws1 = r'\s*(?:/[*].*?[*]/\s*)?'
# Hexadecimal part in an hexadecimal integer/floating-point literal. # This includes decimal separators matching. _hexpart = r'[0-9a-fA-F](\'?[0-9a-fA-F])*' # Decimal part in an decimal integer/floating-point literal. # This includes decimal separators matching. _decpart = r'\d(\'?\d)*' # Integer literal suffix (e.g. 'ull' or 'll'). _intsuffix = r'(([uU]?[zZ])|([zZ][uU])|([uU][lL]{0,2})|([lL]{1,2}[uU]?))?'
# Identifier regex with C and C++ Universal Character Name (UCN) support. _ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})+' _namespaced_ident = r'(?!\d)(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|::)+'
# Single and multiline comment regexes # Beware not to use *? for the inner content! When these regexes # are embedded in larger regexes, that can cause the stuff*? to # match more than it would have if the regex had been used in # a standalone way ... _comment_single = r'//(?:.|(?<=\\)\n)*\n' _comment_multiline = r'/(?:\\\n)?[*](?:[^*]|[*](?!(?:\\\n)?/))*[*](?:\\\n)?/'
# Regex to match optional comments _possible_comments = rf'\s*(?:(?:(?:{_comment_single})|(?:{_comment_multiline}))\s*)*'
tokens = { 'whitespace': [ # preprocessor directives: without whitespace (r'^#if\s+0', Comment.Preproc, 'if0'), ('^#', Comment.Preproc, 'macro'), # or with whitespace ('^(' + _ws1 + r')(#if\s+0)', bygroups(using(this), Comment.Preproc), 'if0'), ('^(' + _ws1 + ')(#)', bygroups(using(this), Comment.Preproc), 'macro'), # Labels: # Line start and possible indentation. (r'(^[ \t]*)' # Not followed by keywords which can be mistaken as labels. r'(?!(?:public|private|protected|default)\b)' # Actual label, followed by a single colon. r'(' + _ident + r')(\s*)(:)(?!:)', bygroups(Whitespace, Name.Label, Whitespace, Punctuation)), (r'\n', Whitespace), (r'[^\S\n]+', Whitespace), (r'\\\n', Text), # line continuation (_comment_single, Comment.Single), (_comment_multiline, Comment.Multiline), # Open until EOF, so no ending delimiter (r'/(\\\n)?[*][\w\W]*', Comment.Multiline), ], 'statements': [ include('keywords'), include('types'), (r'([LuU]|u8)?(")', bygroups(String.Affix, String), 'string'), (r"([LuU]|u8)?(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')", bygroups(String.Affix, String.Char, String.Char, String.Char)),
# Hexadecimal floating-point literals (C11, C++17) (r'0[xX](' + _hexpart + r'\.' + _hexpart + r'|\.' + _hexpart + r'|' + _hexpart + r')[pP][+-]?' + _hexpart + r'[lL]?', Number.Float),
(r'(-)?(' + _decpart + r'\.' + _decpart + r'|\.' + _decpart + r'|' + _decpart + r')[eE][+-]?' + _decpart + r'[fFlL]?', Number.Float), (r'(-)?((' + _decpart + r'\.(' + _decpart + r')?|\.' + _decpart + r')[fFlL]?)|(' + _decpart + r'[fFlL])', Number.Float), (r'(-)?0[xX]' + _hexpart + _intsuffix, Number.Hex), (r'(-)?0[bB][01](\'?[01])*' + _intsuffix, Number.Bin), (r'(-)?0(\'?[0-7])+' + _intsuffix, Number.Oct), (r'(-)?' + _decpart + _intsuffix, Number.Integer), (r'[~!%^&*+=|?:<>/-]', Operator), (r'[()\[\],.]', Punctuation), (r'(true|false|NULL|nullptr)\b', Name.Builtin), (_ident, Name) ], 'types': [ (words(('int8', 'int16', 'int32', 'int64', 'wchar_t'), prefix=r'__', suffix=r'\b'), Keyword.Reserved), (words(('bool', 'int', 'long', 'float', 'short', 'double', 'char', 'unsigned', 'signed', 'void', '_BitInt', '__int128'), suffix=r'\b'), Keyword.Type) ], 'keywords': [ (r'(struct|union)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (r'case\b', Keyword, 'case-value'), (words(('asm', 'auto', 'break', 'const', 'constexpr', 'continue', 'default', 'do', 'else', 'enum', 'extern', 'for', 'goto', 'if', 'register', 'restricted', 'return', 'sizeof', 'struct', 'static', 'switch', 'typedef', 'typeof', 'typeof_unqual', 'volatile', 'while', 'union', 'thread_local', 'alignas', 'alignof', 'static_assert', '_Pragma', 'fortran'), suffix=r'\b'), Keyword), (words(('inline', '_inline', '__inline', 'naked', 'restrict', 'thread'), suffix=r'\b'), Keyword.Reserved), # Vector intrinsics (r'(__m(128i|128d|128|64))\b', Keyword.Reserved), # Microsoft-isms (words(( 'asm', 'based', 'except', 'stdcall', 'cdecl', 'fastcall', 'declspec', 'finally', 'try', 'leave', 'w64', 'unaligned', 'raise', 'noop', 'identifier', 'forceinline', 'assume', 'null'), prefix=r'__', suffix=r'\b'), Keyword.Reserved) ], 'root': [ include('whitespace'), include('keywords'), # functions (r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments r'(' + _possible_comments + r')' r'(' + _namespaced_ident + r')' # method name r'(' + _possible_comments + r')' r'(\([^;"\')]*?\))' # signature r'(' + _possible_comments + r')' r'([^;{/"\']*)(\{)', bygroups(using(this), using(this, state='whitespace'), Name.Function, using(this, state='whitespace'), using(this), using(this, state='whitespace'), using(this), Punctuation), 'function'), # function declarations (r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments r'(' + _possible_comments + r')' r'(' + _namespaced_ident + r')' # method name r'(' + _possible_comments + r')' r'(\([^;"\')]*?\))' # signature r'(' + _possible_comments + r')' r'([^;/"\']*)(;)', bygroups(using(this), using(this, state='whitespace'), Name.Function, using(this, state='whitespace'), using(this), using(this, state='whitespace'), using(this), Punctuation)), include('types'), default('statement'), ], 'statement': [ include('whitespace'), include('statements'), (r'\}', Punctuation), (r'[{;]', Punctuation, '#pop'), ], 'function': [ include('whitespace'), include('statements'), (';', Punctuation), (r'\{', Punctuation, '#push'), (r'\}', Punctuation, '#pop'), ], 'string': [ (r'"', String, '#pop'), (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|' r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape), (r'[^\\"\n]+', String), # all other characters (r'\\\n', String), # line continuation (r'\\', String), # stray backslash ], 'macro': [ (r'('+_ws1+r')(include)('+_ws1+r')("[^"]+")([^\n]*)', bygroups(using(this), Comment.Preproc, using(this), Comment.PreprocFile, Comment.Single)), (r'('+_ws1+r')(include)('+_ws1+r')(<[^>]+>)([^\n]*)', bygroups(using(this), Comment.Preproc, using(this), Comment.PreprocFile, Comment.Single)), (r'[^/\n]+', Comment.Preproc), (r'/[*](.|\n)*?[*]/', Comment.Multiline), (r'//.*?\n', Comment.Single, '#pop'), (r'/', Comment.Preproc), (r'(?<=\\)\n', Comment.Preproc), (r'\n', Comment.Preproc, '#pop'), ], 'if0': [ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'), (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'), (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'), (r'.*?\n', Comment), ], 'classname': [ (_ident, Name.Class, '#pop'), # template specification (r'\s*(?=>)', Text, '#pop'), default('#pop') ], # Mark identifiers preceded by `case` keyword as constants. 'case-value': [ (r'(?<!:)(:)(?!:)', Punctuation, '#pop'), (_ident, Name.Constant), include('whitespace'), include('statements'), ] }
stdlib_types = { 'size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t', 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list', 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t', 'wctrans_t', 'wint_t', 'wctype_t'} c99_types = { 'int8_t', 'int16_t', 'int32_t', 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t', 'int_least16_t', 'int_least32_t', 'int_least64_t', 'uint_least8_t', 'uint_least16_t', 'uint_least32_t', 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t', 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t', 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t'} linux_types = { 'clockid_t', 'cpu_set_t', 'cpumask_t', 'dev_t', 'gid_t', 'id_t', 'ino_t', 'key_t', 'mode_t', 'nfds_t', 'pid_t', 'rlim_t', 'sig_t', 'sighandler_t', 'siginfo_t', 'sigset_t', 'sigval_t', 'socklen_t', 'timer_t', 'uid_t'} c11_atomic_types = { 'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short', 'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong', 'atomic_llong', 'atomic_ullong', 'atomic_char16_t', 'atomic_char32_t', 'atomic_wchar_t', 'atomic_int_least8_t', 'atomic_uint_least8_t', 'atomic_int_least16_t', 'atomic_uint_least16_t', 'atomic_int_least32_t', 'atomic_uint_least32_t', 'atomic_int_least64_t', 'atomic_uint_least64_t', 'atomic_int_fast8_t', 'atomic_uint_fast8_t', 'atomic_int_fast16_t', 'atomic_uint_fast16_t', 'atomic_int_fast32_t', 'atomic_uint_fast32_t', 'atomic_int_fast64_t', 'atomic_uint_fast64_t', 'atomic_intptr_t', 'atomic_uintptr_t', 'atomic_size_t', 'atomic_ptrdiff_t', 'atomic_intmax_t', 'atomic_uintmax_t'}
def __init__(self, **options): self.stdlibhighlighting = get_bool_opt(options, 'stdlibhighlighting', True) self.c99highlighting = get_bool_opt(options, 'c99highlighting', True) self.c11highlighting = get_bool_opt(options, 'c11highlighting', True) self.platformhighlighting = get_bool_opt(options, 'platformhighlighting', True) RegexLexer.__init__(self, **options)
def get_tokens_unprocessed(self, text, stack=('root',)): for index, token, value in \ RegexLexer.get_tokens_unprocessed(self, text, stack): if token is Name: if self.stdlibhighlighting and value in self.stdlib_types: token = Keyword.Type elif self.c99highlighting and value in self.c99_types: token = Keyword.Type elif self.c11highlighting and value in self.c11_atomic_types: token = Keyword.Type elif self.platformhighlighting and value in self.linux_types: token = Keyword.Type yield index, token, value
class CLexer(CFamilyLexer): """ For C source code with preprocessor directives.
Additional options accepted:
`stdlibhighlighting` Highlight common types found in the C/C++ standard library (e.g. `size_t`). (default: ``True``).
`c99highlighting` Highlight common types found in the C99 standard library (e.g. `int8_t`). Actually, this includes all fixed-width integer types. (default: ``True``).
`c11highlighting` Highlight atomic types found in the C11 standard library (e.g. `atomic_bool`). (default: ``True``).
`platformhighlighting` Highlight common types found in the platform SDK headers (e.g. `clockid_t` on Linux). (default: ``True``). """ name = 'C' aliases = ['c'] filenames = ['*.c', '*.h', '*.idc', '*.x[bp]m'] mimetypes = ['text/x-chdr', 'text/x-csrc', 'image/x-xbitmap', 'image/x-xpixmap'] url = 'https://en.wikipedia.org/wiki/C_(programming_language)' version_added = '' priority = 0.1
tokens = { 'keywords': [ (words(( '_Alignas', '_Alignof', '_Noreturn', '_Countof', '_Generic', '_Thread_local', '_Static_assert', '_Imaginary', 'countof', 'noreturn', 'imaginary', 'complex'), suffix=r'\b'), Keyword), inherit ], 'types': [ (words(('_Bool', '_Complex', '_Atomic', '_Decimal32', '_Decimal64', '_Decimal128'), suffix=r'\b'), Keyword.Type), inherit ] }
def analyse_text(text): if re.search(r'^\s*#include [<"]', text, re.MULTILINE): return 0.1 if re.search(r'^\s*#ifn?def ', text, re.MULTILINE): return 0.1
class CppLexer(CFamilyLexer): """ For C++ source code with preprocessor directives.
Additional options accepted:
`stdlibhighlighting` Highlight common types found in the C/C++ standard library (e.g. `size_t`). (default: ``True``).
`c99highlighting` Highlight common types found in the C99 standard library (e.g. `int8_t`). Actually, this includes all fixed-width integer types. (default: ``True``).
`c11highlighting` Highlight atomic types found in the C11 standard library (e.g. `atomic_bool`). (default: ``True``).
`platformhighlighting` Highlight common types found in the platform SDK headers (e.g. `clockid_t` on Linux). (default: ``True``). """ name = 'C++' url = 'https://isocpp.org/' aliases = ['cpp', 'c++'] filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp', '*.CPP', '*.tpp', '*.cppm', '*.ixx', '*.mxx'] mimetypes = ['text/x-c++hdr', 'text/x-c++src'] version_added = '' priority = 0.1
tokens = { 'statements': [ # C++11 raw strings (r'((?:[LuU]|u8)?R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")', bygroups(String.Affix, String, String.Delimiter, String.Delimiter, String, String.Delimiter, String)), inherit, ], 'root': [ inherit, # C++ Microsoft-isms (words(('virtual_inheritance', 'uuidof', 'super', 'extends', 'single_inheritance', 'multiple_inheritance', 'interface', 'implements', 'event', 'finally', 'null'), prefix=r'__', suffix=r'\b'), Keyword.Reserved), # Offload C++ extensions, http://offload.codeplay.com/ (r'__(offload|blockingoffload|outer)\b', Keyword.Pseudo), ], 'enumname': [ include('whitespace'), # 'enum class' and 'enum struct' C++11 support (words(('class', 'struct'), suffix=r'\b'), Keyword), (CFamilyLexer._ident, Name.Class, '#pop'), # template specification (r'\s*(?=>)', Text, '#pop'), default('#pop') ], 'keywords': [ (r'(class|concept|typename)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (words(( 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', 'export', 'friend', 'mutable', 'new', 'operator', 'private', 'protected', 'public', 'reinterpret_cast', 'class', '__restrict', 'static_cast', 'template', 'this', 'throw', 'throws', 'try', 'typeid', 'using', 'virtual', 'concept', 'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval', 'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module', 'typename', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq', 'contract_assert', 'pre', 'post'), suffix=r'\b'), Keyword), (r'namespace\b', Keyword, 'namespace'), (r'(enum)(\s+)', bygroups(Keyword, Whitespace), 'enumname'), inherit ], 'types': [ (r'char(16_t|32_t|8_t)\b', Keyword.Type), inherit ], 'namespace': [ (r'[;{]', Punctuation, ('#pop', 'root')), (r'inline\b', Keyword.Reserved), (CFamilyLexer._ident, Name.Namespace), include('statement') ] }
def analyse_text(text): if re.search('#include <[a-z_]+>', text): return 0.2 if re.search('using namespace ', text): return 0.4123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738""" pygments.lexers.c_like ~~~~~~~~~~~~~~~~~~~~~~
Lexers for other C-like languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \ defaultfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
from pygments.lexers.c_cpp import CLexer, CppLexerfrom pygments.lexers import _mql_builtins
__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer', 'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer', 'OmgIdlLexer', 'PromelaLexer']
class PikeLexer(CppLexer): """ For `Pike <http://pike.lysator.liu.se/>`_ source code. """ name = 'Pike' aliases = ['pike'] filenames = ['*.pike', '*.pmod'] mimetypes = ['text/x-pike'] version_added = '2.0'
tokens = { 'statements': [ (words(( 'catch', 'new', 'private', 'protected', 'public', 'gauge', 'throw', 'throws', 'class', 'interface', 'implement', 'abstract', 'extends', 'from', 'this', 'super', 'constant', 'final', 'static', 'import', 'use', 'extern', 'inline', 'proto', 'break', 'continue', 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'as', 'in', 'version', 'return', 'true', 'false', 'null', '__VERSION__', '__MAJOR__', '__MINOR__', '__BUILD__', '__REAL_VERSION__', '__REAL_MAJOR__', '__REAL_MINOR__', '__REAL_BUILD__', '__DATE__', '__TIME__', '__FILE__', '__DIR__', '__LINE__', '__AUTO_BIGNUM__', '__NT__', '__PIKE__', '__amigaos__', '_Pragma', 'static_assert', 'defined', 'sscanf'), suffix=r'\b'), Keyword), (r'(bool|int|long|float|short|double|char|string|object|void|mapping|' r'array|multiset|program|function|lambda|mixed|' r'[a-z_][a-z0-9_]*_t)\b', Keyword.Type), (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (r'[~!%^&*+=|?:<>/@-]', Operator), inherit, ], 'classname': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop'), # template specification (r'\s*(?=>)', Whitespace, '#pop'), ], }
class NesCLexer(CLexer): """ For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor directives. """ name = 'nesC' aliases = ['nesc'] filenames = ['*.nc'] mimetypes = ['text/x-nescsrc'] version_added = '2.0'
tokens = { 'statements': [ (words(( 'abstract', 'as', 'async', 'atomic', 'call', 'command', 'component', 'components', 'configuration', 'event', 'extends', 'generic', 'implementation', 'includes', 'interface', 'module', 'new', 'norace', 'post', 'provides', 'signal', 'task', 'uses'), suffix=r'\b'), Keyword), (words(('nx_struct', 'nx_union', 'nx_int8_t', 'nx_int16_t', 'nx_int32_t', 'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t', 'nx_uint64_t'), suffix=r'\b'), Keyword.Type), inherit, ], }
class ClayLexer(RegexLexer): """ For Clay source. """ name = 'Clay' filenames = ['*.clay'] aliases = ['clay'] mimetypes = ['text/x-clay'] url = 'http://claylabs.com/clay' version_added = '2.0'
tokens = { 'root': [ (r'\s+', Whitespace), (r'//.*?$', Comment.Single), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), (r'\b(public|private|import|as|record|variant|instance' r'|define|overload|default|external|alias' r'|rvalue|ref|forward|inline|noinline|forceinline' r'|enum|var|and|or|not|if|else|goto|return|while' r'|switch|case|break|continue|for|in|true|false|try|catch|throw' r'|finally|onerror|staticassert|eval|when|newtype' r'|__FILE__|__LINE__|__COLUMN__|__ARG__' r')\b', Keyword), (r'[~!%^&*+=|:<>/-]', Operator), (r'[#(){}\[\],;.]', Punctuation), (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex), (r'\d+[LlUu]*', Number.Integer), (r'\b(true|false)\b', Name.Builtin), (r'(?i)[a-z_?][\w?]*', Name), (r'"""', String, 'tdqs'), (r'"', String, 'dqs'), ], 'strings': [ (r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape), (r'[^\\"]+', String), ], 'nl': [ (r'\n', String), ], 'dqs': [ (r'"', String, '#pop'), include('strings'), ], 'tdqs': [ (r'"""', String, '#pop'), include('strings'), include('nl'), ], }
class ECLexer(CLexer): """ For eC source code with preprocessor directives. """ name = 'eC' aliases = ['ec'] filenames = ['*.ec', '*.eh'] mimetypes = ['text/x-echdr', 'text/x-ecsrc'] url = 'https://ec-lang.org' version_added = '1.5'
tokens = { 'statements': [ (words(( 'virtual', 'class', 'private', 'public', 'property', 'import', 'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get', 'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass', '__on_register_module', 'namespace', 'using', 'typed_object', 'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers', 'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset', 'class_default_property', 'property_category', 'class_data', 'class_property', 'thisclass', 'dbtable', 'dbindex', 'database_open', 'dbfield'), suffix=r'\b'), Keyword), (words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte', 'unichar', 'int64'), suffix=r'\b'), Keyword.Type), (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (r'(null|value|this)\b', Name.Builtin), inherit, ] }
class ValaLexer(RegexLexer): """ For Vala source code with preprocessor directives. """ name = 'Vala' aliases = ['vala', 'vapi'] filenames = ['*.vala', '*.vapi'] mimetypes = ['text/x-vala'] url = 'https://vala.dev' version_added = '1.1'
tokens = { 'whitespace': [ (r'^\s*#if\s+0', Comment.Preproc, 'if0'), (r'\n', Whitespace), (r'\s+', Whitespace), (r'\\\n', Text), # line continuation (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), ], 'statements': [ (r'[L@]?"', String, 'string'), (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char), (r'(?s)""".*?"""', String), # verbatim strings (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), (r'0[0-7]+[Ll]?', Number.Oct), (r'\d+[Ll]?', Number.Integer), (r'[~!%^&*+=|?:<>/-]', Operator), (r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])', bygroups(Punctuation, Name.Decorator, Punctuation)), # TODO: "correctly" parse complex code attributes (r'(\[)(CCode|(?:Integer|Floating)Type)', bygroups(Punctuation, Name.Decorator)), (r'[()\[\],.]', Punctuation), (words(( 'as', 'base', 'break', 'case', 'catch', 'construct', 'continue', 'default', 'delete', 'do', 'else', 'enum', 'finally', 'for', 'foreach', 'get', 'if', 'in', 'is', 'lock', 'new', 'out', 'params', 'return', 'set', 'sizeof', 'switch', 'this', 'throw', 'try', 'typeof', 'while', 'yield'), suffix=r'\b'), Keyword), (words(( 'abstract', 'const', 'delegate', 'dynamic', 'ensures', 'extern', 'inline', 'internal', 'override', 'owned', 'private', 'protected', 'public', 'ref', 'requires', 'signal', 'static', 'throws', 'unowned', 'var', 'virtual', 'volatile', 'weak', 'yields'), suffix=r'\b'), Keyword.Declaration), (r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Whitespace), 'namespace'), (r'(class|errordomain|interface|struct)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'class'), (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), # void is an actual keyword, others are in glib-2.0.vapi (words(( 'void', 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16', 'int32', 'int64', 'long', 'short', 'size_t', 'ssize_t', 'string', 'time_t', 'uchar', 'uint', 'uint8', 'uint16', 'uint32', 'uint64', 'ulong', 'unichar', 'ushort'), suffix=r'\b'), Keyword.Type), (r'(true|false|null)\b', Name.Builtin), (r'[a-zA-Z_]\w*', Name), ], 'root': [ include('whitespace'), default('statement'), ], 'statement': [ include('whitespace'), include('statements'), ('[{}]', Punctuation), (';', Punctuation, '#pop'), ], 'string': [ (r'"', String, '#pop'), (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), (r'[^\\"\n]+', String), # all other characters (r'\\\n', String), # line continuation (r'\\', String), # stray backslash ], 'if0': [ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'), (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'), (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'), (r'.*?\n', Comment), ], 'class': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop') ], 'namespace': [ (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop') ], }
class CudaLexer(CLexer): """ For NVIDIA CUDA™ source. """ name = 'CUDA' filenames = ['*.cu', '*.cuh'] aliases = ['cuda', 'cu'] mimetypes = ['text/x-cuda'] url = 'https://developer.nvidia.com/category/zone/cuda-zone' version_added = '1.6'
function_qualifiers = {'__device__', '__global__', '__host__', '__noinline__', '__forceinline__'} variable_qualifiers = {'__device__', '__constant__', '__shared__', '__restrict__'} vector_types = {'char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3', 'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2', 'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1', 'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1', 'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4', 'ulong4', 'longlong1', 'ulonglong1', 'longlong2', 'ulonglong2', 'float1', 'float2', 'float3', 'float4', 'double1', 'double2', 'dim3'} variables = {'gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize'} functions = {'__threadfence_block', '__threadfence', '__threadfence_system', '__syncthreads', '__syncthreads_count', '__syncthreads_and', '__syncthreads_or'} execution_confs = {'<<<', '>>>'}
def get_tokens_unprocessed(self, text, stack=('root',)): for index, token, value in CLexer.get_tokens_unprocessed(self, text, stack): if token is Name: if value in self.variable_qualifiers: token = Keyword.Type elif value in self.vector_types: token = Keyword.Type elif value in self.variables: token = Name.Builtin elif value in self.execution_confs: token = Keyword.Pseudo elif value in self.function_qualifiers: token = Keyword.Reserved elif value in self.functions: token = Name.Function yield index, token, value
class SwigLexer(CppLexer): """ For `SWIG <http://www.swig.org/>`_ source code. """ name = 'SWIG' aliases = ['swig'] filenames = ['*.swg', '*.i'] mimetypes = ['text/swig'] version_added = '2.0' priority = 0.04 # Lower than C/C++ and Objective C/C++
tokens = { 'root': [ # Match it here so it won't be matched as a function in the rest of root (r'\$\**\&?\w+', Name), inherit ], 'statements': [ # SWIG directives (r'(%[a-z_][a-z0-9_]*)', Name.Function), # Special variables (r'\$\**\&?\w+', Name), # Stringification / additional preprocessor directives (r'##*[a-zA-Z_]\w*', Comment.Preproc), inherit, ], }
# This is a far from complete set of SWIG directives swig_directives = { # Most common directives '%apply', '%define', '%director', '%enddef', '%exception', '%extend', '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include', '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma', '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap', # Less common directives '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear', '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum', '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor', '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor', '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments', '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv', '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception', '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar', '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend', '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall', '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof', '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter'}
def analyse_text(text): rv = 0 # Search for SWIG directives, which are conventionally at the beginning of # a line. The probability of them being within a line is low, so let another # lexer win in this case. matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M) for m in matches: if m in SwigLexer.swig_directives: rv = 0.98 break else: rv = 0.91 # Fraction higher than MatlabLexer return rv
class MqlLexer(CppLexer): """ For `MQL4 <http://docs.mql4.com/>`_ and `MQL5 <http://www.mql5.com/en/docs>`_ source code. """ name = 'MQL' aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5'] filenames = ['*.mq4', '*.mq5', '*.mqh'] mimetypes = ['text/x-mql'] version_added = '2.0'
tokens = { 'statements': [ (words(_mql_builtins.keywords, suffix=r'\b'), Keyword), (words(_mql_builtins.c_types, suffix=r'\b'), Keyword.Type), (words(_mql_builtins.types, suffix=r'\b'), Name.Function), (words(_mql_builtins.constants, suffix=r'\b'), Name.Constant), (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'), Name.Constant), inherit, ], }
class ArduinoLexer(CppLexer): """ For `Arduino(tm) <https://arduino.cc/>`_ source.
This is an extension of the CppLexer, as the Arduino® Language is a superset of C++ """
name = 'Arduino' aliases = ['arduino'] filenames = ['*.ino'] mimetypes = ['text/x-arduino'] version_added = '2.1'
# Language sketch main structure functions structure = {'setup', 'loop'}
# Language operators operators = {'not', 'or', 'and', 'xor'}
# Language 'variables' variables = { 'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL', 'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET', 'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH', 'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false', 'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int', 'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String', 'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string', 'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator', 'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t', 'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const', 'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static', 'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern', 'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit', 'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary', 'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short', 'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong', 'atomic_llong', 'atomic_ullong', 'PROGMEM'}
# Language shipped functions and class ( ) functions = { 'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer', 'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall', 'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient', 'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer', 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console', 'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox', 'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO', 'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File', 'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD', 'runShellCommandAsynchronously', 'analogWriteResolution', 'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution', 'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton', 'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight', 'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds', 'delayMicroseconds', 'beginTransmission', 'getSignalStrength', 'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost', 'getCurrentCarrier', 'readAccelerometer', 'messageAvailable', 'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand', 'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider', 'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt', 'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil', 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite', 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased', 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker', 'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll', 'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead', 'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks', 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode', 'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory', 'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent', 'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased', 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect', 'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed', 'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite', 'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton', 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed', 'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll', 'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall', 'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON', 'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue', 'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex', 'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay', 'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile', 'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT', 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte', 'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer', 'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain', 'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn', 'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink', 'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand', 'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill', 'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer', 'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS', 'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready', 'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close', 'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move', 'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop', 'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan', 'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put', 'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit', 'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase', 'isHexadecimalDigit'}
# do not highlight suppress_highlight = { 'namespace', 'template', 'mutable', 'using', 'asm', 'typeid', 'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept', 'static_assert', 'thread_local', 'restrict'}
def get_tokens_unprocessed(self, text, stack=('root',)): for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack): if value in self.structure: yield index, Name.Builtin, value elif value in self.operators: yield index, Operator, value elif value in self.variables: yield index, Keyword.Reserved, value elif value in self.suppress_highlight: yield index, Name, value elif value in self.functions: yield index, Name.Function, value else: yield index, token, value
class CharmciLexer(CppLexer): """ For `Charm++ <https://charm.cs.illinois.edu>`_ interface files (.ci). """
name = 'Charmci' aliases = ['charmci'] filenames = ['*.ci'] version_added = '2.4'
mimetypes = []
tokens = { 'keywords': [ (r'(module)(\s+)', bygroups(Keyword, Text), 'classname'), (words(('mainmodule', 'mainchare', 'chare', 'array', 'group', 'nodegroup', 'message', 'conditional')), Keyword), (words(('entry', 'aggregate', 'threaded', 'sync', 'exclusive', 'nokeep', 'notrace', 'immediate', 'expedited', 'inline', 'local', 'python', 'accel', 'readwrite', 'writeonly', 'accelblock', 'memcritical', 'packed', 'varsize', 'initproc', 'initnode', 'initcall', 'stacksize', 'createhere', 'createhome', 'reductiontarget', 'iget', 'nocopy', 'mutable', 'migratable', 'readonly')), Keyword), inherit, ], }
class OmgIdlLexer(CLexer): """ Lexer for Object Management Group Interface Definition Language. """
name = 'OMG Interface Definition Language' url = 'https://www.omg.org/spec/IDL/About-IDL/' aliases = ['omg-idl'] filenames = ['*.idl', '*.pidl'] mimetypes = [] version_added = '2.9'
scoped_name = r'((::)?\w+)+'
tokens = { 'values': [ (words(('true', 'false'), prefix=r'(?i)', suffix=r'\b'), Number), (r'([Ll]?)(")', bygroups(String.Affix, String.Double), 'string'), (r'([Ll]?)(\')(\\[^\']+)(\')', bygroups(String.Affix, String.Char, String.Escape, String.Char)), (r'([Ll]?)(\')(\\\')(\')', bygroups(String.Affix, String.Char, String.Escape, String.Char)), (r'([Ll]?)(\'.\')', bygroups(String.Affix, String.Char)), (r'[+-]?\d+(\.\d*)?[Ee][+-]?\d+', Number.Float), (r'[+-]?(\d+\.\d*)|(\d*\.\d+)([Ee][+-]?\d+)?', Number.Float), (r'(?i)[+-]?0x[0-9a-f]+', Number.Hex), (r'[+-]?[1-9]\d*', Number.Integer), (r'[+-]?0[0-7]*', Number.Oct), (r'[\+\-\*\/%^&\|~]', Operator), (words(('<<', '>>')), Operator), (scoped_name, Name), (r'[{};:,<>\[\]]', Punctuation), ], 'annotation_params': [ include('whitespace'), (r'\(', Punctuation, '#push'), include('values'), (r'=', Punctuation), (r'\)', Punctuation, '#pop'), ], 'annotation_params_maybe': [ (r'\(', Punctuation, 'annotation_params'), include('whitespace'), default('#pop'), ], 'annotation_appl': [ (r'@' + scoped_name, Name.Decorator, 'annotation_params_maybe'), ], 'enum': [ include('whitespace'), (r'[{,]', Punctuation), (r'\w+', Name.Constant), include('annotation_appl'), (r'\}', Punctuation, '#pop'), ], 'root': [ include('whitespace'), (words(( 'typedef', 'const', 'in', 'out', 'inout', 'local', ), prefix=r'(?i)', suffix=r'\b'), Keyword.Declaration), (words(( 'void', 'any', 'native', 'bitfield', 'unsigned', 'boolean', 'char', 'wchar', 'octet', 'short', 'long', 'int8', 'uint8', 'int16', 'int32', 'int64', 'uint16', 'uint32', 'uint64', 'float', 'double', 'fixed', 'sequence', 'string', 'wstring', 'map', ), prefix=r'(?i)', suffix=r'\b'), Keyword.Type), (words(( '@annotation', 'struct', 'union', 'bitset', 'interface', 'exception', 'valuetype', 'eventtype', 'component', ), prefix=r'(?i)', suffix=r'(\s+)(\w+)'), bygroups(Keyword, Whitespace, Name.Class)), (words(( 'abstract', 'alias', 'attribute', 'case', 'connector', 'consumes', 'context', 'custom', 'default', 'emits', 'factory', 'finder', 'getraises', 'home', 'import', 'manages', 'mirrorport', 'multiple', 'Object', 'oneway', 'primarykey', 'private', 'port', 'porttype', 'provides', 'public', 'publishes', 'raises', 'readonly', 'setraises', 'supports', 'switch', 'truncatable', 'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase', ), prefix=r'(?i)', suffix=r'\b'), Keyword), (r'(?i)(enum|bitmask)(\s+)(\w+)', bygroups(Keyword, Whitespace, Name.Class), 'enum'), (r'(?i)(module)(\s+)(\w+)', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), (r'(\w+)(\s*)(=)', bygroups(Name.Constant, Whitespace, Operator)), (r'[\(\)]', Punctuation), include('values'), include('annotation_appl'), ], }
class PromelaLexer(CLexer): """ For the Promela language used with SPIN. """ name = 'Promela' aliases = ['promela'] filenames = ['*.pml', '*.prom', '*.prm', '*.promela', '*.pr', '*.pm'] mimetypes = ['text/x-promela'] url = 'https://spinroot.com/spin/whatispin.html' version_added = '2.18'
# Promela's language reference: # https://spinroot.com/spin/Man/promela.html # Promela's grammar definition: # https://spinroot.com/spin/Man/grammar.html
tokens = { 'statements': [ (r'(\[\]|<>|/\\|\\/)|(U|W|V)\b', Operator), # LTL Operators (r'@', Punctuation), #remoterefs (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), inherit ], 'types': [ # Predefined (data types) (words(( 'bit', 'bool', 'byte', 'pid', 'short', 'int', 'unsigned'), suffix=r'\b'), Keyword.Type), ], 'keywords': [ # ControlFlow (words(( 'atomic', 'break', 'd_step', 'do', 'od', 'for', 'in', 'goto', 'if', 'fi', 'unless'), suffix=r'\b'), Keyword), # BasicStatements (words(( 'assert', 'get_priority', 'printf', 'printm', 'set_priority'), suffix=r'\b'), Name.Function), # Embedded C Code (words(( 'c_code', 'c_decl', 'c_expr', 'c_state', 'c_track'), suffix=r'\b'), Keyword), # Predefined (local/global variables) (words(( '_', '_last', '_nr_pr', '_pid', '_priority', 'else', 'np_', 'STDIN'), suffix=r'\b'), Name.Builtin), # Predefined (functions) (words(( 'empty', 'enabled', 'eval', 'full', 'len', 'nempty', 'nfull', 'pc_value'), suffix=r'\b'), Name.Function), # Predefined (operators) (r'run\b', Operator.Word), # Declarators (words(( 'active', 'chan', 'D_proctype', 'hidden', 'init', 'local', 'mtype', 'never', 'notrace', 'proctype', 'show', 'trace', 'typedef', 'xr', 'xs'), suffix=r'\b'), Keyword.Declaration), # Declarators (suffixes) (words(( 'priority', 'provided'), suffix=r'\b'), Keyword), # MetaTerms (declarators) (words(( 'inline', 'ltl', 'select'), suffix=r'\b'), Keyword.Declaration), # MetaTerms (keywords) (r'skip\b', Keyword), ], }1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374""" pygments.lexers.capnproto ~~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for the Cap'n Proto schema language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, defaultfrom pygments.token import Text, Comment, Keyword, Name, Literal, Whitespace
__all__ = ['CapnProtoLexer']
class CapnProtoLexer(RegexLexer): """ For Cap'n Proto source. """ name = 'Cap\'n Proto' url = 'https://capnproto.org' filenames = ['*.capnp'] aliases = ['capnp'] version_added = '2.2'
tokens = { 'root': [ (r'#.*?$', Comment.Single), (r'@[0-9a-zA-Z]*', Name.Decorator), (r'=', Literal, 'expression'), (r':', Name.Class, 'type'), (r'\$', Name.Attribute, 'annotation'), (r'(struct|enum|interface|union|import|using|const|annotation|' r'extends|in|of|on|as|with|from|fixed)\b', Keyword), (r'[\w.]+', Name), (r'[^#@=:$\w\s]+', Text), (r'\s+', Whitespace), ], 'type': [ (r'[^][=;,(){}$]+', Name.Class), (r'[\[(]', Name.Class, 'parentype'), default('#pop'), ], 'parentype': [ (r'[^][;()]+', Name.Class), (r'[\[(]', Name.Class, '#push'), (r'[])]', Name.Class, '#pop'), default('#pop'), ], 'expression': [ (r'[^][;,(){}$]+', Literal), (r'[\[(]', Literal, 'parenexp'), default('#pop'), ], 'parenexp': [ (r'[^][;()]+', Literal), (r'[\[(]', Literal, '#push'), (r'[])]', Literal, '#pop'), default('#pop'), ], 'annotation': [ (r'[^][;,(){}=:]+', Name.Attribute), (r'[\[(]', Name.Attribute, 'annexp'), default('#pop'), ], 'annexp': [ (r'[^][;()]+', Name.Attribute), (r'[\[(]', Name.Attribute, '#push'), (r'[])]', Name.Attribute, '#pop'), default('#pop'), ], }1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495""" pygments.lexers.carbon ~~~~~~~~~~~~~~~~~~~~~~
Lexers for the Carbon programming language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""import re
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['CarbonLexer']
class CarbonLexer(RegexLexer): """ For Carbon source. """ name = 'Carbon' url = 'https://github.com/carbon-language/carbon-lang' filenames = ['*.carbon'] aliases = ['carbon'] mimetypes = ['text/x-carbon'] version_added = '2.15'
flags = re.MULTILINE | re.DOTALL
tokens = { 'root': [ (r'\n', Whitespace), (r'\s+', Whitespace), (r'\\\n', Text), # comments (r'//(.*?)\n', Comment.Single), (r'/(\\\n)?[*].*?[*](\\\n)?/', Comment.Multiline), # Declaration (r'(package|import|api|namespace|library)\b', Keyword.Namespace), (r'(abstract|alias|fn|class|interface|let|var|virtual|external|' r'base|addr|extends|choice|constraint|impl)\b', Keyword.Declaration), # Keywords (words(('as', 'or', 'not', 'and', 'break', 'continue', 'case', 'default', 'if', 'else', 'destructor', 'for', 'forall', 'while', 'where', 'then', 'in', 'is', 'return', 'returned', 'friend', 'partial', 'private', 'protected', 'observe', 'Self', 'override', 'final', 'match', 'type', 'like'), suffix=r'\b'), Keyword), (r'(self)\b', Keyword.Pseudo), (r'(true|false)\b', Keyword.Constant), (r'(auto|bool|string|i8|i16|i32|i64|u8|u16|u32|u64|' r'f8|f16|f32|f64)\b', Keyword.Type), # numeric literals (r'[0-9]*[.][0-9]+', Number.Double), (r'0b[01]+', Number.Bin), (r'0o[0-7]+', Number.Oct), (r'0x[0-9a-fA-F]+', Number.Hex), (r'[0-9]+', Number.Integer), # string literal (r'"(\\.|[^"\\])*"', String), # char literal (r'\'(\\.|[^\'\\])\'', String.Char), # tokens (r'<<=|>>=|<<|>>|<=|>=|\+=|-=|\*=|/=|\%=|\|=|&=|\^=|&&|\|\||&|\||' r'\+\+|--|\%|\^|\~|==|!=|::|[.]{3}|->|=>|[+\-*/&]', Operator), (r'[|<>=!()\[\]{}.,;:\?]', Punctuation), # identifiers (r'[^\W\d]\w*', Name.Other), ] }
def analyse_text(text): result = 0 if 'forall' in text: result += 0.1 if 'type' in text: result += 0.1 if 'Self' in text: result += 0.1 if 'observe' in text: result += 0.1 if 'package' in text: result += 0.1 if 'library' in text: result += 0.1 if 'choice' in text: result += 0.1 if 'addr' in text: result += 0.1 if 'constraint' in text: result += 0.1 if 'impl' in text: result += 0.1 return result123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172""" pygments.lexers.cddl ~~~~~~~~~~~~~~~~~~~~
Lexer for the Concise data definition language (CDDL), a notational convention to express CBOR and JSON data structures.
More information: https://datatracker.ietf.org/doc/rfc8610/
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, bygroups, include, wordsfrom pygments.token import Comment, Error, Keyword, Name, Number, Operator, \ Punctuation, String, Whitespace
__all__ = ['CddlLexer']
class CddlLexer(RegexLexer): """ Lexer for CDDL definitions. """ name = "CDDL" url = 'https://datatracker.ietf.org/doc/rfc8610/' aliases = ["cddl"] filenames = ["*.cddl"] mimetypes = ["text/x-cddl"] version_added = '2.8'
_prelude_types = [ "any", "b64legacy", "b64url", "bigfloat", "bigint", "bignint", "biguint", "bool", "bstr", "bytes", "cbor-any", "decfrac", "eb16", "eb64legacy", "eb64url", "encoded-cbor", "false", "float", "float16", "float16-32", "float32", "float32-64", "float64", "int", "integer", "mime-message", "nil", "nint", "null", "number", "regexp", "tdate", "text", "time", "true", "tstr", "uint", "undefined", "unsigned", "uri", ]
_controls = [ ".and", ".bits", ".cbor", ".cborseq", ".default", ".eq", ".ge", ".gt", ".le", ".lt", ".ne", ".regexp", ".size", ".within", ]
_re_id = ( r"[$@A-Z_a-z]" r"(?:[\-\.]+(?=[$@0-9A-Z_a-z])|[$@0-9A-Z_a-z])*"
)
# While the spec reads more like "an int must not start with 0" we use a # lookahead here that says "after a 0 there must be no digit". This makes the # '0' the invalid character in '01', which looks nicer when highlighted. _re_uint = r"(?:0b[01]+|0x[0-9a-fA-F]+|[1-9]\d*|0(?!\d))" _re_int = r"-?" + _re_uint
tokens = { "commentsandwhitespace": [(r"\s+", Whitespace), (r";.+$", Comment.Single)], "root": [ include("commentsandwhitespace"), # tag types (rf"#(\d\.{_re_uint})?", Keyword.Type), # type or any # occurrence ( rf"({_re_uint})?(\*)({_re_uint})?", bygroups(Number, Operator, Number), ), (r"\?|\+", Operator), # occurrence (r"\^", Operator), # cuts (r"(\.\.\.|\.\.)", Operator), # rangeop (words(_controls, suffix=r"\b"), Operator.Word), # ctlops # into choice op (rf"&(?=\s*({_re_id}|\())", Operator), (rf"~(?=\s*{_re_id})", Operator), # unwrap op (r"//|/(?!/)", Operator), # double und single slash (r"=>|/==|/=|=", Operator), (r"[\[\]{}\(\),<>:]", Punctuation), # Bytestrings (r"(b64)(')", bygroups(String.Affix, String.Single), "bstrb64url"), (r"(h)(')", bygroups(String.Affix, String.Single), "bstrh"), (r"'", String.Single, "bstr"), # Barewords as member keys (must be matched before values, types, typenames, # groupnames). # Token type is String as barewords are always interpreted as such. (rf"({_re_id})(\s*)(:)", bygroups(String, Whitespace, Punctuation)), # predefined types (words(_prelude_types, prefix=r"(?![\-_$@])\b", suffix=r"\b(?![\-_$@])"), Name.Builtin), # user-defined groupnames, typenames (_re_id, Name.Class), # values (r"0b[01]+", Number.Bin), (r"0o[0-7]+", Number.Oct), (r"0x[0-9a-fA-F]+(\.[0-9a-fA-F]+)?p[+-]?\d+", Number.Hex), # hexfloat (r"0x[0-9a-fA-F]+", Number.Hex), # hex # Float (rf"{_re_int}(?=(\.\d|e[+-]?\d))(?:\.\d+)?(?:e[+-]?\d+)?", Number.Float), # Int (_re_int, Number.Integer), (r'"(\\\\|\\"|[^"])*"', String.Double), ], "bstrb64url": [ (r"'", String.Single, "#pop"), include("commentsandwhitespace"), (r"\\.", String.Escape), (r"[0-9a-zA-Z\-_=]+", String.Single), (r".", Error), # (r";.+$", Token.Other), ], "bstrh": [ (r"'", String.Single, "#pop"), include("commentsandwhitespace"), (r"\\.", String.Escape), (r"[0-9a-fA-F]+", String.Single), (r".", Error), ], "bstr": [ (r"'", String.Single, "#pop"), (r"\\.", String.Escape), (r"[^'\\]+", String.Single), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139""" pygments.lexers.chapel ~~~~~~~~~~~~~~~~~~~~~~
Lexer for the Chapel language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, bygroups, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['ChapelLexer']
class ChapelLexer(RegexLexer): """ For Chapel source. """ name = 'Chapel' url = 'https://chapel-lang.org/' filenames = ['*.chpl'] aliases = ['chapel', 'chpl'] version_added = '2.0' # mimetypes = ['text/x-chapel']
known_types = ('bool', 'bytes', 'complex', 'imag', 'int', 'locale', 'nothing', 'opaque', 'range', 'real', 'string', 'uint', 'void')
type_modifiers_par = ('atomic', 'single', 'sync') type_modifiers_mem = ('borrowed', 'owned', 'shared', 'unmanaged') type_modifiers = (*type_modifiers_par, *type_modifiers_mem)
declarations = ('config', 'const', 'in', 'inout', 'out', 'param', 'ref', 'type', 'var')
constants = ('false', 'nil', 'none', 'true')
other_keywords = ('align', 'as', 'begin', 'break', 'by', 'catch', 'cobegin', 'coforall', 'continue', 'defer', 'delete', 'dmapped', 'do', 'domain', 'else', 'enum', 'except', 'export', 'extern', 'for', 'forall', 'foreach', 'forwarding', 'if', 'implements', 'import', 'index', 'init', 'inline', 'label', 'lambda', 'let', 'lifetime', 'local', 'new', 'noinit', 'on', 'only', 'otherwise', 'override', 'pragma', 'primitive', 'private', 'prototype', 'public', 'reduce', 'require', 'return', 'scan', 'select', 'serial', 'sparse', 'subdomain', 'then', 'this', 'throw', 'throws', 'try', 'use', 'when', 'where', 'while', 'with', 'yield', 'zip')
tokens = { 'root': [ (r'\n', Whitespace), (r'\s+', Whitespace), (r'\\\n', Text),
(r'//(.*?)\n', Comment.Single), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
(words(declarations, suffix=r'\b'), Keyword.Declaration), (words(constants, suffix=r'\b'), Keyword.Constant), (words(known_types, suffix=r'\b'), Keyword.Type), (words((*type_modifiers, *other_keywords), suffix=r'\b'), Keyword),
(r'@', Keyword, 'attributename'), (r'(iter)(\s+)', bygroups(Keyword, Whitespace), 'procname'), (r'(proc)(\s+)', bygroups(Keyword, Whitespace), 'procname'), (r'(operator)(\s+)', bygroups(Keyword, Whitespace), 'procname'), (r'(class|interface|module|record|union)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
# imaginary integers (r'\d+i', Number), (r'\d+\.\d*([Ee][-+]\d+)?i', Number), (r'\.\d+([Ee][-+]\d+)?i', Number), (r'\d+[Ee][-+]\d+i', Number),
# reals cannot end with a period due to lexical ambiguity with # .. operator. See reference for rationale. (r'(\d*\.\d+)([eE][+-]?[0-9]+)?i?', Number.Float), (r'\d+[eE][+-]?[0-9]+i?', Number.Float),
# integer literals # -- binary (r'0[bB][01]+', Number.Bin), # -- hex (r'0[xX][0-9a-fA-F]+', Number.Hex), # -- octal (r'0[oO][0-7]+', Number.Oct), # -- decimal (r'[0-9]+', Number.Integer),
# strings (r'"(\\\\|\\"|[^"])*"', String), (r"'(\\\\|\\'|[^'])*'", String),
# tokens (r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|' r'<=>|<~>|\.\.|by|#|\.\.\.|' r'&&|\|\||!|&|\||\^|~|<<|>>|' r'==|!=|<=|>=|<|>|' r'[+\-*/%]|\*\*)', Operator), (r'[:;,.?()\[\]{}]', Punctuation),
# identifiers (r'[a-zA-Z_][\w$]*', Name.Other), ], 'classname': [ (r'[a-zA-Z_][\w$]*', Name.Class, '#pop'), ], 'procname': [ (r'([a-zA-Z_][.\w$]*|' # regular function name, including secondary r'\~[a-zA-Z_][.\w$]*|' # support for legacy destructors r'[+*/!~%<>=&^|\-:]{1,2})', # operators Name.Function, '#pop'),
# allow `proc (atomic T).foo` (r'\(', Punctuation, "receivertype"), (r'\)+\.', Punctuation), ], 'receivertype': [ (words(type_modifiers, suffix=r'\b'), Keyword), (words(known_types, suffix=r'\b'), Keyword.Type), (r'[^()]*', Name.Other, '#pop'), ], 'attributename': [ (r'[a-zA-Z_][.\w$]*', Name.Decorator, '#pop'), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180""" pygments.lexers.clean ~~~~~~~~~~~~~~~~~~~~~
Lexer for the Clean language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import ExtendedRegexLexer, words, default, include, bygroupsfrom pygments.token import Comment, Error, Keyword, Literal, Name, Number, \ Operator, Punctuation, String, Whitespace
__all__ = ['CleanLexer']
class CleanLexer(ExtendedRegexLexer): """ Lexer for the general purpose, state-of-the-art, pure and lazy functional programming language Clean.
.. versionadded: 2.2 """ name = 'Clean' url = 'http://clean.cs.ru.nl/Clean' aliases = ['clean'] filenames = ['*.icl', '*.dcl'] version_added = ''
keywords = ( 'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export', 'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr', 'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where', 'with')
modulewords = ('implementation', 'definition', 'system')
lowerId = r'[a-z`][\w`]*' upperId = r'[A-Z`][\w`]*' funnyId = r'[~@#$%\^?!+\-*<>\\/|&=:]+' scoreUpperId = r'_' + upperId scoreLowerId = r'_' + lowerId moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+' classId = '|'.join([lowerId, upperId, funnyId])
tokens = { 'root': [ include('comments'), include('keywords'), include('module'), include('import'), include('whitespace'), include('literals'), include('operators'), include('delimiters'), include('names'), ], 'whitespace': [ (r'\s+', Whitespace), ], 'comments': [ (r'//.*\n', Comment.Single), (r'/\*', Comment.Multiline, 'comments.in'), (r'/\*\*', Comment.Special, 'comments.in'), ], 'comments.in': [ (r'\*\/', Comment.Multiline, '#pop'), (r'/\*', Comment.Multiline, '#push'), (r'[^*/]+', Comment.Multiline), (r'\*(?!/)', Comment.Multiline), (r'/', Comment.Multiline), ], 'keywords': [ (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), ], 'module': [ (words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace), (r'\bmodule\b', Keyword.Namespace, 'module.name'), ], 'module.name': [ include('whitespace'), (moduleId, Name.Class, '#pop'), ], 'import': [ (r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'), (r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b', bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword), 'import.what'), ], 'import.module': [ (r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)), (r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')), (moduleId, Name.Class), (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), (r'\s+', Whitespace), default('#pop'), ], 'import.module.as': [ include('whitespace'), (lowerId, Name.Class, '#pop'), (upperId, Name.Class, '#pop'), ], 'import.what': [ (r'\b(class)\b(\s+)(' + classId + r')', bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'), (r'\b(instance)(\s+)(' + classId + r')(\s+)', bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'), (r'(::)(\s*)\b(' + upperId + r')\b', bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'), (r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b', bygroups(Keyword, Whitespace, Name)), include('names'), (r'(,)(\s+)', bygroups(Punctuation, Whitespace)), (r'$', Whitespace, '#pop'), include('whitespace'), ], 'import.what.class': [ (r',', Punctuation, '#pop'), (r'\(', Punctuation, 'import.what.class.members'), (r'$', Whitespace, '#pop:2'), include('whitespace'), ], 'import.what.class.members': [ (r',', Punctuation), (r'\.\.', Punctuation), (r'\)', Punctuation, '#pop'), include('names'), ], 'import.what.instance': [ (r'[,)]', Punctuation, '#pop'), (r'\(', Punctuation, 'import.what.instance'), (r'$', Whitespace, '#pop:2'), include('whitespace'), include('names'), ], 'import.what.type': [ (r',', Punctuation, '#pop'), (r'[({]', Punctuation, 'import.what.type.consesandfields'), (r'$', Whitespace, '#pop:2'), include('whitespace'), ], 'import.what.type.consesandfields': [ (r',', Punctuation), (r'\.\.', Punctuation), (r'[)}]', Punctuation, '#pop'), include('names'), ], 'literals': [ (r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char), (r'[+~-]?0[0-7]+\b', Number.Oct), (r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float), (r'[+~-]?\d+\b', Number.Integer), (r'[+~-]?0x[\da-fA-F]+\b', Number.Hex), (r'True|False', Literal), (r'"', String.Double, 'literals.stringd'), ], 'literals.stringd': [ (r'[^\\"\n]+', String.Double), (r'"', String.Double, '#pop'), (r'\\.', String.Double), (r'[$\n]', Error, '#pop'), ], 'operators': [ (r'[-~@#$%\^?!+*<>\\/|&=:.]+', Operator), (r'\b_+\b', Operator), ], 'delimiters': [ (r'[,;(){}\[\]]', Punctuation), (r'(\')([\w`.]+)(\')', bygroups(Punctuation, Name.Class, Punctuation)), ], 'names': [ (lowerId, Name), (scoreLowerId, Name), (funnyId, Name.Function), (upperId, Name.Class), (scoreUpperId, Name.Class), ] }1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980""" pygments.lexers.codeql ~~~~~~~~~~~~~~~~~~~~~~
Lexer for CodeQL query language.
The grammar is originating from: https://github.com/github/vscode-codeql/blob/main/syntaxes/README.md
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
__all__ = ['CodeQLLexer']
import re
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
class CodeQLLexer(RegexLexer): name = 'CodeQL' aliases = ['codeql', 'ql'] filenames = ['*.ql', '*.qll'] mimetypes = [] url = 'https://github.com/github/codeql' version_added = '2.19'
flags = re.MULTILINE | re.UNICODE
tokens = { 'root': [ # Whitespace and comments (r'\s+', Whitespace), (r'//.*?\n', Comment.Single), (r'/\*', Comment.Multiline, 'multiline-comments'),
# Keywords (words(( 'module', 'import', 'class', 'extends', 'implements', 'predicate', 'select', 'where', 'from', 'as', 'and', 'or', 'not', 'in', 'if', 'then', 'else', 'exists', 'forall', 'instanceof', 'private', 'predicate', 'abstract', 'cached', 'external', 'final', 'library', 'override', 'query' ), suffix=r'\b'), Keyword.Builtin),
# Special Keywords (words(('this'), # class related keywords prefix=r'\b', suffix=r'\b\??:?'), Name.Builtin.Pseudo),
# Types (words(( 'boolean', 'date', 'float', 'int', 'string' ), suffix=r'\b'), Keyword.Type),
# Literals (r'"(\\\\|\\[^\\]|[^"\\])*"', String), (r'[0-9]+\.[0-9]+', Number.Float), (r'[0-9]+', Number.Integer), # Operators (r'<=|>=|<|>|=|!=|\+|-|\*|/', Operator),
# Punctuation (r'[.,;:\[\]{}()]+', Punctuation),
# Identifiers (r'@[a-zA-Z_]\w*', Name.Variable), # Variables with @ prefix (r'[A-Z][a-zA-Z0-9_]*', Name.Class), # Types and classes (r'[a-z][a-zA-Z0-9_]*', Name.Variable), # Variables and predicates ], 'multiline-comments': [ (r'[^*/]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ],
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081""" pygments.lexers.comal ~~~~~~~~~~~~~~~~~~~~~
Lexer for COMAL-80.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Comment, Whitespace, Operator, Keyword, String, \ Number, Name, Punctuation
__all__ = ["Comal80Lexer"]
class Comal80Lexer(RegexLexer): """ For COMAL-80 source code. """
name = 'COMAL-80' url = 'https://en.wikipedia.org/wiki/COMAL' aliases = ['comal', 'comal80'] filenames = ['*.cml', '*.comal'] version_added = '' flags = re.IGNORECASE # # COMAL allows for some strange characters in names which we list here so # keywords and word operators will not be recognized at the start of an # identifier. # _suffix = r"\b(?!['\[\]←£\\])" _identifier = r"[a-z]['\[\]←£\\\w]*"
tokens = { 'root': [ (r'//.*\n', Comment.Single), (r'\s+', Whitespace), (r':[=+-]|\<\>|[-+*/^↑<>=]', Operator), (r'(and +then|or +else)' + _suffix, Operator.Word), (words([ 'and', 'bitand', 'bitor', 'bitxor', 'div', 'in', 'mod', 'not', 'or'], suffix=_suffix,), Operator.Word), (words([ 'append', 'at', 'case', 'chain', 'close', 'copy', 'create', 'cursor', 'data', 'delete', 'dir', 'do', 'elif', 'else', 'end', 'endcase', 'endif', 'endfor', 'endloop', 'endtrap', 'endwhile', 'exec', 'exit', 'file', 'for', 'goto', 'handler', 'if', 'input', 'let', 'loop', 'mount', 'null', 'of', 'open', 'otherwise', 'output', 'page', 'pass', 'poke', 'print', 'random', 'read', 'repeat', 'report', 'return', 'rename', 'restore', 'select', 'step', 'stop', 'sys', 'then', 'to', 'trap', 'unit', 'unit$', 'until', 'using', 'when', 'while', 'write', 'zone'], suffix=_suffix), Keyword.Reserved), (words([ 'closed', 'dim', 'endfunc', 'endproc', 'external', 'func', 'import', 'proc', 'ref', 'use'], suffix=_suffix), Keyword.Declaration), (words([ 'abs', 'atn', 'chr$', 'cos', 'eod', 'eof', 'err', 'errfile', 'errtext', 'esc', 'exp', 'int', 'key$', 'len', 'log', 'ord', 'peek', 'randomize', 'rnd', 'sgn', 'sin', 'spc$', 'sqr', 'status$', 'str$', 'tab', 'tan', 'time', 'val'], suffix=_suffix), Name.Builtin), (words(['false', 'pi', 'true'], suffix=_suffix), Keyword.Constant), (r'"', String, 'string'), (_identifier + r":(?=[ \n/])", Name.Label), (_identifier + r"[$#]?", Name), (r'%[01]+', Number.Bin), (r'\$[0-9a-f]+', Number.Hex), (r'\d*\.\d*(e[-+]?\d+)?', Number.Float), (r'\d+', Number.Integer), (r'[(),:;]', Punctuation), ], 'string': [ (r'[^"]+', String), (r'"[0-9]*"', String.Escape), (r'"', String, '#pop'), ], }1234567891011121314151617181920212223242526272829303132333435""" pygments.lexers.compiled ~~~~~~~~~~~~~~~~~~~~~~~~
Just export lexer classes previously contained in this module.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
# ruff: noqa: F401from pygments.lexers.jvm import JavaLexer, ScalaLexerfrom pygments.lexers.c_cpp import CLexer, CppLexerfrom pygments.lexers.d import DLexerfrom pygments.lexers.objective import ObjectiveCLexer, \ ObjectiveCppLexer, LogosLexerfrom pygments.lexers.go import GoLexerfrom pygments.lexers.rust import RustLexerfrom pygments.lexers.c_like import ECLexer, ValaLexer, CudaLexerfrom pygments.lexers.pascal import DelphiLexer, PortugolLexer, Modula2Lexerfrom pygments.lexers.ada import AdaLexerfrom pygments.lexers.business import CobolLexer, CobolFreeformatLexerfrom pygments.lexers.fortran import FortranLexerfrom pygments.lexers.prolog import PrologLexerfrom pygments.lexers.python import CythonLexerfrom pygments.lexers.graphics import GLShaderLexerfrom pygments.lexers.ml import OcamlLexerfrom pygments.lexers.basic import BlitzBasicLexer, BlitzMaxLexer, MonkeyLexerfrom pygments.lexers.dylan import DylanLexer, DylanLidLexer, DylanConsoleLexerfrom pygments.lexers.ooc import OocLexerfrom pygments.lexers.felix import FelixLexerfrom pygments.lexers.nimrod import NimrodLexerfrom pygments.lexers.crystal import CrystalLexer
__all__ = []12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433""" pygments.lexers.configs ~~~~~~~~~~~~~~~~~~~~~~~
Lexers for configuration file formats.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import ExtendedRegexLexer, RegexLexer, default, words, \ bygroups, include, using, line_refrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace, Literal, Error, Genericfrom pygments.lexers.shell import BashLexerfrom pygments.lexers.data import JsonLexer
__all__ = ['IniLexer', 'SystemdLexer', 'DesktopLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer', 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer', 'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer', 'NestedTextLexer', 'SingularityLexer', 'UnixConfigLexer']
class IniLexer(RegexLexer): """ Lexer for configuration files in INI style. """
name = 'INI' aliases = ['ini', 'cfg', 'dosini'] filenames = [ '*.ini', '*.cfg', '*.inf', '.editorconfig', ] mimetypes = ['text/x-ini', 'text/inf'] url = 'https://en.wikipedia.org/wiki/INI_file' version_added = ''
tokens = { 'root': [ (r'\s+', Whitespace), (r'[;#].*', Comment.Single), (r'(\[.*?\])([ \t]*)$', bygroups(Keyword, Whitespace)), (r'''(.*?)([ \t]*)([=:])([ \t]*)(["'])''', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String), "quoted_value"), (r'(.*?)([ \t]*)([=:])([ \t]*)([^;#\n]*)(\\)(\s+)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, Text, Whitespace), "value"), (r'(.*?)([ \t]*)([=:])([ \t]*)([^ ;#\n]*(?: +[^ ;#\n]+)*)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)), # standalone option, supported by some INI parsers (r'(.+?)$', Name.Attribute), ], 'quoted_value': [ (r'''([^"'\n]*)(["'])(\s*)''', bygroups(String, String, Whitespace), "#pop"), (r'[;#].*', Comment.Single), (r'$', String, "#pop"), ], 'value': [ # line continuation (r'\s+', Whitespace), (r'(\s*)(.*)(\\)([ \t]*)', bygroups(Whitespace, String, Text, Whitespace)), (r'.*$', String, "#pop"), ], }
def analyse_text(text): npos = text.find('\n') if npos < 3: return False if text[0] == '[' and text[npos-1] == ']': return 0.8 return False
class DesktopLexer(RegexLexer): """ Lexer for .desktop files. """
name = 'Desktop file' url = "https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" aliases = ['desktop'] filenames = ['*.desktop'] mimetypes = ['application/x-desktop'] version_added = '2.16'
tokens = { 'root': [ (r'^[ \t]*\n', Whitespace), (r'^(#.*)(\n)', bygroups(Comment.Single, Whitespace)), (r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)), (r'([-A-Za-z0-9]+)(\[[^\] \t=]+\])?([ \t]*)(=)([ \t]*)([^\n]*)([ \t\n]*\n)', bygroups(Name.Attribute, Name.Namespace, Whitespace, Operator, Whitespace, String, Whitespace)), ], }
def analyse_text(text): if text.startswith("[Desktop Entry]"): return 1.0 if re.search(r"^\[Desktop Entry\][ \t]*$", text[:500], re.MULTILINE) is not None: return 0.9 return 0.0
class SystemdLexer(RegexLexer): """ Lexer for systemd unit files. """
name = 'Systemd' url = "https://www.freedesktop.org/software/systemd/man/systemd.syntax.html" aliases = ['systemd'] filenames = [ '*.service', '*.socket', '*.device', '*.mount', '*.automount', '*.swap', '*.target', '*.path', '*.timer', '*.slice', '*.scope', ] version_added = '2.16'
tokens = { 'root': [ (r'^[ \t]*\n', Whitespace), (r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)), (r'(\[[^\]\n]+\])(\n)', bygroups(Keyword, Whitespace)), (r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\\)(\n)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, Text, Whitespace), "value"), (r'([^=]+)([ \t]*)(=)([ \t]*)([^\n]*)(\n)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String, Whitespace)), ], 'value': [ # line continuation (r'^([;#].*)(\n)', bygroups(Comment.Single, Whitespace)), (r'([ \t]*)([^\n]*)(\\)(\n)', bygroups(Whitespace, String, Text, Whitespace)), (r'([ \t]*)([^\n]*)(\n)', bygroups(Whitespace, String, Whitespace), "#pop"), ], }
def analyse_text(text): if text.startswith("[Unit]"): return 1.0 if re.search(r"^\[Unit\][ \t]*$", text[:500], re.MULTILINE) is not None: return 0.9 return 0.0
class RegeditLexer(RegexLexer): """ Lexer for Windows Registry files produced by regedit. """
name = 'reg' url = 'http://en.wikipedia.org/wiki/Windows_Registry#.REG_files' aliases = ['registry'] filenames = ['*.reg'] mimetypes = ['text/x-windows-registry'] version_added = '1.6'
tokens = { 'root': [ (r'Windows Registry Editor.*', Text), (r'\s+', Whitespace), (r'[;#].*', Comment.Single), (r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$', bygroups(Keyword, Operator, Name.Builtin, Keyword)), # String keys, which obey somewhat normal escaping (r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace), 'value'), # Bare keys (includes @) (r'(.*?)([ \t]*)(=)([ \t]*)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace), 'value'), ], 'value': [ (r'-', Operator, '#pop'), # delete value (r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)', bygroups(Name.Variable, Punctuation, Number), '#pop'), # As far as I know, .reg files do not support line continuation. (r'.+', String, '#pop'), default('#pop'), ] }
def analyse_text(text): return text.startswith('Windows Registry Editor')
class PropertiesLexer(RegexLexer): """ Lexer for configuration files in Java's properties format.
Note: trailing whitespace counts as part of the value as per spec """
name = 'Properties' aliases = ['properties', 'jproperties'] filenames = ['*.properties'] mimetypes = ['text/x-java-properties'] url = 'https://en.wikipedia.org/wiki/.properties' version_added = '1.4'
tokens = { 'root': [ # comments (r'[!#].*|/{2}.*', Comment.Single), # ending a comment or whitespace-only line (r'\n', Whitespace), # eat whitespace at the beginning of a line (r'^[^\S\n]+', Whitespace), # start lexing a key default('key'), ], 'key': [ # non-escaped key characters (r'[^\\:=\s]+', Name.Attribute), # escapes include('escapes'), # separator is the first non-escaped whitespace or colon or '=' on the line; # if it's whitespace, = and : are gobbled after it (r'([^\S\n]*)([:=])([^\S\n]*)', bygroups(Whitespace, Operator, Whitespace), ('#pop', 'value')), (r'[^\S\n]+', Whitespace, ('#pop', 'value')), # maybe we got no value after all (r'\n', Whitespace, '#pop'), ], 'value': [ # non-escaped value characters (r'[^\\\n]+', String), # escapes include('escapes'), # end the value on an unescaped newline (r'\n', Whitespace, '#pop'), ], 'escapes': [ # line continuations; these gobble whitespace at the beginning of the next line (r'(\\\n)([^\S\n]*)', bygroups(String.Escape, Whitespace)), # other escapes (r'\\(.|\n)', String.Escape), ], }
def _rx_indent(level): # Kconfig *always* interprets a tab as 8 spaces, so this is the default. # Edit this if you are in an environment where KconfigLexer gets expanded # input (tabs expanded to spaces) and the expansion tab width is != 8, # e.g. in connection with Trac (trac.ini, [mimeviewer], tab_width). # Value range here is 2 <= {tab_width} <= 8. tab_width = 8 # Regex matching a given indentation {level}, assuming that indentation is # a multiple of {tab_width}. In other cases there might be problems. if tab_width == 2: space_repeat = '+' else: space_repeat = '{1,%d}' % (tab_width - 1) if level == 1: level_repeat = '' else: level_repeat = f'{{{level}}}' return rf'(?:\t| {space_repeat}\t| {{{tab_width}}}){level_repeat}.*\n'
class KconfigLexer(RegexLexer): """ For Linux-style Kconfig files. """
name = 'Kconfig' aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config'] version_added = '1.6' # Adjust this if new kconfig file names appear in your environment filenames = ['Kconfig*', '*Config.in*', 'external.in*', 'standard-modules.in'] mimetypes = ['text/x-kconfig'] url = 'https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html'
# No re.MULTILINE, indentation-aware help text needs line-by-line handling flags = 0
def call_indent(level): # If indentation >= {level} is detected, enter state 'indent{level}' return (_rx_indent(level), String.Doc, f'indent{level}')
def do_indent(level): # Print paragraphs of indentation level >= {level} as String.Doc, # ignoring blank lines. Then return to 'root' state. return [ (_rx_indent(level), String.Doc), (r'\s*\n', Text), default('#pop:2') ]
tokens = { 'root': [ (r'\s+', Whitespace), (r'#.*?\n', Comment.Single), (words(( 'mainmenu', 'config', 'menuconfig', 'choice', 'endchoice', 'comment', 'menu', 'endmenu', 'visible if', 'if', 'endif', 'source', 'prompt', 'select', 'depends on', 'default', 'range', 'option'), suffix=r'\b'), Keyword), (r'(---help---|help)[\t ]*\n', Keyword, 'help'), (r'(bool|tristate|string|hex|int|defconfig_list|modules|env)\b', Name.Builtin), (r'[!=&|]', Operator), (r'[()]', Punctuation), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String.Single), (r'"(""|[^"])*"', String.Double), (r'\S+', Text), ], # Help text is indented, multi-line and ends when a lower indentation # level is detected. 'help': [ # Skip blank lines after help token, if any (r'\s*\n', Text), # Determine the first help line's indentation level heuristically(!). # Attention: this is not perfect, but works for 99% of "normal" # indentation schemes up to a max. indentation level of 7. call_indent(7), call_indent(6), call_indent(5), call_indent(4), call_indent(3), call_indent(2), call_indent(1), default('#pop'), # for incomplete help sections without text ], # Handle text for indentation levels 7 to 1 'indent7': do_indent(7), 'indent6': do_indent(6), 'indent5': do_indent(5), 'indent4': do_indent(4), 'indent3': do_indent(3), 'indent2': do_indent(2), 'indent1': do_indent(1), }
class Cfengine3Lexer(RegexLexer): """ Lexer for CFEngine3 policy files. """
name = 'CFEngine3' url = 'http://cfengine.org' aliases = ['cfengine3', 'cf3'] filenames = ['*.cf'] mimetypes = [] version_added = '1.5'
tokens = { 'root': [ (r'#.*?\n', Comment), (r'(body)(\s+)(\S+)(\s+)(control)', bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()', bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function, Punctuation), 'arglist'), (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)', bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function)), (r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)', bygroups(Punctuation, Name.Variable, Punctuation, Whitespace, Keyword.Type, Whitespace, Operator, Whitespace)), (r'(\S+)(\s*)(=>)(\s*)', bygroups(Keyword.Reserved, Whitespace, Operator, Text)), (r'"', String, 'string'), (r'(\w+)(\()', bygroups(Name.Function, Punctuation)), (r'([\w.!&|()]+)(::)', bygroups(Name.Class, Punctuation)), (r'(\w+)(:)', bygroups(Keyword.Declaration, Punctuation)), (r'@[{(][^)}]+[})]', Name.Variable), (r'[(){},;]', Punctuation), (r'=>', Operator), (r'->', Operator), (r'\d+\.\d+', Number.Float), (r'\d+', Number.Integer), (r'\w+', Name.Function), (r'\s+', Whitespace), ], 'string': [ (r'\$[{(]', String.Interpol, 'interpol'), (r'\\.', String.Escape), (r'"', String, '#pop'), (r'\n', String), (r'.', String), ], 'interpol': [ (r'\$[{(]', String.Interpol, '#push'), (r'[})]', String.Interpol, '#pop'), (r'[^${()}]+', String.Interpol), ], 'arglist': [ (r'\)', Punctuation, '#pop'), (r',', Punctuation), (r'\w+', Name.Variable), (r'\s+', Whitespace), ], }
class ApacheConfLexer(RegexLexer): """ Lexer for configuration files following the Apache config file format. """
name = 'ApacheConf' aliases = ['apacheconf', 'aconf', 'apache'] filenames = ['.htaccess', 'apache.conf', 'apache2.conf'] mimetypes = ['text/x-apacheconf'] url = 'https://httpd.apache.org/docs/current/configuring.html' version_added = '0.6' flags = re.MULTILINE | re.IGNORECASE
tokens = { 'root': [ (r'\s+', Whitespace), (r'#(.*\\\n)+.*$|(#.*?)$', Comment), (r'(<[^\s>/][^\s>]*)(?:(\s+)(.*))?(>)', bygroups(Name.Tag, Whitespace, String, Name.Tag)), (r'(</[^\s>]+)(>)', bygroups(Name.Tag, Name.Tag)), (r'[a-z]\w*', Name.Builtin, 'value'), (r'\.+', Text), ], 'value': [ (r'\\\n', Text), (r'\n+', Whitespace, '#pop'), (r'\\', Text), (r'[^\S\n]+', Whitespace), (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number), (r'\d+', Number), (r'/([*a-z0-9][*\w./-]+)', String.Other), (r'(on|off|none|any|all|double|email|dns|min|minimal|' r'os|productonly|full|emerg|alert|crit|error|warn|' r'notice|info|debug|registry|script|inetd|standalone|' r'user|group)\b', Keyword), (r'"([^"\\]*(?:\\(.|\n)[^"\\]*)*)"', String.Double), (r'[^\s"\\]+', Text) ], }
class SquidConfLexer(RegexLexer): """ Lexer for squid configuration files. """
name = 'SquidConf' url = 'http://www.squid-cache.org/' aliases = ['squidconf', 'squid.conf', 'squid'] filenames = ['squid.conf'] mimetypes = ['text/x-squidconf'] version_added = '0.9' flags = re.IGNORECASE
keywords = ( "access_log", "acl", "always_direct", "announce_host", "announce_period", "announce_port", "announce_to", "anonymize_headers", "append_domain", "as_whois_server", "auth_param_basic", "authenticate_children", "authenticate_program", "authenticate_ttl", "broken_posts", "buffered_logs", "cache_access_log", "cache_announce", "cache_dir", "cache_dns_program", "cache_effective_group", "cache_effective_user", "cache_host", "cache_host_acl", "cache_host_domain", "cache_log", "cache_mem", "cache_mem_high", "cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer", "cache_peer_access", "cache_replacement_policy", "cache_stoplist", "cache_stoplist_pattern", "cache_store_log", "cache_swap", "cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db", "client_lifetime", "client_netmask", "connect_timeout", "coredump_dir", "dead_peer_timeout", "debug_options", "delay_access", "delay_class", "delay_initial_bucket_level", "delay_parameters", "delay_pools", "deny_info", "dns_children", "dns_defnames", "dns_nameservers", "dns_testnames", "emulate_httpd_log", "err_html_text", "fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port", "fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width", "ftp_passive", "ftp_user", "half_closed_clients", "header_access", "header_replace", "hierarchy_stoplist", "high_response_time_warning", "high_page_fault_warning", "hosts_file", "htcp_port", "http_access", "http_anonymizer", "httpd_accel", "httpd_accel_host", "httpd_accel_port", "httpd_accel_uses_host_header", "httpd_accel_with_proxy", "http_port", "http_reply_access", "icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout", "ident_lookup", "ident_lookup_access", "ident_timeout", "incoming_http_average", "incoming_icp_average", "inside_firewall", "ipcache_high", "ipcache_low", "ipcache_size", "local_domain", "local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries", "log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries", "mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr", "mcast_miss_encode_key", "mcast_miss_port", "memory_pools", "memory_pools_limit", "memory_replacement_policy", "mime_table", "min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops", "minimum_object_size", "minimum_retry_timeout", "miss_access", "negative_dns_ttl", "negative_ttl", "neighbor_timeout", "neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period", "netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy", "pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl", "prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp", "quick_abort", "quick_abort_max", "quick_abort_min", "quick_abort_pct", "range_offset_limit", "read_timeout", "redirect_children", "redirect_program", "redirect_rewrites_host_header", "reference_age", "refresh_pattern", "reload_into_ims", "request_body_max_size", "request_size", "request_timeout", "shutdown_lifetime", "single_parent_bypass", "siteselect_timeout", "snmp_access", "snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy", "store_avg_object_size", "store_objects_per_bucket", "strip_query_terms", "swap_level1_dirs", "swap_level2_dirs", "tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize", "test_reachability", "udp_hit_obj", "udp_hit_obj_size", "udp_incoming_address", "udp_outgoing_address", "unique_hostname", "unlinkd_program", "uri_whitespace", "useragent_log", "visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port", )
opts = ( "proxy-only", "weight", "ttl", "no-query", "default", "round-robin", "multicast-responder", "on", "off", "all", "deny", "allow", "via", "parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2", "credentialsttl", "none", "disable", "offline_toggle", "diskd", )
actions = ( "shutdown", "info", "parameter", "server_list", "client_list", r'squid.conf', )
actions_stats = ( "objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns", "redirector", "io", "reply_headers", "filedescriptors", "netdb", )
actions_log = ("status", "enable", "disable", "clear")
acls = ( "url_regex", "urlpath_regex", "referer_regex", "port", "proto", "req_mime_type", "rep_mime_type", "method", "browser", "user", "src", "dst", "time", "dstdomain", "ident", "snmp_community", )
ipv4_group = r'(\d+|0x[0-9a-f]+)' ipv4 = rf'({ipv4_group}(\.{ipv4_group}){{3}})' ipv6_group = r'([0-9a-f]{0,4})' ipv6 = rf'({ipv6_group}(:{ipv6_group}){{1,7}})' bare_ip = rf'({ipv4}|{ipv6})' # XXX: /integer is a subnet mark, but what is /IP ? # There is no test where it is used. ip = rf'{bare_ip}(/({bare_ip}|\d+))?'
tokens = { 'root': [ (r'\s+', Whitespace), (r'#', Comment, 'comment'), (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), (words(opts, prefix=r'\b', suffix=r'\b'), Name.Constant), # Actions (words(actions, prefix=r'\b', suffix=r'\b'), String), (words(actions_stats, prefix=r'stats/', suffix=r'\b'), String), (words(actions_log, prefix=r'log/', suffix=r'='), String), (words(acls, prefix=r'\b', suffix=r'\b'), Keyword), (ip, Number.Float), (r'(?:\b\d+\b(?:-\b\d+|%)?)', Number), (r'\S+', Text), ], 'comment': [ (r'\s*TAG:.*', String.Escape, '#pop'), (r'.+', Comment, '#pop'), default('#pop'), ], }
class NginxConfLexer(RegexLexer): """ Lexer for Nginx configuration files. """ name = 'Nginx configuration file' url = 'http://nginx.net/' aliases = ['nginx'] filenames = ['nginx.conf'] mimetypes = ['text/x-nginx-conf'] version_added = '0.11'
tokens = { 'root': [ (r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Whitespace, Name)), (r'[^\s;#]+', Keyword, 'stmt'), include('base'), ], 'block': [ (r'\}', Punctuation, '#pop:2'), (r'[^\s;#]+', Keyword.Namespace, 'stmt'), include('base'), ], 'stmt': [ (r'\{', Punctuation, 'block'), (r';', Punctuation, '#pop'), include('base'), ], 'base': [ (r'#.*\n', Comment.Single), (r'on|off', Name.Constant), (r'\$[^\s;#()]+', Name.Variable), (r'([a-z0-9.-]+)(:)([0-9]+)', bygroups(Name, Punctuation, Number.Integer)), (r'[a-z-]+/[a-z-+]+', String), # mimetype # (r'[a-zA-Z._-]+', Keyword), (r'[0-9]+[km]?\b', Number.Integer), (r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Whitespace, String.Regex)), (r'[:=~]', Punctuation), (r'[^\s;#{}$]+', String), # catch all (r'/[^\s;#]*', Name), # pathname (r'\s+', Whitespace), (r'[$;]', Text), # leftover characters ], }
class LighttpdConfLexer(RegexLexer): """ Lexer for Lighttpd configuration files. """ name = 'Lighttpd configuration file' url = 'http://lighttpd.net/' aliases = ['lighttpd', 'lighty'] filenames = ['lighttpd.conf'] mimetypes = ['text/x-lighttpd-conf'] version_added = '0.11'
tokens = { 'root': [ (r'#.*\n', Comment.Single), (r'/\S*', Name), # pathname (r'[a-zA-Z._-]+', Keyword), (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number), (r'[0-9]+', Number), (r'=>|=~|\+=|==|=|\+', Operator), (r'\$[A-Z]+', Name.Builtin), (r'[(){}\[\],]', Punctuation), (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double), (r'\s+', Whitespace), ],
}
class DockerLexer(RegexLexer): """ Lexer for Docker configuration files. """ name = 'Docker' url = 'http://docker.io' aliases = ['docker', 'dockerfile'] filenames = ['Dockerfile', '*.docker'] mimetypes = ['text/x-dockerfile-config'] version_added = '2.0'
_keywords = (r'(?:MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)') _bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)') _lb = r'(?:\s*\\?\s*)' # dockerfile line break regex flags = re.IGNORECASE | re.MULTILINE
tokens = { 'root': [ (r'#.*', Comment), (r'(FROM)([ \t]*)(\S*)([ \t]*)(?:(AS)([ \t]*)(\S*))?', bygroups(Keyword, Whitespace, String, Whitespace, Keyword, Whitespace, String)), (rf'(ONBUILD)(\s+)({_lb})', bygroups(Keyword, Whitespace, using(BashLexer))), (rf'(HEALTHCHECK)(\s+)(({_lb}--\w+=\w+{_lb})*)', bygroups(Keyword, Whitespace, using(BashLexer))), (rf'(VOLUME|ENTRYPOINT|CMD|SHELL)(\s+)({_lb})(\[.*?\])', bygroups(Keyword, Whitespace, using(BashLexer), using(JsonLexer))), (rf'(LABEL|ENV|ARG)(\s+)(({_lb}\w+=\w+{_lb})*)', bygroups(Keyword, Whitespace, using(BashLexer))), (rf'({_keywords}|VOLUME)\b(\s+)(.*)', bygroups(Keyword, Whitespace, String)), (rf'({_bash_keywords})(\s+)', bygroups(Keyword, Whitespace)), (r'(.*\\\n)*.+', using(BashLexer)), ] }
class TerraformLexer(ExtendedRegexLexer): """ Lexer for terraformi ``.tf`` files. """
name = 'Terraform' url = 'https://www.terraform.io/' aliases = ['terraform', 'tf', 'hcl'] filenames = ['*.tf', '*.hcl'] mimetypes = ['application/x-tf', 'application/x-terraform'] version_added = '2.1'
classes = ('backend', 'data', 'module', 'output', 'provider', 'provisioner', 'resource', 'variable') classes_re = "({})".format(('|').join(classes))
types = ('string', 'number', 'bool', 'list', 'tuple', 'map', 'set', 'object', 'null')
numeric_functions = ('abs', 'ceil', 'floor', 'log', 'max', 'mix', 'parseint', 'pow', 'signum')
string_functions = ('chomp', 'format', 'formatlist', 'indent', 'join', 'lower', 'regex', 'regexall', 'replace', 'split', 'strrev', 'substr', 'title', 'trim', 'trimprefix', 'trimsuffix', 'trimspace', 'upper' )
collection_functions = ('alltrue', 'anytrue', 'chunklist', 'coalesce', 'coalescelist', 'compact', 'concat', 'contains', 'distinct', 'element', 'flatten', 'index', 'keys', 'length', 'list', 'lookup', 'map', 'matchkeys', 'merge', 'range', 'reverse', 'setintersection', 'setproduct', 'setsubtract', 'setunion', 'slice', 'sort', 'sum', 'transpose', 'values', 'zipmap' )
encoding_functions = ('base64decode', 'base64encode', 'base64gzip', 'csvdecode', 'jsondecode', 'jsonencode', 'textdecodebase64', 'textencodebase64', 'urlencode', 'yamldecode', 'yamlencode')
filesystem_functions = ('abspath', 'dirname', 'pathexpand', 'basename', 'file', 'fileexists', 'fileset', 'filebase64', 'templatefile')
date_time_functions = ('formatdate', 'timeadd', 'timestamp')
hash_crypto_functions = ('base64sha256', 'base64sha512', 'bcrypt', 'filebase64sha256', 'filebase64sha512', 'filemd5', 'filesha1', 'filesha256', 'filesha512', 'md5', 'rsadecrypt', 'sha1', 'sha256', 'sha512', 'uuid', 'uuidv5')
ip_network_functions = ('cidrhost', 'cidrnetmask', 'cidrsubnet', 'cidrsubnets')
type_conversion_functions = ('can', 'defaults', 'tobool', 'tolist', 'tomap', 'tonumber', 'toset', 'tostring', 'try')
builtins = numeric_functions + string_functions + collection_functions + encoding_functions +\ filesystem_functions + date_time_functions + hash_crypto_functions + ip_network_functions +\ type_conversion_functions builtins_re = "({})".format(('|').join(builtins))
def heredoc_callback(self, match, ctx): # Parse a terraform heredoc # match: 1 = <<[-]?, 2 = name 3 = rest of line
start = match.start(1) yield start, Operator, match.group(1) # <<[-]? yield match.start(2), String.Delimiter, match.group(2) # heredoc name
ctx.pos = match.start(3) ctx.end = match.end(3) yield ctx.pos, String.Heredoc, match.group(3) ctx.pos = match.end()
hdname = match.group(2) tolerant = True # leading whitespace is always accepted
lines = []
for match in line_re.finditer(ctx.text, ctx.pos): if tolerant: check = match.group().strip() else: check = match.group().rstrip() if check == hdname: for amatch in lines: yield amatch.start(), String.Heredoc, amatch.group() yield match.start(), String.Delimiter, match.group() ctx.pos = match.end() break else: lines.append(match) else: # end of heredoc not found -- error! for amatch in lines: yield amatch.start(), Error, amatch.group() ctx.end = len(ctx.text)
tokens = { 'root': [ include('basic'), include('whitespace'),
# Strings (r'(".*")', bygroups(String.Double)),
# Constants (words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Name.Constant),
# Types (words(types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
include('identifier'), include('punctuation'), (r'[0-9]+', Number), ], 'basic': [ (r'\s*/\*', Comment.Multiline, 'comment'), (r'\s*(#|//).*\n', Comment.Single), include('whitespace'),
# e.g. terraform { # e.g. egress { (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=?)(\s*)(\{)', bygroups(Whitespace, Name.Builtin, Whitespace, Operator, Whitespace, Punctuation)),
# Assignment with attributes, e.g. something = ... (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=)(\s*)', bygroups(Whitespace, Name.Attribute, Whitespace, Operator, Whitespace)),
# Assignment with environment variables and similar, e.g. "something" = ... # or key value assignment, e.g. "SlotName" : ... (r'(\s*)("\S+")(\s*)([=:])(\s*)', bygroups(Whitespace, Literal.String.Double, Whitespace, Operator, Whitespace)),
# Functions, e.g. jsonencode(element("value")) (builtins_re + r'(\()', bygroups(Name.Function, Punctuation)),
# List of attributes, e.g. ignore_changes = [last_modified, filename] (r'(\[)([a-z_,\s]+)(\])', bygroups(Punctuation, Name.Builtin, Punctuation)),
# e.g. resource "aws_security_group" "allow_tls" { # e.g. backend "consul" { (classes_re + r'(\s+)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)', bygroups(Keyword.Reserved, Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation)),
# here-doc style delimited strings (r'(<<-?)\s*([a-zA-Z_]\w*)(.*?\n)', heredoc_callback), ], 'identifier': [ (r'\b(var\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)), (r'\b([0-9a-zA-Z-_\[\]]+\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)), ], 'punctuation': [ (r'[\[\]()\{\},.?:!=]', Punctuation), ], 'comment': [ (r'[^*/]', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline) ], 'whitespace': [ (r'\n', Whitespace), (r'\s+', Whitespace), (r'(\\)(\n)', bygroups(Text, Whitespace)), ], }
class TermcapLexer(RegexLexer): """ Lexer for termcap database source.
This is very simple and minimal. """ name = 'Termcap' aliases = ['termcap'] filenames = ['termcap', 'termcap.src'] mimetypes = [] url = 'https://en.wikipedia.org/wiki/Termcap' version_added = '2.1'
# NOTE: # * multiline with trailing backslash # * separator is ':' # * to embed colon as data, we must use \072 # * space after separator is not allowed (mayve) tokens = { 'root': [ (r'^#.*', Comment), (r'^[^\s#:|]+', Name.Tag, 'names'), (r'\s+', Whitespace), ], 'names': [ (r'\n', Whitespace, '#pop'), (r':', Punctuation, 'defs'), (r'\|', Punctuation), (r'[^:|]+', Name.Attribute), ], 'defs': [ (r'(\\)(\n[ \t]*)', bygroups(Text, Whitespace)), (r'\n[ \t]*', Whitespace, '#pop:2'), (r'(#)([0-9]+)', bygroups(Operator, Number)), (r'=', Operator, 'data'), (r':', Punctuation), (r'[^\s:=#]+', Name.Class), ], 'data': [ (r'\\072', Literal), (r':', Punctuation, '#pop'), (r'[^:\\]+', Literal), # for performance (r'.', Literal), ], }
class TerminfoLexer(RegexLexer): """ Lexer for terminfo database source.
This is very simple and minimal. """ name = 'Terminfo' aliases = ['terminfo'] filenames = ['terminfo', 'terminfo.src'] mimetypes = [] url = 'https://en.wikipedia.org/wiki/Terminfo' version_added = '2.1'
# NOTE: # * multiline with leading whitespace # * separator is ',' # * to embed comma as data, we can use \, # * space after separator is allowed tokens = { 'root': [ (r'^#.*$', Comment), (r'^[^\s#,|]+', Name.Tag, 'names'), (r'\s+', Whitespace), ], 'names': [ (r'\n', Whitespace, '#pop'), (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), 'defs'), (r'\|', Punctuation), (r'[^,|]+', Name.Attribute), ], 'defs': [ (r'\n[ \t]+', Whitespace), (r'\n', Whitespace, '#pop:2'), (r'(#)([0-9]+)', bygroups(Operator, Number)), (r'=', Operator, 'data'), (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace)), (r'[^\s,=#]+', Name.Class), ], 'data': [ (r'\\[,\\]', Literal), (r'(,)([ \t]*)', bygroups(Punctuation, Whitespace), '#pop'), (r'[^\\,]+', Literal), # for performance (r'.', Literal), ], }
class PkgConfigLexer(RegexLexer): """ Lexer for pkg-config (see also `manual page <http://linux.die.net/man/1/pkg-config>`_). """
name = 'PkgConfig' url = 'http://www.freedesktop.org/wiki/Software/pkg-config/' aliases = ['pkgconfig'] filenames = ['*.pc'] mimetypes = [] version_added = '2.1'
tokens = { 'root': [ (r'#.*$', Comment.Single),
# variable definitions (r'^(\w+)(=)', bygroups(Name.Attribute, Operator)),
# keyword lines (r'^([\w.]+)(:)', bygroups(Name.Tag, Punctuation), 'spvalue'),
# variable references include('interp'),
# fallback (r'\s+', Whitespace), (r'[^${}#=:\n.]+', Text), (r'.', Text), ], 'interp': [ # you can escape literal "$" as "$$" (r'\$\$', Text),
# variable references (r'\$\{', String.Interpol, 'curly'), ], 'curly': [ (r'\}', String.Interpol, '#pop'), (r'\w+', Name.Attribute), ], 'spvalue': [ include('interp'),
(r'#.*$', Comment.Single, '#pop'), (r'\n', Whitespace, '#pop'),
# fallback (r'\s+', Whitespace), (r'[^${}#\n\s]+', Text), (r'.', Text), ], }
class PacmanConfLexer(RegexLexer): """ Lexer for pacman.conf.
Actually, IniLexer works almost fine for this format, but it yield error token. It is because pacman.conf has a form without assignment like:
UseSyslog Color TotalDownload CheckSpace VerbosePkgLists
These are flags to switch on. """
name = 'PacmanConf' url = 'https://www.archlinux.org/pacman/pacman.conf.5.html' aliases = ['pacmanconf'] filenames = ['pacman.conf'] mimetypes = [] version_added = '2.1'
tokens = { 'root': [ # comment (r'#.*$', Comment.Single),
# section header (r'^(\s*)(\[.*?\])(\s*)$', bygroups(Whitespace, Keyword, Whitespace)),
# variable definitions # (Leading space is allowed...) (r'(\w+)(\s*)(=)', bygroups(Name.Attribute, Whitespace, Operator)),
# flags to on (r'^(\s*)(\w+)(\s*)$', bygroups(Whitespace, Name.Attribute, Whitespace)),
# built-in special values (words(( '$repo', # repository '$arch', # architecture '%o', # outfile '%u', # url ), suffix=r'\b'), Name.Variable),
# fallback (r'\s+', Whitespace), (r'.', Text), ], }
class AugeasLexer(RegexLexer): """ Lexer for Augeas. """ name = 'Augeas' url = 'http://augeas.net' aliases = ['augeas'] filenames = ['*.aug'] version_added = '2.4'
tokens = { 'root': [ (r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), (r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Whitespace, Name.Variable)), (r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Whitespace)), (r'(\()([^:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)), (r'\(\*', Comment.Multiline, 'comment'), (r'[*+\-.;=?|]', Operator), (r'[()\[\]{}]', Operator), (r'"', String.Double, 'string'), (r'\/', String.Regex, 'regex'), (r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)), (r'.', Name.Variable), (r'\s+', Whitespace), ], 'string': [ (r'\\.', String.Escape), (r'[^"]', String.Double), (r'"', String.Double, '#pop'), ], 'regex': [ (r'\\.', String.Escape), (r'[^/]', String.Regex), (r'\/', String.Regex, '#pop'), ], 'comment': [ (r'[^*)]', Comment.Multiline), (r'\(\*', Comment.Multiline, '#push'), (r'\*\)', Comment.Multiline, '#pop'), (r'[)*]', Comment.Multiline) ], }
class TOMLLexer(RegexLexer): """ Lexer for TOML, a simple language for config files. """
name = 'TOML' aliases = ['toml'] filenames = ['*.toml', 'Pipfile', 'poetry.lock'] mimetypes = ['application/toml'] url = 'https://toml.io' version_added = '2.4'
# Based on the TOML spec: https://toml.io/en/v1.0.0
# The following is adapted from CPython's tomllib: _time = r"\d\d:\d\d(:\d\d(\.\d+)?)?" _datetime = rf"""(?x) \d\d\d\d-\d\d-\d\d # date, e.g., 1988-10-27 ( [Tt ] {_time} # optional time ( [Zz]|[+-]\d\d:\d\d # optional time offset )? )? """
tokens = { 'root': [ # Note that we make an effort in order to distinguish # moments at which we're parsing a key and moments at # which we're parsing a value. In the TOML code # # 1234 = 1234 # # the first "1234" should be Name, the second Integer.
# Whitespace (r'\s+', Whitespace),
# Comment (r'#.*', Comment.Single),
# Assignment keys include('key'),
# After "=", find a value (r'(=)(\s*)', bygroups(Operator, Whitespace), 'value'),
# Table header (r'\[\[?', Keyword, 'table-key'), ], 'key': [ # Start of bare key (only ASCII is allowed here). (r'[A-Za-z0-9_-]+', Name), # Quoted key (r'"', String.Double, 'basic-string'), (r"'", String.Single, 'literal-string'), # Dots act as separators in keys (r'\.', Punctuation), ], 'table-key': [ # This is like 'key', but highlights the name components # and separating dots as Keyword because it looks better # when the whole table header is Keyword. We do highlight # strings as strings though. # Start of bare key (only ASCII is allowed here). (r'[A-Za-z0-9_-]+', Keyword), (r'"', String.Double, 'basic-string'), (r"'", String.Single, 'literal-string'), (r'\.', Keyword), (r'\]\]?', Keyword, '#pop'),
# Inline whitespace allowed (r'[ \t]+', Whitespace), ], 'value': [ # Datetime, baretime (_datetime, Literal.Date, '#pop'), (_time, Literal.Date, '#pop'),
# Recognize as float if there is a fractional part # and/or an exponent. (r'[+-]?\d[0-9_]*[eE][+-]?\d[0-9_]*', Number.Float, '#pop'), (r'[+-]?\d[0-9_]*\.\d[0-9_]*([eE][+-]?\d[0-9_]*)?', Number.Float, '#pop'),
# Infinities and NaN (r'[+-]?(inf|nan)', Number.Float, '#pop'),
# Integers (r'-?0b[01_]+', Number.Bin, '#pop'), (r'-?0o[0-7_]+', Number.Oct, '#pop'), (r'-?0x[0-9a-fA-F_]+', Number.Hex, '#pop'), (r'[+-]?[0-9_]+', Number.Integer, '#pop'),
# Strings (r'"""', String.Double, ('#pop', 'multiline-basic-string')), (r'"', String.Double, ('#pop', 'basic-string')), (r"'''", String.Single, ('#pop', 'multiline-literal-string')), (r"'", String.Single, ('#pop', 'literal-string')),
# Booleans (r'true|false', Keyword.Constant, '#pop'),
# Start of array (r'\[', Punctuation, ('#pop', 'array')),
# Start of inline table (r'\{', Punctuation, ('#pop', 'inline-table')), ], 'array': [ # Whitespace, including newlines, is ignored inside arrays, # and comments are allowed. (r'\s+', Whitespace), (r'#.*', Comment.Single),
# Delimiters (r',', Punctuation),
# End of array (r'\]', Punctuation, '#pop'),
# Parse a value and come back default('value'), ], 'inline-table': [ # Whitespace (since TOML 1.1.0, same as in array) (r'\s+', Whitespace), (r'#.*', Comment.Single),
# Keys include('key'),
# Values (r'(=)(\s*)', bygroups(Punctuation, Whitespace), 'value'),
# Delimiters (r',', Punctuation),
# End of inline table (r'\}', Punctuation, '#pop'), ], 'basic-string': [ (r'"', String.Double, '#pop'), include('escapes'), (r'[^"\\]+', String.Double), ], 'literal-string': [ (r".*?'", String.Single, '#pop'), ], 'multiline-basic-string': [ (r'"""', String.Double, '#pop'), (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), include('escapes'), (r'[^"\\]+', String.Double), (r'"', String.Double), ], 'multiline-literal-string': [ (r"'''", String.Single, '#pop'), (r"[^']+", String.Single), (r"'", String.Single), ], 'escapes': [ (r'\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}', String.Escape), (r'\\.', String.Escape), ], }
class NestedTextLexer(RegexLexer): """ Lexer for *NextedText*, a human-friendly data format.
.. versionchanged:: 2.16 Added support for *NextedText* v3.0. """
name = 'NestedText' url = 'https://nestedtext.org' aliases = ['nestedtext', 'nt'] filenames = ['*.nt'] version_added = '2.9'
tokens = { 'root': [ # Comment: # ... (r'^([ ]*)(#.*)$', bygroups(Whitespace, Comment)),
# Inline dictionary: {...} (r'^([ ]*)(\{)', bygroups(Whitespace, Punctuation), 'inline_dict'),
# Inline list: [...] (r'^([ ]*)(\[)', bygroups(Whitespace, Punctuation), 'inline_list'),
# empty multiline string item: > (r'^([ ]*)(>)$', bygroups(Whitespace, Punctuation)),
# multiline string item: > ... (r'^([ ]*)(>)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)),
# empty list item: - (r'^([ ]*)(-)$', bygroups(Whitespace, Punctuation)),
# list item: - ... (r'^([ ]*)(-)( )(.*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Text, Whitespace)),
# empty multiline key item: : (r'^([ ]*)(:)$', bygroups(Whitespace, Punctuation)),
# multiline key item: : ... (r'^([ ]*)(:)( )([^\n]*?)([ \t]*)$', bygroups(Whitespace, Punctuation, Whitespace, Name.Tag, Whitespace)),
# empty dict key item: ...: (r'^([ ]*)([^\{\[\s].*?)(:)$', bygroups(Whitespace, Name.Tag, Punctuation)),
# dict key item: ...: ... (r'^([ ]*)([^\{\[\s].*?)(:)( )(.*?)([ \t]*)$', bygroups(Whitespace, Name.Tag, Punctuation, Whitespace, Text, Whitespace)), ], 'inline_list': [ include('whitespace'), (r'[^\{\}\[\],\s]+', Text), include('inline_value'), (r',', Punctuation), (r'\]', Punctuation, '#pop'), (r'\n', Error, '#pop'), ], 'inline_dict': [ include('whitespace'), (r'[^\{\}\[\],:\s]+', Name.Tag), (r':', Punctuation, 'inline_dict_value'), (r'\}', Punctuation, '#pop'), (r'\n', Error, '#pop'), ], 'inline_dict_value': [ include('whitespace'), (r'[^\{\}\[\],:\s]+', Text), include('inline_value'), (r',', Punctuation, '#pop'), (r'\}', Punctuation, '#pop:2'), ], 'inline_value': [ include('whitespace'), (r'\{', Punctuation, 'inline_dict'), (r'\[', Punctuation, 'inline_list'), ], 'whitespace': [ (r'[ \t]+', Whitespace), ], }
class SingularityLexer(RegexLexer): """ Lexer for Singularity definition files. """
name = 'Singularity' url = 'https://www.sylabs.io/guides/3.0/user-guide/definition_files.html' aliases = ['singularity'] filenames = ['*.def', 'Singularity'] version_added = '2.6' flags = re.IGNORECASE | re.MULTILINE | re.DOTALL
_headers = r'^(\s*)(bootstrap|from|osversion|mirrorurl|include|registry|namespace|includecmd)(:)' _section = r'^(%(?:pre|post|setup|environment|help|labels|test|runscript|files|startscript))(\s*)' _appsect = r'^(%app(?:install|help|run|labels|env|test|files))(\s*)'
tokens = { 'root': [ (_section, bygroups(Generic.Heading, Whitespace), 'script'), (_appsect, bygroups(Generic.Heading, Whitespace), 'script'), (_headers, bygroups(Whitespace, Keyword, Text)), (r'\s*#.*?\n', Comment), (r'\b(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b', Number), (r'[ \t]+', Whitespace), (r'(?!^\s*%).', Text), ], 'script': [ (r'(.+?(?=^\s*%))|(.*)', using(BashLexer), '#pop'), ], }
def analyse_text(text): """This is a quite simple script file, but there are a few keywords which seem unique to this language.""" result = 0 if re.search(r'\b(?:osversion|includecmd|mirrorurl)\b', text, re.IGNORECASE): result += 0.5
if re.search(SingularityLexer._section[1:], text): result += 0.49
return result
class UnixConfigLexer(RegexLexer): """ Lexer for Unix/Linux config files using colon-separated values, e.g.
* ``/etc/group`` * ``/etc/passwd`` * ``/etc/shadow`` """
name = 'Unix/Linux config files' aliases = ['unixconfig', 'linuxconfig'] filenames = [] url = 'https://en.wikipedia.org/wiki/Configuration_file#Unix_and_Unix-like_operating_systems' version_added = '2.12'
tokens = { 'root': [ (r'^#.*', Comment), (r'\n', Whitespace), (r':', Punctuation), (r'[0-9]+', Number), (r'((?!\n)[a-zA-Z0-9\_\-\s\(\),]){2,}', Text), (r'[^:\n]+', String), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114""" pygments.lexers.console ~~~~~~~~~~~~~~~~~~~~~~~
Lexers for misc console output.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, include, bygroupsfrom pygments.token import Generic, Comment, String, Text, Keyword, Name, \ Punctuation, Number, Whitespace
__all__ = ['VCTreeStatusLexer', 'PyPyLogLexer']
class VCTreeStatusLexer(RegexLexer): """ For colorizing output of version control status commands, like "hg status" or "svn status". """ name = 'VCTreeStatus' aliases = ['vctreestatus'] filenames = [] mimetypes = [] url = "" version_added = '2.0'
tokens = { 'root': [ (r'^A \+ C\s+', Generic.Error), (r'^A\s+\+?\s+', String), (r'^M\s+', Generic.Inserted), (r'^C\s+', Generic.Error), (r'^D\s+', Generic.Deleted), (r'^[?!]\s+', Comment.Preproc), (r' >\s+.*\n', Comment.Preproc), (r'\S+', Text), (r'\s+', Whitespace), ] }
class PyPyLogLexer(RegexLexer): """ Lexer for PyPy log files. """ name = "PyPy Log" aliases = ["pypylog", "pypy"] filenames = ["*.pypylog"] mimetypes = ['application/x-pypylog'] url = 'pypy.org' version_added = '1.5'
tokens = { "root": [ (r"\[\w+\] \{jit-log-.*?$", Keyword, "jit-log"), (r"\[\w+\] \{jit-backend-counts$", Keyword, "jit-backend-counts"), include("extra-stuff"), ], "jit-log": [ (r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"), (r"^\+\d+: ", Comment), (r"--end of the loop--", Comment), (r"[ifp]\d+", Name), (r"ptr\d+", Name), (r"(\()(\w+(?:\.\w+)?)(\))", bygroups(Punctuation, Name.Builtin, Punctuation)), (r"[\[\]=,()]", Punctuation), (r"(\d+\.\d+|inf|-inf)", Number.Float), (r"-?\d+", Number.Integer), (r"'.*'", String), (r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name), (r"<.*?>+", Name.Builtin), (r"(label|debug_merge_point|jump|finish)", Name.Class), (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|" r"int_floordiv|int_mod|int_lshift|int_rshift|int_and|int_or|" r"int_xor|int_eq|int_ne|int_ge|int_gt|int_le|int_lt|int_is_zero|" r"int_is_true|" r"uint_floordiv|uint_ge|uint_lt|" r"float_add|float_sub|float_mul|float_truediv|float_neg|" r"float_eq|float_ne|float_ge|float_gt|float_le|float_lt|float_abs|" r"ptr_eq|ptr_ne|instance_ptr_eq|instance_ptr_ne|" r"cast_int_to_float|cast_float_to_int|" r"force_token|quasiimmut_field|same_as|virtual_ref_finish|" r"virtual_ref|mark_opaque_ptr|" r"call_may_force|call_assembler|call_loopinvariant|" r"call_release_gil|call_pure|call|" r"new_with_vtable|new_array|newstr|newunicode|new|" r"arraylen_gc|" r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|" r"getarrayitem_raw|setarrayitem_raw|getfield_gc_pure|" r"getfield_gc|getinteriorfield_gc|setinteriorfield_gc|" r"getfield_raw|setfield_gc|setfield_raw|" r"strgetitem|strsetitem|strlen|copystrcontent|" r"unicodegetitem|unicodesetitem|unicodelen|" r"guard_true|guard_false|guard_value|guard_isnull|" r"guard_nonnull_class|guard_nonnull|guard_class|guard_no_overflow|" r"guard_not_forced|guard_no_exception|guard_not_invalidated)", Name.Builtin), include("extra-stuff"), ], "jit-backend-counts": [ (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"), (r":", Punctuation), (r"\d+", Number), include("extra-stuff"), ], "extra-stuff": [ (r"\s+", Whitespace), (r"#.*?$", Comment), ], }12345678910111213141516171819202122232425262728293031323334353637383940414243""" pygments.lexers.cplint ~~~~~~~~~~~~~~~~~~~~~~
Lexer for the cplint language
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import bygroups, inherit, wordsfrom pygments.lexers import PrologLexerfrom pygments.token import Operator, Keyword, Name, String, Punctuation
__all__ = ['CplintLexer']
class CplintLexer(PrologLexer): """ Lexer for cplint files, including CP-logic, Logic Programs with Annotated Disjunctions, Distributional Clauses syntax, ProbLog, DTProbLog. """ name = 'cplint' url = 'https://cplint.eu' aliases = ['cplint'] filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl'] mimetypes = ['text/x-cplint'] version_added = '2.12'
tokens = { 'root': [ (r'map_query', Keyword), (words(('gaussian', 'uniform_dens', 'dirichlet', 'gamma', 'beta', 'poisson', 'binomial', 'geometric', 'exponential', 'pascal', 'multinomial', 'user', 'val', 'uniform', 'discrete', 'finite')), Name.Builtin), # annotations of atoms (r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)), (r':(-|=)|::?|~=?|=>', Operator), (r'\?', Name.Builtin), inherit, ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364""" pygments.lexers.crystal ~~~~~~~~~~~~~~~~~~~~~~~
Lexer for Crystal.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import ExtendedRegexLexer, include, bygroups, default, \ words, line_refrom pygments.token import Comment, Operator, Keyword, Name, String, Number, \ Punctuation, Error, Whitespace
__all__ = ['CrystalLexer']
CRYSTAL_OPERATORS = [ '!=', '!~', '!', '%', '&&', '&', '**', '*', '+', '-', '/', '<=>', '<<', '<=', '<', '===', '==', '=~', '=', '>=', '>>', '>', '[]=', '[]?', '[]', '^', '||', '|', '~']
class CrystalLexer(ExtendedRegexLexer): """ For Crystal source code. """
name = 'Crystal' url = 'https://crystal-lang.org' aliases = ['cr', 'crystal'] filenames = ['*.cr'] mimetypes = ['text/x-crystal'] version_added = '2.2'
flags = re.DOTALL | re.MULTILINE
def heredoc_callback(self, match, ctx): # okay, this is the hardest part of parsing Crystal... # match: 1 = <<-?, 2 = quote? 3 = name 4 = quote? 5 = rest of line
start = match.start(1) yield start, Operator, match.group(1) # <<-? yield match.start(2), String.Heredoc, match.group(2) # quote ", ', ` yield match.start(3), String.Delimiter, match.group(3) # heredoc name yield match.start(4), String.Heredoc, match.group(4) # quote again
heredocstack = ctx.__dict__.setdefault('heredocstack', []) outermost = not bool(heredocstack) heredocstack.append((match.group(1) == '<<-', match.group(3)))
ctx.pos = match.start(5) ctx.end = match.end(5) # this may find other heredocs, so limit the recursion depth if len(heredocstack) < 100: yield from self.get_tokens_unprocessed(context=ctx) else: yield ctx.pos, String.Heredoc, match.group(5) ctx.pos = match.end()
if outermost: # this is the outer heredoc again, now we can process them all for tolerant, hdname in heredocstack: lines = [] for match in line_re.finditer(ctx.text, ctx.pos): if tolerant: check = match.group().strip() else: check = match.group().rstrip() if check == hdname: for amatch in lines: yield amatch.start(), String.Heredoc, amatch.group() yield match.start(), String.Delimiter, match.group() ctx.pos = match.end() break else: lines.append(match) else: # end of heredoc not found -- error! for amatch in lines: yield amatch.start(), Error, amatch.group() ctx.end = len(ctx.text) del heredocstack[:]
def gen_crystalstrings_rules(): states = {} states['strings'] = [ (r'\:\w+[!?]?', String.Symbol), (words(CRYSTAL_OPERATORS, prefix=r'\:'), String.Symbol), (r":'(\\\\|\\[^\\]|[^'\\])*'", String.Symbol), # This allows arbitrary text after '\ for simplicity (r"'(\\\\|\\'|[^']|\\[^'\\]+)'", String.Char), (r':"', String.Symbol, 'simple-sym'), # Crystal doesn't have "symbol:"s but this simplifies function args (r'([a-zA-Z_]\w*)(:)(?!:)', bygroups(String.Symbol, Punctuation)), (r'"', String.Double, 'simple-string'), (r'(?<!\.)`', String.Backtick, 'simple-backtick'), ]
# double-quoted string and symbol for name, ttype, end in ('string', String.Double, '"'), \ ('sym', String.Symbol, '"'), \ ('backtick', String.Backtick, '`'): states['simple-'+name] = [ include('string-escaped' if name == 'sym' else 'string-intp-escaped'), (rf'[^\\{end}#]+', ttype), (r'[\\#]', ttype), (end, ttype, '#pop'), ]
# https://crystal-lang.org/docs/syntax_and_semantics/literals/string.html#percent-string-literals for lbrace, rbrace, bracecc, name in \ ('\\{', '\\}', '{}', 'cb'), \ ('\\[', '\\]', '\\[\\]', 'sb'), \ ('\\(', '\\)', '()', 'pa'), \ ('<', '>', '<>', 'ab'), \ ('\\|', '\\|', '\\|', 'pi'): states[name+'-intp-string'] = [ (r'\\' + lbrace, String.Other), ] + (lbrace != rbrace) * [ (lbrace, String.Other, '#push'), ] + [ (rbrace, String.Other, '#pop'), include('string-intp-escaped'), (r'[\\#' + bracecc + ']', String.Other), (r'[^\\#' + bracecc + ']+', String.Other), ] states['strings'].append((r'%Q?' + lbrace, String.Other, name+'-intp-string')) states[name+'-string'] = [ (r'\\[\\' + bracecc + ']', String.Other), ] + (lbrace != rbrace) * [ (lbrace, String.Other, '#push'), ] + [ (rbrace, String.Other, '#pop'), (r'[\\#' + bracecc + ']', String.Other), (r'[^\\#' + bracecc + ']+', String.Other), ] # https://crystal-lang.org/docs/syntax_and_semantics/literals/array.html#percent-array-literals states['strings'].append((r'%[qwi]' + lbrace, String.Other, name+'-string')) states[name+'-regex'] = [ (r'\\[\\' + bracecc + ']', String.Regex), ] + (lbrace != rbrace) * [ (lbrace, String.Regex, '#push'), ] + [ (rbrace + '[imsx]*', String.Regex, '#pop'), include('string-intp'), (r'[\\#' + bracecc + ']', String.Regex), (r'[^\\#' + bracecc + ']+', String.Regex), ] states['strings'].append((r'%r' + lbrace, String.Regex, name+'-regex'))
return states
tokens = { 'root': [ (r'#.*?$', Comment.Single), # keywords (words(''' abstract asm begin break case do else elsif end ensure extend if in include next of private protected require rescue return select self super then unless until when while with yield '''.split(), suffix=r'\b'), Keyword), (words(''' previous_def forall out uninitialized __DIR__ __FILE__ __LINE__ __END_LINE__ '''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Keyword.Pseudo), # https://crystal-lang.org/docs/syntax_and_semantics/is_a.html (r'\.(is_a\?|nil\?|responds_to\?|as\?|as\b)', Keyword.Pseudo), (words(['true', 'false', 'nil'], suffix=r'\b'), Keyword.Constant), # start of function, class and module names (r'(module|lib)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)', bygroups(Keyword, Whitespace, Name.Namespace)), (r'(def|fun|macro)(\s+)((?:[a-zA-Z_]\w*::)*)', bygroups(Keyword, Whitespace, Name.Namespace), 'funcname'), (r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'), (r'(annotation|class|struct|union|type|alias|enum)(\s+)((?:[a-zA-Z_]\w*::)*)', bygroups(Keyword, Whitespace, Name.Namespace), 'classname'), # https://crystal-lang.org/api/toplevel.html (words(''' instance_sizeof offsetof pointerof sizeof typeof '''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Keyword.Pseudo), # macros (r'(?<!\.)(debugger\b|p!|pp!|record\b|spawn\b)', Name.Builtin.Pseudo), # builtins (words(''' abort at_exit caller exit gets loop main p pp print printf puts raise rand read_line sleep spawn sprintf system '''.split(), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), # https://crystal-lang.org/api/Object.html#macro-summary (r'(?<!\.)(((class_)?((getter|property)\b[!?]?|setter\b))|' r'(def_(clone|equals|equals_and_hash|hash)|delegate|forward_missing_to)\b)', Name.Builtin.Pseudo), # normal heredocs (r'(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)', heredoc_callback), # empty string heredocs (r'(<<-?)("|\')()(\2)(.*?\n)', heredoc_callback), (r'__END__', Comment.Preproc, 'end-part'), # multiline regex (after keywords or assignments) (r'(?:^|(?<=[=<>~!:])|' r'(?<=(?:\s|;)when\s)|' r'(?<=(?:\s|;)or\s)|' r'(?<=(?:\s|;)and\s)|' r'(?<=\.index\s)|' r'(?<=\.scan\s)|' r'(?<=\.sub\s)|' r'(?<=\.sub!\s)|' r'(?<=\.gsub\s)|' r'(?<=\.gsub!\s)|' r'(?<=\.match\s)|' r'(?<=(?:\s|;)if\s)|' r'(?<=(?:\s|;)elsif\s)|' r'(?<=^when\s)|' r'(?<=^index\s)|' r'(?<=^scan\s)|' r'(?<=^sub\s)|' r'(?<=^gsub\s)|' r'(?<=^sub!\s)|' r'(?<=^gsub!\s)|' r'(?<=^match\s)|' r'(?<=^if\s)|' r'(?<=^elsif\s)' r')(\s*)(/)', bygroups(Whitespace, String.Regex), 'multiline-regex'), # multiline regex (in method calls or subscripts) (r'(?<=\(|,|\[)/', String.Regex, 'multiline-regex'), # multiline regex (this time the funny no whitespace rule) (r'(\s+)(/)(?![\s=])', bygroups(Whitespace, String.Regex), 'multiline-regex'), # lex numbers and ignore following regular expressions which # are division operators in fact (grrrr. i hate that. any # better ideas?) # since pygments 0.7 we also eat a "?" operator after numbers # so that the char operator does not work. Chars are not allowed # there so that you can use the ternary operator. # stupid example: # x>=0?n[x]:"" (r'(0o[0-7]+(?:_[0-7]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?', bygroups(Number.Oct, Whitespace, Operator)), (r'(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?', bygroups(Number.Hex, Whitespace, Operator)), (r'(0b[01]+(?:_[01]+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?', bygroups(Number.Bin, Whitespace, Operator)), # 3 separate expressions for floats because any of the 3 optional # parts makes it a float (r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)(?:e[+-]?[0-9]+)?' r'(?:_?f[0-9]+)?)(\s*)([/?])?', bygroups(Number.Float, Whitespace, Operator)), (r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)' r'(?:_?f[0-9]+)?)(\s*)([/?])?', bygroups(Number.Float, Whitespace, Operator)), (r'((?:0(?![0-9])|[1-9][\d_]*)(?:\.\d[\d_]*)?(?:e[+-]?[0-9]+)?' r'(?:_?f[0-9]+))(\s*)([/?])?', bygroups(Number.Float, Whitespace, Operator)), (r'(0\b|[1-9][\d]*(?:_\d+)*(?:_?[iu][0-9]+)?)\b(\s*)([/?])?', bygroups(Number.Integer, Whitespace, Operator)), # Names (r'@@[a-zA-Z_]\w*', Name.Variable.Class), (r'@[a-zA-Z_]\w*', Name.Variable.Instance), (r'\$\w+', Name.Variable.Global), (r'\$[!@&`\'+~=/\\,;.<>_*$?:"^-]', Name.Variable.Global), (r'\$-[0adFiIlpvw]', Name.Variable.Global), (r'::', Operator), include('strings'), # https://crystal-lang.org/reference/syntax_and_semantics/literals/char.html (r'\?(\\[MC]-)*' # modifiers r'(\\([\\abefnrtv#"\']|[0-7]{1,3}|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|u\{[a-fA-F0-9 ]+\})|\S)' r'(?!\w)', String.Char), (r'[A-Z][A-Z_]+\b(?!::|\.)', Name.Constant), # macro expansion (r'\{%', String.Interpol, 'in-macro-control'), (r'\{\{', String.Interpol, 'in-macro-expr'), # annotations (r'(@\[)(\s*)([A-Z]\w*(::[A-Z]\w*)*)', bygroups(Operator, Whitespace, Name.Decorator), 'in-annot'), # this is needed because Crystal attributes can look # like keywords (class) or like this: ` ?!? (words(CRYSTAL_OPERATORS, prefix=r'(\.|::)'), bygroups(Operator, Name.Operator)), (r'(\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])', bygroups(Operator, Name)), # Names can end with [!?] unless it's "!=" (r'[a-zA-Z_]\w*(?:[!?](?!=))?', Name), (r'(\[|\]\??|\*\*|<=>?|>=|<<?|>>?|=~|===|' r'!~|&&?|\|\||\.{1,3})', Operator), (r'[-+/*%=<>&!^|~]=?', Operator), (r'[(){};,/?:\\]', Punctuation), (r'\s+', Whitespace) ], 'funcname': [ (r'(?:([a-zA-Z_]\w*)(\.))?' r'([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|' r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', bygroups(Name.Class, Operator, Name.Function), '#pop'), default('#pop') ], 'classname': [ (r'[A-Z_]\w*', Name.Class), (r'(\()(\s*)([A-Z_]\w*)(\s*)(\))', bygroups(Punctuation, Whitespace, Name.Class, Whitespace, Punctuation)), default('#pop') ], 'in-intp': [ (r'\{', String.Interpol, '#push'), (r'\}', String.Interpol, '#pop'), include('root'), ], 'string-intp': [ (r'#\{', String.Interpol, 'in-intp'), ], 'string-escaped': [ # https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html (r'\\([\\abefnrtv#"\']|[0-7]{1,3}|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|u\{[a-fA-F0-9 ]+\})', String.Escape) ], 'string-intp-escaped': [ include('string-intp'), include('string-escaped'), ], 'interpolated-regex': [ include('string-intp'), (r'[\\#]', String.Regex), (r'[^\\#]+', String.Regex), ], 'interpolated-string': [ include('string-intp'), (r'[\\#]', String.Other), (r'[^\\#]+', String.Other), ], 'multiline-regex': [ include('string-intp'), (r'\\\\', String.Regex), (r'\\/', String.Regex), (r'[\\#]', String.Regex), (r'[^\\/#]+', String.Regex), (r'/[imsx]*', String.Regex, '#pop'), ], 'end-part': [ (r'.+', Comment.Preproc, '#pop') ], 'in-macro-control': [ (r'\{%', String.Interpol, '#push'), (r'%\}', String.Interpol, '#pop'), (r'(for|verbatim)\b', Keyword), include('root'), ], 'in-macro-expr': [ (r'\{\{', String.Interpol, '#push'), (r'\}\}', String.Interpol, '#pop'), include('root'), ], 'in-annot': [ (r'\[', Operator, '#push'), (r'\]', Operator, '#pop'), include('root'), ], } tokens.update(gen_crystalstrings_rules())123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466""" pygments.lexers.csound ~~~~~~~~~~~~~~~~~~~~~~
Lexers for Csound languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, bygroups, default, include, using, wordsfrom pygments.token import Comment, Error, Keyword, Name, Number, Operator, Punctuation, \ String, Text, Whitespacefrom pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES, REMOVED_OPCODESfrom pygments.lexers.html import HtmlLexerfrom pygments.lexers.python import PythonLexerfrom pygments.lexers.scripting import LuaLexer
__all__ = ['CsoundScoreLexer', 'CsoundOrchestraLexer', 'CsoundDocumentLexer']
newline = (r'((?:(?:;|//).*)*)(\n)', bygroups(Comment.Single, Text))
class CsoundLexer(RegexLexer): url = 'https://csound.com/'
tokens = { 'whitespace': [ (r'[ \t]+', Whitespace), (r'/[*](?:.|\n)*?[*]/', Comment.Multiline), (r'(?:;|//).*$', Comment.Single), (r'(\\)(\n)', bygroups(Text, Whitespace)) ],
'preprocessor directives': [ (r'#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+', Comment.Preproc), (r'#includestr', Comment.Preproc, 'includestr directive'), (r'#include', Comment.Preproc, 'include directive'), (r'#[ \t]*define', Comment.Preproc, 'define directive'), (r'#(?:ifn?def|undef)\b', Comment.Preproc, 'macro directive') ],
'include directive': [ include('whitespace'), (r'([^ \t]).*?\1', String, '#pop') ], 'includestr directive': [ include('whitespace'), (r'"', String, ('#pop', 'quoted string')) ],
'define directive': [ (r'\n', Whitespace), include('whitespace'), (r'([A-Z_a-z]\w*)(\()', bygroups(Comment.Preproc, Punctuation), ('#pop', 'macro parameter name list')), (r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'before macro body')) ], 'macro parameter name list': [ include('whitespace'), (r'[A-Z_a-z]\w*', Comment.Preproc), (r"['#]", Punctuation), (r'\)', Punctuation, ('#pop', 'before macro body')) ], 'before macro body': [ (r'\n', Whitespace), include('whitespace'), (r'#', Punctuation, ('#pop', 'macro body')) ], 'macro body': [ (r'(?:\\(?!#)|[^#\\]|\n)+', Comment.Preproc), (r'\\#', Comment.Preproc), (r'(?<!\\)#', Punctuation, '#pop') ],
'macro directive': [ include('whitespace'), (r'[A-Z_a-z]\w*', Comment.Preproc, '#pop') ],
'macro uses': [ (r'(\$[A-Z_a-z]\w*\.?)(\()', bygroups(Comment.Preproc, Punctuation), 'macro parameter value list'), (r'\$[A-Z_a-z]\w*(?:\.|\b)', Comment.Preproc) ], 'macro parameter value list': [ (r'(?:[^\'#"{()]|\{(?!\{))+', Comment.Preproc), (r"['#]", Punctuation), (r'"', String, 'macro parameter value quoted string'), (r'\{\{', String, 'macro parameter value braced string'), (r'\(', Comment.Preproc, 'macro parameter value parenthetical'), (r'\)', Punctuation, '#pop') ], 'macro parameter value quoted string': [ (r"\\[#'()]", Comment.Preproc), (r"[#'()]", Error), include('quoted string') ], 'macro parameter value braced string': [ (r"\\[#'()]", Comment.Preproc), (r"[#'()]", Error), include('braced string') ], 'macro parameter value parenthetical': [ (r'(?:[^\\()]|\\\))+', Comment.Preproc), (r'\(', Comment.Preproc, '#push'), (r'\)', Comment.Preproc, '#pop') ],
'whitespace and macro uses': [ include('whitespace'), include('macro uses') ],
'numbers': [ (r'\d+[Ee][+-]?\d+|(\d+\.\d*|\d*\.\d+)([Ee][+-]?\d+)?', Number.Float), (r'(0[Xx])([0-9A-Fa-f]+)', bygroups(Keyword.Type, Number.Hex)), (r'\d+', Number.Integer) ],
'quoted string': [ (r'"', String, '#pop'), (r'[^"$]+', String), include('macro uses'), (r'[$]', String) ],
'braced string': [ # Do nothing. This must be defined in subclasses. ] }
class CsoundScoreLexer(CsoundLexer): """ For `Csound <https://csound.com>`_ scores. """
name = 'Csound Score' aliases = ['csound-score', 'csound-sco'] filenames = ['*.sco'] version_added = '2.1'
tokens = { 'root': [ (r'\n', Whitespace), include('whitespace and macro uses'), include('preprocessor directives'),
(r'[aBbCdefiqstvxy]', Keyword), # There is also a w statement that is generated internally and should not be # used; see https://github.com/csound/csound/issues/750.
(r'z', Keyword.Constant), # z is a constant equal to 800,000,000,000. 800 billion seconds is about # 25,367.8 years. See also # https://csound.com/docs/manual/ScoreTop.html and # https://github.com/csound/csound/search?q=stof+path%3AEngine+filename%3Asread.c.
(r'([nNpP][pP])(\d+)', bygroups(Keyword, Number.Integer)),
(r'[mn]', Keyword, 'mark statement'),
include('numbers'), (r'[!+\-*/^%&|<>#~.]', Operator), (r'[()\[\]]', Punctuation), (r'"', String, 'quoted string'), (r'\{', Comment.Preproc, 'loop after left brace'), ],
'mark statement': [ include('whitespace and macro uses'), (r'[A-Z_a-z]\w*', Name.Label), (r'\n', Whitespace, '#pop') ],
'loop after left brace': [ include('whitespace and macro uses'), (r'\d+', Number.Integer, ('#pop', 'loop after repeat count')), ], 'loop after repeat count': [ include('whitespace and macro uses'), (r'[A-Z_a-z]\w*', Comment.Preproc, ('#pop', 'loop')) ], 'loop': [ (r'\}', Comment.Preproc, '#pop'), include('root') ],
# Braced strings are not allowed in Csound scores, but this is needed because the # superclass includes it. 'braced string': [ (r'\}\}', String, '#pop'), (r'[^}]|\}(?!\})', String) ] }
class CsoundOrchestraLexer(CsoundLexer): """ For `Csound <https://csound.com>`_ orchestras. """
name = 'Csound Orchestra' aliases = ['csound', 'csound-orc'] filenames = ['*.orc', '*.udo'] version_added = '2.1'
user_defined_opcodes = set()
def opcode_name_callback(lexer, match): opcode = match.group(0) lexer.user_defined_opcodes.add(opcode) yield match.start(), Name.Function, opcode
def name_callback(lexer, match): type_annotation_token = Keyword.Type
name = match.group(1) if name in OPCODES or name in DEPRECATED_OPCODES or name in REMOVED_OPCODES: yield match.start(), Name.Builtin, name elif name in lexer.user_defined_opcodes: yield match.start(), Name.Function, name else: type_annotation_token = Name name_match = re.search(r'^(g?[afikSw])(\w+)', name) if name_match: yield name_match.start(1), Keyword.Type, name_match.group(1) yield name_match.start(2), Name, name_match.group(2) else: yield match.start(), Name, name
if match.group(2): yield match.start(2), Punctuation, match.group(2) yield match.start(3), type_annotation_token, match.group(3)
tokens = { 'root': [ (r'\n', Whitespace),
(r'^([ \t]*)(\w+)(:)([ \t]+|$)', bygroups(Whitespace, Name.Label, Punctuation, Whitespace)),
include('whitespace and macro uses'), include('preprocessor directives'),
(r'\binstr\b', Keyword.Declaration, 'instrument numbers and identifiers'), (r'\bopcode\b', Keyword.Declaration, 'after opcode keyword'), (r'\b(?:end(?:in|op))\b', Keyword.Declaration),
include('partial statements') ],
'partial statements': [ (r'\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\b', Name.Variable.Global),
include('numbers'),
(r'\+=|-=|\*=|/=|<<|>>|<=|>=|==|!=|&&|\|\||[~¬]|[=!+\-*/^%&|<>#?:]', Operator), (r'[(),\[\]]', Punctuation),
(r'"', String, 'quoted string'), (r'\{\{', String, 'braced string'),
(words(( 'do', 'else', 'elseif', 'endif', 'enduntil', 'fi', 'if', 'ithen', 'kthen', 'od', 'then', 'until', 'while', ), prefix=r'\b', suffix=r'\b'), Keyword), (words(('return', 'rireturn'), prefix=r'\b', suffix=r'\b'), Keyword.Pseudo),
(r'\b[ik]?goto\b', Keyword, 'goto label'), (r'\b(r(?:einit|igoto)|tigoto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation), 'goto label'), (r'\b(c(?:g|in?|k|nk?)goto)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation), ('goto label', 'goto argument')), (r'\b(timout)(\(|\b)', bygroups(Keyword.Pseudo, Punctuation), ('goto label', 'goto argument', 'goto argument')), (r'\b(loop_[gl][et])(\(|\b)', bygroups(Keyword.Pseudo, Punctuation), ('goto label', 'goto argument', 'goto argument', 'goto argument')),
(r'\bprintk?s\b', Name.Builtin, 'prints opcode'), (r'\b(?:readscore|scoreline(?:_i)?)\b', Name.Builtin, 'Csound score opcode'), (r'\bpyl?run[it]?\b', Name.Builtin, 'Python opcode'), (r'\blua_(?:exec|opdef)\b', Name.Builtin, 'Lua opcode'), (r'\bp\d+\b', Name.Variable.Instance), (r'\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\b', name_callback) ],
'instrument numbers and identifiers': [ include('whitespace and macro uses'), (r'\d+|[A-Z_a-z]\w*', Name.Function), (r'[+,]', Punctuation), (r'\n', Whitespace, '#pop') ],
'after opcode keyword': [ include('whitespace and macro uses'), (r'[A-Z_a-z]\w*', opcode_name_callback, ('#pop', 'opcode type signatures')), (r'\n', Whitespace, '#pop') ], 'opcode type signatures': [ include('whitespace and macro uses'),
# https://github.com/csound/csound/search?q=XIDENT+path%3AEngine+filename%3Acsound_orc.lex (r'0|[afijkKoOpPStV\[\]]+', Keyword.Type),
(r',', Punctuation), (r'\n', Whitespace, '#pop') ],
'quoted string': [ (r'"', String, '#pop'), (r'[^\\"$%)]+', String), include('macro uses'), include('escape sequences'), include('format specifiers'), (r'[\\$%)]', String) ], 'braced string': [ (r'\}\}', String, '#pop'), (r'(?:[^\\%)}]|\}(?!\}))+', String), include('escape sequences'), include('format specifiers'), (r'[\\%)]', String) ], 'escape sequences': [ # https://github.com/csound/csound/search?q=unquote_string+path%3AEngine+filename%3Acsound_orc_compile.c (r'\\(?:[\\abnrt"]|[0-7]{1,3})', String.Escape) ], # Format specifiers are highlighted in all strings, even though only # fprintks https://csound.com/docs/manual/fprintks.html # fprints https://csound.com/docs/manual/fprints.html # printf/printf_i https://csound.com/docs/manual/printf.html # printks https://csound.com/docs/manual/printks.html # prints https://csound.com/docs/manual/prints.html # sprintf https://csound.com/docs/manual/sprintf.html # sprintfk https://csound.com/docs/manual/sprintfk.html # work with strings that contain format specifiers. In addition, these opcodes’ # handling of format specifiers is inconsistent: # - fprintks and fprints accept %a and %A specifiers, and accept %s specifiers # starting in Csound 6.15.0. # - printks and prints accept %a and %A specifiers, but don’t accept %s # specifiers. # - printf, printf_i, sprintf, and sprintfk don’t accept %a and %A specifiers, # but accept %s specifiers. # See https://github.com/csound/csound/issues/747 for more information. 'format specifiers': [ (r'%[#0\- +]*\d*(?:\.\d+)?[AE-GXac-giosux]', String.Interpol), (r'%%', String.Escape) ],
'goto argument': [ include('whitespace and macro uses'), (r',', Punctuation, '#pop'), include('partial statements') ], 'goto label': [ include('whitespace and macro uses'), (r'\w+', Name.Label, '#pop'), default('#pop') ],
'prints opcode': [ include('whitespace and macro uses'), (r'"', String, 'prints quoted string'), default('#pop') ], 'prints quoted string': [ (r'\\\\[aAbBnNrRtT]', String.Escape), (r'%[!nNrRtT]|[~^]{1,2}', String.Escape), include('quoted string') ],
'Csound score opcode': [ include('whitespace and macro uses'), (r'"', String, 'quoted string'), (r'\{\{', String, 'Csound score'), (r'\n', Whitespace, '#pop') ], 'Csound score': [ (r'\}\}', String, '#pop'), (r'([^}]+)|\}(?!\})', using(CsoundScoreLexer)) ],
'Python opcode': [ include('whitespace and macro uses'), (r'"', String, 'quoted string'), (r'\{\{', String, 'Python'), (r'\n', Whitespace, '#pop') ], 'Python': [ (r'\}\}', String, '#pop'), (r'([^}]+)|\}(?!\})', using(PythonLexer)) ],
'Lua opcode': [ include('whitespace and macro uses'), (r'"', String, 'quoted string'), (r'\{\{', String, 'Lua'), (r'\n', Whitespace, '#pop') ], 'Lua': [ (r'\}\}', String, '#pop'), (r'([^}]+)|\}(?!\})', using(LuaLexer)) ] }
class CsoundDocumentLexer(RegexLexer): """ For Csound documents. """
name = 'Csound Document' aliases = ['csound-document', 'csound-csd'] filenames = ['*.csd'] url = 'https://csound.com' version_added = '2.1'
# These tokens are based on those in XmlLexer in pygments/lexers/html.py. Making # CsoundDocumentLexer a subclass of XmlLexer rather than RegexLexer may seem like a # better idea, since Csound Document files look like XML files. However, Csound # Documents can contain Csound comments (preceded by //, for example) before and # after the root element, unescaped bitwise AND & and less than < operators, etc. In # other words, while Csound Document files look like XML files, they may not actually # be XML files. tokens = { 'root': [ (r'/[*](.|\n)*?[*]/', Comment.Multiline), (r'(?:;|//).*$', Comment.Single), (r'[^/;<]+|/(?!/)', Text),
(r'<\s*CsInstruments', Name.Tag, ('orchestra', 'tag')), (r'<\s*CsScore', Name.Tag, ('score', 'tag')), (r'<\s*[Hh][Tt][Mm][Ll]', Name.Tag, ('HTML', 'tag')),
(r'<\s*[\w:.-]+', Name.Tag, 'tag'), (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag) ],
'orchestra': [ (r'<\s*/\s*CsInstruments\s*>', Name.Tag, '#pop'), (r'(.|\n)+?(?=<\s*/\s*CsInstruments\s*>)', using(CsoundOrchestraLexer)) ], 'score': [ (r'<\s*/\s*CsScore\s*>', Name.Tag, '#pop'), (r'(.|\n)+?(?=<\s*/\s*CsScore\s*>)', using(CsoundScoreLexer)) ], 'HTML': [ (r'<\s*/\s*[Hh][Tt][Mm][Ll]\s*>', Name.Tag, '#pop'), (r'(.|\n)+?(?=<\s*/\s*[Hh][Tt][Mm][Ll]\s*>)', using(HtmlLexer)) ],
'tag': [ (r'\s+', Whitespace), (r'[\w.:-]+\s*=', Name.Attribute, 'attr'), (r'/?\s*>', Name.Tag, '#pop') ], 'attr': [ (r'\s+', Whitespace), (r'".*?"', String, '#pop'), (r"'.*?'", String, '#pop'), (r'[^\s>]+', String, '#pop') ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632""" pygments.lexers.css ~~~~~~~~~~~~~~~~~~~
Lexers for CSS and related stylesheet formats.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import reimport copy
from pygments.lexer import ExtendedRegexLexer, RegexLexer, include, bygroups, \ default, words, inheritfrom pygments.token import Comment, Operator, Keyword, Name, String, Number, \ Punctuation, Whitespacefrom pygments.lexers._css_builtins import _css_properties
__all__ = ['CssLexer', 'SassLexer', 'ScssLexer', 'LessCssLexer']
# List of vendor prefixes obtained from:# https://www.w3.org/TR/CSS21/syndata.html#vendor-keyword-history_vendor_prefixes = ( '-ms-', 'mso-', '-moz-', '-o-', '-xv-', '-atsc-', '-wap-', '-khtml-', '-webkit-', 'prince-', '-ah-', '-hp-', '-ro-', '-rim-', '-tc-',)
# List of extended color keywords obtained from:# https://drafts.csswg.org/css-color/#named-colors_color_keywords = ( 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen',) + ('transparent',)
# List of keyword values obtained from:# http://cssvalues.com/_keyword_values = ( 'absolute', 'alias', 'all', 'all-petite-caps', 'all-scroll', 'all-small-caps', 'allow-end', 'alpha', 'alternate', 'alternate-reverse', 'always', 'armenian', 'auto', 'avoid', 'avoid-column', 'avoid-page', 'backwards', 'balance', 'baseline', 'below', 'blink', 'block', 'bold', 'bolder', 'border-box', 'both', 'bottom', 'box-decoration', 'break-word', 'capitalize', 'cell', 'center', 'circle', 'clip', 'clone', 'close-quote', 'col-resize', 'collapse', 'color', 'color-burn', 'color-dodge', 'column', 'column-reverse', 'compact', 'condensed', 'contain', 'container', 'content-box', 'context-menu', 'copy', 'cover', 'crisp-edges', 'crosshair', 'currentColor', 'cursive', 'darken', 'dashed', 'decimal', 'decimal-leading-zero', 'default', 'descendants', 'difference', 'digits', 'disc', 'distribute', 'dot', 'dotted', 'double', 'double-circle', 'e-resize', 'each-line', 'ease', 'ease-in', 'ease-in-out', 'ease-out', 'edges', 'ellipsis', 'end', 'ew-resize', 'exclusion', 'expanded', 'extra-condensed', 'extra-expanded', 'fantasy', 'fill', 'fill-box', 'filled', 'first', 'fixed', 'flat', 'flex', 'flex-end', 'flex-start', 'flip', 'force-end', 'forwards', 'from-image', 'full-width', 'geometricPrecision', 'georgian', 'groove', 'hanging', 'hard-light', 'help', 'hidden', 'hide', 'horizontal', 'hue', 'icon', 'infinite', 'inherit', 'initial', 'ink', 'inline', 'inline-block', 'inline-flex', 'inline-table', 'inset', 'inside', 'inter-word', 'invert', 'isolate', 'italic', 'justify', 'large', 'larger', 'last', 'left', 'lighten', 'lighter', 'line-through', 'linear', 'list-item', 'local', 'loose', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman', 'lowercase', 'ltr', 'luminance', 'luminosity', 'mandatory', 'manipulation', 'manual', 'margin-box', 'match-parent', 'medium', 'mixed', 'monospace', 'move', 'multiply', 'n-resize', 'ne-resize', 'nesw-resize', 'no-close-quote', 'no-drop', 'no-open-quote', 'no-repeat', 'none', 'normal', 'not-allowed', 'nowrap', 'ns-resize', 'nw-resize', 'nwse-resize', 'objects', 'oblique', 'off', 'on', 'open', 'open-quote', 'optimizeLegibility', 'optimizeSpeed', 'outset', 'outside', 'over', 'overlay', 'overline', 'padding-box', 'page', 'pan-down', 'pan-left', 'pan-right', 'pan-up', 'pan-x', 'pan-y', 'paused', 'petite-caps', 'pixelated', 'pointer', 'preserve-3d', 'progress', 'proximity', 'relative', 'repeat', 'repeat no-repeat', 'repeat-x', 'repeat-y', 'reverse', 'revert', 'ridge', 'right', 'round', 'row', 'row-resize', 'row-reverse', 'rtl', 'ruby', 'ruby-base', 'ruby-base-container', 'ruby-text', 'ruby-text-container', 'run-in', 'running', 's-resize', 'sans-serif', 'saturation', 'scale-down', 'screen', 'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'sesame', 'show', 'sideways', 'sideways-left', 'sideways-right', 'slice', 'small', 'small-caps', 'smaller', 'smooth', 'snap', 'soft-light', 'solid', 'space', 'space-around', 'space-between', 'spaces', 'square', 'start', 'static', 'step-end', 'step-start', 'sticky', 'stretch', 'strict', 'stroke-box', 'style', 'sw-resize', 'table', 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'text', 'thick', 'thin', 'titling-caps', 'to', 'top', 'triangle', 'ultra-condensed', 'ultra-expanded', 'under', 'underline', 'unicase', 'unset', 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'upright', 'use-glyph-orientation', 'vertical', 'vertical-text', 'view-box', 'visible', 'w-resize', 'wait', 'wavy', 'weight', 'weight style', 'wrap', 'wrap-reverse', 'x-large', 'x-small', 'xx-large', 'xx-small', 'zoom-in', 'zoom-out',)
# List of other keyword values from other sources:_other_keyword_values = ( 'above', 'aural', 'behind', 'bidi-override', 'center-left', 'center-right', 'cjk-ideographic', 'continuous', 'crop', 'cross', 'embed', 'far-left', 'far-right', 'fast', 'faster', 'hebrew', 'high', 'higher', 'hiragana', 'hiragana-iroha', 'katakana', 'katakana-iroha', 'landscape', 'left-side', 'leftwards', 'level', 'loud', 'low', 'lower', 'message-box', 'middle', 'mix', 'narrower', 'once', 'portrait', 'right-side', 'rightwards', 'silent', 'slow', 'slower', 'small-caption', 'soft', 'spell-out', 'status-bar', 'super', 'text-bottom', 'text-top', 'wider', 'x-fast', 'x-high', 'x-loud', 'x-low', 'x-soft', 'yes', 'pre', 'pre-wrap', 'pre-line',)
# List of functional notation and function keyword values:_functional_notation_keyword_values = ( 'attr', 'blackness', 'blend', 'blenda', 'blur', 'brightness', 'calc', 'circle', 'color-mod', 'contrast', 'counter', 'cubic-bezier', 'device-cmyk', 'drop-shadow', 'ellipse', 'gray', 'grayscale', 'hsl', 'hsla', 'hue', 'hue-rotate', 'hwb', 'image', 'inset', 'invert', 'lightness', 'linear-gradient', 'matrix', 'matrix3d', 'opacity', 'perspective', 'polygon', 'radial-gradient', 'rect', 'repeating-linear-gradient', 'repeating-radial-gradient', 'rgb', 'rgba', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'saturate', 'saturation', 'scale', 'scale3d', 'scaleX', 'scaleY', 'scaleZ', 'sepia', 'shade', 'skewX', 'skewY', 'steps', 'tint', 'toggle', 'translate', 'translate3d', 'translateX', 'translateY', 'translateZ', 'whiteness',)# Note! Handle url(...) separately.
# List of units obtained from:# https://www.w3.org/TR/css3-values/_angle_units = ( 'deg', 'grad', 'rad', 'turn',)_frequency_units = ( 'Hz', 'kHz',)_length_units = ( 'em', 'ex', 'ch', 'rem', 'vh', 'vw', 'vmin', 'vmax', 'px', 'mm', 'cm', 'in', 'pt', 'pc', 'q',)_resolution_units = ( 'dpi', 'dpcm', 'dppx',)_time_units = ( 's', 'ms',)_all_units = _angle_units + _frequency_units + _length_units + \ _resolution_units + _time_units
class CssLexer(RegexLexer): """ For CSS (Cascading Style Sheets). """
name = 'CSS' url = 'https://www.w3.org/TR/CSS/#css' aliases = ['css'] filenames = ['*.css'] mimetypes = ['text/css'] version_added = ''
tokens = { 'root': [ include('basics'), ], 'basics': [ (r'\s+', Whitespace), (r'/\*(?:.|\n)*?\*/', Comment), (r'\{', Punctuation, 'content'), (r'(\:{1,2})([\w-]+)', bygroups(Punctuation, Name.Decorator)), (r'(\.)([\w-]+)', bygroups(Punctuation, Name.Class)), (r'(\#)([\w-]+)', bygroups(Punctuation, Name.Namespace)), (r'(@)([\w-]+)', bygroups(Punctuation, Keyword), 'atrule'), (r'[\w-]+', Name.Tag), (r'[~^*!%&$\[\]()<>|+=@:;,./?-]', Operator), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), ], 'atrule': [ (r'\{', Punctuation, 'atcontent'), (r';', Punctuation, '#pop'), include('basics'), ], 'atcontent': [ include('basics'), (r'\}', Punctuation, '#pop:2'), ], 'content': [ (r'\s+', Whitespace), (r'\}', Punctuation, '#pop'), (r';', Punctuation), (r'^@.*?$', Comment.Preproc),
(words(_vendor_prefixes,), Keyword.Pseudo), (r'('+r'|'.join(_css_properties)+r')(\s*)(\:)', bygroups(Keyword, Whitespace, Punctuation), 'value-start'), (r'([-]+[a-zA-Z_][\w-]*)(\s*)(\:)', bygroups(Name.Variable, Whitespace, Punctuation), 'value-start'), (r'([a-zA-Z_][\w-]*)(\s*)(\:)', bygroups(Name, Whitespace, Punctuation), 'value-start'),
(r'/\*(?:.|\n)*?\*/', Comment), ], 'value-start': [ (r'\s+', Whitespace), (words(_vendor_prefixes,), Name.Builtin.Pseudo), include('urls'), (r'('+r'|'.join(_functional_notation_keyword_values)+r')(\()', bygroups(Name.Builtin, Punctuation), 'function-start'), (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'), (words(_keyword_values, suffix=r'\b'), Keyword.Constant), (words(_other_keyword_values, suffix=r'\b'), Keyword.Constant), (words(_color_keywords, suffix=r'\b'), Keyword.Constant), # for transition-property etc. (words(_css_properties, suffix=r'\b'), Keyword), (r'\!important', Comment.Preproc), (r'/\*(?:.|\n)*?\*/', Comment),
include('numeric-values'),
(r'[~^*!%&<>|+=@:./?-]+', Operator), (r'[\[\](),]+', Punctuation), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), (r'[a-zA-Z_][\w-]*', Name), (r';', Punctuation, '#pop'), (r'\}', Punctuation, '#pop:2'), ], 'function-start': [ (r'\s+', Whitespace), (r'[-]+([A-Za-z][\w+]*[-]*)+', Name.Variable), include('urls'), (words(_vendor_prefixes,), Keyword.Pseudo), (words(_keyword_values, suffix=r'\b'), Keyword.Constant), (words(_other_keyword_values, suffix=r'\b'), Keyword.Constant), (words(_color_keywords, suffix=r'\b'), Keyword.Constant),
# function-start may be entered recursively (r'(' + r'|'.join(_functional_notation_keyword_values) + r')(\()', bygroups(Name.Builtin, Punctuation), 'function-start'), (r'([a-zA-Z_][\w-]+)(\()', bygroups(Name.Function, Punctuation), 'function-start'),
(r'/\*(?:.|\n)*?\*/', Comment), include('numeric-values'), (r'[*+/-]', Operator), (r',', Punctuation), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), (r'[a-zA-Z_-]\w*', Name), (r'\)', Punctuation, '#pop'), ], 'urls': [ (r'(url)(\()(".*?")(\))', bygroups(Name.Builtin, Punctuation, String.Double, Punctuation)), (r"(url)(\()('.*?')(\))", bygroups(Name.Builtin, Punctuation, String.Single, Punctuation)), (r'(url)(\()(.*?)(\))', bygroups(Name.Builtin, Punctuation, String.Other, Punctuation)), ], 'numeric-values': [ (r'\#[a-zA-Z0-9]{1,6}', Number.Hex), (r'[+\-]?[0-9]*[.][0-9]+', Number.Float, 'numeric-end'), (r'[+\-]?[0-9]+', Number.Integer, 'numeric-end'), ], 'numeric-end': [ (words(_all_units, suffix=r'\b'), Keyword.Type), (r'%', Keyword.Type), default('#pop'), ], }
common_sass_tokens = { 'value': [ (r'[ \t]+', Whitespace), (r'[!$][\w-]+', Name.Variable), (r'url\(', String.Other, 'string-url'), (r'[a-z_-][\w-]*(?=\()', Name.Function), (words(_css_properties + ( 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', 'baseline', 'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both', 'capitalize', 'center-left', 'center-right', 'center', 'circle', 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', 'crosshair', 'cross', 'cursive', 'dashed', 'decimal-leading-zero', 'decimal', 'default', 'digits', 'disc', 'dotted', 'double', 'e-resize', 'embed', 'extra-condensed', 'extra-expanded', 'expanded', 'fantasy', 'far-left', 'far-right', 'faster', 'fast', 'fixed', 'georgian', 'groove', 'hebrew', 'help', 'hidden', 'hide', 'higher', 'high', 'hiragana-iroha', 'hiragana', 'icon', 'inherit', 'inline-table', 'inline', 'inset', 'inside', 'invert', 'italic', 'justify', 'katakana-iroha', 'katakana', 'landscape', 'larger', 'large', 'left-side', 'leftwards', 'level', 'lighter', 'line-through', 'list-item', 'loud', 'lower-alpha', 'lower-greek', 'lower-roman', 'lowercase', 'ltr', 'lower', 'low', 'medium', 'message-box', 'middle', 'mix', 'monospace', 'n-resize', 'narrower', 'ne-resize', 'no-close-quote', 'no-open-quote', 'no-repeat', 'none', 'normal', 'nowrap', 'nw-resize', 'oblique', 'once', 'open-quote', 'outset', 'outside', 'overline', 'pointer', 'portrait', 'px', 'relative', 'repeat-x', 'repeat-y', 'repeat', 'rgb', 'ridge', 'right-side', 'rightwards', 's-resize', 'sans-serif', 'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'silent', 'slow', 'slower', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid', 'spell-out', 'square', 'static', 'status-bar', 'super', 'sw-resize', 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'text', 'text-bottom', 'text-top', 'thick', 'thin', 'transparent', 'ultra-condensed', 'ultra-expanded', 'underline', 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', 'visible', 'w-resize', 'wait', 'wider', 'x-fast', 'x-high', 'x-large', 'x-loud', 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yes'), suffix=r'\b'), Name.Constant), (words(_color_keywords, suffix=r'\b'), Name.Entity), (words(( 'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'), suffix=r'\b'), Name.Builtin), (r'\!(important|default)', Name.Exception), (r'(true|false)', Name.Pseudo), (r'(and|or|not)', Operator.Word), (r'/\*', Comment.Multiline, 'inline-comment'), (r'//[^\n]*', Comment.Single), (r'\#[a-z0-9]{1,6}', Number.Hex), (r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)), (r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)), (r'#\{', String.Interpol, 'interpolation'), (r'[~^*!&%<>|+=@:,./?-]+', Operator), (r'[\[\]()]+', Punctuation), (r'"', String.Double, 'string-double'), (r"'", String.Single, 'string-single'), (r'[a-z_-][\w-]*', Name), ],
'interpolation': [ (r'\}', String.Interpol, '#pop'), include('value'), ],
'selector': [ (r'[ \t]+', Whitespace), (r'\:', Name.Decorator, 'pseudo-class'), (r'\.', Name.Class, 'class'), (r'\#', Name.Namespace, 'id'), (r'[\w-]+', Name.Tag), (r'#\{', String.Interpol, 'interpolation'), (r'&', Keyword), (r'[~^*!&\[\]()<>|+=@:;,./?-]', Operator), (r'"', String.Double, 'string-double'), (r"'", String.Single, 'string-single'), ],
'string-double': [ (r'(\\.|#(?=[^\n{])|[^\n"#])+', String.Double), (r'#\{', String.Interpol, 'interpolation'), (r'"', String.Double, '#pop'), ],
'string-single': [ (r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Single), (r'#\{', String.Interpol, 'interpolation'), (r"'", String.Single, '#pop'), ],
'string-url': [ (r'(\\#|#(?=[^\n{])|[^\n#)])+', String.Other), (r'#\{', String.Interpol, 'interpolation'), (r'\)', String.Other, '#pop'), ],
'pseudo-class': [ (r'[\w-]+', Name.Decorator), (r'#\{', String.Interpol, 'interpolation'), default('#pop'), ],
'class': [ (r'[\w-]+', Name.Class), (r'#\{', String.Interpol, 'interpolation'), default('#pop'), ],
'id': [ (r'[\w-]+', Name.Namespace), (r'#\{', String.Interpol, 'interpolation'), default('#pop'), ],
'for': [ (r'(from|to|through)', Operator.Word), include('value'), ],}
def _indentation(lexer, match, ctx): indentation = match.group(0) yield match.start(), Whitespace, indentation ctx.last_indentation = indentation ctx.pos = match.end()
if hasattr(ctx, 'block_state') and ctx.block_state and \ indentation.startswith(ctx.block_indentation) and \ indentation != ctx.block_indentation: ctx.stack.append(ctx.block_state) else: ctx.block_state = None ctx.block_indentation = None ctx.stack.append('content')
def _starts_block(token, state): def callback(lexer, match, ctx): yield match.start(), token, match.group(0)
if hasattr(ctx, 'last_indentation'): ctx.block_indentation = ctx.last_indentation else: ctx.block_indentation = ''
ctx.block_state = state ctx.pos = match.end()
return callback
class SassLexer(ExtendedRegexLexer): """ For Sass stylesheets. """
name = 'Sass' url = 'https://sass-lang.com/' aliases = ['sass'] filenames = ['*.sass'] mimetypes = ['text/x-sass'] version_added = '1.3'
flags = re.IGNORECASE | re.MULTILINE
tokens = { 'root': [ (r'[ \t]*\n', Whitespace), (r'[ \t]*', _indentation), ],
'content': [ (r'//[^\n]*', _starts_block(Comment.Single, 'single-comment'), 'root'), (r'/\*[^\n]*', _starts_block(Comment.Multiline, 'multi-comment'), 'root'), (r'@import', Keyword, 'import'), (r'@for', Keyword, 'for'), (r'@(debug|warn|if|while)', Keyword, 'value'), (r'(@mixin)( )([\w-]+)', bygroups(Keyword, Whitespace, Name.Function), 'value'), (r'(@include)( )([\w-]+)', bygroups(Keyword, Whitespace, Name.Decorator), 'value'), (r'@extend', Keyword, 'selector'), (r'@[\w-]+', Keyword, 'selector'), (r'=[\w-]+', Name.Function, 'value'), (r'\+[\w-]+', Name.Decorator, 'value'), (r'([!$][\w-]\w*)([ \t]*(?:(?:\|\|)?=|:))', bygroups(Name.Variable, Operator), 'value'), (r':', Name.Attribute, 'old-style-attr'), (r'(?=.+?[=:]([^a-z]|$))', Name.Attribute, 'new-style-attr'), default('selector'), ],
'single-comment': [ (r'.+', Comment.Single), (r'\n', Whitespace, 'root'), ],
'multi-comment': [ (r'.+', Comment.Multiline), (r'\n', Whitespace, 'root'), ],
'import': [ (r'[ \t]+', Whitespace), (r'\S+', String), (r'\n', Whitespace, 'root'), ],
'old-style-attr': [ (r'[^\s:="\[]+', Name.Attribute), (r'#\{', String.Interpol, 'interpolation'), (r'([ \t]*)(=)', bygroups(Whitespace, Operator), 'value'), default('value'), ],
'new-style-attr': [ (r'[^\s:="\[]+', Name.Attribute), (r'#\{', String.Interpol, 'interpolation'), (r'([ \t]*)([=:])', bygroups(Whitespace, Operator), 'value'), ],
'inline-comment': [ (r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline), (r'#\{', String.Interpol, 'interpolation'), (r"\*/", Comment, '#pop'), ], } for group, common in common_sass_tokens.items(): tokens[group] = copy.copy(common) tokens['value'].append((r'\n', Whitespace, 'root')) tokens['selector'].append((r'\n', Whitespace, 'root'))
class ScssLexer(RegexLexer): """ For SCSS stylesheets. """
name = 'SCSS' url = 'https://sass-lang.com/' aliases = ['scss'] filenames = ['*.scss'] mimetypes = ['text/x-scss'] version_added = ''
flags = re.IGNORECASE | re.DOTALL tokens = { 'root': [ (r'\s+', Whitespace), (r'//.*?\n', Comment.Single), (r'/\*.*?\*/', Comment.Multiline), (r'@import', Keyword, 'value'), (r'@for', Keyword, 'for'), (r'@(debug|warn|if|while)', Keyword, 'value'), (r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'), (r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'), (r'@extend', Keyword, 'selector'), (r'(@media)(\s+)', bygroups(Keyword, Whitespace), 'value'), (r'@[\w-]+', Keyword, 'selector'), (r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'), # TODO: broken, and prone to infinite loops. # (r'(?=[^;{}][;}])', Name.Attribute, 'attr'), # (r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'), default('selector'), ],
'attr': [ (r'[^\s:="\[]+', Name.Attribute), (r'#\{', String.Interpol, 'interpolation'), (r'[ \t]*:', Operator, 'value'), default('#pop'), ],
'inline-comment': [ (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline), (r'#\{', String.Interpol, 'interpolation'), (r"\*/", Comment, '#pop'), ], } for group, common in common_sass_tokens.items(): tokens[group] = copy.copy(common) tokens['value'].extend([(r'\n', Whitespace), (r'[;{}]', Punctuation, '#pop')]) tokens['selector'].extend([(r'\n', Whitespace), (r'[;{}]', Punctuation, '#pop')])
class LessCssLexer(CssLexer): """ For LESS styleshets. """
name = 'LessCss' url = 'http://lesscss.org/' aliases = ['less'] filenames = ['*.less'] mimetypes = ['text/x-less-css'] version_added = '2.1'
tokens = { # FIXME: It's not currently possible to simply do the following, # as `include('basics')` doesn't take overrides into account: # 'basics': [ # (r'//.*\n', Comment.Single), # (r'/\*(?:.|\n)*?\*/', Comment.Multiline), # inherit, # ], 'root': [ (r'@\w+', Name.Variable), (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], 'atcontent': [ (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], 'atrule': [ (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], 'content': [ (r'\{', Punctuation, '#push'), (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], 'value-start': [ (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], 'function-start': [ (r'//.*\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), inherit, ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259""" pygments.lexers.d ~~~~~~~~~~~~~~~~~
Lexers for D languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, include, words, bygroupsfrom pygments.token import Comment, Keyword, Name, String, Number, \ Punctuation, Whitespace
__all__ = ['DLexer', 'CrocLexer', 'MiniDLexer']
class DLexer(RegexLexer): """ For D source. """ name = 'D' url = 'https://dlang.org/' filenames = ['*.d', '*.di'] aliases = ['d'] mimetypes = ['text/x-dsrc'] version_added = '1.2'
tokens = { 'root': [ (r'\n', Whitespace), (r'\s+', Whitespace), # (r'\\\n', Text), # line continuations # Comments (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), (r'/\+', Comment.Multiline, 'nested_comment'), # Keywords (words(( 'abstract', 'alias', 'align', 'asm', 'assert', 'auto', 'body', 'break', 'case', 'cast', 'catch', 'class', 'const', 'continue', 'debug', 'default', 'delegate', 'delete', 'deprecated', 'do', 'else', 'enum', 'export', 'extern', 'finally', 'final', 'foreach_reverse', 'foreach', 'for', 'function', 'goto', 'if', 'immutable', 'import', 'interface', 'invariant', 'inout', 'in', 'is', 'lazy', 'mixin', 'module', 'new', 'nothrow', 'out', 'override', 'package', 'pragma', 'private', 'protected', 'public', 'pure', 'ref', 'return', 'scope', 'shared', 'static', 'struct', 'super', 'switch', 'synchronized', 'template', 'this', 'throw', 'try', 'typeid', 'typeof', 'union', 'unittest', 'version', 'volatile', 'while', 'with', '__gshared', '__traits', '__vector', '__parameters'), suffix=r'\b'), Keyword), (words(( # Removed in 2.072 'typedef', ), suffix=r'\b'), Keyword.Removed), (words(( 'bool', 'byte', 'cdouble', 'cent', 'cfloat', 'char', 'creal', 'dchar', 'double', 'float', 'idouble', 'ifloat', 'int', 'ireal', 'long', 'real', 'short', 'ubyte', 'ucent', 'uint', 'ulong', 'ushort', 'void', 'wchar'), suffix=r'\b'), Keyword.Type), (r'(false|true|null)\b', Keyword.Constant), (words(( '__FILE__', '__FILE_FULL_PATH__', '__MODULE__', '__LINE__', '__FUNCTION__', '__PRETTY_FUNCTION__', '__DATE__', '__EOF__', '__TIME__', '__TIMESTAMP__', '__VENDOR__', '__VERSION__'), suffix=r'\b'), Keyword.Pseudo), (r'macro\b', Keyword.Reserved), (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin), # FloatLiteral # -- HexFloat (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)' r'[pP][+\-]?[0-9_]+[fFL]?[i]?', Number.Float), # -- DecimalFloat (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|' r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?', Number.Float), (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float), # IntegerLiteral # -- Binary (r'0[Bb][01_]+', Number.Bin), # -- Octal (r'0[0-7_]+', Number.Oct), # -- Hexadecimal (r'0[xX][0-9a-fA-F_]+', Number.Hex), # -- Decimal (r'(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?', Number.Integer), # CharacterLiteral (r"""'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}""" r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'""", String.Char), # StringLiteral # -- WysiwygString (r'r"[^"]*"[cwd]?', String), # -- AlternateWysiwygString (r'`[^`]*`[cwd]?', String), # -- DoubleQuotedString (r'"(\\\\|\\[^\\]|[^"\\])*"[cwd]?', String), # -- EscapeSequence (r"\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}" r"|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)", String), # -- HexString (r'x"[0-9a-fA-F_\s]*"[cwd]?', String), # -- DelimitedString (r'q"\[', String, 'delimited_bracket'), (r'q"\(', String, 'delimited_parenthesis'), (r'q"<', String, 'delimited_angle'), (r'q"\{', String, 'delimited_curly'), (r'q"([a-zA-Z_]\w*)\n.*?\n\1"', String), (r'q"(.).*?\1"', String), # -- TokenString (r'q\{', String, 'token_string'), # Attributes (r'@([a-zA-Z_]\w*)?', Name.Decorator), # Tokens (r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>=' r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)' r'|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]', Punctuation), # Identifier (r'[a-zA-Z_]\w*', Name), # Line (r'(#line)(\s)(.*)(\n)', bygroups(Comment.Special, Whitespace, Comment.Special, Whitespace)), ], 'nested_comment': [ (r'[^+/]+', Comment.Multiline), (r'/\+', Comment.Multiline, '#push'), (r'\+/', Comment.Multiline, '#pop'), (r'[+/]', Comment.Multiline), ], 'token_string': [ (r'\{', Punctuation, 'token_string_nest'), (r'\}', String, '#pop'), include('root'), ], 'token_string_nest': [ (r'\{', Punctuation, '#push'), (r'\}', Punctuation, '#pop'), include('root'), ], 'delimited_bracket': [ (r'[^\[\]]+', String), (r'\[', String, 'delimited_inside_bracket'), (r'\]"', String, '#pop'), ], 'delimited_inside_bracket': [ (r'[^\[\]]+', String), (r'\[', String, '#push'), (r'\]', String, '#pop'), ], 'delimited_parenthesis': [ (r'[^()]+', String), (r'\(', String, 'delimited_inside_parenthesis'), (r'\)"', String, '#pop'), ], 'delimited_inside_parenthesis': [ (r'[^()]+', String), (r'\(', String, '#push'), (r'\)', String, '#pop'), ], 'delimited_angle': [ (r'[^<>]+', String), (r'<', String, 'delimited_inside_angle'), (r'>"', String, '#pop'), ], 'delimited_inside_angle': [ (r'[^<>]+', String), (r'<', String, '#push'), (r'>', String, '#pop'), ], 'delimited_curly': [ (r'[^{}]+', String), (r'\{', String, 'delimited_inside_curly'), (r'\}"', String, '#pop'), ], 'delimited_inside_curly': [ (r'[^{}]+', String), (r'\{', String, '#push'), (r'\}', String, '#pop'), ], }
class CrocLexer(RegexLexer): """ For Croc source. """ name = 'Croc' url = 'http://jfbillingsley.com/croc' filenames = ['*.croc'] aliases = ['croc'] mimetypes = ['text/x-crocsrc'] version_added = ''
tokens = { 'root': [ (r'\n', Whitespace), (r'\s+', Whitespace), # Comments (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'/\*', Comment.Multiline, 'nestedcomment'), # Keywords (words(( 'as', 'assert', 'break', 'case', 'catch', 'class', 'continue', 'default', 'do', 'else', 'finally', 'for', 'foreach', 'function', 'global', 'namespace', 'if', 'import', 'in', 'is', 'local', 'module', 'return', 'scope', 'super', 'switch', 'this', 'throw', 'try', 'vararg', 'while', 'with', 'yield'), suffix=r'\b'), Keyword), (r'(false|true|null)\b', Keyword.Constant), # FloatLiteral (r'([0-9][0-9_]*)(?=[.eE])(\.[0-9][0-9_]*)?([eE][+\-]?[0-9_]+)?', Number.Float), # IntegerLiteral # -- Binary (r'0[bB][01][01_]*', Number.Bin), # -- Hexadecimal (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex), # -- Decimal (r'([0-9][0-9_]*)(?![.eE])', Number.Integer), # CharacterLiteral (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-9]{1,3}""" r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""", String.Char), # StringLiteral # -- WysiwygString (r'@"(""|[^"])*"', String), (r'@`(``|[^`])*`', String), (r"@'(''|[^'])*'", String), # -- DoubleQuotedString (r'"(\\\\|\\[^\\]|[^"\\])*"', String), # Tokens (r'(~=|\^=|%=|\*=|==|!=|>>>=|>>>|>>=|>>|>=|<=>|\?=|-\>' r'|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.|/=)' r'|[-/.&$@|\+<>!()\[\]{}?,;:=*%^~#\\]', Punctuation), # Identifier (r'[a-zA-Z_]\w*', Name), ], 'nestedcomment': [ (r'[^*/]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ], }
class MiniDLexer(CrocLexer): """ For MiniD source. MiniD is now known as Croc. """ name = 'MiniD' filenames = [] # don't lex .md as MiniD, reserve for Markdown aliases = ['minid'] mimetypes = ['text/x-minidsrc'] version_added = ''123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126""" pygments.lexers.dalvik ~~~~~~~~~~~~~~~~~~~~~~
Pygments lexers for Dalvik VM-related languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroupsfrom pygments.token import Keyword, Text, Comment, Name, String, Number, \ Punctuation, Whitespace
__all__ = ['SmaliLexer']
class SmaliLexer(RegexLexer): """ For Smali (Android/Dalvik) assembly code. """ name = 'Smali' url = 'http://code.google.com/p/smali/' aliases = ['smali'] filenames = ['*.smali'] mimetypes = ['text/smali'] version_added = '1.6'
tokens = { 'root': [ include('comment'), include('label'), include('field'), include('method'), include('class'), include('directive'), include('access-modifier'), include('instruction'), include('literal'), include('punctuation'), include('type'), include('whitespace') ], 'directive': [ (r'^([ \t]*)(\.(?:class|super|implements|field|subannotation|annotation|' r'enum|method|registers|locals|array-data|packed-switch|' r'sparse-switch|catchall|catch|line|parameter|local|prologue|' r'epilogue|source))', bygroups(Whitespace, Keyword)), (r'^([ \t]*)(\.end)( )(field|subannotation|annotation|method|array-data|' 'packed-switch|sparse-switch|parameter|local)', bygroups(Whitespace, Keyword, Whitespace, Keyword)), (r'^([ \t]*)(\.restart)( )(local)', bygroups(Whitespace, Keyword, Whitespace, Keyword)), ], 'access-modifier': [ (r'(public|private|protected|static|final|synchronized|bridge|' r'varargs|native|abstract|strictfp|synthetic|constructor|' r'declared-synchronized|interface|enum|annotation|volatile|' r'transient)', Keyword), ], 'whitespace': [ (r'\n', Whitespace), (r'\s+', Whitespace), ], 'instruction': [ (r'\b[vp]\d+\b', Name.Builtin), # registers (r'(\b[a-z][A-Za-z0-9/-]+)(\s+)', bygroups(Text, Whitespace)), # instructions ], 'literal': [ (r'".*"', String), (r'0x[0-9A-Fa-f]+t?', Number.Hex), (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'[0-9]+L?', Number.Integer), ], 'field': [ (r'(\$?\b)([\w$]*)(:)', bygroups(Punctuation, Name.Variable, Punctuation)), ], 'method': [ (r'<(?:cl)?init>', Name.Function), # constructor (r'(\$?\b)([\w$]*)(\()', bygroups(Punctuation, Name.Function, Punctuation)), ], 'label': [ (r':\w+', Name.Label), ], 'class': [ # class names in the form Lcom/namespace/ClassName; # I only want to color the ClassName part, so the namespace part is # treated as 'Text' (r'(L)((?:[\w$]+/)*)([\w$]+)(;)', bygroups(Keyword.Type, Text, Name.Class, Text)), ], 'punctuation': [ (r'->', Punctuation), (r'[{},():=.-]', Punctuation), ], 'type': [ (r'[ZBSCIJFDV\[]+', Keyword.Type), ], 'comment': [ (r'#.*?\n', Comment), ], }
def analyse_text(text): score = 0 if re.search(r'^\s*\.class\s', text, re.MULTILINE): score += 0.5 if re.search(r'\b((check-cast|instance-of|throw-verification-error' r')\b|(-to|add|[ais]get|[ais]put|and|cmpl|const|div|' r'if|invoke|move|mul|neg|not|or|rem|return|rsub|shl|' r'shr|sub|ushr)[-/])|{|}', text, re.MULTILINE): score += 0.3 if re.search(r'(\.(catchall|epilogue|restart local|prologue)|' r'\b(array-data|class-change-error|declared-synchronized|' r'(field|inline|vtable)@0x[0-9a-fA-F]|generic-error|' r'illegal-class-access|illegal-field-access|' r'illegal-method-access|instantiation-error|no-error|' r'no-such-class|no-such-field|no-such-method|' r'packed-switch|sparse-switch))\b', text, re.MULTILINE): score += 0.6 return score123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763""" pygments.lexers.data ~~~~~~~~~~~~~~~~~~~~
Lexers for data file format.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import Lexer, ExtendedRegexLexer, LexerContext, \ include, bygroupsfrom pygments.token import Comment, Error, Keyword, Literal, Name, Number, \ Punctuation, String, Whitespace
__all__ = ['YamlLexer', 'JsonLexer', 'JsonBareObjectLexer', 'JsonLdLexer']
class YamlLexerContext(LexerContext): """Indentation context for the YAML lexer."""
def __init__(self, *args, **kwds): super().__init__(*args, **kwds) self.indent_stack = [] self.indent = -1 self.next_indent = 0 self.block_scalar_indent = None
class YamlLexer(ExtendedRegexLexer): """ Lexer for YAML, a human-friendly data serialization language. """
name = 'YAML' url = 'http://yaml.org/' aliases = ['yaml'] filenames = ['*.yaml', '*.yml'] mimetypes = ['text/x-yaml'] version_added = '0.11'
def something(token_class): """Do not produce empty tokens.""" def callback(lexer, match, context): text = match.group() if not text: return yield match.start(), token_class, text context.pos = match.end() return callback
def reset_indent(token_class): """Reset the indentation levels.""" def callback(lexer, match, context): text = match.group() context.indent_stack = [] context.indent = -1 context.next_indent = 0 context.block_scalar_indent = None yield match.start(), token_class, text context.pos = match.end() return callback
def save_indent(token_class, start=False): """Save a possible indentation level.""" def callback(lexer, match, context): text = match.group() extra = '' if start: context.next_indent = len(text) if context.next_indent < context.indent: while context.next_indent < context.indent: context.indent = context.indent_stack.pop() if context.next_indent > context.indent: extra = text[context.indent:] text = text[:context.indent] else: context.next_indent += len(text) if text: yield match.start(), token_class, text if extra: yield match.start()+len(text), token_class.Error, extra context.pos = match.end() return callback
def set_indent(token_class, implicit=False): """Set the previously saved indentation level.""" def callback(lexer, match, context): text = match.group() if context.indent < context.next_indent: context.indent_stack.append(context.indent) context.indent = context.next_indent if not implicit: context.next_indent += len(text) yield match.start(), token_class, text context.pos = match.end() return callback
def set_block_scalar_indent(token_class): """Set an explicit indentation level for a block scalar.""" def callback(lexer, match, context): text = match.group() context.block_scalar_indent = None if not text: return increment = match.group(1) if increment: current_indent = max(context.indent, 0) increment = int(increment) context.block_scalar_indent = current_indent + increment if text: yield match.start(), token_class, text context.pos = match.end() return callback
def parse_block_scalar_empty_line(indent_token_class, content_token_class): """Process an empty line in a block scalar.""" def callback(lexer, match, context): text = match.group() if (context.block_scalar_indent is None or len(text) <= context.block_scalar_indent): if text: yield match.start(), indent_token_class, text else: indentation = text[:context.block_scalar_indent] content = text[context.block_scalar_indent:] yield match.start(), indent_token_class, indentation yield (match.start()+context.block_scalar_indent, content_token_class, content) context.pos = match.end() return callback
def parse_block_scalar_indent(token_class): """Process indentation spaces in a block scalar.""" def callback(lexer, match, context): text = match.group() if context.block_scalar_indent is None: if len(text) <= max(context.indent, 0): context.stack.pop() context.stack.pop() return context.block_scalar_indent = len(text) else: if len(text) < context.block_scalar_indent: context.stack.pop() context.stack.pop() return if text: yield match.start(), token_class, text context.pos = match.end() return callback
def parse_plain_scalar_indent(token_class): """Process indentation spaces in a plain scalar.""" def callback(lexer, match, context): text = match.group() if len(text) <= context.indent: context.stack.pop() context.stack.pop() return if text: yield match.start(), token_class, text context.pos = match.end() return callback
tokens = { # the root rules 'root': [ # ignored whitespaces (r'[ ]+(?=#|$)', Whitespace), # line breaks (r'\n+', Whitespace), # a comment (r'#[^\n]*', Comment.Single), # the '%YAML' directive (r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'), # the %TAG directive (r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'), # document start and document end indicators (r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace), 'block-line'), # indentation spaces (r'[ ]*(?!\s|$)', save_indent(Whitespace, start=True), ('block-line', 'indentation')), ],
# trailing whitespaces after directives or a block scalar indicator 'ignored-line': [ # ignored whitespaces (r'[ ]+(?=#|$)', Whitespace), # a comment (r'#[^\n]*', Comment.Single), # line break (r'\n', Whitespace, '#pop:2'), ],
# the %YAML directive 'yaml-directive': [ # the version number (r'([ ]+)([0-9]+\.[0-9]+)', bygroups(Whitespace, Number), 'ignored-line'), ],
# the %TAG directive 'tag-directive': [ # a tag handle and the corresponding prefix (r'([ ]+)(!|![\w-]*!)' r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)', bygroups(Whitespace, Keyword.Type, Whitespace, Keyword.Type), 'ignored-line'), ],
# block scalar indicators and indentation spaces 'indentation': [ # trailing whitespaces are ignored (r'[ ]*$', something(Whitespace), '#pop:2'), # whitespaces preceding block collection indicators (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Whitespace)), # block collection indicators (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)), # the beginning a block line (r'[ ]*', save_indent(Whitespace), '#pop'), ],
# an indented line in the block context 'block-line': [ # the line end (r'[ ]*(?=#|$)', something(Whitespace), '#pop'), # whitespaces separating tokens (r'[ ]+', Whitespace), # key with colon (r'''([^#,?\[\]{}"'\n]+)(:)(?=[ ]|$)''', bygroups(Name.Tag, set_indent(Punctuation, implicit=True))), # tags, anchors and aliases, include('descriptors'), # block collections and scalars include('block-nodes'), # flow collections and quoted scalars include('flow-nodes'), # a plain scalar (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)', something(Name.Variable), 'plain-scalar-in-block-context'), ],
# tags, anchors, aliases 'descriptors': [ # a full-form tag (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type), # a tag in the form '!', '!suffix' or '!handle!suffix' (r'!(?:[\w-]+!)?' r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]*', Keyword.Type), # an anchor (r'&[\w-]+', Name.Label), # an alias (r'\*[\w-]+', Name.Variable), ],
# block collections and scalars 'block-nodes': [ # implicit key (r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)), # literal and folded scalars (r'[|>]', Punctuation.Indicator, ('block-scalar-content', 'block-scalar-header')), ],
# flow collections and quoted scalars 'flow-nodes': [ # a flow sequence (r'\[', Punctuation.Indicator, 'flow-sequence'), # a flow mapping (r'\{', Punctuation.Indicator, 'flow-mapping'), # a single-quoted scalar (r'\'', String, 'single-quoted-scalar'), # a double-quoted scalar (r'\"', String, 'double-quoted-scalar'), ],
# the content of a flow collection 'flow-collection': [ # whitespaces (r'[ ]+', Whitespace), # line breaks (r'\n+', Whitespace), # a comment (r'#[^\n]*', Comment.Single), # simple indicators (r'[?:,]', Punctuation.Indicator), # tags, anchors and aliases include('descriptors'), # nested collections and quoted scalars include('flow-nodes'), # a plain scalar (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`])', something(Name.Variable), 'plain-scalar-in-flow-context'), ],
# a flow sequence indicated by '[' and ']' 'flow-sequence': [ # include flow collection rules include('flow-collection'), # the closing indicator (r'\]', Punctuation.Indicator, '#pop'), ],
# a flow mapping indicated by '{' and '}' 'flow-mapping': [ # key with colon (r'''([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''', bygroups(Name.Tag, Punctuation)), # include flow collection rules include('flow-collection'), # the closing indicator (r'\}', Punctuation.Indicator, '#pop'), ],
# block scalar lines 'block-scalar-content': [ # line break (r'\n', Whitespace), # empty line (r'^[ ]+$', parse_block_scalar_empty_line(Whitespace, Name.Constant)), # indentation spaces (we may leave the state here) (r'^[ ]*', parse_block_scalar_indent(Whitespace)), # line content (r'[\S\t ]+', Name.Constant), ],
# the content of a literal or folded scalar 'block-scalar-header': [ # indentation indicator followed by chomping flag (r'([1-9])?[+-]?(?=[ ]|$)', set_block_scalar_indent(Punctuation.Indicator), 'ignored-line'), # chomping flag followed by indentation indicator (r'[+-]?([1-9])?(?=[ ]|$)', set_block_scalar_indent(Punctuation.Indicator), 'ignored-line'), ],
# ignored and regular whitespaces in quoted scalars 'quoted-scalar-whitespaces': [ # leading and trailing whitespaces are ignored (r'^[ ]+', Whitespace), (r'[ ]+$', Whitespace), # line breaks are ignored (r'\n+', Whitespace), # other whitespaces are a part of the value (r'[ ]+', Name.Variable), ],
# single-quoted scalars 'single-quoted-scalar': [ # include whitespace and line break rules include('quoted-scalar-whitespaces'), # escaping of the quote character (r'\'\'', String.Escape), # regular non-whitespace characters (r'[^\s\']+', String), # the closing quote (r'\'', String, '#pop'), ],
# double-quoted scalars 'double-quoted-scalar': [ # include whitespace and line break rules include('quoted-scalar-whitespaces'), # escaping of special characters (r'\\[0abt\tn\nvfre "\\N_LP]', String), # escape codes (r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})', String.Escape), # regular non-whitespace characters (r'[^\s"\\]+', String), # the closing quote (r'"', String, '#pop'), ],
# the beginning of a new line while scanning a plain scalar 'plain-scalar-in-block-context-new-line': [ # empty lines (r'^[ ]+$', Whitespace), # line breaks (r'\n+', Whitespace), # document start and document end indicators (r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'), # indentation spaces (we may leave the block line state here) (r'^[ ]*', parse_plain_scalar_indent(Whitespace), '#pop'), ],
# a plain scalar in the block context 'plain-scalar-in-block-context': [ # the scalar ends with the ':' indicator (r'[ ]*(?=:[ ]|:$)', something(Whitespace), '#pop'), # the scalar ends with whitespaces followed by a comment (r'[ ]+(?=#)', Whitespace, '#pop'), # trailing whitespaces are ignored (r'[ ]+$', Whitespace), # line breaks are ignored (r'\n+', Whitespace, 'plain-scalar-in-block-context-new-line'), # other whitespaces are a part of the value (r'[ ]+', Literal.Scalar.Plain), # regular non-whitespace characters (r'(?::(?!\s)|[^\s:])+', Literal.Scalar.Plain), ],
# a plain scalar is the flow context 'plain-scalar-in-flow-context': [ # the scalar ends with an indicator character (r'[ ]*(?=[,:?\[\]{}])', something(Whitespace), '#pop'), # the scalar ends with a comment (r'[ ]+(?=#)', Whitespace, '#pop'), # leading and trailing whitespaces are ignored (r'^[ ]+', Whitespace), (r'[ ]+$', Whitespace), # line breaks are ignored (r'\n+', Whitespace), # other whitespaces are a part of the value (r'[ ]+', Name.Variable), # regular non-whitespace characters (r'[^\s,:?\[\]{}]+', Name.Variable), ],
}
def get_tokens_unprocessed(self, text=None, context=None): if context is None: context = YamlLexerContext(text, 0) return super().get_tokens_unprocessed(text, context)
class JsonLexer(Lexer): """ For JSON data structures.
Javascript-style comments are supported (like ``/* */`` and ``//``), though comments are not part of the JSON specification. This allows users to highlight JSON as it is used in the wild.
No validation is performed on the input JSON document. """
name = 'JSON' url = 'https://www.json.org' aliases = ['json', 'json-object'] filenames = ['*.json', '*.jsonl', '*.ndjson', 'Pipfile.lock', '*.module', '*.xc'] mimetypes = ['application/json', 'application/json-object', 'application/x-ndjson', 'application/jsonl', 'application/json-seq'] version_added = '1.5'
# No validation of integers, floats, or constants is done. # As long as the characters are members of the following # sets, the token will be considered valid. For example, # # "--1--" is parsed as an integer # "1...eee" is parsed as a float # "trustful" is parsed as a constant # integers = set('-0123456789') floats = set('.eE+') constants = set('truefalsenull') # true|false|null hexadecimals = set('0123456789abcdefABCDEF') punctuations = set('{}[],') whitespaces = {'\u0020', '\u000a', '\u000d', '\u0009'}
def get_tokens_unprocessed(self, text): """Parse JSON data."""
in_string = False in_escape = False in_unicode_escape = 0 in_whitespace = False in_constant = False in_number = False in_float = False in_punctuation = False in_comment_single = False in_comment_multiline = False expecting_second_comment_opener = False # // or /* expecting_second_comment_closer = False # */
start = 0
# The queue is used to store data that may need to be tokenized # differently based on what follows. In particular, JSON object # keys are tokenized differently than string values, but cannot # be distinguished until punctuation is encountered outside the # string. # # A ":" character after the string indicates that the string is # an object key; any other character indicates the string is a # regular string value. # # The queue holds tuples that contain the following data: # # (start_index, token_type, text) # # By default the token type of text in double quotes is # String.Double. The token type will be replaced if a colon # is encountered after the string closes. # queue = []
for stop, character in enumerate(text): if in_string: if in_unicode_escape: if character in self.hexadecimals: in_unicode_escape -= 1 if not in_unicode_escape: in_escape = False else: in_unicode_escape = 0 in_escape = False
elif in_escape: if character == 'u': in_unicode_escape = 4 else: in_escape = False
elif character == '\\': in_escape = True
elif character == '"': queue.append((start, String.Double, text[start:stop + 1])) in_string = False in_escape = False in_unicode_escape = 0
continue
elif in_whitespace: if character in self.whitespaces: continue
if queue: queue.append((start, Whitespace, text[start:stop])) else: yield start, Whitespace, text[start:stop] in_whitespace = False # Fall through so the new character can be evaluated.
elif in_constant: if character in self.constants: continue
yield start, Keyword.Constant, text[start:stop] in_constant = False # Fall through so the new character can be evaluated.
elif in_number: if character in self.integers: continue elif character in self.floats: in_float = True continue
if in_float: yield start, Number.Float, text[start:stop] else: yield start, Number.Integer, text[start:stop] in_number = False in_float = False # Fall through so the new character can be evaluated.
elif in_punctuation: if character in self.punctuations: continue
yield start, Punctuation, text[start:stop] in_punctuation = False # Fall through so the new character can be evaluated.
elif in_comment_single: if character != '\n': continue
if queue: queue.append((start, Comment.Single, text[start:stop])) else: yield start, Comment.Single, text[start:stop]
in_comment_single = False # Fall through so the new character can be evaluated.
elif in_comment_multiline: if character == '*': expecting_second_comment_closer = True elif expecting_second_comment_closer: expecting_second_comment_closer = False if character == '/': if queue: queue.append((start, Comment.Multiline, text[start:stop + 1])) else: yield start, Comment.Multiline, text[start:stop + 1]
in_comment_multiline = False
continue
elif expecting_second_comment_opener: expecting_second_comment_opener = False if character == '/': in_comment_single = True continue elif character == '*': in_comment_multiline = True continue
# Exhaust the queue. Accept the existing token types. yield from queue queue.clear()
yield start, Error, text[start:stop] # Fall through so the new character can be evaluated.
start = stop
if character == '"': in_string = True
elif character in self.whitespaces: in_whitespace = True
elif character in {'f', 'n', 't'}: # The first letters of true|false|null # Exhaust the queue. Accept the existing token types. yield from queue queue.clear()
in_constant = True
elif character in self.integers: # Exhaust the queue. Accept the existing token types. yield from queue queue.clear()
in_number = True
elif character == ':': # Yield from the queue. Replace string token types. for _start, _token, _text in queue: # There can be only three types of tokens before a ':': # Whitespace, Comment, or a quoted string. # # If it's a quoted string we emit Name.Tag. # Otherwise, we yield the original token. # # In all other cases this would be invalid JSON, # but this is not a validating JSON lexer, so it's OK. if _token is String.Double: yield _start, Name.Tag, _text else: yield _start, _token, _text queue.clear()
in_punctuation = True
elif character in self.punctuations: # Exhaust the queue. Accept the existing token types. yield from queue queue.clear()
in_punctuation = True
elif character == '/': # This is the beginning of a comment. expecting_second_comment_opener = True
else: # Exhaust the queue. Accept the existing token types. yield from queue queue.clear()
yield start, Error, character
# Yield any remaining text. yield from queue if in_string: yield start, Error, text[start:] elif in_float: yield start, Number.Float, text[start:] elif in_number: yield start, Number.Integer, text[start:] elif in_constant: yield start, Keyword.Constant, text[start:] elif in_whitespace: yield start, Whitespace, text[start:] elif in_punctuation: yield start, Punctuation, text[start:] elif in_comment_single: yield start, Comment.Single, text[start:] elif in_comment_multiline: yield start, Error, text[start:] elif expecting_second_comment_opener: yield start, Error, text[start:]
class JsonBareObjectLexer(JsonLexer): """ For JSON data structures (with missing object curly braces).
.. deprecated:: 2.8.0
Behaves the same as `JsonLexer` now. """
name = 'JSONBareObject' aliases = [] filenames = [] mimetypes = [] version_added = '2.2'
class JsonLdLexer(JsonLexer): """ For JSON-LD linked data. """
name = 'JSON-LD' url = 'https://json-ld.org/' aliases = ['jsonld', 'json-ld'] filenames = ['*.jsonld'] mimetypes = ['application/ld+json'] version_added = '2.0'
json_ld_keywords = { f'"@{keyword}"' for keyword in ( 'base', 'container', 'context', 'direction', 'graph', 'id', 'import', 'included', 'index', 'json', 'language', 'list', 'nest', 'none', 'prefix', 'propagate', 'protected', 'reverse', 'set', 'type', 'value', 'version', 'vocab', ) }
def get_tokens_unprocessed(self, text): for start, token, value in super().get_tokens_unprocessed(text): if token is Name.Tag and value in self.json_ld_keywords: yield start, Name.Decorator, value else: yield start, token, value123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135""" pygments.lexers.dax ~~~~~~~~~~~~~~~~~~~
Lexer for LilyPond.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Comment, Punctuation, Whitespace,\ Name, Operator, String, Number, Text
__all__ = ['DaxLexer']
class DaxLexer(RegexLexer): """ Lexer for Power BI DAX Referenced from: https://github.com/sql-bi/SyntaxHighlighterBrushDax """ name = 'Dax' aliases = ['dax'] filenames = ['*.dax'] url = 'https://learn.microsoft.com/en-us/dax/dax-function-reference' mimetypes = [] version_added = '2.15'
tokens = { 'root': [ (r'\s+', Whitespace), (r"--.*\n?", Comment.Single), # Comment: Double dash comment (r"//.*\n?", Comment.Single), # Comment: Double backslash comment (r'/\*', Comment.Multiline, 'multiline-comments'), (words(('abs', 'accrint', 'accrintm', 'acos', 'acosh', 'acot', 'acoth', 'addcolumns', 'addmissingitems', 'all', 'allcrossfiltered', 'allexcept', 'allnoblankrow', 'allselected', 'amordegrc', 'amorlinc', 'and','approximatedistinctcount', 'asin', 'asinh', 'atan', 'atanh', 'average', 'averagea', 'averagex', 'beta.dist', 'beta.inv', 'bitand', 'bitlshift', 'bitor', 'bitrshift', 'bitxor', 'blank', 'calculate', 'calculatetable', 'calendar', 'calendarauto', 'ceiling', 'chisq.dist', 'chisq.dist.rt', 'chisq.inv', 'chisq.inv.rt', 'closingbalancemonth', 'closingbalancequarter', 'closingbalanceyear', 'coalesce', 'columnstatistics', 'combin', 'combina', 'combinevalues', 'concatenate', 'concatenatex', 'confidence.norm', 'confidence.t', 'contains', 'containsrow', 'containsstring', 'containsstringexact', 'convert', 'cos', 'cosh', 'cot', 'coth', 'count', 'counta', 'countax', 'countblank', 'countrows', 'countx', 'coupdaybs', 'coupdays', 'coupdaysnc', 'coupncd', 'coupnum', 'couppcd', 'crossfilter', 'crossjoin', 'cumipmt', 'cumprinc', 'currency', 'currentgroup', 'customdata', 'datatable', 'date', 'dateadd', 'datediff', 'datesbetween', 'datesinperiod', 'datesmtd', 'datesqtd', 'datesytd', 'datevalue', 'day', 'db', 'ddb', 'degrees', 'detailrows', 'disc', 'distinct', 'distinctcount', 'distinctcountnoblank', 'divide', 'dollarde', 'dollarfr', 'duration', 'earlier', 'earliest', 'edate', 'effect', 'endofmonth', 'endofquarter', 'endofyear', 'eomonth', 'error', 'evaluateandlog', 'even', 'exact', 'except', 'exp', 'expon.dist', 'fact', 'false', 'filter', 'filters', 'find', 'firstdate', 'firstnonblank', 'firstnonblankvalue', 'fixed', 'floor', 'format', 'fv', 'gcd', 'generate', 'generateall', 'generateseries', 'geomean', 'geomeanx', 'groupby', 'hash', 'hasonefilter', 'hasonevalue', 'hour', 'if', 'if.eager', 'iferror', 'ignore', 'index', 'int', 'intersect', 'intrate', 'ipmt', 'isafter', 'isblank', 'iscrossfiltered', 'isempty', 'iserror', 'iseven', 'isfiltered', 'isinscope', 'islogical', 'isnontext', 'isnumber', 'iso.ceiling', 'isodd', 'isonorafter', 'ispmt', 'isselectedmeasure', 'issubtotal', 'istext', 'keepfilters', 'keywordmatch', 'lastdate', 'lastnonblank', 'lastnonblankvalue', 'lcm', 'left', 'len', 'linest', 'linestx', 'ln', 'log', 'log10', 'lookupvalue', 'lower', 'max', 'maxa', 'maxx', 'mduration', 'median', 'medianx', 'mid', 'min', 'mina', 'minute', 'minx', 'mod', 'month', 'mround', 'nameof', 'naturalinnerjoin', 'naturalleftouterjoin', 'networkdays', 'nextday', 'nextmonth', 'nextquarter', 'nextyear', 'nominal', 'nonvisual', 'norm.dist', 'norm.inv', 'norm.s.dist', 'norm.s.inv', 'not', 'now', 'nper', 'odd', 'oddfprice', 'oddfyield', 'oddlprice', 'oddlyield', 'offset', 'openingbalancemonth', 'openingbalancequarter', 'openingbalanceyear', 'or', 'orderby', 'parallelperiod', 'partitionby', 'path', 'pathcontains', 'pathitem', 'pathitemreverse', 'pathlength', 'pduration', 'percentile.exc', 'percentile.inc', 'percentilex.exc', 'percentilex.inc', 'permut', 'pi', 'pmt', 'poisson.dist', 'power', 'ppmt', 'previousday', 'previousmonth', 'previousquarter', 'previousyear', 'price', 'pricedisc', 'pricemat', 'product', 'productx', 'pv', 'quarter', 'quotient', 'radians', 'rand', 'randbetween', 'rank.eq', 'rankx', 'rate', 'received', 'related', 'relatedtable', 'removefilters', 'replace', 'rept', 'right', 'rollup', 'rollupaddissubtotal', 'rollupgroup', 'rollupissubtotal', 'round', 'rounddown', 'roundup', 'row', 'rri', 'sameperiodlastyear', 'sample', 'sampleaxiswithlocalminmax', 'search', 'second', 'selectcolumns', 'selectedmeasure', 'selectedmeasureformatstring', 'selectedmeasurename', 'selectedvalue', 'sign', 'sin', 'sinh', 'sln', 'sqrt', 'sqrtpi', 'startofmonth', 'startofquarter', 'startofyear', 'stdev.p', 'stdev.s', 'stdevx.p', 'stdevx.s', 'substitute', 'substitutewithindex', 'sum', 'summarize', 'summarizecolumns', 'sumx', 'switch', 'syd', 't.dist', 't.dist.2t', 't.dist.rt', 't.inv', 't.inv.2t', 'tan', 'tanh', 'tbilleq', 'tbillprice', 'tbillyield', 'time', 'timevalue', 'tocsv', 'today', 'tojson', 'topn', 'topnperlevel', 'topnskip', 'totalmtd', 'totalqtd', 'totalytd', 'treatas', 'trim', 'true', 'trunc', 'unichar', 'unicode', 'union', 'upper', 'userculture', 'userelationship', 'username', 'userobjectid', 'userprincipalname', 'utcnow', 'utctoday', 'value', 'values', 'var.p', 'var.s', 'varx.p', 'varx.s', 'vdb', 'weekday', 'weeknum', 'window', 'xirr', 'xnpv', 'year', 'yearfrac', 'yield', 'yielddisc', 'yieldmat'), prefix=r'(?i)', suffix=r'\b'), Name.Function), #Functions
(words(('at','asc','boolean','both','by','create','currency', 'datetime','day','define','desc','double', 'evaluate','false','integer','measure', 'month','none','order','return','single','start','string', 'table','true','var','year'), prefix=r'(?i)', suffix=r'\b'), Name.Builtin), # Keyword
(r':=|[-+*\/=^]', Operator), (r'\b(IN|NOT)\b', Operator.Word), (r'"', String, 'string'), #StringLiteral (r"'(?:[^']|'')*'(?!')(?:\[[ \w]+\])?|\w+\[[ \w]+\]", Name.Attribute), # Column reference (r"\[[ \w]+\]", Name.Attribute), #Measure reference (r'(?<!\w)(\d+\.?\d*|\.\d+\b)', Number),# Number (r'[\[\](){}`,.]', Punctuation), #Parenthesis (r'.*\n', Text),
], 'multiline-comments': [ (r'/\*', Comment.Multiline, 'multiline-comments'), (r'\*/', Comment.Multiline, '#pop'), (r'[^/*]+', Comment.Multiline), (r'[/*]', Comment.Multiline) ], 'string': [ (r'""', String.Escape), (r'"', String, '#pop'), (r'[^"]+', String), ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120""" pygments.lexers.devicetree ~~~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for Devicetree language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, bygroups, include, default, wordsfrom pygments.token import Comment, Keyword, Name, Number, Operator, \ Punctuation, String, Text, Whitespace
__all__ = ['DevicetreeLexer']
class DevicetreeLexer(RegexLexer): """ Lexer for Devicetree files. """
name = 'Devicetree' url = 'https://www.devicetree.org/' aliases = ['devicetree', 'dts'] filenames = ['*.dts', '*.dtsi'] mimetypes = ['text/x-c'] version_added = '2.7'
#: optional Whitespace or /*...*/ style comment _ws = r'\s*(?:/[*][^*/]*?[*]/\s*)*'
tokens = { 'macro': [ # Include preprocessor directives (C style): (r'(#include)(' + _ws + r')([^\n]+)', bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)), # Define preprocessor directives (C style): (r'(#define)(' + _ws + r')([^\n]+)', bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc)), # devicetree style with file: (r'(/[^*/{]+/)(' + _ws + r')("[^\n{]+")', bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)), # devicetree style with property: (r'(/[^*/{]+/)(' + _ws + r')([^\n;{]*)([;]?)', bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc, Punctuation)), ], 'whitespace': [ (r'\n', Whitespace), (r'\s+', Whitespace), (r'\\\n', Text), # line continuation (r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single), (r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline), # Open until EOF, so no ending delimiter (r'/(\\\n)?[*][\w\W]*', Comment.Multiline), ], 'statements': [ (r'(L?)(")', bygroups(String.Affix, String), 'string'), (r'0x[0-9a-fA-F]+', Number.Hex), (r'\d+', Number.Integer), (r'([^\s{}/*]*)(\s*)(:)', bygroups(Name.Label, Text, Punctuation), '#pop'), (words(('compatible', 'model', 'phandle', 'status', '#address-cells', '#size-cells', 'reg', 'virtual-reg', 'ranges', 'dma-ranges', 'device_type', 'name'), suffix=r'\b'), Keyword.Reserved), (r'([~!%^&*+=|?:<>/#-])', Operator), (r'[(){},.\]]', Punctuation), (r'\[', Punctuation, 'bytestring'), (r'[a-zA-Z_][\w-]*(?=(?:\s*,' + _ws + r'[a-zA-Z_][\w-]*)*' + _ws + r'[=;])', Name), (r'[a-zA-Z_]\w*', Name.Attribute), ], 'root': [ include('whitespace'), include('macro'), # Overlay/fragment: &label { ... } or &{/path/to/node} { ... } (r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)', bygroups(Operator, Name.Function, Punctuation, Name.Namespace, Punctuation, Comment.Multiline, Punctuation), 'node'), # Nodes (r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)', bygroups(Name.Function, Operator, Number.Integer, Comment.Multiline, Punctuation), 'node'),
default('statement'), ], 'statement': [ include('whitespace'), include('statements'), (';', Punctuation, '#pop'), ], 'node': [ include('whitespace'), include('macro'), # Overlay/fragment: &label { ... } or &{/path/to/node} { ... } (r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)', bygroups(Operator, Name.Function, Punctuation, Name.Namespace, Punctuation, Comment.Multiline, Punctuation), '#push'), (r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)', bygroups(Name.Function, Operator, Number.Integer, Comment.Multiline, Punctuation), '#push'),
include('statements'),
(r'\};', Punctuation, '#pop'), (';', Punctuation), ], 'string': [ (r'"', String, '#pop'), (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|' r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape), (r'[^\\"\n]+', String), # all other characters (r'\\\n', String), # line continuation (r'\\', String), # stray backslash ], 'bytestring': [ (r'\]', Punctuation, '#pop'), (r'[0-9a-fA-F]{2}', Number.Hex), (r'\s+', Whitespace), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169""" pygments.lexers.diff ~~~~~~~~~~~~~~~~~~~~
Lexers for diff/patch formats.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroupsfrom pygments.token import Text, Comment, Operator, Keyword, Name, Generic, \ Literal, Whitespace
__all__ = ['DiffLexer', 'DarcsPatchLexer', 'WDiffLexer']
class DiffLexer(RegexLexer): """ Lexer for unified or context-style diffs or patches. """
name = 'Diff' aliases = ['diff', 'udiff'] filenames = ['*.diff', '*.patch'] mimetypes = ['text/x-diff', 'text/x-patch'] url = 'https://en.wikipedia.org/wiki/Diff' version_added = ''
tokens = { 'root': [ (r'( )(.*)(\n)', bygroups(Whitespace, Text, Whitespace)), (r'(!.*|---)(\n)', bygroups(Generic.Strong, Whitespace)), (r'((?:< |-).*)(\n)', bygroups(Generic.Deleted, Whitespace)), (r'((?:> |\+).*)(\n)', bygroups(Generic.Inserted, Whitespace)), ( r'(@.*|\d(?:,\d+)?(?:a|c|d)\d+(?:,\d+)?)(\n)', bygroups(Generic.Subheading, Whitespace), ), (r'((?:[Ii]ndex|diff).*)(\n)', bygroups(Generic.Heading, Whitespace)), (r'(=.*)(\n)', bygroups(Generic.Heading, Whitespace)), (r'(.*)(\n)', bygroups(Text, Whitespace)), ] }
def analyse_text(text): if text[:7] == 'Index: ': return True if text[:5] == 'diff ': return True if text[:4] == '--- ': return 0.9
class DarcsPatchLexer(RegexLexer): """ DarcsPatchLexer is a lexer for the various versions of the darcs patch format. Examples of this format are derived by commands such as ``darcs annotate --patch`` and ``darcs send``. """
name = 'Darcs Patch' aliases = ['dpatch'] filenames = ['*.dpatch', '*.darcspatch'] url = 'https://darcs.net' version_added = '0.10'
DPATCH_KEYWORDS = ('hunk', 'addfile', 'adddir', 'rmfile', 'rmdir', 'move', 'replace')
tokens = { 'root': [ (r'<', Operator), (r'>', Operator), (r'\{', Operator), (r'\}', Operator), (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)(\])', bygroups(Operator, Keyword, Name, Whitespace, Name, Operator, Literal.Date, Whitespace, Operator)), (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)', bygroups(Operator, Keyword, Name, Whitespace, Name, Operator, Literal.Date, Whitespace), 'comment'), (r'New patches:', Generic.Heading), (r'Context:', Generic.Heading), (r'Patch bundle hash:', Generic.Heading), (r'(\s*)({})(.*)(\n)'.format('|'.join(DPATCH_KEYWORDS)), bygroups(Whitespace, Keyword, Text, Whitespace)), (r'\+', Generic.Inserted, "insert"), (r'-', Generic.Deleted, "delete"), (r'(.*)(\n)', bygroups(Text, Whitespace)), ], 'comment': [ (r'[^\]].*\n', Comment), (r'\]', Operator, "#pop"), ], 'specialText': [ # darcs add [_CODE_] special operators for clarity (r'\n', Whitespace, "#pop"), # line-based (r'\[_[^_]*_]', Operator), ], 'insert': [ include('specialText'), (r'\[', Generic.Inserted), (r'[^\n\[]+', Generic.Inserted), ], 'delete': [ include('specialText'), (r'\[', Generic.Deleted), (r'[^\n\[]+', Generic.Deleted), ], }
class WDiffLexer(RegexLexer): """ A wdiff lexer.
Note that:
* It only works with normal output (without options like ``-l``). * If the target files contain "[-", "-]", "{+", or "+}", especially they are unbalanced, the lexer will get confused. """
name = 'WDiff' url = 'https://www.gnu.org/software/wdiff/' aliases = ['wdiff'] filenames = ['*.wdiff'] mimetypes = [] version_added = '2.2'
flags = re.MULTILINE | re.DOTALL
# We can only assume "[-" after "[-" before "-]" is `nested`, # for instance wdiff to wdiff outputs. We have no way to # distinct these marker is of wdiff output from original text.
ins_op = r"\{\+" ins_cl = r"\+\}" del_op = r"\[\-" del_cl = r"\-\]" normal = r'[^{}[\]+-]+' # for performance tokens = { 'root': [ (ins_op, Generic.Inserted, 'inserted'), (del_op, Generic.Deleted, 'deleted'), (normal, Text), (r'.', Text), ], 'inserted': [ (ins_op, Generic.Inserted, '#push'), (del_op, Generic.Inserted, '#push'), (del_cl, Generic.Inserted, '#pop'),
(ins_cl, Generic.Inserted, '#pop'), (normal, Generic.Inserted), (r'.', Generic.Inserted), ], 'deleted': [ (del_op, Generic.Deleted, '#push'), (ins_op, Generic.Deleted, '#push'), (ins_cl, Generic.Deleted, '#pop'),
(del_cl, Generic.Deleted, '#pop'), (normal, Generic.Deleted), (r'.', Generic.Deleted), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109""" pygments.lexers.dns ~~~~~~~~~~~~~~~~~~~
Pygments lexers for DNS
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.token import Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace, Literalfrom pygments.lexer import RegexLexer, bygroups, include
__all__ = ['DnsZoneLexer']
CLASSES = [ "IN", "CS", "CH", "HS",]
CLASSES_RE = "(" + "|".join(CLASSES) + ')'
class DnsZoneLexer(RegexLexer):
""" Lexer for DNS zone file """
flags = re.MULTILINE
name = 'Zone' aliases = ['zone'] filenames = [ "*.zone" ] url = "https://datatracker.ietf.org/doc/html/rfc1035" mimetypes = ['text/dns'] version_added = '2.16'
tokens = { 'root': [ # Empty/comment line: (r'([ \t]*)(;.*)(\n)', bygroups(Whitespace, Comment.Single, Whitespace)), # Special directives: (r'^\$ORIGIN\b', Keyword, 'values'), (r'^\$TTL\b', Keyword, 'values'), (r'^\$INCLUDE\b', Comment.Preproc, 'include'), # TODO, $GENERATE https://bind9.readthedocs.io/en/v9.18.14/chapter3.html#soa-rr (r'^\$[A-Z]+\b', Keyword, 'values'), # Records: # <domain-name> [<TTL>] [<class>] <type> <RDATA> [<comment>] (r'^(@)([ \t]+)(?:([0-9]+[smhdw]?)([ \t]+))?(?:' + CLASSES_RE + "([ \t]+))?([A-Z]+)([ \t]+)", bygroups(Operator, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace), "values"), (r'^([^ \t\n]*)([ \t]+)(?:([0-9]+[smhdw]?)([ \t]+))?(?:' + CLASSES_RE + "([ \t]+))?([A-Z]+)([ \t]+)", bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace), "values"), # <domain-name> [<class>] [<TTL>] <type> <RDATA> [<comment>] (r'^(Operator)([ \t]+)(?:' + CLASSES_RE + "([ \t]+))?(?:([0-9]+[smhdw]?)([ \t]+))?([A-Z]+)([ \t]+)", bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace), "values"), (r'^([^ \t\n]*)([ \t]+)(?:' + CLASSES_RE + "([ \t]+))?(?:([0-9]+[smhdw]?)([ \t]+))?([A-Z]+)([ \t]+)", bygroups(Name, Whitespace, Number.Integer, Whitespace, Name.Class, Whitespace, Keyword.Type, Whitespace), "values"), ], # Parsing values: 'values': [ (r'\n', Whitespace, "#pop"), (r'\(', Punctuation, 'nested'), include('simple-value'), ], # Parsing nested values (...): 'nested': [ (r'\)', Punctuation, "#pop"), include('multiple-simple-values'), ], # Parsing values: 'simple-value': [ (r'(;.*)', bygroups(Comment.Single)), (r'[ \t]+', Whitespace), (r"@\b", Operator), ('"', String, 'string'), (r'[0-9]+[smhdw]?$', Number.Integer), (r'([0-9]+[smhdw]?)([ \t]+)', bygroups(Number.Integer, Whitespace)), (r'\S+', Literal), ], 'multiple-simple-values': [ include('simple-value'), (r'[\n]+', Whitespace), ], 'include': [ (r'([ \t]+)([^ \t\n]+)([ \t]+)([-\._a-zA-Z]+)([ \t]+)(;.*)?$', bygroups(Whitespace, Comment.PreprocFile, Whitespace, Name, Whitespace, Comment.Single), '#pop'), (r'([ \t]+)([^ \t\n]+)([ \t\n]+)$', bygroups(Whitespace, Comment.PreprocFile, Whitespace), '#pop'), ], "string": [ (r'\\"', String), (r'"', String, "#pop"), (r'[^"]+', String), ] }
def analyse_text(text): return text.startswith("$ORIGIN")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873""" pygments.lexers.dotnet ~~~~~~~~~~~~~~~~~~~~~~
Lexers for .net languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""import re
from pygments.lexer import RegexLexer, DelegatingLexer, bygroups, include, \ using, this, default, wordsfrom pygments.token import Punctuation, Text, Comment, Operator, Keyword, \ Name, String, Number, Literal, Other, Whitespacefrom pygments.util import get_choice_optfrom pygments import unistring as uni
from pygments.lexers.html import XmlLexer
__all__ = ['CSharpLexer', 'NemerleLexer', 'BooLexer', 'VbNetLexer', 'CSharpAspxLexer', 'VbNetAspxLexer', 'FSharpLexer', 'XppLexer']
class CSharpLexer(RegexLexer): """ For C# source code.
Additional options accepted:
`unicodelevel` Determines which Unicode characters this lexer allows for identifiers. The possible values are:
* ``none`` -- only the ASCII letters and numbers are allowed. This is the fastest selection. * ``basic`` -- all Unicode characters from the specification except category ``Lo`` are allowed. * ``full`` -- all Unicode characters as specified in the C# specs are allowed. Note that this means a considerable slowdown since the ``Lo`` category has more than 40,000 characters in it!
The default value is ``basic``.
.. versionadded:: 0.8 """
name = 'C#' url = 'https://docs.microsoft.com/en-us/dotnet/csharp/' aliases = ['csharp', 'c#', 'cs'] filenames = ['*.cs'] mimetypes = ['text/x-csharp'] # inferred version_added = ''
flags = re.MULTILINE | re.DOTALL
# for the range of allowed unicode characters in identifiers, see # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
levels = { 'none': r'@?[_a-zA-Z]\w*', 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' + '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), 'full': ('@?(?:_|[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), }
tokens = {} token_variants = True
for levelname, cs_ident in levels.items(): tokens[levelname] = { 'root': [ include('numbers'), # method names (r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type r'(' + cs_ident + ')' # method name r'(\s*)(\()', # signature start bygroups(Whitespace, using(this), Name.Function, Whitespace, Punctuation)), (r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)), (r'[^\S\n]+', Whitespace), (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation (r'//.*?\n', Comment.Single), (r'/[*].*?[*]/', Comment.Multiline), (r'\n', Whitespace), (words(( '>>>=', '>>=', '<<=', '<=', '>=', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '??=', '=>', '??', '?.', '!=', '==', '&&', '||', '>>>', '>>', '<<', '++', '--', '+', '-', '*', '/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=', )), Operator), (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator), (r'[()\[\];:,.]', Punctuation), (r'[{}]', Punctuation), (r'@"(""|[^"])*"', String), (r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String), (r"'\\.'|'[^\\]'", String.Char), (r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?" r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number), (r'(#)([ \t]*)(if|endif|else|elif|define|undef|' r'line|error|warning|region|endregion|pragma)\b(.*?)(\n)', bygroups(Comment.Preproc, Whitespace, Comment.Preproc, Comment.Preproc, Whitespace)), (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace, Keyword)), (words(( 'abstract', 'as', 'async', 'await', 'base', 'break', 'by', 'case', 'catch', 'checked', 'const', 'continue', 'default', 'delegate', 'do', 'else', 'enum', 'event', 'explicit', 'extern', 'false', 'finally', 'fixed', 'for', 'foreach', 'goto', 'if', 'implicit', 'in', 'interface', 'internal', 'is', 'let', 'lock', 'new', 'null', 'on', 'operator', 'out', 'override', 'params', 'private', 'protected', 'public', 'readonly', 'ref', 'return', 'sealed', 'sizeof', 'stackalloc', 'static', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'unchecked', 'unsafe', 'virtual', 'void', 'while', 'get', 'set', 'new', 'partial', 'yield', 'add', 'remove', 'value', 'alias', 'ascending', 'descending', 'from', 'group', 'into', 'orderby', 'select', 'thenby', 'where', 'join', 'equals', 'record', 'allows', 'and', 'init', 'managed', 'nameof', 'nint', 'not', 'notnull', 'nuint', 'or', 'scoped', 'unmanaged', 'when', 'with' ), suffix=r'\b'), Keyword), # version 1: assumes that 'file' is the only contextual keyword # that is a class modifier (r'(file)(\s+)(record|class|abstract|enum|new|sealed|static)\b', bygroups(Keyword, Whitespace, Keyword)), (r'(global)(::)', bygroups(Keyword, Punctuation)), (r'(bool|byte|char|decimal|double|dynamic|float|int|long|object|' r'sbyte|short|string|uint|ulong|ushort|var)\b\??', Keyword.Type), (r'(class|struct)(\s+)', bygroups(Keyword, Whitespace), 'class'), (r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace), 'namespace'), (cs_ident, Name), ], 'numbers_int': [ (r"0[xX][0-9a-fA-F]+(([uU][lL]?)|[lL][uU]?)?", Number.Hex), (r"0[bB][01]+(([uU][lL]?)|[lL][uU]?)?", Number.Bin), (r"[0-9]+(([uU][lL]?)|[lL][uU]?)?", Number.Integer), ], 'numbers_float': [ (r"([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|" r"(\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|" r"([0-9]+([eE][+-]?[0-9]+)[fFdDmM]?)|" r"([0-9]+[fFdDmM])", Number.Float), ], 'numbers': [ include('numbers_float'), include('numbers_int'), ], 'class': [ (cs_ident, Name.Class, '#pop'), default('#pop'), ], 'namespace': [ (r'(?=\()', Text, '#pop'), # using (resource) ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop'), ] }
def __init__(self, **options): level = get_choice_opt(options, 'unicodelevel', list(self.tokens), 'basic') if level not in self._all_tokens: # compile the regexes now self._tokens = self.__class__.process_tokendef(level) else: self._tokens = self._all_tokens[level]
RegexLexer.__init__(self, **options)
class NemerleLexer(RegexLexer): """ For Nemerle source code.
Additional options accepted:
`unicodelevel` Determines which Unicode characters this lexer allows for identifiers. The possible values are:
* ``none`` -- only the ASCII letters and numbers are allowed. This is the fastest selection. * ``basic`` -- all Unicode characters from the specification except category ``Lo`` are allowed. * ``full`` -- all Unicode characters as specified in the C# specs are allowed. Note that this means a considerable slowdown since the ``Lo`` category has more than 40,000 characters in it!
The default value is ``basic``. """
name = 'Nemerle' url = 'http://nemerle.org' aliases = ['nemerle'] filenames = ['*.n'] mimetypes = ['text/x-nemerle'] # inferred version_added = '1.5'
flags = re.MULTILINE | re.DOTALL
# for the range of allowed unicode characters in identifiers, see # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
levels = { 'none': r'@?[_a-zA-Z]\w*', 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' + '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), 'full': ('@?(?:_|[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), }
tokens = {} token_variants = True
for levelname, cs_ident in levels.items(): tokens[levelname] = { 'root': [ # method names (r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type r'(' + cs_ident + ')' # method name r'(\s*)(\()', # signature start bygroups(Whitespace, using(this), Name.Function, Whitespace, \ Punctuation)), (r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)), (r'[^\S\n]+', Whitespace), (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation (r'//.*?\n', Comment.Single), (r'/[*].*?[*]/', Comment.Multiline), (r'\n', Whitespace), (r'(\$)(\s*)(")', bygroups(String, Whitespace, String), 'splice-string'), (r'(\$)(\s*)(<#)', bygroups(String, Whitespace, String), 'splice-string2'), (r'<#', String, 'recursive-string'),
(r'(<\[)(\s*)(' + cs_ident + ':)?', bygroups(Keyword, Whitespace, Keyword)), (r'\]\>', Keyword),
# quasiquotation only (r'\$' + cs_ident, Name), (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'),
(r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation), (r'[{}]', Punctuation), (r'@"(""|[^"])*"', String), (r'"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String), (r"'\\.'|'[^\\]'", String.Char), (r"0[xX][0-9a-fA-F]+[Ll]?", Number), (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFLdD]?", Number), (r'(#)([ \t]*)(if|endif|else|elif|define|undef|' r'line|error|warning|region|endregion|pragma)\b', bygroups(Comment.Preproc, Whitespace, Comment.Preproc), 'preproc'), (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace, Keyword)), (r'(abstract|and|as|base|catch|def|delegate|' r'enum|event|extern|false|finally|' r'fun|implements|interface|internal|' r'is|macro|match|matches|module|mutable|new|' r'null|out|override|params|partial|private|' r'protected|public|ref|sealed|static|' r'syntax|this|throw|true|try|type|typeof|' r'virtual|volatile|when|where|with|' r'assert|assert2|async|break|checked|continue|do|else|' r'ensures|for|foreach|if|late|lock|new|nolate|' r'otherwise|regexp|repeat|requires|return|surroundwith|' r'unchecked|unless|using|while|yield)\b', Keyword), (r'(global)(::)', bygroups(Keyword, Punctuation)), (r'(bool|byte|char|decimal|double|float|int|long|object|sbyte|' r'short|string|uint|ulong|ushort|void|array|list)\b\??', Keyword.Type), (r'(:>?)(\s*)(' + cs_ident + r'\??)', bygroups(Punctuation, Whitespace, Keyword.Type)), (r'(class|struct|variant|module)(\s+)', bygroups(Keyword, Whitespace), 'class'), (r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace), 'namespace'), (cs_ident, Name), ], 'class': [ (cs_ident, Name.Class, '#pop') ], 'preproc': [ (r'\w+', Comment.Preproc), (r'[ \t]+', Whitespace), (r'\n', Whitespace, '#pop') ], 'namespace': [ (r'(?=\()', Text, '#pop'), # using (resource) ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop') ], 'splice-string': [ (r'[^"$]', String), (r'\$' + cs_ident, Name), (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'), (r'\\"', String), (r'"', String, '#pop') ], 'splice-string2': [ (r'[^#<>$]', String), (r'\$' + cs_ident, Name), (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'), (r'<#', String, '#push'), (r'#>', String, '#pop') ], 'recursive-string': [ (r'[^#<>]', String), (r'<#', String, '#push'), (r'#>', String, '#pop') ], 'splice-string-content': [ (r'if|match', Keyword), (r'[~!%^&*+=|\[\]:;,.<>/?-\\"$ ]', Punctuation), (cs_ident, Name), (r'\d+', Number), (r'\(', Punctuation, '#push'), (r'\)', Punctuation, '#pop') ] }
def __init__(self, **options): level = get_choice_opt(options, 'unicodelevel', list(self.tokens), 'basic') if level not in self._all_tokens: # compile the regexes now self._tokens = self.__class__.process_tokendef(level) else: self._tokens = self._all_tokens[level]
RegexLexer.__init__(self, **options)
def analyse_text(text): """Nemerle is quite similar to Python, but @if is relatively uncommon elsewhere.""" result = 0
if '@if' in text: result += 0.1
return result
class BooLexer(RegexLexer): """ For Boo source code. """
name = 'Boo' url = 'https://github.com/boo-lang/boo' aliases = ['boo'] filenames = ['*.boo'] mimetypes = ['text/x-boo'] version_added = ''
tokens = { 'root': [ (r'\s+', Whitespace), (r'(#|//).*$', Comment.Single), (r'/[*]', Comment.Multiline, 'comment'), (r'[]{}:(),.;[]', Punctuation), (r'(\\)(\n)', bygroups(Text, Whitespace)), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'/(\\\\|\\[^\\]|[^/\\\s])/', String.Regex), (r'@/(\\\\|\\[^\\]|[^/\\])*/', String.Regex), (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator), (r'(as|abstract|callable|constructor|destructor|do|import|' r'enum|event|final|get|interface|internal|of|override|' r'partial|private|protected|public|return|set|static|' r'struct|transient|virtual|yield|super|and|break|cast|' r'continue|elif|else|ensure|except|for|given|goto|if|in|' r'is|isa|not|or|otherwise|pass|raise|ref|try|unless|when|' r'while|from|as)\b', Keyword), (r'def(?=\s+\(.*?\))', Keyword), (r'(def)(\s+)', bygroups(Keyword, Whitespace), 'funcname'), (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (r'(namespace)(\s+)', bygroups(Keyword, Whitespace), 'namespace'), (r'(?<!\.)(true|false|null|self|__eval__|__switch__|array|' r'assert|checked|enumerate|filter|getter|len|lock|map|' r'matrix|max|min|normalArrayIndexing|print|property|range|' r'rawArrayIndexing|required|typeof|unchecked|using|' r'yieldAll|zip)\b', Name.Builtin), (r'"""(\\\\|\\"|.*?)"""', String.Double), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), (r'[a-zA-Z_]\w*', Name), (r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float), (r'[0-9][0-9.]*(ms?|d|h|s)', Number), (r'0\d+', Number.Oct), (r'0x[a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer), ], 'comment': [ ('/[*]', Comment.Multiline, '#push'), ('[*]/', Comment.Multiline, '#pop'), ('[^/*]', Comment.Multiline), ('[*/]', Comment.Multiline) ], 'funcname': [ (r'[a-zA-Z_]\w*', Name.Function, '#pop') ], 'classname': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop') ], 'namespace': [ (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop') ] }
class VbNetLexer(RegexLexer): """ For Visual Basic.NET source code. Also LibreOffice Basic, OpenOffice Basic, and StarOffice Basic. """
name = 'VB.net' url = 'https://docs.microsoft.com/en-us/dotnet/visual-basic/' aliases = ['vb.net', 'vbnet', 'lobas', 'oobas', 'sobas', 'visual-basic', 'visualbasic'] filenames = ['*.vb', '*.bas'] mimetypes = ['text/x-vbnet', 'text/x-vba'] # (?) version_added = ''
uni_name = '[_' + uni.combine('Ll', 'Lt', 'Lm', 'Nl') + ']' + \ '[' + uni.combine('Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'
flags = re.MULTILINE | re.IGNORECASE tokens = { 'root': [ (r'^\s*<.*?>', Name.Attribute), (r'\s+', Whitespace), (r'\n', Whitespace), (r'(rem\b.*?)(\n)', bygroups(Comment, Whitespace)), (r"('.*?)(\n)", bygroups(Comment, Whitespace)), (r'#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|' r'#ExternalSource.*?\n|#End\s+ExternalSource|' r'#Region.*?\n|#End\s+Region|#ExternalChecksum', Comment.Preproc), (r'[(){}!#,.:]', Punctuation), (r'(Option)(\s+)(Strict|Explicit|Compare)(\s+)' r'(On|Off|Binary|Text)', bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Keyword.Declaration)), (words(( 'AddHandler', 'Alias', 'ByRef', 'ByVal', 'Call', 'Case', 'Catch', 'CBool', 'CByte', 'CChar', 'CDate', 'CDec', 'CDbl', 'CInt', 'CLng', 'CObj', 'Continue', 'CSByte', 'CShort', 'CSng', 'CStr', 'CType', 'CUInt', 'CULng', 'CUShort', 'Declare', 'Default', 'Delegate', 'DirectCast', 'Do', 'Each', 'Else', 'ElseIf', 'EndIf', 'Erase', 'Error', 'Event', 'Exit', 'False', 'Finally', 'For', 'Friend', 'Get', 'Global', 'GoSub', 'GoTo', 'Handles', 'If', 'Implements', 'Inherits', 'Interface', 'Let', 'Lib', 'Loop', 'Me', 'MustInherit', 'MustOverride', 'MyBase', 'MyClass', 'Narrowing', 'New', 'Next', 'Not', 'Nothing', 'NotInheritable', 'NotOverridable', 'Of', 'On', 'Operator', 'Option', 'Optional', 'Overloads', 'Overridable', 'Overrides', 'ParamArray', 'Partial', 'Private', 'Protected', 'Public', 'RaiseEvent', 'ReadOnly', 'ReDim', 'RemoveHandler', 'Resume', 'Return', 'Select', 'Set', 'Shadows', 'Shared', 'Single', 'Static', 'Step', 'Stop', 'SyncLock', 'Then', 'Throw', 'To', 'True', 'Try', 'TryCast', 'Wend', 'Using', 'When', 'While', 'Widening', 'With', 'WithEvents', 'WriteOnly'), prefix=r'(?<!\.)', suffix=r'\b'), Keyword), (r'(?<!\.)End\b', Keyword, 'end'), (r'(?<!\.)(Dim|Const)\b', Keyword, 'dim'), (r'(?<!\.)(Function|Sub|Property)(\s+)', bygroups(Keyword, Whitespace), 'funcname'), (r'(?<!\.)(Class|Structure|Enum)(\s+)', bygroups(Keyword, Whitespace), 'classname'), (r'(?<!\.)(Module|Namespace|Imports)(\s+)', bygroups(Keyword, Whitespace), 'namespace'), (r'(?<!\.)(Boolean|Byte|Char|Date|Decimal|Double|Integer|Long|' r'Object|SByte|Short|Single|String|Variant|UInteger|ULong|' r'UShort)\b', Keyword.Type), (r'(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|' r'Or|OrElse|TypeOf|Xor)\b', Operator.Word), (r'&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|' r'<=|>=|<>|[-&*/\\^+=<>\[\]]', Operator), ('"', String, 'string'), (r'(_)(\n)', bygroups(Text, Whitespace)), # Line continuation (must be before Name) (uni_name + '[%&@!#$]?', Name), ('#.*?#', Literal.Date), (r'(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?', Number.Float), (r'\d+([SILDFR]|US|UI|UL)?', Number.Integer), (r'&H[0-9a-f]+([SILDFR]|US|UI|UL)?', Number.Integer), (r'&O[0-7]+([SILDFR]|US|UI|UL)?', Number.Integer), ], 'string': [ (r'""', String), (r'"C?', String, '#pop'), (r'[^"]+', String), ], 'dim': [ (uni_name, Name.Variable, '#pop'), default('#pop'), # any other syntax ], 'funcname': [ (uni_name, Name.Function, '#pop'), ], 'classname': [ (uni_name, Name.Class, '#pop'), ], 'namespace': [ (uni_name, Name.Namespace), (r'\.', Name.Namespace), default('#pop'), ], 'end': [ (r'\s+', Whitespace), (r'(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b', Keyword, '#pop'), default('#pop'), ] }
def analyse_text(text): if re.search(r'^\s*(#If|Module|Namespace)', text, re.MULTILINE): return 0.5
class GenericAspxLexer(RegexLexer): """ Lexer for ASP.NET pages. """
name = 'aspx-gen' filenames = [] mimetypes = [] url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
flags = re.DOTALL
tokens = { 'root': [ (r'(<%[@=#]?)(.*?)(%>)', bygroups(Name.Tag, Other, Name.Tag)), (r'(<script.*?>)(.*?)(</script>)', bygroups(using(XmlLexer), Other, using(XmlLexer))), (r'(.+?)(?=<)', using(XmlLexer)), (r'.+', using(XmlLexer)), ], }
# TODO support multiple languages within the same source fileclass CSharpAspxLexer(DelegatingLexer): """ Lexer for highlighting C# within ASP.NET pages. """
name = 'aspx-cs' aliases = ['aspx-cs'] filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'] mimetypes = [] url = 'https://dotnet.microsoft.com/en-us/apps/aspnet' version_added = ''
def __init__(self, **options): super().__init__(CSharpLexer, GenericAspxLexer, **options)
def analyse_text(text): if re.search(r'Page\s*Language="C#"', text, re.I) is not None: return 0.2 elif re.search(r'script[^>]+language=["\']C#', text, re.I) is not None: return 0.15
class VbNetAspxLexer(DelegatingLexer): """ Lexer for highlighting Visual Basic.net within ASP.NET pages. """
name = 'aspx-vb' aliases = ['aspx-vb'] filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'] mimetypes = [] url = 'https://dotnet.microsoft.com/en-us/apps/aspnet' version_added = ''
def __init__(self, **options): super().__init__(VbNetLexer, GenericAspxLexer, **options)
def analyse_text(text): if re.search(r'Page\s*Language="Vb"', text, re.I) is not None: return 0.2 elif re.search(r'script[^>]+language=["\']vb', text, re.I) is not None: return 0.15
# Very close to functional.OcamlLexerclass FSharpLexer(RegexLexer): """ For the F# language (version 3.0). """
name = 'F#' url = 'https://fsharp.org/' aliases = ['fsharp', 'f#'] filenames = ['*.fs', '*.fsi', '*.fsx'] mimetypes = ['text/x-fsharp'] version_added = '1.5'
keywords = [ 'abstract', 'as', 'assert', 'base', 'begin', 'class', 'default', 'delegate', 'do!', 'do', 'done', 'downcast', 'downto', 'elif', 'else', 'end', 'exception', 'extern', 'false', 'finally', 'for', 'function', 'fun', 'global', 'if', 'inherit', 'inline', 'interface', 'internal', 'in', 'lazy', 'let!', 'let', 'match', 'member', 'module', 'mutable', 'namespace', 'new', 'null', 'of', 'open', 'override', 'private', 'public', 'rec', 'return!', 'return', 'select', 'static', 'struct', 'then', 'to', 'true', 'try', 'type', 'upcast', 'use!', 'use', 'val', 'void', 'when', 'while', 'with', 'yield!', 'yield', ] # Reserved words; cannot hurt to color them as keywords too. keywords += [ 'atomic', 'break', 'checked', 'component', 'const', 'constraint', 'constructor', 'continue', 'eager', 'event', 'external', 'fixed', 'functor', 'include', 'method', 'mixin', 'object', 'parallel', 'process', 'protected', 'pure', 'sealed', 'tailcall', 'trait', 'virtual', 'volatile', ] keyopts = [ '!=', '#', '&&', '&', r'\(', r'\)', r'\*', r'\+', ',', r'-\.', '->', '-', r'\.\.', r'\.', '::', ':=', ':>', ':', ';;', ';', '<-', r'<\]', '<', r'>\]', '>', r'\?\?', r'\?', r'\[<', r'\[\|', r'\[', r'\]', '_', '`', r'\{', r'\|\]', r'\|', r'\}', '~', '<@@', '<@', '=', '@>', '@@>', ]
operators = r'[!$%&*+\./:<=>?@^|~-]' word_operators = ['and', 'or', 'not'] prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = [ 'sbyte', 'byte', 'char', 'nativeint', 'unativeint', 'float32', 'single', 'float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64', 'decimal', 'unit', 'bool', 'string', 'list', 'exn', 'obj', 'enum', ]
# See http://msdn.microsoft.com/en-us/library/dd233181.aspx and/or # http://fsharp.org/about/files/spec.pdf for reference. Good luck.
tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbrafv]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\u[0-9a-fA-F]{4}', String.Escape), (r'\\U[0-9a-fA-F]{8}', String.Escape), ], 'root': [ (r'\s+', Whitespace), (r'\(\)|\[\]', Name.Builtin.Pseudo), (r'\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name), (r'(///.*?)(\n)', bygroups(String.Doc, Whitespace)), (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'\(\*(?!\))', Comment, 'comment'),
(r'@"', String, 'lstring'), (r'"""', String, 'tqs'), (r'"', String, 'string'),
(r'\b(open|module)(\s+)([\w.]+)', bygroups(Keyword, Whitespace, Name.Namespace)), (r'\b(let!?)(\s+)(\w+)', bygroups(Keyword, Whitespace, Name.Variable)), (r'\b(type)(\s+)(\w+)', bygroups(Keyword, Whitespace, Name.Class)), (r'\b(member|override)(\s+)(\w+)(\.)(\w+)', bygroups(Keyword, Whitespace, Name, Punctuation, Name.Function)), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'``([^`\n\r\t]|`[^`\n\r\t])+``', Name), (r'({})'.format('|'.join(keyopts)), Operator), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type), (r'(#)([ \t]*)(if|endif|else|line|nowarn|light|\d+)\b(.*?)(\n)', bygroups(Comment.Preproc, Whitespace, Comment.Preproc, Comment.Preproc, Whitespace)),
(r"[^\W\d][\w']*", Name),
(r'\d[\d_]*[uU]?[yslLnQRZINGmM]?', Number.Integer), (r'0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?', Number.Hex), (r'0[oO][0-7][0-7_]*[uU]?[yslLn]?', Number.Oct), (r'0[bB][01][01_]*[uU]?[yslLn]?', Number.Bin), (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?', Number.Float),
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?", String.Char), (r"'.'", String.Char), (r"'", Keyword), # a stray quote is another syntax element
(r'@?"', String.Double, 'string'),
(r'[~?][a-z][\w\']*:', Name.Variable), ], 'dotted': [ (r'\s+', Whitespace), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), # e.g. dictionary index access default('#pop'), ], 'comment': [ (r'[^(*)@"]+', Comment), (r'\(\*', Comment, '#push'), (r'\*\)', Comment, '#pop'), # comments cannot be closed within strings in comments (r'@"', String, 'lstring'), (r'"""', String, 'tqs'), (r'"', String, 'string'), (r'[(*)@]', Comment), ], 'string': [ (r'[^\\"]+', String), include('escape-sequence'), (r'\\\n', String), (r'\n', String), # newlines are allowed in any string (r'"B?', String, '#pop'), ], 'lstring': [ (r'[^"]+', String), (r'\n', String), (r'""', String), (r'"B?', String, '#pop'), ], 'tqs': [ (r'[^"]+', String), (r'\n', String), (r'"""B?', String, '#pop'), (r'"', String), ], }
def analyse_text(text): """F# doesn't have that many unique features -- |> and <| are weak indicators.""" result = 0 if '|>' in text: result += 0.05 if '<|' in text: result += 0.05
return result
class XppLexer(RegexLexer):
""" For X++ source code. This is based loosely on the CSharpLexer """
name = 'X++' url = 'https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-language-reference' aliases = ['xpp', 'x++'] filenames = ['*.xpp'] version_added = '2.15'
flags = re.MULTILINE
XPP_CHARS = ('@?(?:_|[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*') # Temporary, see # https://github.com/thatch/regexlint/pull/49 XPP_CHARS = XPP_CHARS.replace('\x00', '\x01')
OPERATORS = ( '<=', '>=', '+=', '-=', '*=', '/=', '!=', '==', '&&', '||', '>>', '<<', '++', '--', '+', '-', '*', '/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=', ) KEYWORDS = ('abstract','anytype','as','async','asc','at','avg','break','breakpoint','by','byref','case','catch', 'changecompany','client','container','continue','count','crosscompany','default','delegate', 'delete_from','desc','display','div','do','edit','else','element','eventhandler','exists','false','final', 'firstfast','firstonly','firstonly10','firstonly100','firstonly1000','flush','for','forceliterals', 'forcenestedloop','forceplaceholders','forceselectorder','forupdate','from','group','if','insert_recordset', 'interface','is','join','like','maxof','minof','mod','new','next','nofetch','notexists','null','optimisticlock','order', 'outer','pause','pessimisticlock','print','private','protected','public','repeatableread','retry','return', 'reverse','select','server','setting','static','sum','super','switch','tablelock','this','throw','true','try','ttsabort','ttsbegin', 'ttscommit','update_recordset','validtimestate','void','where','while','window') RUNTIME_FUNCTIONS = ('_duration','abs','acos','any2Date','any2Enum','any2Guid','any2Int','any2Int64','any2Real','any2Str','anytodate', 'anytoenum','anytoguid','anytoint','anytoint64','anytoreal','anytostr','asin','atan','beep','cTerm','char2Num','classIdGet', 'corrFlagGet','corrFlagSet','cos','cosh','curExt','curUserId','date2Num','date2Str','datetime2Str','dayName','dayOfMth', 'dayOfWk','dayOfYr','ddb','decRound','dg','dimOf','endMth','enum2str','exp','exp10','fV','fieldId2Name','fieldId2PName', 'fieldName2Id','frac','funcName','getCurrentPartition','getCurrentPartitionRecId','getPrefix','guid2Str','idg','indexId2Name', 'indexName2Id','int2Str','int642Str','intvMax','intvName','intvNo','intvNorm','log10','logN','match','max','min','mkDate','mthName', 'mthOfYr','newGuid','nextMth','nextQtr','nextYr','num2Char','num2Date','num2Str','pmt','power','prevMth','prevQtr','prevYr', 'prmIsDefault','pt','pv','rate','refPrintAll','round','runAs','sessionId','setPrefix','sin','sinh','sleep','sln','str2Date', 'str2Datetime','str2Enum','str2Guid','str2Int','str2Int64','str2Num','str2Time','strAlpha','strCmp','strColSeq','strDel', 'strFind','strFmt','strIns','strKeep','strLTrim','strLen','strLine','strLwr','strNFind','strPoke','strPrompt','strRTrim', 'strRem','strRep','strScan','strUpr','subStr','syd','systemDateGet','systemDateSet','tableId2Name', 'tableId2PName','tableName2Id','tan','tanh','term','time2Str','timeNow','today','trunc','typeOf','uint2Str','wkOfYr','year') COMPILE_FUNCTIONS = ('attributeStr','classNum','classStr','configurationKeyNum','configurationKeyStr','dataEntityDataSourceStr','delegateStr', 'dimensionHierarchyLevelStr','dimensionHierarchyStr','dimensionReferenceStr','dutyStr','enumCnt','enumLiteralStr','enumNum','enumStr', 'extendedTypeNum','extendedTypeStr','fieldNum','fieldPName','fieldStr','formControlStr','formDataFieldStr','formDataSourceStr', 'formMethodStr','formStr','identifierStr','indexNum','indexStr','licenseCodeNum','licenseCodeStr','literalStr','maxDate','maxInt', 'measureStr','measurementStr','menuItemActionStr','menuItemDisplayStr','menuItemOutputStr','menuStr','methodStr','minInt','privilegeStr', 'queryDatasourceStr','queryMethodStr','queryStr','reportStr','resourceStr','roleStr','ssrsReportStr','staticDelegateStr','staticMethodStr', 'tableCollectionStr','tableFieldGroupStr','tableMethodStr','tableNum','tablePName','tableStaticMethodStr','tableStr','tileStr','varStr', 'webActionItemStr','webDisplayContentItemStr','webFormStr','webMenuStr','webOutputContentItemStr','webReportStr','webSiteTempStr', 'webStaticFileStr','webUrlItemStr','webWebPartStr','webletItemStr','webpageDefStr','websiteDefStr','workflowApprovalStr', 'workflowCategoryStr','workflowTaskStr','workflowTypeStr')
tokens = {}
tokens = { 'root': [ # method names (r'(\s*)\b(else|if)\b([^\n])', bygroups(Whitespace, Keyword, using(this))), # ensure that if is not treated like a function (r'^([ \t]*)((?:' + XPP_CHARS + r'(?:\[\])?\s+)+?)' # return type r'(' + XPP_CHARS + ')' # method name r'(\s*)(\()', # signature start bygroups(Whitespace, using(this), Name.Function, Whitespace, Punctuation)), (r'^(\s*)(\[)([^\n]*?)(\])', bygroups(Whitespace, Name.Attribute, Name.Variable.Class, Name.Attribute)), (r'[^\S\n]+', Whitespace), (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation (r'//[^\n]*?\n', Comment.Single), (r'/[*][^\n]*?[*]/', Comment.Multiline), (r'\n', Whitespace), (words(OPERATORS), Operator), (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator), (r'[()\[\];:,.#@]', Punctuation), (r'[{}]', Punctuation), (r'@"(""|[^"])*"', String), (r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String), (r"'\\.'|'[^\\]'", String.Char), (r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?" r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number), (words(KEYWORDS, suffix=r'\b'), Keyword), (r'(boolean|int|int64|str|real|guid|date)\b\??', Keyword.Type), (r'(class|struct|extends|implements)(\s+)', bygroups(Keyword, Whitespace), 'class'), (r'('+XPP_CHARS+')(::)', bygroups(Name.Variable.Class, Punctuation)), (r'(\s*)(\w+)(\s+\w+(,|=)?[^\n]*;)', bygroups(Whitespace, Name.Variable.Class, using(this))), # declaration # x++ specific function to get field should highlight the classname (r'(fieldNum\()('+XPP_CHARS+r')(\s*,\s*)('+XPP_CHARS+r')(\s*\))', bygroups(using(this), Name.Variable.Class, using(this), Name.Property, using(this))), # x++ specific function to get table should highlight the classname (r'(tableNum\()('+XPP_CHARS+r')(\s*\))', bygroups(using(this), Name.Variable.Class, using(this))), (words(RUNTIME_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic), (words(COMPILE_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic), (XPP_CHARS, Name), ], 'class': [ (XPP_CHARS, Name.Class, '#pop'), default('#pop'), ], 'namespace': [ (r'(?=\()', Text, '#pop'), # using (resource) ('(' + XPP_CHARS + r'|\.)+', Name.Namespace, '#pop'), ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970""" pygments.lexers.dsls ~~~~~~~~~~~~~~~~~~~~
Lexers for various domain-specific languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import ExtendedRegexLexer, RegexLexer, bygroups, words, \ include, default, this, using, combinedfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['ProtoBufLexer', 'ZeekLexer', 'PuppetLexer', 'RslLexer', 'MscgenLexer', 'VGLLexer', 'AlloyLexer', 'PanLexer', 'CrmshLexer', 'ThriftLexer', 'FlatlineLexer', 'SnowballLexer']
class ProtoBufLexer(RegexLexer): """ Lexer for Protocol Buffer definition files. """
name = 'Protocol Buffer' url = 'https://developers.google.com/protocol-buffers/' aliases = ['protobuf', 'proto'] filenames = ['*.proto'] version_added = '1.4'
tokens = { 'root': [ (r'[ \t]+', Whitespace), (r'[,;{}\[\]()<>]', Punctuation), (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single), (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline), (words(( 'import', 'option', 'optional', 'required', 'repeated', 'reserved', 'default', 'packed', 'ctype', 'extensions', 'to', 'max', 'rpc', 'returns', 'oneof', 'syntax'), prefix=r'\b', suffix=r'\b'), Keyword), (words(( 'int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'fixed32', 'fixed64', 'sfixed32', 'sfixed64', 'float', 'double', 'bool', 'string', 'bytes'), suffix=r'\b'), Keyword.Type), (r'(true|false)\b', Keyword.Constant), (r'(package)(\s+)', bygroups(Keyword.Namespace, Whitespace), 'package'), (r'(message|extend)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'message'), (r'(enum|group|service)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'type'), (r'\".*?\"', String), (r'\'.*?\'', String), (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float), (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), (r'(\-?(inf|nan))\b', Number.Float), (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex), (r'0[0-7]+[LlUu]*', Number.Oct), (r'\d+[LlUu]*', Number.Integer), (r'[+-=]', Operator), (r'([a-zA-Z_][\w.]*)([ \t]*)(=)', bygroups(Name.Attribute, Whitespace, Operator)), (r'[a-zA-Z_][\w.]*', Name), ], 'package': [ (r'[a-zA-Z_][\w\.]*', Name.Namespace, '#pop'), default('#pop'), ], 'message': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop'), default('#pop'), ], 'type': [ (r'[a-zA-Z_]\w*', Name, '#pop'), default('#pop'), ], }
class ThriftLexer(RegexLexer): """ For Thrift interface definitions. """ name = 'Thrift' url = 'https://thrift.apache.org/' aliases = ['thrift'] filenames = ['*.thrift'] mimetypes = ['application/x-thrift'] version_added = '2.1'
tokens = { 'root': [ include('whitespace'), include('comments'), (r'"', String.Double, combined('stringescape', 'dqs')), (r'\'', String.Single, combined('stringescape', 'sqs')), (r'(namespace)(\s+)', bygroups(Keyword.Namespace, Whitespace), 'namespace'), (r'(enum|union|struct|service|exception)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'class'), (r'((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)' # return arguments r'((?:[^\W\d]|\$)[\w$]*)' # method name r'(\s*)(\()', # signature start bygroups(using(this), Name.Function, Whitespace, Operator)), include('keywords'), include('numbers'), (r'[&=]', Operator), (r'[:;,{}()<>\[\]]', Punctuation), (r'[a-zA-Z_](\.\w|\w)*', Name), ], 'whitespace': [ (r'\n', Whitespace), (r'\s+', Whitespace), ], 'comments': [ (r'#.*$', Comment), (r'//.*?\n', Comment), (r'/\*[\w\W]*?\*/', Comment.Multiline), ], 'stringescape': [ (r'\\([\\nrt"\'])', String.Escape), ], 'dqs': [ (r'"', String.Double, '#pop'), (r'[^\\"\n]+', String.Double), ], 'sqs': [ (r"'", String.Single, '#pop'), (r'[^\\\'\n]+', String.Single), ], 'namespace': [ (r'[a-z*](\.\w|\w)*', Name.Namespace, '#pop'), default('#pop'), ], 'class': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop'), default('#pop'), ], 'keywords': [ (r'(async|oneway|extends|throws|required|optional)\b', Keyword), (r'(true|false)\b', Keyword.Constant), (r'(const|typedef)\b', Keyword.Declaration), (words(( 'cpp_namespace', 'cpp_include', 'cpp_type', 'java_package', 'cocoa_prefix', 'csharp_namespace', 'delphi_namespace', 'php_namespace', 'py_module', 'perl_package', 'ruby_namespace', 'smalltalk_category', 'smalltalk_prefix', 'xsd_all', 'xsd_optional', 'xsd_nillable', 'xsd_namespace', 'xsd_attrs', 'include'), suffix=r'\b'), Keyword.Namespace), (words(( 'void', 'bool', 'byte', 'i16', 'i32', 'i64', 'double', 'string', 'binary', 'map', 'list', 'set', 'slist', 'senum'), suffix=r'\b'), Keyword.Type), (words(( 'BEGIN', 'END', '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__', 'abstract', 'alias', 'and', 'args', 'as', 'assert', 'begin', 'break', 'case', 'catch', 'class', 'clone', 'continue', 'declare', 'def', 'default', 'del', 'delete', 'do', 'dynamic', 'elif', 'else', 'elseif', 'elsif', 'end', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'ensure', 'except', 'exec', 'finally', 'float', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'import', 'in', 'inline', 'instanceof', 'interface', 'is', 'lambda', 'module', 'native', 'new', 'next', 'nil', 'not', 'or', 'pass', 'public', 'print', 'private', 'protected', 'raise', 'redo', 'rescue', 'retry', 'register', 'return', 'self', 'sizeof', 'static', 'super', 'switch', 'synchronized', 'then', 'this', 'throw', 'transient', 'try', 'undef', 'unless', 'unsigned', 'until', 'use', 'var', 'virtual', 'volatile', 'when', 'while', 'with', 'xor', 'yield'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), ], 'numbers': [ (r'[+-]?(\d+\.\d+([eE][+-]?\d+)?|\.?\d+[eE][+-]?\d+)', Number.Float), (r'[+-]?0x[0-9A-Fa-f]+', Number.Hex), (r'[+-]?[0-9]+', Number.Integer), ], }
class ZeekLexer(RegexLexer): """ For Zeek scripts. """ name = 'Zeek' url = 'https://www.zeek.org/' aliases = ['zeek', 'bro'] filenames = ['*.zeek', '*.bro'] version_added = '2.5'
_hex = r'[0-9a-fA-F]' _float = r'((\d*\.?\d+)|(\d+\.?\d*))([eE][-+]?\d+)?' _h = r'[A-Za-z0-9][-A-Za-z0-9]*'
tokens = { 'root': [ include('whitespace'), include('comments'), include('directives'), include('attributes'), include('types'), include('keywords'), include('literals'), include('operators'), include('punctuation'), (r'((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(?=\s*\()', Name.Function), include('identifiers'), ],
'whitespace': [ (r'\n', Whitespace), (r'\s+', Whitespace), (r'(\\)(\n)', bygroups(Text, Whitespace)), ],
'comments': [ (r'#.*$', Comment), ],
'directives': [ (r'@(load-plugin|load-sigs|load|unload)\b.*$', Comment.Preproc), (r'@(DEBUG|DIR|FILENAME|deprecated|if|ifdef|ifndef|else|endif)\b', Comment.Preproc), (r'(@prefixes)(\s*)((\+?=).*)$', bygroups(Comment.Preproc, Whitespace, Comment.Preproc)), ],
'attributes': [ (words(('redef', 'priority', 'log', 'optional', 'default', 'add_func', 'delete_func', 'expire_func', 'read_expire', 'write_expire', 'create_expire', 'synchronized', 'persistent', 'rotate_interval', 'rotate_size', 'encrypt', 'raw_output', 'mergeable', 'error_handler', 'type_column', 'deprecated'), prefix=r'&', suffix=r'\b'), Keyword.Pseudo), ],
'types': [ (words(('any', 'enum', 'record', 'set', 'table', 'vector', 'function', 'hook', 'event', 'addr', 'bool', 'count', 'double', 'file', 'int', 'interval', 'pattern', 'port', 'string', 'subnet', 'time'), suffix=r'\b'), Keyword.Type),
(r'(opaque)(\s+)(of)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)\b', bygroups(Keyword.Type, Whitespace, Operator.Word, Whitespace, Keyword.Type)),
(r'(type)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(\s*)(:)(\s*)\b(record|enum)\b', bygroups(Keyword, Whitespace, Name.Class, Whitespace, Operator, Whitespace, Keyword.Type)),
(r'(type)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)(\s*)(:)', bygroups(Keyword, Whitespace, Name, Whitespace, Operator)),
(r'(redef)(\s+)(record|enum)(\s+)((?:[A-Za-z_]\w*)(?:::(?:[A-Za-z_]\w*))*)\b', bygroups(Keyword, Whitespace, Keyword.Type, Whitespace, Name.Class)), ],
'keywords': [ (words(('redef', 'export', 'if', 'else', 'for', 'while', 'return', 'break', 'next', 'continue', 'fallthrough', 'switch', 'default', 'case', 'add', 'delete', 'when', 'timeout', 'schedule'), suffix=r'\b'), Keyword), (r'(print)\b', Keyword), (r'(global|local|const|option)\b', Keyword.Declaration), (r'(module)(\s+)(([A-Za-z_]\w*)(?:::([A-Za-z_]\w*))*)\b', bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), ],
'literals': [ (r'"', String, 'string'),
# Not the greatest match for patterns, but generally helps # disambiguate between start of a pattern and just a division # operator. (r'/(?=.*/)', String.Regex, 'regex'),
(r'(T|F)\b', Keyword.Constant),
# Port (r'\d{1,5}/(udp|tcp|icmp|unknown)\b', Number),
# IPv4 Address (r'(\d{1,3}.){3}(\d{1,3})\b', Number),
# IPv6 Address (r'\[([0-9a-fA-F]{0,4}:){2,7}([0-9a-fA-F]{0,4})?((\d{1,3}.){3}(\d{1,3}))?\]', Number),
# Numeric (r'0[xX]' + _hex + r'+\b', Number.Hex), (_float + r'\s*(day|hr|min|sec|msec|usec)s?\b', Number.Float), (_float + r'\b', Number.Float), (r'(\d+)\b', Number.Integer),
# Hostnames (_h + r'(\.' + _h + r')+', String), ],
'operators': [ (r'[!%*/+<=>~|&^-]', Operator), (r'([-+=&|]{2}|[+=!><-]=)', Operator), (r'(in|as|is|of)\b', Operator.Word), (r'\??\$', Operator), ],
'punctuation': [ (r'[{}()\[\],;.]', Punctuation), # The "ternary if", which uses '?' and ':', could instead be # treated as an Operator, but colons are more frequently used to # separate field/identifier names from their types, so the (often) # less-prominent Punctuation is used even with '?' for consistency. (r'[?:]', Punctuation), ],
'identifiers': [ (r'([a-zA-Z_]\w*)(::)', bygroups(Name, Punctuation)), (r'[a-zA-Z_]\w*', Name) ],
'string': [ (r'\\.', String.Escape), (r'%-?[0-9]*(\.[0-9]+)?[DTd-gsx]', String.Escape), (r'"', String, '#pop'), (r'.', String), ],
'regex': [ (r'\\.', String.Escape), (r'/', String.Regex, '#pop'), (r'.', String.Regex), ], }
BroLexer = ZeekLexer
class PuppetLexer(RegexLexer): """ For Puppet configuration DSL. """ name = 'Puppet' url = 'https://puppet.com/' aliases = ['puppet'] filenames = ['*.pp'] version_added = '1.6'
tokens = { 'root': [ include('comments'), include('keywords'), include('names'), include('numbers'), include('operators'), include('strings'),
(r'[]{}:(),;[]', Punctuation), (r'\s+', Whitespace), ],
'comments': [ (r'(\s*)(#.*)$', bygroups(Whitespace, Comment)), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), ],
'operators': [ (r'(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)', Operator), (r'(in|and|or|not)\b', Operator.Word), ],
'names': [ (r'[a-zA-Z_]\w*', Name.Attribute), (r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation, String, Punctuation)), (r'\$\S+', Name.Variable), ],
'numbers': [ # Copypasta from the Python lexer (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[0-7]+j?', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+j?', Number.Integer) ],
'keywords': [ # Left out 'group' and 'require' # Since they're often used as attributes (words(( 'absent', 'alert', 'alias', 'audit', 'augeas', 'before', 'case', 'check', 'class', 'computer', 'configured', 'contained', 'create_resources', 'crit', 'cron', 'debug', 'default', 'define', 'defined', 'directory', 'else', 'elsif', 'emerg', 'err', 'exec', 'extlookup', 'fail', 'false', 'file', 'filebucket', 'fqdn_rand', 'generate', 'host', 'if', 'import', 'include', 'info', 'inherits', 'inline_template', 'installed', 'interface', 'k5login', 'latest', 'link', 'loglevel', 'macauthorization', 'mailalias', 'maillist', 'mcx', 'md5', 'mount', 'mounted', 'nagios_command', 'nagios_contact', 'nagios_contactgroup', 'nagios_host', 'nagios_hostdependency', 'nagios_hostescalation', 'nagios_hostextinfo', 'nagios_hostgroup', 'nagios_service', 'nagios_servicedependency', 'nagios_serviceescalation', 'nagios_serviceextinfo', 'nagios_servicegroup', 'nagios_timeperiod', 'node', 'noop', 'notice', 'notify', 'package', 'present', 'purged', 'realize', 'regsubst', 'resources', 'role', 'router', 'running', 'schedule', 'scheduled_task', 'search', 'selboolean', 'selmodule', 'service', 'sha1', 'shellquote', 'split', 'sprintf', 'ssh_authorized_key', 'sshkey', 'stage', 'stopped', 'subscribe', 'tag', 'tagged', 'template', 'tidy', 'true', 'undef', 'unmounted', 'user', 'versioncmp', 'vlan', 'warning', 'yumrepo', 'zfs', 'zone', 'zpool'), prefix='(?i)', suffix=r'\b'), Keyword), ],
'strings': [ (r'"([^"])*"', String), (r"'(\\'|[^'])*'", String), ],
}
class RslLexer(RegexLexer): """ RSL is the formal specification language used in RAISE (Rigorous Approach to Industrial Software Engineering) method. """ name = 'RSL' url = 'http://en.wikipedia.org/wiki/RAISE' aliases = ['rsl'] filenames = ['*.rsl'] mimetypes = ['text/rsl'] version_added = '2.0'
flags = re.MULTILINE | re.DOTALL
tokens = { 'root': [ (words(( 'Bool', 'Char', 'Int', 'Nat', 'Real', 'Text', 'Unit', 'abs', 'all', 'always', 'any', 'as', 'axiom', 'card', 'case', 'channel', 'chaos', 'class', 'devt_relation', 'dom', 'elems', 'else', 'elif', 'end', 'exists', 'extend', 'false', 'for', 'hd', 'hide', 'if', 'in', 'is', 'inds', 'initialise', 'int', 'inter', 'isin', 'len', 'let', 'local', 'ltl_assertion', 'object', 'of', 'out', 'post', 'pre', 'read', 'real', 'rng', 'scheme', 'skip', 'stop', 'swap', 'then', 'theory', 'test_case', 'tl', 'transition_system', 'true', 'type', 'union', 'until', 'use', 'value', 'variable', 'while', 'with', 'write', '~isin', '-inflist', '-infset', '-list', '-set'), prefix=r'\b', suffix=r'\b'), Keyword), (r'(variable|value)\b', Keyword.Declaration), (r'--.*?\n', Comment), (r'<:.*?:>', Comment), (r'\{!.*?!\}', Comment), (r'/\*.*?\*/', Comment), (r'^([ \t]*)([\w]+)([ \t]*)(:[^:])', bygroups(Whitespace, Name.Function, Whitespace, Name.Function)), (r'(^[ \t]*)([\w]+)([ \t]*)(\([\w\s,]*\))([ \t]*)(is|as)', bygroups(Whitespace, Name.Function, Whitespace, Text, Whitespace, Keyword)), (r'\b[A-Z]\w*\b', Keyword.Type), (r'(true|false)\b', Keyword.Constant), (r'".*"', String), (r'\'.\'', String.Char), (r'(><|->|-m->|/\\|<=|<<=|<\.|\|\||\|\^\||-~->|-~m->|\\/|>=|>>|' r'\.>|\+\+|-\\|<->|=>|:-|~=|\*\*|<<|>>=|\+>|!!|\|=\||#)', Operator), (r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'0x[0-9a-f]+', Number.Hex), (r'[0-9]+', Number.Integer), (r'\s+', Whitespace), (r'.', Text), ], }
def analyse_text(text): """ Check for the most common text in the beginning of a RSL file. """ if re.search(r'scheme\s*.*?=\s*class\s*type', text, re.I) is not None: return 1.0
class MscgenLexer(RegexLexer): """ For Mscgen files. """ name = 'Mscgen' url = 'http://www.mcternan.me.uk/mscgen/' aliases = ['mscgen', 'msc'] filenames = ['*.msc'] version_added = '1.6'
_var = r'(\w+|"(?:\\"|[^"])*")'
tokens = { 'root': [ (r'msc\b', Keyword.Type), # Options (r'(hscale|HSCALE|width|WIDTH|wordwraparcs|WORDWRAPARCS' r'|arcgradient|ARCGRADIENT)\b', Name.Property), # Operators (r'(abox|ABOX|rbox|RBOX|box|BOX|note|NOTE)\b', Operator.Word), (r'(\.|-|\|){3}', Keyword), (r'(?:-|=|\.|:){2}' r'|<<=>>|<->|<=>|<<>>|<:>' r'|->|=>>|>>|=>|:>|-x|-X' r'|<-|<<=|<<|<=|<:|x-|X-|=', Operator), # Names (r'\*', Name.Builtin), (_var, Name.Variable), # Other (r'\[', Punctuation, 'attrs'), (r'\{|\}|,|;', Punctuation), include('comments') ], 'attrs': [ (r'\]', Punctuation, '#pop'), (_var + r'(\s*)(=)(\s*)' + _var, bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)), (r',', Punctuation), include('comments') ], 'comments': [ (r'(?://|#).*?\n', Comment.Single), (r'/\*(?:.|\n)*?\*/', Comment.Multiline), (r'[ \t\r\n]+', Whitespace) ] }
class VGLLexer(RegexLexer): """ For SampleManager VGL source code. """ name = 'VGL' url = 'http://www.thermoscientific.com/samplemanager' aliases = ['vgl'] filenames = ['*.rpf'] version_added = '1.6'
flags = re.MULTILINE | re.DOTALL | re.IGNORECASE
tokens = { 'root': [ (r'\{[^}]*\}', Comment.Multiline), (r'declare', Keyword.Constant), (r'(if|then|else|endif|while|do|endwhile|and|or|prompt|object' r'|create|on|line|with|global|routine|value|endroutine|constant' r'|global|set|join|library|compile_option|file|exists|create|copy' r'|delete|enable|windows|name|notprotected)(?! *[=<>.,()])', Keyword), (r'(true|false|null|empty|error|locked)', Keyword.Constant), (r'[~^*#!%&\[\]()<>|+=:;,./?-]', Operator), (r'"[^"]*"', String), (r'(\.)([a-z_$][\w$]*)', bygroups(Operator, Name.Attribute)), (r'[0-9][0-9]*(\.[0-9]+(e[+\-]?[0-9]+)?)?', Number), (r'[a-z_$][\w$]*', Name), (r'[\r\n]+', Whitespace), (r'\s+', Whitespace) ] }
class AlloyLexer(RegexLexer): """ For Alloy source code. """
name = 'Alloy' url = 'http://alloy.mit.edu' aliases = ['alloy'] filenames = ['*.als'] mimetypes = ['text/x-alloy'] version_added = '2.0'
flags = re.MULTILINE | re.DOTALL
iden_rex = r'[a-zA-Z_][\w]*"*' string_rex = r'"\b(\\\\|\\[^\\]|[^"\\])*"' text_tuple = (r'[^\S\n]+', Whitespace)
tokens = { 'sig': [ (r'(extends)\b', Keyword, '#pop'), (iden_rex, Name), text_tuple, (r',', Punctuation), (r'\{', Operator, '#pop'), ], 'module': [ text_tuple, (iden_rex, Name, '#pop'), ], 'fun': [ text_tuple, (r'\{', Operator, '#pop'), (iden_rex, Name, '#pop'), ], 'fact': [ include('fun'), (string_rex, String, '#pop'), ], 'root': [ (r'--.*?$', Comment.Single), (r'//.*?$', Comment.Single), (r'/\*.*?\*/', Comment.Multiline), text_tuple, (r'(module|open)(\s+)', bygroups(Keyword.Namespace, Whitespace), 'module'), (r'(sig|enum)(\s+)', bygroups(Keyword.Declaration, Whitespace), 'sig'), (r'(iden|univ|none)\b', Keyword.Constant), (r'(int|Int)\b', Keyword.Type), (r'(var|this|abstract|extends|set|seq|one|lone|let)\b', Keyword), (r'(all|some|no|sum|disj|when|else)\b', Keyword), (r'(run|check|for|but|exactly|expect|as|steps)\b', Keyword), (r'(always|after|eventually|until|release)\b', Keyword), # future time operators (r'(historically|before|once|since|triggered)\b', Keyword), # past time operators (r'(and|or|implies|iff|in)\b', Operator.Word), (r'(fun|pred|assert)(\s+)', bygroups(Keyword, Whitespace), 'fun'), (r'(fact)(\s+)', bygroups(Keyword, Whitespace), 'fact'), (r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.\.|\.|->', Operator), (r'[-+/*%=<>&!^|~{}\[\]().\';]', Operator), (iden_rex, Name), (r'[:,]', Punctuation), (r'[0-9]+', Number.Integer), (string_rex, String), (r'\n', Whitespace), ] }
class PanLexer(RegexLexer): """ Lexer for pan source files.
Based on tcsh lexer. """
name = 'Pan' url = 'https://github.com/quattor/pan/' aliases = ['pan'] filenames = ['*.pan'] version_added = '2.0'
tokens = { 'root': [ include('basic'), (r'\(', Keyword, 'paren'), (r'\{', Keyword, 'curly'), include('data'), ], 'basic': [ (words(( 'if', 'for', 'with', 'else', 'type', 'bind', 'while', 'valid', 'final', 'prefix', 'unique', 'object', 'foreach', 'include', 'template', 'function', 'variable', 'structure', 'extensible', 'declaration'), prefix=r'\b', suffix=r'\b'), Keyword), (words(( 'file_contents', 'format', 'index', 'length', 'match', 'matches', 'replace', 'splice', 'split', 'substr', 'to_lowercase', 'to_uppercase', 'debug', 'error', 'traceback', 'deprecated', 'base64_decode', 'base64_encode', 'digest', 'escape', 'unescape', 'append', 'create', 'first', 'nlist', 'key', 'list', 'merge', 'next', 'prepend', 'is_boolean', 'is_defined', 'is_double', 'is_list', 'is_long', 'is_nlist', 'is_null', 'is_number', 'is_property', 'is_resource', 'is_string', 'to_boolean', 'to_double', 'to_long', 'to_string', 'clone', 'delete', 'exists', 'path_exists', 'if_exists', 'return', 'value'), prefix=r'\b', suffix=r'\b'), Name.Builtin), (r'#.*', Comment), (r'\\[\w\W]', String.Escape), (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Whitespace, Operator)), (r'[\[\]{}()=]+', Operator), (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String), (r';', Punctuation), ], 'data': [ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double), (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), (r'\s+', Whitespace), (r'[^=\s\[\]{}()$"\'`\\;#]+', Text), (r'\d+(?= |\Z)', Number), ], 'curly': [ (r'\}', Keyword, '#pop'), (r':-', Keyword), (r'\w+', Name.Variable), (r'[^}:"\'`$]+', Punctuation), (r':', Punctuation), include('root'), ], 'paren': [ (r'\)', Keyword, '#pop'), include('root'), ], }
class CrmshLexer(RegexLexer): """ Lexer for crmsh configuration files for Pacemaker clusters. """ name = 'Crmsh' url = 'http://crmsh.github.io/' aliases = ['crmsh', 'pcmk'] filenames = ['*.crmsh', '*.pcmk'] mimetypes = [] version_added = '2.1'
elem = words(( 'node', 'primitive', 'group', 'clone', 'ms', 'location', 'colocation', 'order', 'fencing_topology', 'rsc_ticket', 'rsc_template', 'property', 'rsc_defaults', 'op_defaults', 'acl_target', 'acl_group', 'user', 'role', 'tag'), suffix=r'(?![\w#$-])') sub = words(( 'params', 'meta', 'operations', 'op', 'rule', 'attributes', 'utilization'), suffix=r'(?![\w#$-])') acl = words(('read', 'write', 'deny'), suffix=r'(?![\w#$-])') bin_rel = words(('and', 'or'), suffix=r'(?![\w#$-])') un_ops = words(('defined', 'not_defined'), suffix=r'(?![\w#$-])') date_exp = words(('in_range', 'date', 'spec', 'in'), suffix=r'(?![\w#$-])') acl_mod = (r'(?:tag|ref|reference|attribute|type|xpath)') bin_ops = (r'(?:lt|gt|lte|gte|eq|ne)') val_qual = (r'(?:string|version|number)') rsc_role_action = (r'(?:Master|Started|Slave|Stopped|' r'start|promote|demote|stop)')
tokens = { 'root': [ (r'^(#.*)(\n)?', bygroups(Comment, Whitespace)), # attr=value (nvpair) (r'([\w#$-]+)(=)("(?:""|[^"])*"|\S+)', bygroups(Name.Attribute, Punctuation, String)), # need this construct, otherwise numeric node ids # are matched as scores # elem id: (r'(node)(\s+)([\w#$-]+)(:)', bygroups(Keyword, Whitespace, Name, Punctuation)), # scores (r'([+-]?([0-9]+|inf)):', Number), # keywords (elements and other) (elem, Keyword), (sub, Keyword), (acl, Keyword), # binary operators (rf'(?:{val_qual}:)?({bin_ops})(?![\w#$-])', Operator.Word), # other operators (bin_rel, Operator.Word), (un_ops, Operator.Word), (date_exp, Operator.Word), # builtin attributes (e.g. #uname) (r'#[a-z]+(?![\w#$-])', Name.Builtin), # acl_mod:blah (rf'({acl_mod})(:)("(?:""|[^"])*"|\S+)', bygroups(Keyword, Punctuation, Name)), # rsc_id[:(role|action)] # NB: this matches all other identifiers (rf'([\w#$-]+)(?:(:)({rsc_role_action}))?(?![\w#$-])', bygroups(Name, Punctuation, Operator.Word)), # punctuation (r'(\\(?=\n)|[\[\](){}/:@])', Punctuation), (r'\s+|\n', Whitespace), ], }
class FlatlineLexer(RegexLexer): """ Lexer for Flatline expressions. """ name = 'Flatline' url = 'https://github.com/bigmlcom/flatline' aliases = ['flatline'] filenames = [] mimetypes = ['text/x-flatline'] version_added = '2.2'
special_forms = ('let',)
builtins = ( "!=", "*", "+", "-", "<", "<=", "=", ">", ">=", "abs", "acos", "all", "all-but", "all-with-defaults", "all-with-numeric-default", "and", "asin", "atan", "avg", "avg-window", "bin-center", "bin-count", "call", "category-count", "ceil", "cond", "cond-window", "cons", "cos", "cosh", "count", "diff-window", "div", "ensure-value", "ensure-weighted-value", "epoch", "epoch-day", "epoch-fields", "epoch-hour", "epoch-millisecond", "epoch-minute", "epoch-month", "epoch-second", "epoch-weekday", "epoch-year", "exp", "f", "field", "field-prop", "fields", "filter", "first", "floor", "head", "if", "in", "integer", "language", "length", "levenshtein", "linear-regression", "list", "ln", "log", "log10", "map", "matches", "matches?", "max", "maximum", "md5", "mean", "median", "min", "minimum", "missing", "missing-count", "missing?", "missing_count", "mod", "mode", "normalize", "not", "nth", "occurrences", "or", "percentile", "percentile-label", "population", "population-fraction", "pow", "preferred", "preferred?", "quantile-label", "rand", "rand-int", "random-value", "re-quote", "real", "replace", "replace-first", "rest", "round", "row-number", "segment-label", "sha1", "sha256", "sin", "sinh", "sqrt", "square", "standard-deviation", "standard_deviation", "str", "subs", "sum", "sum-squares", "sum-window", "sum_squares", "summary", "summary-no", "summary-str", "tail", "tan", "tanh", "to-degrees", "to-radians", "variance", "vectorize", "weighted-random-value", "window", "winnow", "within-percentiles?", "z-score", )
valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+'
tokens = { 'root': [ # whitespaces - usually not relevant (r'[,]+', Text), (r'\s+', Whitespace),
# numbers (r'-?\d+\.\d+', Number.Float), (r'-?\d+', Number.Integer), (r'0x-?[a-f\d]+', Number.Hex),
# strings, symbols and characters (r'"(\\\\|\\[^\\]|[^"\\])*"', String), (r"\\(.|[a-z]+)", String.Char),
# expression template placeholder (r'_', String.Symbol),
# highlight the special forms (words(special_forms, suffix=' '), Keyword),
# highlight the builtins (words(builtins, suffix=' '), Name.Builtin),
# the remaining functions (r'(?<=\()' + valid_name, Name.Function),
# find the remaining variables (valid_name, Name.Variable),
# parentheses (r'(\(|\))', Punctuation), ], }
class SnowballLexer(ExtendedRegexLexer): """ Lexer for Snowball source code. """
name = 'Snowball' url = 'https://snowballstem.org/' aliases = ['snowball'] filenames = ['*.sbl'] version_added = '2.2'
_ws = r'\n\r\t '
def __init__(self, **options): self._reset_stringescapes() ExtendedRegexLexer.__init__(self, **options)
def _reset_stringescapes(self): self._start = "'" self._end = "'"
def _string(do_string_first): def callback(lexer, match, ctx): s = match.start() text = match.group() string = re.compile(rf'([^{re.escape(lexer._start)}]*)(.)').match escape = re.compile(rf'([^{re.escape(lexer._end)}]*)(.)').match pos = 0 do_string = do_string_first while pos < len(text): if do_string: match = string(text, pos) yield s + match.start(1), String.Single, match.group(1) if match.group(2) == "'": yield s + match.start(2), String.Single, match.group(2) ctx.stack.pop() break yield s + match.start(2), String.Escape, match.group(2) pos = match.end() match = escape(text, pos) yield s + match.start(), String.Escape, match.group() if match.group(2) != lexer._end: ctx.stack[-1] = 'escape' break pos = match.end() do_string = True ctx.pos = s + match.end() return callback
def _stringescapes(lexer, match, ctx): lexer._start = match.group(3) lexer._end = match.group(5) return bygroups(Keyword.Reserved, Whitespace, String.Escape, Whitespace, String.Escape)(lexer, match, ctx)
tokens = { 'root': [ (r'len\b', Name.Builtin), (r'lenof\b', Operator.Word), include('root1'), ], 'root1': [ (rf'[{_ws}]+', Whitespace), (r'\d+', Number.Integer), (r"'", String.Single, 'string'), (r'[()]', Punctuation), (r'/\*[\w\W]*?\*/', Comment.Multiline), (r'//.*', Comment.Single), (r'[!*+\-/<=>]=|[-=]>|<[+-]|[$*+\-/<=>?\[\]]', Operator), (words(('as', 'get', 'hex', 'among', 'define', 'decimal', 'backwardmode'), suffix=r'\b'), Keyword.Reserved), (words(('strings', 'booleans', 'integers', 'routines', 'externals', 'groupings'), suffix=r'\b'), Keyword.Reserved, 'declaration'), (words(('do', 'or', 'and', 'for', 'hop', 'non', 'not', 'set', 'try', 'fail', 'goto', 'loop', 'next', 'test', 'true', 'false', 'unset', 'atmark', 'attach', 'delete', 'gopast', 'insert', 'repeat', 'sizeof', 'tomark', 'atleast', 'atlimit', 'reverse', 'setmark', 'tolimit', 'setlimit', 'backwards', 'substring'), suffix=r'\b'), Operator.Word), (words(('size', 'limit', 'cursor', 'maxint', 'minint'), suffix=r'\b'), Name.Builtin), (rf'(stringdef\b)([{_ws}]*)([^{_ws}]+)', bygroups(Keyword.Reserved, Whitespace, String.Escape)), (rf'(stringescapes\b)([{_ws}]*)(.)([{_ws}]*)(.)', _stringescapes), (r'[A-Za-z]\w*', Name), ], 'declaration': [ (r'\)', Punctuation, '#pop'), (words(('len', 'lenof'), suffix=r'\b'), Name, ('root1', 'declaration')), include('root1'), ], 'string': [ (r"[^']*'", _string(True)), ], 'escape': [ (r"[^']*'", _string(False)), ], }
def get_tokens_unprocessed(self, text=None, context=None): self._reset_stringescapes() return ExtendedRegexLexer.get_tokens_unprocessed(self, text, context)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279""" pygments.lexers.dylan ~~~~~~~~~~~~~~~~~~~~~
Lexers for the Dylan language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \ default, line_refrom pygments.token import Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Generic, Literal, Whitespace
__all__ = ['DylanLexer', 'DylanConsoleLexer', 'DylanLidLexer']
class DylanLexer(RegexLexer): """ For the Dylan language. """
name = 'Dylan' url = 'http://www.opendylan.org/' aliases = ['dylan'] filenames = ['*.dylan', '*.dyl', '*.intr'] mimetypes = ['text/x-dylan'] version_added = '0.7'
flags = re.IGNORECASE
builtins = { 'subclass', 'abstract', 'block', 'concrete', 'constant', 'class', 'compiler-open', 'compiler-sideways', 'domain', 'dynamic', 'each-subclass', 'exception', 'exclude', 'function', 'generic', 'handler', 'inherited', 'inline', 'inline-only', 'instance', 'interface', 'import', 'keyword', 'library', 'macro', 'method', 'module', 'open', 'primary', 'required', 'sealed', 'sideways', 'singleton', 'slot', 'thread', 'variable', 'virtual'}
keywords = { 'above', 'afterwards', 'begin', 'below', 'by', 'case', 'cleanup', 'create', 'define', 'else', 'elseif', 'end', 'export', 'finally', 'for', 'from', 'if', 'in', 'let', 'local', 'otherwise', 'rename', 'select', 'signal', 'then', 'to', 'unless', 'until', 'use', 'when', 'while'}
operators = { '~', '+', '-', '*', '|', '^', '=', '==', '~=', '~==', '<', '<=', '>', '>=', '&', '|'}
functions = { 'abort', 'abs', 'add', 'add!', 'add-method', 'add-new', 'add-new!', 'all-superclasses', 'always', 'any?', 'applicable-method?', 'apply', 'aref', 'aref-setter', 'as', 'as-lowercase', 'as-lowercase!', 'as-uppercase', 'as-uppercase!', 'ash', 'backward-iteration-protocol', 'break', 'ceiling', 'ceiling/', 'cerror', 'check-type', 'choose', 'choose-by', 'complement', 'compose', 'concatenate', 'concatenate-as', 'condition-format-arguments', 'condition-format-string', 'conjoin', 'copy-sequence', 'curry', 'default-handler', 'dimension', 'dimensions', 'direct-subclasses', 'direct-superclasses', 'disjoin', 'do', 'do-handlers', 'element', 'element-setter', 'empty?', 'error', 'even?', 'every?', 'false-or', 'fill!', 'find-key', 'find-method', 'first', 'first-setter', 'floor', 'floor/', 'forward-iteration-protocol', 'function-arguments', 'function-return-values', 'function-specializers', 'gcd', 'generic-function-mandatory-keywords', 'generic-function-methods', 'head', 'head-setter', 'identity', 'initialize', 'instance?', 'integral?', 'intersection', 'key-sequence', 'key-test', 'last', 'last-setter', 'lcm', 'limited', 'list', 'logand', 'logbit?', 'logior', 'lognot', 'logxor', 'make', 'map', 'map-as', 'map-into', 'max', 'member?', 'merge-hash-codes', 'min', 'modulo', 'negative', 'negative?', 'next-method', 'object-class', 'object-hash', 'odd?', 'one-of', 'pair', 'pop', 'pop-last', 'positive?', 'push', 'push-last', 'range', 'rank', 'rcurry', 'reduce', 'reduce1', 'remainder', 'remove', 'remove!', 'remove-duplicates', 'remove-duplicates!', 'remove-key!', 'remove-method', 'replace-elements!', 'replace-subsequence!', 'restart-query', 'return-allowed?', 'return-description', 'return-query', 'reverse', 'reverse!', 'round', 'round/', 'row-major-index', 'second', 'second-setter', 'shallow-copy', 'signal', 'singleton', 'size', 'size-setter', 'slot-initialized?', 'sort', 'sort!', 'sorted-applicable-methods', 'subsequence-position', 'subtype?', 'table-protocol', 'tail', 'tail-setter', 'third', 'third-setter', 'truncate', 'truncate/', 'type-error-expected-type', 'type-error-value', 'type-for-copy', 'type-union', 'union', 'values', 'vector', 'zero?'}
valid_name = '\\\\?[\\w!&*<>|^$%@\\-+~?/=]+'
def get_tokens_unprocessed(self, text): for index, token, value in RegexLexer.get_tokens_unprocessed(self, text): if token is Name: lowercase_value = value.lower() if lowercase_value in self.builtins: yield index, Name.Builtin, value continue if lowercase_value in self.keywords: yield index, Keyword, value continue if lowercase_value in self.functions: yield index, Name.Builtin, value continue if lowercase_value in self.operators: yield index, Operator, value continue yield index, token, value
tokens = { 'root': [ # Whitespace (r'\s+', Whitespace),
# single line comment (r'//.*?\n', Comment.Single),
# lid header (r'([a-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)', bygroups(Name.Attribute, Operator, Whitespace, String)),
default('code') # no header match, switch to code ], 'code': [ # Whitespace (r'\s+', Whitespace),
# single line comment (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
# multi-line comment (r'/\*', Comment.Multiline, 'comment'),
# strings and characters (r'"', String, 'string'), (r"'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'", String.Char),
# binary integer (r'#b[01]+', Number.Bin),
# octal integer (r'#o[0-7]+', Number.Oct),
# floating point (r'[-+]?(\d*\.\d+(e[-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)', Number.Float),
# decimal integer (r'[-+]?\d+', Number.Integer),
# hex integer (r'#x[0-9a-f]+', Number.Hex),
# Macro parameters (r'(\?' + valid_name + ')(:)' r'(token|name|variable|expression|body|case-body|\*)', bygroups(Name.Tag, Operator, Name.Builtin)), (r'(\?)(:)(token|name|variable|expression|body|case-body|\*)', bygroups(Name.Tag, Operator, Name.Builtin)), (r'\?' + valid_name, Name.Tag),
# Punctuation (r'(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])', Punctuation),
# Most operators are picked up as names and then re-flagged. # This one isn't valid in a name though, so we pick it up now. (r':=', Operator),
# Pick up #t / #f before we match other stuff with #. (r'#[tf]', Literal),
# #"foo" style keywords (r'#"', String.Symbol, 'keyword'),
# #rest, #key, #all-keys, etc. (r'#[a-z0-9-]+', Keyword),
# required-init-keyword: style keywords. (valid_name + ':', Keyword),
# class names ('<' + valid_name + '>', Name.Class),
# define variable forms. (r'\*' + valid_name + r'\*', Name.Variable.Global),
# define constant forms. (r'\$' + valid_name, Name.Constant),
# everything else. We re-flag some of these in the method above. (valid_name, Name), ], 'comment': [ (r'[^*/]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline) ], 'keyword': [ (r'"', String.Symbol, '#pop'), (r'[^\\"]+', String.Symbol), # all other characters ], 'string': [ (r'"', String, '#pop'), (r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})', String.Escape), (r'[^\\"\n]+', String), # all other characters (r'\\\n', String), # line continuation (r'\\', String), # stray backslash ] }
class DylanLidLexer(RegexLexer): """ For Dylan LID (Library Interchange Definition) files. """
name = 'DylanLID' aliases = ['dylan-lid', 'lid'] filenames = ['*.lid', '*.hdp'] mimetypes = ['text/x-dylan-lid'] url = 'http://www.opendylan.org/' version_added = '1.6' flags = re.IGNORECASE
tokens = { 'root': [ # Whitespace (r'\s+', Whitespace),
# single line comment (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
# lid header (r'(.*?)(:)([ \t]*)(.*(?:\n[ \t].+)*)', bygroups(Name.Attribute, Operator, Whitespace, String)), ] }
class DylanConsoleLexer(Lexer): """ For Dylan interactive console output.
This is based on a copy of the ``RubyConsoleLexer``. """ name = 'Dylan session' aliases = ['dylan-console', 'dylan-repl'] filenames = ['*.dylan-console'] mimetypes = ['text/x-dylan-console'] url = 'http://www.opendylan.org/' version_added = '1.6' _example = 'dylan-console/console.dylan-console'
_prompt_re = re.compile(r'\?| ')
def get_tokens_unprocessed(self, text): dylexer = DylanLexer(**self.options)
curcode = '' insertions = [] for match in line_re.finditer(text): line = match.group() m = self._prompt_re.match(line) if m is not None: end = m.end() insertions.append((len(curcode), [(0, Generic.Prompt, line[:end])])) curcode += line[end:] else: if curcode: yield from do_insertions(insertions, dylexer.get_tokens_unprocessed(curcode)) curcode = '' insertions = [] yield match.start(), Generic.Output, line if curcode: yield from do_insertions(insertions, dylexer.get_tokens_unprocessed(curcode))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144""" pygments.lexers.ecl ~~~~~~~~~~~~~~~~~~~
Lexers for the ECL language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, wordsfrom pygments.token import Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
__all__ = ['ECLLexer']
class ECLLexer(RegexLexer): """ Lexer for the declarative big-data ECL language. """
name = 'ECL' url = 'https://hpccsystems.com/training/documentation/ecl-language-reference/html' aliases = ['ecl'] filenames = ['*.ecl'] mimetypes = ['application/x-ecl'] version_added = '1.5'
flags = re.IGNORECASE | re.MULTILINE
tokens = { 'root': [ include('whitespace'), include('statements'), ], 'whitespace': [ (r'\s+', Whitespace), (r'\/\/.*', Comment.Single), (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline), ], 'statements': [ include('types'), include('keywords'), include('functions'), include('hash'), (r'"', String, 'string'), (r'\'', String, 'string'), (r'(\d+\.\d*|\.\d+|\d+)e[+-]?\d+[lu]*', Number.Float), (r'(\d+\.\d*|\.\d+|\d+f)f?', Number.Float), (r'0x[0-9a-f]+[lu]*', Number.Hex), (r'0[0-7]+[lu]*', Number.Oct), (r'\d+[lu]*', Number.Integer), (r'[~!%^&*+=|?:<>/-]+', Operator), (r'[{}()\[\],.;]', Punctuation), (r'[a-z_]\w*', Name), ], 'hash': [ (r'^#.*$', Comment.Preproc), ], 'types': [ (r'(RECORD|END)\D', Keyword.Declaration), (r'((?:ASCII|BIG_ENDIAN|BOOLEAN|DATA|DECIMAL|EBCDIC|INTEGER|PATTERN|' r'QSTRING|REAL|RECORD|RULE|SET OF|STRING|TOKEN|UDECIMAL|UNICODE|' r'UNSIGNED|VARSTRING|VARUNICODE)\d*)(\s+)', bygroups(Keyword.Type, Whitespace)), ], 'keywords': [ (words(( 'APPLY', 'ASSERT', 'BUILD', 'BUILDINDEX', 'EVALUATE', 'FAIL', 'KEYDIFF', 'KEYPATCH', 'LOADXML', 'NOTHOR', 'NOTIFY', 'OUTPUT', 'PARALLEL', 'SEQUENTIAL', 'SOAPCALL', 'CHECKPOINT', 'DEPRECATED', 'FAILCODE', 'FAILMESSAGE', 'FAILURE', 'GLOBAL', 'INDEPENDENT', 'ONWARNING', 'PERSIST', 'PRIORITY', 'RECOVERY', 'STORED', 'SUCCESS', 'WAIT', 'WHEN'), suffix=r'\b'), Keyword.Reserved), # These are classed differently, check later (words(( 'ALL', 'AND', 'ANY', 'AS', 'ATMOST', 'BEFORE', 'BEGINC++', 'BEST', 'BETWEEN', 'CASE', 'CONST', 'COUNTER', 'CSV', 'DESCEND', 'ENCRYPT', 'ENDC++', 'ENDMACRO', 'EXCEPT', 'EXCLUSIVE', 'EXPIRE', 'EXPORT', 'EXTEND', 'FALSE', 'FEW', 'FIRST', 'FLAT', 'FULL', 'FUNCTION', 'GROUP', 'HEADER', 'HEADING', 'HOLE', 'IFBLOCK', 'IMPORT', 'IN', 'JOINED', 'KEEP', 'KEYED', 'LAST', 'LEFT', 'LIMIT', 'LOAD', 'LOCAL', 'LOCALE', 'LOOKUP', 'MACRO', 'MANY', 'MAXCOUNT', 'MAXLENGTH', 'MIN SKEW', 'MODULE', 'INTERFACE', 'NAMED', 'NOCASE', 'NOROOT', 'NOSCAN', 'NOSORT', 'NOT', 'OF', 'ONLY', 'OPT', 'OR', 'OUTER', 'OVERWRITE', 'PACKED', 'PARTITION', 'PENALTY', 'PHYSICALLENGTH', 'PIPE', 'QUOTE', 'RELATIONSHIP', 'REPEAT', 'RETURN', 'RIGHT', 'SCAN', 'SELF', 'SEPARATOR', 'SERVICE', 'SHARED', 'SKEW', 'SKIP', 'SQL', 'STORE', 'TERMINATOR', 'THOR', 'THRESHOLD', 'TOKEN', 'TRANSFORM', 'TRIM', 'TRUE', 'TYPE', 'UNICODEORDER', 'UNSORTED', 'VALIDATE', 'VIRTUAL', 'WHOLE', 'WILD', 'WITHIN', 'XML', 'XPATH', '__COMPRESSED__'), suffix=r'\b'), Keyword.Reserved), ], 'functions': [ (words(( 'ABS', 'ACOS', 'ALLNODES', 'ASCII', 'ASIN', 'ASSTRING', 'ATAN', 'ATAN2', 'AVE', 'CASE', 'CHOOSE', 'CHOOSEN', 'CHOOSESETS', 'CLUSTERSIZE', 'COMBINE', 'CORRELATION', 'COS', 'COSH', 'COUNT', 'COVARIANCE', 'CRON', 'DATASET', 'DEDUP', 'DEFINE', 'DENORMALIZE', 'DISTRIBUTE', 'DISTRIBUTED', 'DISTRIBUTION', 'EBCDIC', 'ENTH', 'ERROR', 'EVALUATE', 'EVENT', 'EVENTEXTRA', 'EVENTNAME', 'EXISTS', 'EXP', 'FAILCODE', 'FAILMESSAGE', 'FETCH', 'FROMUNICODE', 'GETISVALID', 'GLOBAL', 'GRAPH', 'GROUP', 'HASH', 'HASH32', 'HASH64', 'HASHCRC', 'HASHMD5', 'HAVING', 'IF', 'INDEX', 'INTFORMAT', 'ISVALID', 'ITERATE', 'JOIN', 'KEYUNICODE', 'LENGTH', 'LIBRARY', 'LIMIT', 'LN', 'LOCAL', 'LOG', 'LOOP', 'MAP', 'MATCHED', 'MATCHLENGTH', 'MATCHPOSITION', 'MATCHTEXT', 'MATCHUNICODE', 'MAX', 'MERGE', 'MERGEJOIN', 'MIN', 'NOLOCAL', 'NONEMPTY', 'NORMALIZE', 'PARSE', 'PIPE', 'POWER', 'PRELOAD', 'PROCESS', 'PROJECT', 'PULL', 'RANDOM', 'RANGE', 'RANK', 'RANKED', 'REALFORMAT', 'RECORDOF', 'REGEXFIND', 'REGEXREPLACE', 'REGROUP', 'REJECTED', 'ROLLUP', 'ROUND', 'ROUNDUP', 'ROW', 'ROWDIFF', 'SAMPLE', 'SET', 'SIN', 'SINH', 'SIZEOF', 'SOAPCALL', 'SORT', 'SORTED', 'SQRT', 'STEPPED', 'STORED', 'SUM', 'TABLE', 'TAN', 'TANH', 'THISNODE', 'TOPN', 'TOUNICODE', 'TRANSFER', 'TRIM', 'TRUNCATE', 'TYPEOF', 'UNGROUP', 'UNICODEORDER', 'VARIANCE', 'WHICH', 'WORKUNIT', 'XMLDECODE', 'XMLENCODE', 'XMLTEXT', 'XMLUNICODE'), suffix=r'\b'), Name.Function), ], 'string': [ (r'"', String, '#pop'), (r'\'', String, '#pop'), (r'[^"\']+', String), ], }
def analyse_text(text): """This is very difficult to guess relative to other business languages. -> in conjunction with BEGIN/END seems relatively rare though.""" result = 0
if '->' in text: result += 0.01 if 'BEGIN' in text: result += 0.01 if 'END' in text: result += 0.01
return result.cache/pip/http-v2/a/1/9/5/3/a19537d3cf37c122db841d6fe4cd322bc10d1a558bb00d146b85cb9aAdded
.cache/pip/http-v2/a/1/9/5/3/a19537d3cf37c122db841d6fe4cd322bc10d1a558bb00d146b85cb9a.bodyAdded
.cache/pip/http-v2/a/3/2/7/2/a3272be75c47d40339fd3bd21ed3327aebabd76954c68f902bf35782Added
.cache/pip/http-v2/a/3/2/7/2/a3272be75c47d40339fd3bd21ed3327aebabd76954c68f902bf35782.bodyAdded+134
.cache/pip/http-v2/a/f/2/9/f/af29feb3d93cb03190397ce919a96d795669e4f05d0c1e5af7d6405cAdded
.cache/pip/http-v2/a/f/5/3/d/af53d10b2a0401eb083b4e24ccf3518cc83ed2a451d87928b17de49aAdded
.cache/pip/http-v2/a/f/5/3/d/af53d10b2a0401eb083b4e24ccf3518cc83ed2a451d87928b17de49a.bodyAdded
.cache/pip/http-v2/d/d/2/0/6/dd206ee8d449d4bec512242e8f8ebadb5a808c682766018f3921f62b.bodyAdded+51
.cache/pip/http-v2/e/5/8/5/b/e585bbf94bc6bd5f1a310aa9356bdd33cf1860b5d9f831257a0a9cfe.bodyAdded+408
.cache/pip/http-v2/e/7/5/e/3/e75e3a72ec5ffce867a4e738b4b84c7a8477fb04f819b70bfe837470Added
.cache/pip/http-v2/e/d/e/d/1/eded1062df3a835b1d654db11016327d0de7276866caf329f6f27b1c.bodyAdded+94
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/formatters/bbcode.pyAdded+108
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/formatters/rtf.pyAdded+349
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/_mapping.pyAdded+603
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bare.pyAdded+101
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/basic.pyAdded+656
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bdd.pyAdded+57
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/berry.pyAdded+99
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bibtex.pyAdded+159
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/blueprint.pyAdded+173
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/boa.pyAdded+97
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/bqn.pyAdded+112
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/business.pyAdded+625
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/c_cpp.pyAdded+415
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/c_like.pyAdded+738
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/capnproto.pyAdded+74
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/carbon.pyAdded+95
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/cddl.pyAdded+172
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/chapel.pyAdded+139
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/clean.pyAdded+180
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/codeql.pyAdded+80
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/comal.pyAdded+81
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/compiled.pyAdded+35
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/configs.pyAdded+1433
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/console.pyAdded+114
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/cplint.pyAdded+43
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/crystal.pyAdded+364
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/csound.pyAdded+466
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/css.pyAdded+632
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/d.pyAdded+259
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dalvik.pyAdded+126
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/data.pyAdded+763
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dax.pyAdded+135
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/devicetree.pyAdded+120
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/diff.pyAdded+169
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dns.pyAdded+109
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dotnet.pyAdded+873
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dsls.pyAdded+970
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/dylan.pyAdded+279
.cache/uv/archive-v0/8HXDPXsFSToj27nOg3aiO/pygments/lexers/ecl.pyAdded+144