What is the logic when using boost::spirit::x3::position_tagged as a base class for some AST nodes (how to choose which one should be marked, for example, for a C-like language?) And other constructions used in determining the rule identifier , eg:
struct error_handler_tag; struct error_handler_base { template< typename Iterator, typename Exception, typename Context > x3::error_handler_result on_error(Iterator & , Iterator const & , Exception const & x, Context const & context) { std::string message_ = "Error! Expecting: " + x.which() + " here:"; auto & error_handler = x3::get< error_handler_tag >(context).get(); error_handler(x.where(), message_); return x3::error_handler_result::fail; } }; struct annotation_base { template< typename T, typename Iterator, typename Context > void on_success(Iterator const & first, Iterator const & last, T & ast, Context const & context) { auto & error_handler = x3::get< error_handler_tag >(context).get(); error_handler.tag(ast, first, last); } };
?
In case of erroneous input (does not correspond to the grammar), this part of the code does nothing (even in the case of a simple grammar that should recognize identifiers) - do not print an error message.
source share