use tree_builder_macro::rule; #[derive(Debug)] pub struct Eval(Box); tree_builder::ast_parser_maker!(Eval => @Add); rule! {Add => @Mult, @AddAux?} rule! { AddAux => "+", @Mult, @AddAux? | "-", @Mult, @AddAux? } rule! {Mult => @Atom, @MultAux?;} rule! { MultAux => "*", @Atom, @MultAux? | "/", @Atom, @MultAux? } rule! { Atom => @Number | "(", @Add, ")" } rule! {Number => @Float | @Integer} rule !(Float #=> #d+, ".", #d+ , EPart?); rule !(Integer #=> #d+, EPart?); rule !(EPart #=> ("E" | "e"), ("-" | "+")?, #d+); fn main(){}