
Last chance! 50% off unlimited learning
Sale ends in
alt
combinator is similar to alternation in BNF. the parser
(alt(p1, p2))
recognises anything that p1
or p2
would.
The approach taken in this parser follows (Fairbairn86), in which either is
interpretted in a sequential (or exclusive) manner, returning the result of
the first parser to succeed, and failure if neither does.%alt%
is the infix notation for the alt
function, and it is the
preferred way to use the alt
operator.
alt(p1, p2)
then
(item() %alt% succeed("2")) ("abcdef")
Run the code above in your browser using DataLab