Skip to main content

lectes

lectes is a simple Python scanner generator. It can be used to easily define scanners with Python code.

Documentation: https://maxcode123.github.io/lectes/

Example

from lectes import Rule, Configuration, Regex, Scanner


config = Configuration(
    [
        Rule(name="FOR", regex=Regex("for")),
        Rule(name="INT", regex=Regex("[0-9]+")),
        Rule(name="ID", regex=Regex("[a-zA-Z][a-zA-Z0-9]*")),
        Rule(name="WHITESPACE", regex=Regex("( )")),
    ]
)

scanner = Scanner(config)

program = "somevar in othervar for 9 let"

for token in scanner.scan(program):
    print(token)

Command line

lectes also comes with a lectes command that scans a file or stdin with a grammar file, one NAME regex rule per line:

$ cat arithmetic.lectes
INT     [0-9]+
PLUS    \+
WS      \s+

$ echo '12 + 3' | lectes arithmetic.lectes
1:1     INT   '12'
1:3     WS    ' '
1:4     PLUS  '+'
1:5     WS    ' '
1:6     INT   '3'
1:7     WS    '\n'

Use --format json for JSON Lines output. See the command-line docs for every option.

Installation

As a library:

pip install lectes

As a command-line tool:

uv tool install lectes   # or: pipx install lectes
uvx lectes grammar.lectes input.txt   # run once without installing

Metadata

Release files for lectes 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lectes 0.4.0
File Size Uploaded Provenance Actions
lectes-0.4.0.tar.gz 25.3 kB Without provenance Details for lectes-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lectes 0.4.0
File Interpreter ABI Platform Actions
lectes-0.4.0-py3-none-any.whl Python 3 none any Details for lectes-0.4.0-py3-none-any.whl

Total release size: 56.8 kB

Release files / lectes-0.4.0.tar.gz

Download URL lectes-0.4.0.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5d59ab77fd62bbb87dcb926aeda9f6acdd88da446af73bc959523c33d2ac10f5
BLAKE2b-256 checksum
How to use checksums
3ee082cc6471fa6f9fc4343951568aa279a5b892b5c7ff386de98f31e250cf3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lectes-0.4.0-py3-none-any.whl

Download URL lectes-0.4.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be915d57882f11bd6d572341398ec1a3caa7a17f494d784e6eed9920bcba3232
BLAKE2b-256 checksum
How to use checksums
55ccd73d79a662d28bebf96ad82f1c495833aedcba975781f32fda48fa9a86aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lectes 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page