parsimonious: a parser combinator library for Rust
The goal of this library is to provide parser combinators that:
- are optimized for LL(1) grammars,
- support streaming input,
- do as little buffering or copying as possible, and
- do as little dynamic method dispatch as possible.
It is based on:
- Monadic Parsing in Haskell by G. Hutton and E. Meijer, JFP 8(4) pp. 437-444,
- Nom, eating data byte by byte by G. Couprie.
Example
To parse a sequence of alphanumerics into a string buffer:
let ALPHANUMERIC = character_guard;
let ALPHANUMERICS = ALPHANUMERIC.star;
If you provide complete input to the parser, you will get back a Done
response, for example:
if let Done = ALPHANUMERICS.init.parse
prints:
Matched abc123 with left over !.
If you provide incomplete input, you will get back a Continue
response, for example:
if let Continue = ALPHANUMERICS.init.parse
prints:
Still going...
Matched abc123 with left over !.