match

convenient function to instantiate a matcher

Parser!(T)
match
(
T
)
(
T[] s
,
bool collect = true
)

Examples

matching a string

auto parser = match("test");
auto res = parser.parseAll("test");

res.success.should == true;
res.rest.length.should == 0;

transform match result

auto parser = match("test") ^^ (objects) {
    auto res = objects;
    if (objects[0] == "test")
    {
        res[0] = "super";
    }
    return objects;
};
auto res = parser.parse("test");
res.success.should == true;
res.results[0].should == "super";

Meta