aa

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.

aa
(
size_t minTimes = 1
size_t maxTimes = size_t.max
P
)
()
if (
isParser!P &&
isTuple!(ParserValue!P)
&&
ParserValue!P.length == 2
)

Examples

1 import pry.atoms, pry.stream;
2 import std.conv;
3 alias S = SimpleStream!string;
4 with(parsers!S) {
5 	auto p = seq(range!('a', 'z').rep.skipWs, stk!'=', range!('0', '9').rep.skipWs)
6 			.map!(x => tuple(x[0], to!int(x[2]))).aa;
7 	auto s = "a = 1 b = 3 temp = 36".stream;
8 	int[string] table;
9 	S.Error err;
10 	assert(p.parse(s, table, err));
11 	assert(s.empty);
12 	assert(table["a"] == 1);
13 	assert(table["b"] == 3);
14 	assert(table["temp"] == 36);
15 }

Meta