Crate fn_bnf

source
Expand description

Repository Latest version Documentation MSRV unsafe forbidden License

§fn-bnf

This crate contains a no_std compatible, low-allocation parsing library that uses a BNF-like syntax with the define! macro to allow for using arbitrary Rust items as grammar rules, and for parsing both strs and any [T] (for example, [u8] or [Token]).

If you just want to skip to writing grammars, look at the documentation for define!.

§Feature flags

This crate has two feature flags:

  • more_tuple_impls, raising the amount of elements Rule is implemented for on tuples of Rules from 16 to 256 - however, enabling this will raise compilation times dramatically
  • error_in_core, enabling use of this library before Rust 1.81.0 on nightly compilers - however, continued support for versions below 1.81.0 is not guaranteed

§A note about the stack

This library’s very lifeblood is deep - and likely recursive - function calls. You may run into stack overflow issues if you have an overly complex grammar, or are blindly parsing malicious input.

§Licensing

This crate is dual-licensed under the Apache 2.0 or MIT licenses.

Modules§

  • Contains some common error types.

Macros§

  • Allows defining multiple custom rules using a PEG-like syntax.
  • Convenience macro for quickly defining errors with static messages for use in your grammars.

Structs§

Traits§

  • Defines a rule’s name separate from the Rule trait.
  • Trait dictating that something can be used as a rule within a parsing grammar.

Type Aliases§

  • Alias for a refernce to a dyn Rule object of a given type and output.
  • The ! type.

Derive Macros§

  • Derive macro generating an impl of the trait NamedRule.