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 str
s and any [T]
(for example, [u8]
or [Token]
).
If you just want to skip to writing grammars, look at the documentation for define!
.
This crate has two feature flags:
more_tuple_impls
, raising the amount of elements Rule
is implemented for
on tuples of Rule
s from 16 to 256 - however, enabling this will raise compilation times dramaticallyerror_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 guaranteedThis 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.
This crate is dual-licensed under the Apache 2.0 or MIT licenses.
Rule::attempt
.Rule::consume_all
.Rule::take
.Rule::map_parsed
.Rule::prevent
.Rule::repeat
Rule::repeat_for
.Rule::spanned
to store the span and source of a given parsed rule.Rule::spanned
.Rule::try_map_parsed
.Rule
trait.dyn
Rule object of a given type and output.!
type.NamedRule
.