[antlr-interest] How to disable error messages
Simos Xenitellis
simos.lists at googlemail.com
Sat Jun 14 11:49:42 PDT 2008
O/H JLIST έγραψε:
> 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'
>
> The grammar works OK so I'd like to disable these errors from
> the console after starting the program. I wonder if there is a
> simple way to turn that off from code?
>
The source of the problem is probably the fact
that Python 2.x defaults to the ASCII encoding for text strings.
Therefore, when you interact with Unicode text,
you get all sort of encoding problems.
You can configure your installation of Python to go for utf-8
/usr/lib/python2.5/site.py:
def setencoding():
"""Set the string encoding used by the Unicode implementation. The
default is 'ascii', but if you're willing to experiment, you can
change this."""
encoding = "utf-8" # Default value set by _PyUnicode_Init()
This should solve the Unicode problems in a painless way.
Simos
More information about the antlr-interest
mailing list