lazyParser

convenient function to instantiate a lazy parser with a function

  1. Parser!(T) lazyParser(Parser!(T) delegate() parser)
  2. Parser!(T) lazyParser(Parser!(T) function() parser)
    Parser!(T)
    lazyParser
    (
    T
    )
    (
    Parser!(T) function
    ()
    parser
    )

Examples

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";

Meta