Takes three parsers, open, close,
and parser. between matches multiple
instances of parser, surrounded by
open and close. It returns the
result of parser.
This is a look-ahead combinator. It keeps trying the
close parser until it succeeds. That means you
can use it like this, and parser won't
consume the ending quote:
many1(anyChar) will consume all input until the
end of the string, not giving the close parser a
chance to succeed.
This combinator is obviously expensive, as it applies the
close parser at every step. This combinator can
also get into an infinite loop if parser succeeds
without consuming any input.
Takes three parsers,
open,close, andparser.betweenmatches multiple instances ofparser, surrounded byopenandclose. It returns the result ofparser.This is a look-ahead combinator. It keeps trying the
closeparser until it succeeds. That means you can use it like this, andparserwon't consume the ending quote:This combinator succeeds even if it parses zero instances of
parser. So for the above parser, this input would succeed:"".If you want it to consume at least one instance of
parser, usebetween1.Even though this is a look-ahead combinator, it won't work if you supply a greedy parser. You can make the above parser fail simply by adding
many1:many1(anyChar)will consume all input until the end of the string, not giving thecloseparser a chance to succeed.This combinator is obviously expensive, as it applies the
closeparser at every step. This combinator can also get into an infinite loop ifparsersucceeds without consuming any input.