Metadata-Version: 2.4
Name: lark-rust
Version: 0.1.1
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Text Processing :: General
Requires-Dist: lark>=1.0
License-File: LICENSE
Summary: High-performance Rust-accelerated drop-in replacement for lark's LALR parser stack
Keywords: lark,parser,lalr,rust,performance
Author-email: Robert Ozimek <robertozimek@users.noreply.github.com>
License-Expression: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/robertozimek/lark-rust
Project-URL: Issues, https://github.com/robertozimek/lark-rust/issues
Project-URL: Repository, https://github.com/robertozimek/lark-rust

# lark-rust

High-performance Rust-accelerated drop-in replacement for [lark](https://github.com/lark-parser/lark)'s LALR parser stack. A faster alternative to [lark-cython](https://github.com/lark-parser/lark_cython).

## Installation

```bash
pip install lark-rust
```

## Usage

```python
from lark import Lark
import lark_rust

parser = Lark(grammar, parser='lalr', _plugins=lark_rust.plugins)
result = parser.parse(text)
```

That's it — same lark API, just faster.

## What's accelerated

The Rust native extension accelerates the hot-path components:

- **Token** — creation, hashing, equality comparison
- **Scanner** — regex matching via `fancy-regex`
- **BasicLexer** — token loop with single-pass newline counting
- **LineCounter** — position tracking
- **LexerState** — lexer state management

The parser, tree builder, and tree traversal are implemented in Python with full lark compatibility:

- **ContextualLexer**, **LALR_Parser** (with serialize/deserialize/on_error)
- **ParseTreeBuilder** with ExpandSingleChild, PropagatePositions, ChildFilter
- **Tree** with iter_subtrees, find_data, scan_values, pretty printing

## lark-cython compatibility

lark-rust is a drop-in replacement for lark-cython. All plugins supported by lark-cython are supported:

- `BasicLexer`, `ContextualLexer`, `LexerThread`
- `LALR_Parser`, `_Parser`, `ParseTreeBuilder`

## Requirements

- Python >= 3.8
- lark >= 1.0

## License

MIT

