Similar to many, apply a parser repeatedly until it fails, but it requires at
least one item to succeed.
Example
// This parser parses an int and then all of the spaces after it. constint = number({ int: (n) =>n }).skip(spaces); // We then repeat that parser zero or more times. constints: Parser<number[]> = many(int);
ints.run("1 2 3") // => Ok([1, 2, 3])
ints.run("") // => Err ...
Remarks
You can think of it like this:
constmany1 = (parseItem) => many(parseItem).andThen((items) => items.length === 0 ? problem("Need to succeed at least once!") : succeed(items) );
Similar to many, apply a parser repeatedly until it fails, but it requires at least one item to succeed.
Example
Remarks
You can think of it like this: