poetry-lark
Lark is an amazing parsing toolkit for Python, built with a focus on ergonomics, performance and modularity. Lark can parse all context-free languages. To put it simply, it means that it is capable of parsing almost any programming language out there, and to some degree most natural languages too.
Lark can generate a stand-alone LALR(1) parser from a grammar. This plugin integrates Lark into the Poetry build system and provides several commands for configuring standalone parsers using pyproject.toml and Poetry.
Install
$ poetry self add poetry-lark
The plugin depends only on Lark and Poetry, but you can use Lark's extra features:
interegular(if it is installed, Lark uses it to check for collisions, and warn about any conflicts that it can find)regex(if you want to use theregexmodule instead of theremodule).
Usage
$ poetry lark-add <module> <grammar-file>
$ poetry lark-remove <module>
$ poetry lark-build <module>
By default, the plugin is integrated into the Poetry build system and generates all parser modules specified in the pyproject.toml (if auto-build option is not configured as false for parser module).
In the simplest case, when adding a parser, you will get:
[[tool.lark.standalone]]
module = "parser"
source = "grammar.lark"
In a more complex case you can use all features of Lark standalone parser:
[[tool.lark.standalone]]
module = {expose = "parser", from = "src", auto-build = true}
source = "grammar.lark"
start = ["start"]
lexer = "contextual"
enable_compress = false
keep_all_tokens = false
propagate_positions = false
use_bytes = false
use_maybe_placeholders = true
use_regex = false
use_strict = false
These options are available on lark-add command:
| Argument | Description |
|---|---|
--src |
use the 'src' layout for the project |
-s <symbol>, --start <symbol> |
the grammar's start symbols, default start, can be multiple |
-l <lexer>, --lexer <lexer> |
the lexer to use, basic or contextual, default contextual |
-c, --enable-compress |
enable compression in the generated parser |
-K, --keep-all-tokens |
prevent removal of 'punctuation' tokens in the parse tree |
-P, --propagate-positions |
propagate positional attributes into metadata |
--use-bytes |
use bytes as input type instead of str |
--use-regex |
use the regex module instead of the re module |
--use-strict |
use strict mode in parsing |
--no-maybe-placeholders |
disable placeholders for empty optional tokens |
--no-auto-build |
disable automatic build for the module |
Metadata
Release files for poetry-lark 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| poetry_lark-1.1.0.tar.gz | 8.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| poetry_lark-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / poetry_lark-1.1.0.tar.gz
| Download URL | poetry_lark-1.1.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
412da403e8836312cb9c1eb3700be178512f4f9a0d097b352fcc3b64e59a9cf6
|
|
BLAKE2b-256 checksum How to use checksums |
e7ad153254c77268c0ca829f09909c81e149ca0838e5701dc7e4e4054dbba0b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Release files / poetry_lark-1.1.0-py3-none-any.whl
| Download URL | poetry_lark-1.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec4b74c358368ca0dc800b82df049b5faff4d151558faf6377d087cc414ee79d
|
|
BLAKE2b-256 checksum How to use checksums |
ae648fd59218174db9a828811eec0c63ba16456c2dba8eac029954ee4bfcfabb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Security for poetry-lark 1.1.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.