How can I use polymorphic attributes with boost::spirit::qi parsers?

Spirit is a lot friendlier to compiletime-polymorphism typedef variant<Command1, Command2, Command3> Command; But, let’s suppose you really want to do the old-fashioned polymorphism thing… Just newing-up the polymorphic objects on the fly during parsing, however, is a sure-fire way to make your parser bloated with semantic actions create lot of memory leaks on back-tracking in … Read more

Assigning parsers to auto variables

Spirit Parsers are not designed to be used with auto in Spirit V2. This is because the underlying Proto expression templates hold references to the temporaries. You can use qi::copy() (existing in the trunk after boost_1_55_0, not in any released version at this time) boost::proto::deep_copy or BOOST_SPIRIT_AUTO (first coined here) I’ve written about these things … Read more

Boost spirit skipper issues

In general the following directives are helpful for inhibiting/switching skippers mid-grammar: qi::lexeme [ p ]which inhibits a skipper, e.g. if you want to be sure you parse an identifier without internal skips) – see also no_skip for comparison qi::raw [ p ]which parses like always, including skips, but returns the raw iterator range of the … Read more