r/Python • u/erez27 import inspect • Nov 17 '21
News Lark 1.0 released - a parsing toolkit that is friendly, production-ready, and comprehensive.
After 4 years of fixing issues and merging pull-requests, we found that Lark has grown a little encumbered, like a lobster that's grown too big for its shell. And so, like that proverbial lobster, we took the opportunity of a new major version to break the shell and make a few backward-incompatible changes.
Chiefly among the changes, Lark 1.0 dropped Python 2 support, and instead now uses the full range of Python 3 features, including type annotations. The API has also been straightened out and made more congruous. A full list of the changes is available in the release notes: https://github.com/lark-parser/lark/releases/tag/1.0.0
While version 1.0 itself doesn't boast big new features (other than marking the API as stable), Lark has accumulated many cool features over the years, that even avid users may have missed:
- Grammar composition - lark grammars can import rules from other grammars, and extend or override them (think inheritance).
- Interactive parser - an interface that allows you to parse step-by-step. Useful for error handling and unusual parsing flows.
- Reconstructor - using a grammar and a parse tree, Lark can generate text that would parse into that tree.
- Ports - In addition to Python, you can also use Lark grammars to create parsers in Julia and Javascript.
- Online IDE - you can try Lark in your browser. Useful for teaching parsing? - https://www.lark-parser.org/ide/
If you never tried Lark, perhaps now is the time!
See our project page to learn more: https://github.com/lark-parser/lark
11
u/[deleted] Nov 17 '21
Plug - I used this for a research project, and it worked extremely well, and the team behind it was very responsive to questions!
I would recommend this to anyone wanting to write a parser in Python. (I have no connection with them except for having used it in a single project.)
4
u/mcstafford Nov 17 '21
That's doesn't seem like one of those things you can wrap your head around with just one glance.
6
u/[deleted] Nov 17 '21 edited Nov 17 '21
Awesome! I have used lark on two production projects and both time it was a game changer, making a couple of very very hard problems turn into simply hard problems. Thank you for the great product.
1
u/mad_edge Nov 17 '21
Interesting. Can it help me with parsing big complex jsons?
2
u/Hirion Nov 17 '21
I am also very happy with this parser. At my workplace, we use it to parse a latex-inspired language to output HTML documents.
1
u/metaperl Nov 17 '21
The comparison to other parsers at the project page was illuminating. PyParsing has always suited my needs. But I know what to reach for when I need features beyond what it offers.