alt {Ramble} | R Documentation |
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)
p1 |
the first parser |
p2 |
the second parser |
Returns the first parser if it suceeds otherwise the second parser
(item() %alt% succeed("2")) ("abcdef")