ExprParser

example of an expression parser. expr -> term { + term } term -> factor { * factor } factor -> number | ( expr )

Members

Functions

expr
Parser!(immutable(char)) expr()
Undocumented in source. Be warned that the author may not have intended to support it.
factor
Parser!(immutable(char)) factor()
Undocumented in source. Be warned that the author may not have intended to support it.
lazyExpr
Parser!(immutable(char)) lazyExpr()
Undocumented in source. Be warned that the author may not have intended to support it.
term
Parser!(immutable(char)) term()
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

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;

Meta