Macro parses_to

macro_rules! parses_to {
    ( parser: $parser:ident, input: $string:expr, rule: $rules:tt :: $rule:tt,
      tokens: [ $( $names:ident $calls:tt ),* $(,)* ] ) => { ... };
}

Testing tool that compares produced tokens.

This macro takes several arguments:

Note: start_pos and end_pos are byte positions.

Examples

# #[macro_use]
# extern crate pest;
# use pest::Parser;
# use pest::error::Error;
# use pest::iterators::Pairs;
# fn main() {
# #[allow(non_camel_case_types)]
# #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
# enum Rule {
#     a,
#     b,
#     c
# }
#
# struct AbcParser;
#
# impl Parser<Rule> for AbcParser {
#     fn parse<'i>(_: Rule, input: &'i str) -> Result<Pairs<'i, Rule>, Error<Rule>> {
#         pest::state(input, |state| {
#             state.rule(Rule::a, |state| {
#                 state.skip(1).unwrap().rule(Rule::b, |state| {
#                     state.skip(1)
#                 }).unwrap().skip(1)
#             }).and_then(|state| {
#                 state.skip(1).unwrap().rule(Rule::c, |state| {
#                     state.skip(1)
#                 })
#             })
#         })
#     }
# }
parses_to! {
    parser: AbcParser,
    input:  "abcde",
    rule:   Rule::a,
    tokens: [
        a(0, 3, [
            b(1, 2)
        ]),
        c(4, 5)
    ]
};
# }