parsy
Typed Parsy
NOTE: This repo is an experimental attempt to create a backwards
incompatible version of parsy that has strong type guarantees, with no
Any
slipping in to spoil things.
This means removing anything that cannot be typed fully, and providing alternatives. Main changes:
- Removed
seq
, and replaced it with&
operator support which returns a 2-tuple - Removed
alt
- you can use only|
operator. - Removed
.combine
and.combine_dict
- you have to use.map
instead, which is type-safe but much trickier, especially once you have nested tuples.
The docs have not been updated, you’ll need to look at the source code if you are interested.
Parsy is an easy and elegant way to parse text in Python by combining small parsers into complex, larger parsers. If it means anything to you, it's a monadic parser combinator library for LL(infinity) grammars in the spirit of Parsec, Parsnip, and Parsimmon. But don't worry, it has really good documentation and it doesn't say things like that!
Parsy requires Python 3.6 or greater.
For a good example of the kind of clear, declarative code you can create using parsy, see the SQL SELECT statement example or JSON parser.
Links:
To contribute, please create a fork and submit a pull request on GitHub, after checking the contributing section of the docs. Thanks!
If you like parsy and think it should be better known, you could:
- Star this project on GitHub.
- Vote for it being included on awesome-python.
Parsy was originally written by Jeanine Adkisson, with contributions by other people as can be found in the git commit history.