title: How to override error reporting in c++ target of antlr4?
body: <p>To report errors in a different way in antlr4-java target, we do the following:</p>
  
  <p>(1) define a new listener:</p>
  
  <pre><code>class DescriptiveErrorListener extends BaseErrorListener {
      public static DescriptiveErrorListener INSTANCE =
          new DescriptiveErrorListener();
      @Override
      public void syntaxError(Recognizer&lt;?, ?&gt; recognizer,
              Object offendingSymbol,
                          int line, int charPositionInLine,
                          String msg, RecognitionException e)
      {
          String printMsg = String.format("ERR: %s:%d:%d: %s",
              recognizer.getInputStream().getSourceName(), line,
              charPositionInLine+1, msg);
          System.err.println(printMsg);
      }
  }
  </code></pre>
  
  <p>(2) override the reporter for lexer and parser:</p>
  
  <pre><code>lexer.removeErrorListeners();
  lexer.addErrorListener(DescriptiveErrorListener.INSTANCE);
  ..
  parser.removeErrorListeners();
  parser.addErrorListener(DescriptiveErrorListener.INSTANCE);
  </code></pre>
  
  <p>What would be the corresponding code in c++ target?</p>