edit : I have ripped out the lexer as it does not cleanly integrate with Qi and just obfuscates grammars (see here).
Here is one brittle hack to detect what token was caught by the on_error
mechanism. Wiring this up will not be pleasant :D
template<typename State>
struct error_handler_impl
{
typedef void result_type;
State & state;
error_handler_impl(State & state) : state(state) {}
template <typename What, typename Iterator>
void operator()(const std::string & msg,What what, Iterator it) const
{
if(boost::get<boost::spirit::utf8_string>(what.value) == state.tok.identifier.definition())
{
std::cout << "token type is identifier" << std::endl;
}
}
};
state.tok
is the lexer object, via which the token definitions may be accessed.