macro_rules! state {
(
$(#[$meta:meta])*
$name:ident <-- ( $($enter_actions:tt)* ) {
$($arms:tt)*
}
$($rest:tt)*
) => {
#[allow(unused_variables)]
$(#[$meta])*
fn $name(&mut self, context: &mut Self::Context, input: &[u8]) -> StateResult {
let _ = self.consume_ch(input);
action_list!(|self, context, input|> $($enter_actions)*);
self.unconsume_ch();
let entered: fn(&mut Self, &mut Self::Context, &[u8]) -> StateResult = |this, context, input| {
state_body!(|[this, context, input]|> [$($arms)*]);
};
self.set_state(entered);
return entered(self, context, input);
}
state!($($rest)*);
};
(
$(#[$meta:meta])*
$name:ident {
$($arms:tt)*
}
$($rest:tt)*
) => {
#[allow(unused_variables)]
$(#[$meta])*
fn $name(&mut self, context: &mut Self::Context, input: &[u8]) -> StateResult {
state_body!(|[self, context, input]|> [$($arms)*]);
}
state!($($rest)*);
};
() => ();
}