seq

Apply multiple parsers one after another as a sequence.

seq
(
P...
)
if (
allSatisfy!(isParser, P)
)

Examples

import pry.atoms, pry.stream;
import std.range.primitives, std.typecons;
alias S = SimpleStream!string;
with(parsers!S) {
	auto elements = seq(tk!'a', range!('a', 'd'), tk!'c');
	S s = S("abc");
	Tuple!(dchar, dchar, dchar) val;
	S.Error err;
	assert(elements.parse(s, val, err));
	assert(s.empty);
	assert(val == tuple('a', 'b', 'c'));
	s = S("axc");
	assert(!elements.parse(s, val, err));
	assert(s.front == 'a');
	assert(err.location == 1);
}
import pry.atoms, pry.stream;
alias S = SimpleStream!string;
with(parsers!S) {
	auto p = seq(tk!'a', tk!'b', eof);
	auto s1 = "abc".stream;
	auto s2 = "ab".stream;
	S.Error err;
	Tuple!(dchar, dchar) val;
	assert(!p.parse(s1, val, err));
	assert(p.parse(s2, val, err));
}

Meta