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