[antlr-interest] LL versus LR question

Chris Poirier cpoirier at dreaming.org
Mon Feb 2 17:46:49 PST 2004


Hi all,

Jason wrote:
> First off, I lied; it is more infinite recursion.
>
> I've made quite a bit of progress with the converion
> of my grammar from YACC to ANTLR.  There are still
> pieces of the grammar though in which rules
> 'cyclically' reference other rules thereby generating
> infinite recursions.  I'm having difficulty figuring
> out how to rewrite these sections to eliminate the
> left recursions.  Here is a slightly pared down
> example:

I'm very new to ANTRL myself (new, as in, a week), and I don't expect to
be writing my first grammar until later this week.  Prior to this, I've
written only ad hoc parsers, usually of fairly simple languages.

I've been looking at Jason's example for a while, and I'm not seeing
infinite recursion (recursion, but not infinite), but I think that's
because I'm always considering the right end.  Is Jason's grammar
problem one where LR(k) will work and LL(k) won't?

Thanks,
   Chris.


> //BEGIN EXAMPLE
> dimentia:
> 	membrane B A
>       |
> 	A C membrane D
>       |
> 	gentle B A
>       |
> 	A C gentle D
> 	;
>
> gentle:
> 	G
>       |
> 	dimentia B E C
>       |
> 	membrane B F C
>       |
> 	F C dimentia H
>       |
> 	F C membrane H
>       |
> 	membrane B E C
>       |
> 	E C dimentia H
>       |
> 	E C membrane H
> 	;
>
> membrane:
> 	I
>       |
> 	J
>       |
> 	gentle B K
>       |
>     membrane L K
> 	;
> //END EXAMPLE

 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list