import pry.atoms, pry.stream; import std.conv; alias S = SimpleStream!string; with(parsers!S) { auto p = seq(range!('a', 'z').rep.skipWs, stk!'=', range!('0', '9').rep.skipWs) .map!(x => tuple(x[0], to!int(x[2]))).aa; auto s = "a = 1 b = 3 temp = 36".stream; int[string] table; S.Error err; assert(p.parse(s, table, err)); assert(s.empty); assert(table["a"] == 1); assert(table["b"] == 3); assert(table["temp"] == 36); }
Apply parser of key-value pairs (2-tuples) for minTimes times or more up to maxTimes, construct an AA out of the results of parsing.