Skip to main content

Yet Another LR Implementation

This is another implementation of the classic LR(1) parsing algorithm, along with Knuth’s LR(1) table generation algorithm.

Rather than follow the model of tools like yacc and require external code generation, this library is driven dynamically from Python code.

An obvious question is, “why?”

Two reasons:

  • firstly, to experiment with surface syntax for expressing grammars in Python code in as uninvasive a way as possible.

    The package “ptk” takes a similar approach here.

  • secondly, to provide a playground to look at other “cutting-edge” parsing algorithms, as a basis for improving my own understanding of them.

By “cutting-edge” I’m largely referring to the late 1970s.

The current implementation is largely inspired by yacc, including yacc’s various deficiencies:

  • there’s a linearisation used for reduce/reduce conflict resolution;

  • there’s a linearisation used for token precedence.

In practice, it’s easy to get bitten by both of these - as it is for the default shift/reduce resolution to mask errors. A more flexible partial ordering is certainly feasible.

Credits

Some of the example grammars included in the tests are derived from the (Red) Dragon Book, which I’ve had since I was about 16; it’s a book which definitely shaped my life.

I’ve no idea how the reference numbers line up with later additions.

Compilers: Principles, Techniques, and Tools (1986) by Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman

Metadata

Release files for yalr 0.0.5

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

Source distribution (sdist)

Source distribution for yalr 0.0.5
File Size Uploaded Provenance
yalr-0.0.5.tar.gz 9.6 kB Without provenance Details

Release files / yalr-0.0.5.tar.gz

Download URL yalr-0.0.5.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
49d6b4f4f1f0da2e21b59955f9fa1e3968f8dee8a1f8c0d8a55df088cf90ccec
BLAKE2b-256 checksum
How to use checksums
1deb365779a3e64904e15c3e3c088cd6198862d9430201fd884877b5455069dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for yalr 0.0.5

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.

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file No provenance

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