[antlr-interest] How to disable error messages

Jim Idle jimi at temporal-wave.com
Sat Jun 14 13:38:26 PDT 2008


On Sat, 2008-06-14 at 10:53 -0700, JLIST wrote:

> Hi,
> 
> I'm using Python code generated by Antlr. I'm getting a lot
> of errors like this:
> 
> line 1:0 no viable alternative at character '\xe6'


You are getting these because your lexer is not covering that character
in any token. Perhaps this is a utf input stream? Your lexer should be
able to consumer any character thrown at it, even if it throws it away.
If these characters really are superfluous, then it really is an error,
in which case you want, as the last lexer rule:

UNKNOWN : . { <print message about bad character but perhaps a better
one than the default> ;

Or, if they are are allowed to be in the stream but you just wish to
silently ignore them, then:

ANY    : . { Python equivalent of skip(); } ;

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080614/9a8b6dd8/attachment.html 


More information about the antlr-interest mailing list