On Feb 1, 2006, at 5:33 PM, Phil Endecott wrote:
> I have been trying to get repeat_p to work for me, but I can't seem to
> pass it a functor like I can with if_p. Is this the expected
> I'm parsing MIME headers with the familiar "Name: Value" format; one
> is "Content-Length", and I want to process exactly that many
> characters of body using a rule like this:
> rule_t message_body =
> ( repeat_p(body_length_expected(this))[anychar_p] )
> body_length_expected is a functor that looks up Content-Length from
> the current headers:
for one thing body_length_expected(this) is a constructor call
creating a body_length_expected and
not an integer required by repeat_p. At the minimum you need
body_length_expected(this)() in the repeat_p.
If this function is computable when rule_t is constructed then it is
enough if it is to be computed when the rule
is evaluated then the grammar needs to compute and store the value
before the repeat_p is called.
rule_t message_body =
see the docs and the 'pascal style string' example of the docs of
repeat_p, as it looks like what you are doing.
Namely parse something to find the length to match and then excepting
exactly that many chars .