I have this grammar
template<typename Iterator>
struct brainDSL : qi::grammar<Iterator, _problem(), ascii::space_type>
{
brainDSL() : base_type(p_rule)
{
p_rule = problem_;
}
qi::rule<Iterator, _problem(), ascii::space_type> p_rule;
};
And these are the parsers:
struct type_ : qi::symbols<char, _problem::_type>
{
type_()
{
add
("single_stage", _problem::_type::single_stage)
("two_stage", _problem::_type::two_stage)
("multi_stage", _problem::_type::multi_stage)
;
}
} type_;
struct command_ : qi::symbols<char, _problem::_command>
{
command_()
{
add
("maximize", _problem::_command::maximize)
("minimize", _problem::_command::minimize)
;
}
} command_;
auto name_ = qi::lexeme[*(qi::char_ - ':')];
auto problem_ =
type_
>> command_
>> name_ >> ':'
;
I would add the structs and the fusion macro, but I don't think it's necessary. Executing this against a test string, this code compiles correctly but raises an exception inside boost.
If I remove the name_ parser and leave problem_ like this:
auto problem_ =
type_
>> command_
;
It matches correctly. But if I add anything, even qi::eps, I get exceptions again:
auto problem_ =
type_
>> command_
>> qi::eps
;
What is the underlying rule from Boost Spirit I'm violating here?