I’m new to ANTLR and parsing in general. I have been working on a backend for a Language Server and a transpiler for a simple scripting language with ANTLR. What I’ve just started is looking into producing better error output when the user types invalid syntax (via IDE or at compile time).
I was wondering if anyone knew of resources that would help a newb like me out with patterns and strategies for creating smarter syntax error messages from an ANTLR parser/lexer. The messages from the default ErrorListener are decent for debugging the ANTLR grammar, but not useful enough for a compiler/IDE error reporting. I’d like something that users can understand without knowledge of ANTLR and my language grammar.
All I know at this point is to create & use my own ErrorListener and override the syntaxError() method. Inside the syntaxError method is where I should launch my logic for generating a smarter error message when given the lexer/parser, offendingSymbol, and symbol line number/column number.