title: error handling and annotation in Boost.Spirit X3
body: <p>What is the logic under using <code>boost::spirit::x3::position_tagged</code> as base class for some AST nodes (how to choose which should be tagged, e.g. for C-like language?) and other constructions, used in rule ID definition, like:</p>
  
  <pre><code>struct error_handler_tag;
  
  struct error_handler_base
  {
  
      template&lt; typename Iterator, typename Exception, typename Context &gt;
      x3::error_handler_result
      on_error(Iterator &amp; /*first*/, Iterator const &amp; /*last*/,
               Exception const &amp; x, Context const &amp; context)
      {
          std::string message_ = "Error! Expecting: " + x.which() + " here:";
          auto &amp; error_handler = x3::get&lt; error_handler_tag &gt;(context).get();
          error_handler(x.where(), message_);
          return x3::error_handler_result::fail;
      }
  
  };
  
  struct annotation_base
  {
  
      template&lt; typename T, typename Iterator, typename Context &gt;
      void
      on_success(Iterator const &amp; first, Iterator const &amp; last,
                 T &amp; ast, Context const &amp; context)
      {
          auto &amp; error_handler = x3::get&lt; error_handler_tag &gt;(context).get();
          error_handler.tag(ast, first, last);
      }
  
  };
  // ...
  error_handler_type error_handler(beg, end, std::cerr);
  auto const parser_ = x3::with&lt; error_handler_tag &gt;(std::ref(error_handler))[grammar];
  // ...
  </code></pre>
  
  <p>?</p>
  
  <p>In case of erroneous input (grammar not match) this part of code does nothing (even in case of simpliest grammar, which should recognize an identifiers) - not printing an error mesage.</p>