I am trying to add error handling to one of my basic parsers. The parsers are the following:
struct string_literal_id : error_handler_base, annotation_base{};
struct regex_literal_id : error_handler_base, annotation_base{};
struct bool_literal_id : error_handler_base, annotation_base{};
typedef x3::rule<string_literal_id, string_literal> string_literal_type;
typedef x3::rule<regex_literal_id, regex_literal> regex_literal_type;
typedef x3::rule<bool_literal_id, bool_literal> bool_literal_type;
const string_literal_type string_literal_p = "string_literal";
const regex_literal_type regex_literal = "regex_literal";
const bool_literal_type bool_literal = "bool_literal";
auto const string_literal_p_def = x3::lexeme['"' >> +(x3::char_ - '"') >> '"'];
auto const regex_literal_def = x3::lexeme["'" >> +(x3::char_ - "'") >> "'"];
auto const bool_literal_def = x3::bool_;
BOOST_SPIRIT_DEFINE(string_literal_p, regex_literal, bool_literal)
they parse into these structs:
struct string_literal : x3::position_tagged {
std::string compile_out() const;
std::string value;
};
struct regex_literal : x3::position_tagged {
std::string compile_out() const;
std::string value;
};
struct bool_literal : x3::position_tagged {
std::string compile_out() const;
bool value;
};
BOOST_FUSION_ADAPT_STRUCT(
string_literal,
(std::string, value)
)
BOOST_FUSION_ADAPT_STRUCT(
regex_literal,
(std::string, value)
)
BOOST_FUSION_ADAPT_STRUCT(
bool_literal,
(bool, value)
)
I am using this bases for error_handling and annotation: annotation, error_handling.
when I try to test the parsers and compile them I am getting these errors:
/home/lukas/ClionProjects/tests/main.cpp:33:71: Fehler: keine passende Funktion für Aufruf von »boost::spirit::x3::unused_type::get()«
auto &error_handler = x3::get<error_handler_tag>(context).get();
which is german for
Error: no matching function for calling »boost::spirit::x3::unused_type::get()«
auto &error_handler = x3::get<error_handler_tag>(context).get();
I tried to learn how to use error implement error handling in spirit x3 by myself, but I can't find a way to make this work. Could anybody help me understanding how error_handling works in x3? I am stuck at this point.