example of an expression parser. expr -> term { + term } term -> factor { * factor } factor -> number | ( expr )
a simple expression parser
auto parser = new ExprParser; auto p = parser.expr(); auto res = p.parse("1+2*3"); res.success.should == true; res.results[0].get!double.should == 7; res = p.parse("(1+2)*3"); res.success.should == true; res.results[0].get!double.should == 9;
See Implementation
example of an expression parser. expr -> term { + term } term -> factor { * factor } factor -> number | ( expr )