Function chainReduce

  • Make a Matcher that takes 0 or more matches from parsers returned by provided parser-generating function.

    This is like a combination of chain and reduceLeft. Each next parser is made based on previously accumulated value, parsing continues from left to right until first nonmatch.

    Type Parameters

    • TToken

    • TOptions

    • TAcc

    Parameters

    • acc: TAcc

      Initial value for the accumulator.

    • f: ((acc: TAcc, data: Data<TToken, TOptions>, i: number) => Parser<TToken, TOptions, TAcc>)

      A function that returns a parser based on previously accumulated value.

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

          • acc: TAcc

            Accumulated value.

          • data: Data<TToken, TOptions>

            Data object (tokens and options).

          • i: number

            Parser position in the tokens array (before each parser called).

          Returns Parser<TToken, TOptions, TAcc>

    Returns Matcher<TToken, TOptions, TAcc>

Generated using TypeDoc