[−][src]Function lip::sequence
pub fn sequence<'a, A: Clone + 'a, S: Clone + 'a>(
start: &'static str,
item: BoxedParser<'a, A, S>,
separator: &'static str,
spaces: BoxedParser<'a, (), S>,
end: &'static str,
trailing: Trailing
) -> BoxedParser<'a, Vec<A>, S>
Parse a sequence like lists or code blocks.
Example: Parse a list containing the string "abc" with optional trailing comma:
assert_succeed(sequence( "[", token("abc"), ",", space0(), "]", Trailing::Optional), "[abc, abc, abc]", vec!["abc", "abc", "abc"]);
Note: spaces
are inserted between every part.
So if you use space1
instead of space0
, you need to
put more spaces before and after separators, between
start symbol and first item and between last item or separator
and the end symbol:
assert_succeed(sequence( "[", token("abc"), ",", space1(), "]", Trailing::Optional), "[ abc , abc , abc ]", vec!["abc", "abc", "abc"]);