Function seq

  • seq takes an array of parsers and runs them sequentially. If any of the parsers fail, seq fails without consuming any input.

    The second argument to seq is a function. The first argument of that function is an array of results: one result from each of the parsers you gave to seq. The second is an object containing any captures. You can use this second argument, the transformer function, to transform these however you want and return a result

    Tarsec includes the utility functions getResults and getCaptures to just return the results array or captures object respectively for you.

    Finally, you don't need to use seq at all. You can just hand write the logic. But you'll need to do the error handling and pass the remaining input to the next parser yourself. seq also does some backtracking for you that you will need to do yourself.

    Also see seqR and seqC for convenience functions that return the results or captures respectively.

    Type Parameters

    Parameters

    • parsers: T

      parsers to run sequentially

    • transform: ((results, captures) => U)

      function to transform the results and captures. The params are the results and captures

        • (results, captures): U
        • Parameters

          Returns U

    • debugName: string = ""

      optional name for trace debugging

    Returns Parser<U>

Generated using TypeDoc