[antlr-interest] How does one suppress 'no viable alternative at character' warning messages

Markus Stoeger spamhole at gmx.at
Wed Sep 17 13:18:06 PDT 2008


Terence Parr schrieb:
> Try overriding  nextToken()...hmm...that might be hard.
>   
Would this FAQ solve Tim's problem? 
http://www.antlr.org/wiki/pages/viewpage.action?pageId=5341217

We used that today and it worked. It makes any unmatched character stop 
the whole thing. The method explained in the book's chapter 10.4 about 
exiting the recognizer on the first error only works for the parser, but 
not for the lexer. The lexer still accepts unknown characters and continues.

I think it would be great if error reporting and recovery were 
configurable or at least easier to modify than by overriding methods. 
(Correctly) overriding methods is quite complicated and hard to get 
right imo. Especially when you're new to antlr and don't know the 
internals very well yet it's quite easy to screw it up (I have 
experience with screwing it up ;-).

Max



More information about the antlr-interest mailing list