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.
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
andgetCaptures
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
andseqC
for convenience functions that return the results or captures respectively.