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.
partial class XPars
You need to implement IAntlrErrorListener<IToken>. If all you want to is report errors like you have above, then you should focus on the SyntaxError
method. Several base classes are available if you want to extend one.
The error listener is attached to the parser instance by calling parser.AddErrorListener(listener)
.
Edit: You need to create a new class which implements the error listener interface. You then attach the listener to the parser. The parser itself will not implement the error listener interface.