[antlr-interest] bad generated code?

Monty Zukowski monty at codetransform.com
Fri Sep 30 17:57:16 PDT 2005


I dunno.  Try putting parenthesis around the two alternatives?

Monty

On Sep 30, 2005, at 5:48 PM, Christian Bird wrote:

> Good suggestion, but unfortunately the code generated for name is
> still the same.  I don't understand antlr could ever generate code
> that looks like:
>
> if ((_t.getType()==A) && (_t.getType()==B)) {}
>
> When A is not the same as B.  I'm guessing, however, that a treeparser
> generator is more complicated to write and probably not as often
> used/tested by antlr users as a normal parser generator (most people
> I've talked to here at UC Davis only use it for parsers and lexers,
> not AST traversals).
>
> Any other ideas?  I appreciate your taking a look at it.
>
> -- Chris
>
> On 9/30/05, Monty Zukowski <monty at codetransform.com> wrote:
>
>>
>>
>> On Sep 30, 2005, at 4:57 PM, Christian Bird wrote:
>>
>>  zimport :
>>     #("import"
>>         (name ARROW complexNameList SEMI |
>>         "all" identifier SEMI) )
>>     ;
>> It does seem like a code gen bug.  I would recommend breaking this  
>> up into
>> another rule if you can:
>>
>> zimport: #("import" importSuffix)
>> importSuffix: name ARROW complexNameList SEMI
>>                        | "all" identifier SEMI
>>                        ;
>>
>> See if that still triggers the problem.
>>
>> Monty
>>
>
>
> --
> Christian Bird
> cabird at gmail.com
>
>
>



More information about the antlr-interest mailing list