At 03:40 PM 1/16/2009, Jim Idle wrote: >Gerald Rosenberg wrote: >>At 01:20 PM 1/16/2009, Jim Idle wrote: > >Hence, because the reference parser is simple, and does not know >anything about the object it will generate code to reference, there >is no way to protect you from the NPE, hence there is nothing to fix per se.
Hmmm, if the code gen is smart enough to break up gDecl .setName($k.start.getStartIndex()); to produce this gDecl .setName((k != null ? ((CommonToken) k.start ) : null ).getStartIndex()); then it should be able to produce this instead gDecl .setName((k != null ? ((CommonToken) k.start.getStartIndex()) : null )); Yes, "start" could be null, but at least with this production, the code gen is leaving me no more worse off than I was to begin with. The null check will continue to protect in the case of optional label references - a really different requirement than a null check on "start". The current production unfortunately kills the whole 'protect the optional label reference' point of the code generated null check. I did see Ter's note that the current code gen analysis is not looking far enough ahead to handle this. But, that is just one of those minor, no-doubt short-lived practical inconveniences. ;-) >It's one of those things that you have to garner some extra >knowledge from by looking at the code, which you have done :-) I have to say that I am doing this less and less and, always now, the issues are these kind of odd code generation issues. The evolution of Antlr as a language has been amazing to watch. Still, I look forward to when lifting the cover will not be required except in the most exceptional of circumstances. Best, Gerald --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
