[antlr-interest] simple(?) grammar question using antlrworks

Andrew Houghton aah at roarmouse.org
Tue Apr 24 10:02:38 PDT 2007


On Apr 24, 2007, at 4:03 AM, Johannes Luber wrote:

>
> There are two things I've noticed. The first one is that you used
> "protected" instead "fragment". ANTLRworks uses ANTLR3 so it shouldn't
> have worked ever. The second one is that you put EOF at the end of a
> recursive rule. Obviously you end to have EOF everytime you enter a  
> new
> recursion level, making in the end alternatives unavailable. The
> solution is create a separate start rule like I did below. BTW, may I
> use parts of your grammar in my tutorial
> <http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser 
> +Grammars+-+No+Past+Experience+Required>?
> I believe you applied my advice about EOF there and I have overlooked
> this special case while writing the text.
>
> Best regards,
> Johannes Luber
>

Johannes --

Thank you for the response -- I *did* use your tutorial, and the EOF  
addition was a late-night shot in the dark.  I know it didn't make  
sense from a recursion standpoint, but I was hoping that ANTLR  
somehow applied magic to that.

In any case, you're welcome to use my grammar as you see fit.  I'm  
reading up on ANTLR3, I hadn't realized that it was significantly  
different than ANTLR2, which is what all the tutorials I've seen seem  
to use.

Thanks again,

- Andrew




More information about the antlr-interest mailing list