Attempting to learn Boost::Spirit and want to tackle a simple example for c-style identifiers. The grammar below doesn't compile claiming 'incompatible_start_rule'. The goal is for this grammar to return a string instead of a vector of strings, as the default attribute propagation rules would.
template <typename IT>
struct cppIdentifier : qi::grammar<IT, std::string, space_type()>
{
cppIdentifier() : cppIdentifier::base_type(start)
{
start = char_("a-zA-Z_")[boost::phoenix::push_back(_val, _1)]
>> *(char_("a-zA-Z0-9_")[boost::phoenix::push_back(_val, _1)]);
}
qi::rule<IT, std::string, space_type> start;
};
What do I have to do to achieve this?
Also please note that I am well aware that there are likely a host of alternative, more convenient options for this particular problem, but I am academically interested in how to manipulate the attribute type of a custom grammar, so please leave those in the comments instead of the answers.