Yiming Jing | ebb1872 | 2021-07-16 13:15:12 -0700 | [diff] [blame] | 1 | //! # Rusticata-macros |
| 2 | //! |
| 3 | //! Helper macros for the [rusticata](https://github.com/rusticata) project. |
| 4 | //! |
| 5 | //! This crate contains some additions to [nom](https://github.com/Geal/nom). |
| 6 | //! |
| 7 | //! For example, the `error_if!` macro allows to test a condition and return an error from the parser if the condition |
| 8 | //! fails: |
| 9 | //! |
| 10 | //! ```rust |
| 11 | //! # extern crate rusticata_macros; |
| 12 | //! # extern crate nom; |
| 13 | //! # use nom::{do_parse, take, IResult}; |
| 14 | //! # use nom::error::ErrorKind; |
| 15 | //! # use nom::number::streaming::be_u8; |
| 16 | //! use rusticata_macros::error_if; |
| 17 | //! # fn parser(s:&[u8]) { |
| 18 | //! let r : IResult<&[u8],()> = do_parse!( |
| 19 | //! s, |
| 20 | //! l: be_u8 >> |
| 21 | //! error_if!(l < 4, ErrorKind::Verify) >> |
| 22 | //! data: take!(l - 4) >> |
| 23 | //! (()) |
| 24 | //! ); |
| 25 | //! # } |
| 26 | //! ``` |
| 27 | //! |
| 28 | //! See the documentation for more details and examples. |
| 29 | |
| 30 | #![deny( |
| 31 | missing_docs, |
| 32 | unsafe_code, |
| 33 | unstable_features, |
| 34 | unused_import_braces, |
| 35 | unused_qualifications |
| 36 | )] |
| 37 | |
| 38 | #[macro_use] |
| 39 | extern crate nom; |
| 40 | |
| 41 | extern crate core; |
| 42 | |
| 43 | pub mod combinator; |
| 44 | |
| 45 | pub use macros::*; |
| 46 | #[macro_use] |
| 47 | pub mod macros; |
| 48 | |
| 49 | pub mod debug; |
| 50 | mod traits; |
| 51 | pub use traits::*; |