Parsing.Combinators.Array
- Package
- purescript-parsing
- Repository
- purescript-contrib/purescript-parsing
These combinators will produce Array
s, as opposed to the other combinators
of the same names in the Parsing.Combinators module
which mostly produce List
s. These Array
combinators will run in a bit
less time (~85% runtime) than the similar List
combinators, and they will run in a
lot less time (~10% runtime) than the similar combinators in Data.Array.
If there is some other combinator which returns
a List
but we want an Array
, and there is no Array
version of the
combinator in this module, then we can rely on the
Data.Array.fromFoldable
function for a pretty fast transformation from List
to Array
.
#many1 Source
many1 :: forall s m a. ParserT s m a -> ParserT s m (NonEmptyArray a)
Match the phrase p
as many times as possible, at least once.
#manyIndex Source
manyIndex :: forall s m a. Int -> Int -> (Int -> ParserT s m a) -> ParserT s m (Tuple Int (Array a))
Parse the phrase as many times as possible, at least N times, but no more than M times. If the phrase can’t parse as least N times then the whole parser fails. If the phrase parses successfully M times then stop. The current phrase index, starting at 0, is passed to the phrase.
Returns the array of parse results and the number of results.
manyIndex n n (\_ -> p)
is equivalent to replicateA n p
.