tree_automata/bottom_up/
macros.rs1#[macro_export]
2macro_rules! automaton {
3 ( $( $token:tt )* ) => {
4 {
5 let mut automaton = Automaton::new();
6 automaton_items!(automaton $( $token )*);
7 automaton
8 }
9 }
10}
11
12#[macro_export]
13macro_rules! automaton_items {
14 ( $aut:ident $f:tt ( $( $sub:expr ),* ) -> $q:tt, $( $token:tt )* ) => {
15 let mut subs = Vec::new();
16 $(
17 subs.push($sub.clone());
18 )*
19 $aut.add(Configuration($f.clone(), subs), NoLabel, $q);
20 automaton_items!($aut $( $token )*)
21 };
22 ( $aut:ident $f:tt -> $q:tt, $( $token:tt )* ) => {
23 $aut.add(Configuration($f.clone(), Vec::new()), NoLabel, $q);
24 automaton_items!($aut $( $token )*)
25 };
26 ( $aut:ident finals $($q:tt)* ) => {
27 $(
28 $aut.set_final($q);
29 )*
30 }
31}