title: How to collect errors during run time given by a parser in Antlr4
body: <p>I have upgraded from Antlr 3 to Antlr 4. I was using this code to catch exceptions using this code. But this is not working for Antlr 4. </p>
  
  <pre><code>partial class XParser
  {
      public override void ReportError(RecognitionException e)
      {
          base.ReportError(e);
          Console.WriteLine("Error in Parser at line " + ":" + e.OffendingToken.Column + e.OffendingToken.Line + e.Message);
      }
  }
  </code></pre>
  
  <p>This is the error that appears</p>
  
  <pre><code>'Parser.ReportError(Antlr4.Runtime.RecognitionException)': no suitable method found to override
  </code></pre>
  
  <p>In Antlr 4 what is the expected way of accumulating errors that occurs in the input stream. I was unable to find a way to achieve this on the net. Please provide me some guidelines.</p>
  
  <p>EDIT:</p>
  
  <p>I have implemented the XParser as below</p>
  
  <pre><code>partial class XParser : IAntlrErrorListener&lt;IToken&gt;
  {
      public void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
      {
          Console.WriteLine("Error in parser at line " + ":" + e.OffendingToken.Column + e.OffendingToken.Line + e.Message);
      }
  }
  </code></pre>
  
  <p>As you said I can extend this parser class using any of the mentioned classes. But I was unable to register this listener, in the main program I am confused with passing argument as the <code>listener</code>. Please help me with the registering.</p>
  
  <p>As I can see these classes has the capability of producing more meaningful error messages don't they?</p>