1 import pry.atoms, pry.stream, std.conv; 2 alias S = SimpleStream!string; 3 with(parsers!S){ 4 auto p = delimited( 5 range!('0', '9').rep.skipWs.map!(x => to!int(x)), 6 stk!',' 7 ); 8 auto s = " 2, 4,5".stream; 9 int[] values; 10 S.Error err; 11 assert(p.parse(s, values, err)); 12 assert(values == [2, 4, 5]); 13 s = "10".stream; 14 assert(p.parse(s, values, err)); 15 assert(values == [10]); 16 s = "".stream; 17 assert(p.parse(s, values, err)); 18 assert(values == []); 19 }
Parse a sequence of item delimited by del