3 releases (breaking)
0.3.0 | Mar 11, 2024 |
---|---|
0.2.0 | Jan 5, 2024 |
0.1.0 | Dec 20, 2023 |
#169 in Parser tooling
57KB
520 lines
Parser Combinators for Unique Results
parcours is a minimalistic crate to help with the creation of parsers and lexers. It provides a set of parser combinators for parsers that return unique results; that is, at most one output.
The name "parcours" is inspired from the sport Parkour, in which practitioners attempt to "get from point A to point B in the fastest and most efficient way possible, without assisting equipment".
In the same sense, parcours provides only very basic building blocks for parsers, but these building blocks are very generic and incur very small overhead, so you can do nearly everything with them.
Features
no_std
and no dependency onalloc
→ suitable for constrained (embedded) environments- no other dependencies
- zero-copy parsing
- fast build times: ~600ms for a JSON parser with
--release
- high performance
- works on any kind of input (helpers for
&str
and&[T]
are provided) - precedence climbing
Related Work
I discovered the lip crate only once I was already on a good way into writing parcours. It is spiritually the closest to parcours in the Rust ecosystem that I found so far. Apart from it, there are many parser combinator crates. I have personally implemented quite complex parsers using nom and chumsky, which both provide nice machinery for common use cases, but I always struggled once I wanted to do something that was not intended by these crates. In contrast, parcours provides much less machinery, and it is my hope that this makes it also more flexible.