Function many

  • Run a parser zero or more times. So if you wanted to parse a list of integers, you could say:

    Example

       // This parser parses an int and then all of the spaces after it.
    const int = number({ int: (n) => n }).skip(spaces);
    // We then repeat that parser zero or more times.
    const ints: Parser<number[]> = many(int);

    ints.run("1 2 3")
    // => Ok([1, 2, 3])

    ints.run("")
    // => Ok([])

    Type Parameters

    • A

    Parameters

    Returns Simple.Parser<A[]>