Re: shift/reduce conflict issues (RKRayhawk)
9 Sep 2003 23:05:12 -0400

          From comp.compilers

Related articles
shift/reduce conflict issues (2003-09-04)
Re: shift/reduce conflict issues (Mykola Rabchevskiy) (2003-09-09)
Re: shift/reduce conflict issues (2003-09-09)
Re: shift/reduce conflict issues (2003-09-09)
Re: shift/reduce conflict issues (Pete Jinks) (2003-09-09)
| List of all articles for this month |

From: (RKRayhawk)
Newsgroups: comp.compilers
Date: 9 Sep 2003 23:05:12 -0400
Organization: AOL
References: 03-09-027
Keywords: parse, yacc
Posted-Date: 09 Sep 2003 23:05:12 EDT (Alfonso Urdaneta)
Date: 9/4/03 9:48 PM EST

posted a bison grammar and commented in part ...


I followed the manuals suggestion and made the variable sequence left
recursive, but I have also been thinking that making it right
recursive (and making the fd right associative as well) might be the

Perhaps you will wish to consider the advice to avoid right recursion
with a tool like bison.

Also, you may be allowing your notion of recursion to blur with
associativity (a bit hard to tell from your post)

Let me suggest a certain approach to one of the rules that is
problematic (this posted material here has not been tested, it is the
idea that counts not the exact code).

declaration: label_identifier_seq_top
| MONTY_STORE MONTY_FD label_identifier_seq_top

label_identifier_seq_top: label_identifier label_identifier_seq_deeper

label_identifier_seq_deeper: /* epsilon */
| MONTY_FD label_identifier
| label_identifier_seq_deeper MONTY_FD label_identifier

        { printf("\tidentifier %s\n", $<text>2 ); }

So, the notion is that the original rule that you posted,
label_identifier_seq, is not really recursive. So do not make it left
recursive or right recursive. The possibilty of making it an extended,
comma delimitted, list is a recursive rule (which is optional all
together so you also need the epsilon in there, which is mildly
distracting). So make the extending of the list recursive (and with
bison do left recursion, lest you bust up your stack in a nasty way).

Hope that is useful,
Bob Rayhawk

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.