map

Apply a mapping function to the value of parser.

template map(alias f)
map
(
Parser
)
(
Parser parser
)
if (
isParser!Parser
)

Members

Functions

map
auto map(Parser parser)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

import std.conv;
import pry.atoms, pry.stream;
alias S = SimpleStream!string;
with(parsers!S) {
	auto digits = range!('0', '9').rep.map!(x=>x.to!int);
	S s = S("90");
	int r;
	S.Error err;
	assert(digits.parse(s, r, err));
	assert(r == 90);
	s = S("a");
	assert(!digits.parse(s, r, err));
	assert(err.location == 0);
}

Meta