optional

Try to apply parser, produce null on failure.

optional
(
P
)
()
if (
isParser!P
)

Examples

1 import pry.atoms, pry.stream;
2 alias S = SimpleStream!string;
3 with(parsers!S){
4 	auto p = range!('a', 'z').optional;
5 	auto s = "a".stream;
6 	Nullable!dchar c;
7 	S.Error err;
8 	assert(p.parse(s, c, err));
9 	assert(c == 'a');
10 	assert(s.empty);
11 	assert(p.parse(s, c, err));
12 	assert(c.isNull);
13 }

Meta