[antlr-interest] Antlr3.4 Python bugs, workarounds

Benjamin S Wolf jokeserver at gmail.com
Sun Oct 30 21:48:38 PDT 2011


On Fri, Oct 28, 2011 at 11:56 AM, Benjamin Niemann <pink at odahoda.de> wrote:
> On Fri, Oct 7, 2011 at 11:17 PM, Benjamin S Wolf <jokeserver at gmail.com> wrote:
>> I've discovered two bugs in working with the Python target to generate lexers.
>>
>> The first is in that when supplying k, the generated code for special
>> state transitions is invalid: the "elif" keyword is split across lines
>> as "el\nif", so the python interpreter crashes upon reading "el".
>
> That's been reported before, but I have problem reproducing it. Are
> you using antlr-3.4-complete.jar (I can only see this problem with
> that build) or did you build it yourself from antlr-3.4.tar.gz (or
> something else completely)?

Using antlr-3.4-complete.jar, yes.

I tried reducing my test case as far as I could, but it won't generate
the DFA with the special state transitions if I use fewer than 57
rules. Eventually I tried generating 57 rules to trigger it, and here
is the (excruciatingly ugly) result. (Note that I have rules that
start with 'a' and rules that start with 'b'. This triggers the
"el\nif" case. If I only used 'a' rules, the special state transition
would only need to check "if s == 0" since no other character is
valid.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: minimal.g
Type: application/octet-stream
Size: 827 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20111031/33310970/attachment.obj 


More information about the antlr-interest mailing list