[antlr-interest] What if you want errors to exit the parser? (v3)

David Holroyd dave at badgers-in-foil.co.uk
Tue Oct 31 08:43:46 PST 2006


On Mon, Oct 30, 2006 at 01:01:35PM -0800, Terence Parr wrote:
> but, it tries to recover from token mismatches by insertion/ 
> deletion....do we need an option afterall to tell ANTLR to let errors  
> cause exceptions in middle of alts?

Well, for my current project (programmatic code generation) I want to
know right away if the provided fragment of input didn't match the
grammar.  Unit testing the application code using my framework thereby
becomes much easier, as an application coding error is more likely to
immediately turn into an unexpected exception.

Adding an empty @rulectch seems to mostly do what I want at the moment.
In the future, since the same framework is used for both code generation
and code introspection, it may be useful to be able to choose at runtime
if the ANTLR-generated code should perform error recovery, so that it
can deal with wonkey input files.


ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list