fuel_pest

Macro parses_to

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

Testing tool that compares produced tokens.

This macro takes several arguments:

  • parser - name of the data structure implementing Parser
  • input - input to be tested against
  • rule - Rule which will be run
  • tokens - token pairs of the form name(start_pos, end_pos, [nested_child_tokens])

Note: start_pos and end_pos are byte positions.

ยงExamples

parses_to! {
    parser: AbcParser,
    input:  Arc::from("abcde"),
    rule:   Rule::a,
    tokens: [
        a(0, 3, [
            b(1, 2)
        ]),
        c(4, 5)
    ]
};