[antlr-interest] Python3 target

Murat Knecht murat.knecht at student.hpi.uni-potsdam.de
Wed May 20 02:27:57 PDT 2009


Hi Ben,

thanks for your fast reply and this simply advice - I didn't think of
running 2to3 on ANTLR. After having some fun with 2to3, I managed to
port both the antlr3-python runtime to python3, as well as the python
target.

Unfortunately, there are still errors in the generated code (and in the
runtime), such as the following. Those are not fixed by 2to3, I guess
because type information is missing:

    if (('\t' <= LA9_0 <= '\n') or LA9_0 == '\r' or LA9_0 == ' ') :
TypeError: unorderable types: str() <= int()

I'll do some patching to get ANTLR to work locally ...

All the best,
Murat

Benjamin Niemann schrieb:
> Hi Murat,
>
> On Tue, May 19, 2009 at 6:00 PM, Murat Knecht
> <murat.knecht at student.hpi.uni-potsdam.de> wrote:
>   
>> I just tried the native Python target with ANTLR3 and stumbled upon
>> problems using the generated parser in Python v3.
>> The documentation says that the current version supports v2.4 and 2.5.
>> Are there any plans to produce a Python3 compatible target or is one
>> already being made?
>>
>> So far, it seems the problems are rather minor, e.g. using old unicode
>> u'blub' strings, which are not allowed in Python anymore. I could
>> probably just hack the python target, but then an in-house solution
>> clearly is nicer and better maintainable.
>>     
>
> I thought about it, but no action taken yet. To keep the
> maintainability high, this probably needs some tweaks in the codegen
> code (e.g. allow 'subclassing' of targets, if implemented as a
> separate target).
>
> Have you tried using the 2to3 tool on the generated code/runtime module?
>
> -Ben
>
>   
>> Sorry, if this has been asked before. Googling python3 and antlr usually
>> results in something about antlr3 (Google is trying just too hard.)
>>
>> Best regards,
>> Murat
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>     



More information about the antlr-interest mailing list