pMany1
Returns a Parser that runs parser one or more times, collecting each output into a List. Fails if parser does not match at least once.
Equivalent to requiring one mandatory match followed by pMany: the first run of parser must succeed, after which further runs are collected until failure.
Behaviour
| Condition | Result |
|---|---|
| parser fails on first attempt | Failure from parser |
| parser succeeds N times then fails (N ≥ 1) | Success with N values; index advanced past all |
Type parameters
O — the output type of parser; each successful value is collected.
U — the user context type threaded through unchanged.
Example
val digit = pSatisfy<Char, Unit> { it.isDigit() }
val digits = pMany1(digit)
val input = ParserInput.of("42!".toList(), Unit)
val result = digits(input) // Success(['4','2'], nextIndex=2, ...)Content copied to clipboard
Return
a Parser that succeeds with a non-empty list, or fails if parser does not match at least once.
Parameters
parser
the parser to run one or more times.