1 import pry.atoms, pry.stream; 2 alias S = SimpleStream!string; 3 with(parsers!S) { 4 auto normal = range!('0', '9').rep; 5 auto skipping = range!('0', '9').skipWs.rep; 6 auto s1 = "0 9 1".stream; 7 string r; 8 S.Error err; 9 assert(skipping.parse(s1, r, err)); 10 assert(s1.empty); 11 assert(r == "0 9 1"); 12 13 auto s2 = "0 9 1".stream; 14 assert(normal.parse(s2, r, err)); 15 assert(!s2.empty); 16 assert(r == "0"); 17 assert(s2.front == ' '); 18 }
Skip whitespace at front then apply the parser.