Boost logo

Boost Users :

From: Alessandro Re (akirosspower_at_[hidden])
Date: 2008-07-21 08:14:24


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?
Thanks very much


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