|Left Recursion in Yacc email@example.com (Mike) (2000-12-24)|
|Re: Left Recursion in Yacc firstname.lastname@example.org (2000-12-31)|
|Re: Left Recursion in Yacc email@example.com (Martin von Loewis) (2000-12-31)|
|Re: Left Recursion in Yacc firstname.lastname@example.org (2001-01-09)|
|Date:||24 Dec 2000 16:02:47 -0500|
|Keywords:||yacc, question, comment|
|Posted-Date:||24 Dec 2000 16:02:47 EST|
I have a question about left recursive rules in Yacc/Bison. Suppose I
have a left recursive rule
expression:expression ',' ITEM
Now I want to create a list of items separated by a ',' from my input.
Although it is clear that the grammar would allow me to have a list of
one or more items. What is confusing for me is the actions that would
be taken. More specifically, how exactly would the recursion be
handled. Would I get the list in reverse order? If yes, why is that.
Let's say that the input is:
How exactly would Yacc/Bison handle this list?
Thanks a lot in advance!
[You can make the list any way you want, although if you do the simplest
think and link $1 to $3 in your first rule, you'll end up with a backwards
list. It's easy enough to make one pass at the end and reverse the links.
Return to the
Search the comp.compilers archives again.