1 Feb 11:50
name() and on_error
<hauns <at> mac.com>
2010-02-01 10:50:12 GMT
2010-02-01 10:50:12 GMT
i now have spent already more time on this than i should, so i might as well ask. i noticed that in all published
examples on the use of the on_error<fail> clause that a preceding section of statements names the rules
within the grammar elaboratively:
term.name("term");
factor.name("factor");
however, i cannot see where that name is actually used (i.e., calling rule.name()). in our standard error
handler, how would i go about accessing the name of the rule that failed? i am thinking of something like:
struct error_handler_phx
{
template <typename, typename, typename>
struct result { typedef void type; };
template <typename Iterator>
void operator()(qi::info const& what, Iterator pos, Iterator last) const
{
std::cout << "error in rule " << HOW_TO_ACCESS_RULE.NAME()_HERE? << ": expecting " << what << " at " <<
std::string(pos,last) << std::endl;
}
};
passing in an extra string with the rule name appears awkward as the rule was already named, so it should be
somehow available to the handler. thanks!
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
(Continue reading)
RSS Feed