1 import std.conv; 2 import pry.atoms, pry.stream; 3 alias S = SimpleStream!string; 4 with(parsers!S) { 5 auto digits = range!('0', '9').rep.map!(x=>x.to!int); 6 S s = S("90"); 7 int r; 8 S.Error err; 9 assert(digits.parse(s, r, err)); 10 assert(r == 90); 11 s = S("a"); 12 assert(!digits.parse(s, r, err)); 13 assert(err.location == 0); 14 }
Apply a mapping function to the value of parser.