Function reduceRight

  • Make a Matcher that takes 0 or more matches from the same parser and reduces them into one value in right-to-left (last-to-first) order.

    Note: accumulator is the right (second) argument.

    Use rightAssoc1 if you have an initial value to be parsed after all matches.

    Implementation is based on many and map.

    Type Parameters

    • TToken

    • TOptions

    • TValue

    • TAcc

    Parameters

    • p: Parser<TToken, TOptions, TValue>

      Parser for each next value.

    • acc: TAcc

      Initial value for the accumulator.

    • reducer: ((v: TValue, acc: TAcc, data: Data<TToken, TOptions>, i: number, j: number) => TAcc)

      Function to combine the accumulator and each parsed value.

        • (v: TValue, acc: TAcc, data: Data<TToken, TOptions>, i: number, j: number): TAcc
        • Parameters

          • v: TValue

            Value from each successful parsing.

          • acc: TAcc

            Accumulated value.

          • data: Data<TToken, TOptions>

            Data object (tokens and options).

          • i: number

            Position before all successful parsings.

          • j: number

            Position after all successful parsings.

          Returns TAcc

    Returns Matcher<TToken, TOptions, TAcc>

Generated using TypeDoc