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