
John Ky wrote:
Is it possible to define a rule:
rule<> mystringrule = confix_p('"', *c_escape_ch_p, '"')
differently such that I can use
std::string value;
bool result = parse("\"hello world\"", mystringrule[assign_a(value)]).full;
and get the text = "hello world" assigned to value?
Currently, I get text = "\"hello world\"" instead. ie with double quotes at either end.
I'ld suggest to use closures for that (not tested): struct strlit_closure : public boost::spirit::closure<strlit_closure, std::string> { member1 val; }; typedef rule<strlit_closure> rule_type; rule_type mystringrule = confix_p('"', *c_escape_ch_p[assign_a(mystringrule.val)], '"'); bool result = parse("\"hello world\"", mystringrule[assign_a(value)]).full; This is based on the fact, that the first closure member of a rule is used as the rule's value. HTH Regards Hartmut