I am writing a grammar that contains a rule for parsing email addresses. The rule is declared as:
qi::rule<Iterator, ascii::space_type, std::string()> email;
and its definition is:
email
=
qi::lexeme[
+ascii::alnum
>> *(qi::char_(".") >> +ascii::alnum)
>> qi::char_("@")
>> +ascii::alnum
>> +(qi::char_(".") >> +ascii::alnum)
]
When I parse a text using this grammar, the parser correctly matches the email address, but the rule's synthesized attribute does not correspond to the correct address. For example, if the text contains the address info.it@example.com, the synthesized attribute is info.@example. I think this is due to the kleen and plus operators.
I am using boost 1.48 and I have tested the code with boost 1.54 and in that version it works properly, but unfortunately I cannot upgrade to it in my project.
I can I work around this problem, maybe using semantic actions?