template<typename Start, typename Inner, typename Sep, typename End>
class fcppt::parse::list< Start, Inner, Sep, End >
Parses lists, e.g., [a_1,...,a_n].
A list parser consists of a start parser Start, an end parser End, a separator parser Sep and an inner parser Inner. The purpose of this parser is to parse lists like [a_1,...,a_n], where Start recognizes '[', End recognizes ']', Sep recognizes ',' and Inner recognizes the a_i, producing the results r_1, ..., r_n. The result of the list parser is then vector{r_1,...,r_n}.
This is implemented as follows: The start parser is tried first and parses the beginning of the list. Then, the end parser is tried, which parses the end of the list. If this succeeds, the list is empty and the result is the empty vector. Otherwise, the list is nonempty and the inner parser is tried. If this succeeds, this provides the first element r_1 of the result. Then, the separator parser is tried, followed by the inner parser. This is done as long as possible, giving the remaining elements r_2, ..., r_n of the result, which are again taken from the inner parser. Lastly, the end parser is tried and if it succeeds, the result is vector{r_1,...,r_n}
.
Equivalent to:
- Template Parameters
-
Start | A parser with result type unit. |
End | A parser with result type unit. |
Sep | A parser with result type unit. |