anpa 0.11.0

A generic monadic parser combinator library inspired by Haskell's parsec.
Documentation

anpa

A generic monadic parser combinator library based on anpa which in turn is inspired by Haskell's parsec.

Features

All parsers and combinators, with the exceptions below, are allocation free and can be used with no_std when disabling the default features of this crate.

Allocating parsers:

  • many_to_vec, many_to_map_ordered: Require feature "alloc"
  • many_to_map: Requires feature "std"

Performance tuning

While the performance should be good with the default settings, you can try to modify the following for further performance tuning:

rustc

  • lto=true: Likely gives a substantial performance increase.
  • panic=abort: Likely gives a performance increase.
  • codegen-units=N: In the benchmarks, a value of 4 seems to give the best performance.

LLVM flags

Enable by setting environment variable RUSTFLAGS="-Cllvm-flags=--flag_name=value" cargo build ...

  • inline-threshold=N: Try to play around with values larger than 225. Note that larger values lead to larger binaries.

Examples

See the provided test parsers

  • JSON parser: JSON DOM parser. It's only ~30 LOC and gives a good overview on how to use the library, including recursive parsers.
  • SemVer Parser: a parser for the SemVer format

These parsers can be enabled using the features "json" and "semver" respectively.

Dependencies

None

TODO

  • Add support for Read
  • More extensive test cases

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.