Linter for (Pygments) regular expressions
Project description
Regexlint is intended to be run as a linter against an importable Pygments lexer, and flag problems that will prevent the lexer from performing well (since we don’t have branch coverage for lexers :)
As a simple example, alternations are first match, so it will flag this as never matching “elseif”:
(else|elseif)
It also understands some Pygments internals, for example bygroups(...)` needs to have the same number of args as the regex has capture groups. Too many will result in duplicate text; too few will result in missing text. There should also not be any gaps between the capture groups, so this example flags two problems:
(r'(foo)\s+(bar)', bygroups(Blah)),
Usage
make demo
or
regexlint pygments.lexers.web:HtmlLexer
or
python3 regexlint/cmdline.py pygments.lexers.web
Todo
Figure out which phase should remove unnecessary backslashes
Write the alternation expander, so that ([ax]|a[bc]) fails the alternation order checks
Make more general than just for Pygments
License
This project is licensed under the Apache Public License, see COPYING
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file regexlint-2.0.tar.gz.
File metadata
- Download URL: regexlint-2.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c17b6c8d7feb552a8c61fab071048d65a3da46b54f9787c2aa9f373d22fd629a
|
|
| MD5 |
f0c816ddce8d7bdfda7c53d505582479
|
|
| BLAKE2b-256 |
e500a2a82f046c4349248befe84990eb99edc74a5677e063c2f1d066772193c2
|
File details
Details for the file regexlint-2.0-py3-none-any.whl.
File metadata
- Download URL: regexlint-2.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c81144c09b8ec8319bd992c8407a0bb78b8b5374fa5ad57f240f8d810d82c5c6
|
|
| MD5 |
e52b3995a5202cdc5b7cacaf78a9f178
|
|
| BLAKE2b-256 |
b0b928d22928be0ab771bb61094d71067d5aa069c82a8e0f8d6ea90011150fbd
|