import pry.atoms, pry.stream, std.conv; alias S = SimpleStream!string; with(parsers!S){ auto p = seq(tk!'-'.optional, range!('0', '9').rep) .slice .map!(x => to!int(x)); auto s = "-13".stream; int value; S.Error err; assert(p.parse(s, value, err)); assert(value == -13); s = "5".stream; assert(p.parse(s, value, err)); assert(value == 5); }
Apply parser, discard the value and instead produce the slice of parsed stream.