%ret% | R Documentation |
Sometimes we are not interested in the result from a parser, only that the
parser succeeds. It may be convenient to return some short representation
or nothing even rather than the string itself. The %ret%
combinator is
useful in such cases. The parser (p %ret% c)
has the same behavior as p
,
except that it returns the value c
if successful.
p %ret% c
p |
a parser. |
c |
string, i.e. a single-element character vector. |
A parser.
(p %xret% c)(x): if p(x)==[] then fail()(x) else succeed(c)(x[-1])
%using%
(literal("A") %ret% "We have an A!") (LETTERS[1:5])
(literal("A") %ret% NULL) (LETTERS[1:5])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.