Finite state machines in rust; bendns fork to add types.
debugging tool
| -rw-r--r-- | rust-fsm-dsl/src/lib.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/rust-fsm-dsl/src/lib.rs b/rust-fsm-dsl/src/lib.rs index 47e55f1..1e9ba99 100644 --- a/rust-fsm-dsl/src/lib.rs +++ b/rust-fsm-dsl/src/lib.rs @@ -1,6 +1,6 @@ //! DSL implementation for defining finite state machines for `rust-fsm`. See //! more in the `rust-fsm` crate documentation. - +#![allow(unexpected_cfgs)] #![recursion_limit = "128"] extern crate proc_macro; @@ -135,6 +135,8 @@ pub fn state_machine(tokens: TokenStream) -> TokenStream { // let x = format!("{}, {} {} => {}", initial_, input_, guard, output_); transition_cases.push(quote! { (Self::#initial_, Self::Input::#input_) #guard => { + #[cfg(fsm_debug)] + println!("matched {} => {} {}", stringify!(#initial_), stringify!(#input_), stringify!(#guard)); ::core::result::Result::Ok((Self::#final_, #output_)) } }); @@ -175,7 +177,7 @@ pub fn state_machine(tokens: TokenStream) -> TokenStream { impl #input_generics #f #input_generics { #input_visibility fn name(&self) -> &'static str { - match self { #(Self::#matcher => stringify!(#x)),* } + match self { #(Self::#matcher => stringify!(#x),)* _ => unreachable!(), } } } } @@ -193,7 +195,7 @@ pub fn state_machine(tokens: TokenStream) -> TokenStream { impl #f { #state_visibility fn name(&self) -> &'static str { - match self { #(Self::#matcher => stringify!(#x)),* } + match self { #(Self::#matcher => stringify!(#x),)* _ => unreachable!(), } } } } @@ -212,7 +214,7 @@ pub fn state_machine(tokens: TokenStream) -> TokenStream { impl #output_generics #output_name #output_generics { #output_visibility fn name(&self) -> &'static str { - match self { #(Self::#matcher => stringify!(#outputs)),* } + match self { #(Self::#matcher => stringify!(#outputs),)* _ => unreachable!(), } } } } |