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 implementingParser
input
- input to be tested againstrule
-Rule
which will be runtokens
- token pairs of the formname(start_pos, end_pos, [nested_child_tokens])
Note: start_pos
and end_pos
are byte positions.
ยงExamples
parses_to! {
parser: AbcParser,
input: "abcde",
rule: Rule::a,
tokens: [
a(0, 3, [
b(1, 2)
]),
c(4, 5)
]
};