Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lark-parser/lark_cython
Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance
https://github.com/lark-parser/lark_cython
Last synced: 4 days ago
JSON representation
Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance
- Host: GitHub
- URL: https://github.com/lark-parser/lark_cython
- Owner: lark-parser
- License: mit
- Created: 2022-01-26T09:13:29.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T06:36:58.000Z (9 months ago)
- Last Synced: 2024-05-01T09:39:46.084Z (7 months ago)
- Language: Cython
- Homepage:
- Size: 45.9 KB
- Stars: 44
- Watchers: 4
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Lark-Cython
Cython plugin for [Lark](https://github.com/lark-parser/lark), reimplementing the LALR parser & lexer for better performance on CPython.
Install:
```python
pip install lark-cython
```Usage:
```python
import lark_cythonparser = Lark(grammar, parser="lalr", _plugins=lark_cython.plugins)
# Use Lark as you usually would, with a huge performance boost
```See the [examples](https://github.com/lark-parser/lark_cython/tree/master/examples) for more.
## Differences from Lark
- `Token` instances do not inherit from `str`. You must use the `value` attribute to get the string.
## Other caveats
- Postlexer isn't currently implemented
## Speed
In current benchmarks, lark-cython is about 50% to 80% faster than Lark.
We're still in the early stages, and in the future, lark-cython might go a lot faster.
## Other
License: MIT
Author: [Erez Shinan](https://github.com/erezsh/)
Special thanks goes to [Datafold](https://github.com/datafold) for commissioning the draft for lark-cython, and allowing me to release it as open-source.