|
Boost Users : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2008-07-21 09:22:23
Alessandro Re wrote:
> Hello,
> I've this code:
>
> // w and space_signaler are a function objects which print out some info.
> bool read_str(const char *in, StrList &w) {
> rule<> identifier = +alnum_p;
> rule<> statement = identifier[w] >> ch_p(';')[w];
>
> return parse(
> in,
> (statement)[w],
> space_p[space_signaler] // Called for initial spaces only
> ).full;
> }
>
> Well, I don't understand why if i use (statement)[w] where signaled,
> the space_signaler is never called for non-initial spaces, while if i
> write directly the rule, it does correctly:
>
> return parse(
> in,
> (identifier[w] >> ch_p(';')[w])[w],
> space_p[space_signaler] // Called for every space
> ).full;
>
> In the latter case, it parses (skipping spaces) inputs like:
> "hello;"
> "hello ;"
> " hello ; "
> while in the former it parses correctly inputs like
> " hello;"
> "hello;"
> disallowing spaces between the word and the semicolon.
>
> Can someone explain me why does this happens?
The proper Spirit forum is:
https://lists.sourceforge.net/lists/listinfo/spirit-general
Anyway, I am surprised this compiled at all. You have the wrong
rule type. I suggest not using bare rules this way. Use a
grammar instead. Please post to the Spirit mailing list for
follow ups. Thanks!
Regards,
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net