unittest to show the simplest usage of lazy
// endless -> a | a opt(endless) struct Endless { static Parser!(immutable(char)) lazyEndless() { return lazyParser!(immutable(char))(&parser); } static Parser!(immutable(char)) parser() { return match("a") ~ (-(lazyEndless())); } } auto p = Endless.parser(); auto res = p.parse("aa"); res.success.should == true; res.results.should == ["a", "a"]; res = p.parse("aab"); res.success.should == true; res.results.should == ["a", "a"]; res.rest.should == "b";
convenient function to instantiate a lazy parser with a function