Re: shift/reduce conflict issues

Pete Jinks <>
9 Sep 2003 23:05:53 -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: Pete Jinks <>
Newsgroups: comp.compilers
Date: 9 Sep 2003 23:05:53 -0400
Organization: Computer Science Dept, University of Manchester
References: 03-09-027
Keywords: parse
Posted-Date: 09 Sep 2003 23:05:53 EDT

Alfonso Urdaneta wrote:
> Basically I need to parse a line that may look like this.
> 'george', 'barney', 'wilma', 'pebbles', 25 CHAR
> what I _think_ is happening is that the last comma before the 25 is
> throwing it for a loop, as the parser doesn't know if another
> identifier is coming, or if the length is coming.

Agreed. (Formally, your grammar is LR(2) rather than LR(1), which is
all that yacc can cope with.)

Here is an equivalent LR(1) grammar, which works ok with yacc:

fred : fredhead fredtail


fredtail: label_identifier MONTY_FD declare_length
| label_identifier MONTY_FD fredtail

declare_length and label_identifier as before

You may find the following link useful:

Peter J. Jinks, Room 2.99, Department of Computer Science,
University of Manchester, Oxford Road, Manchester, M13 9PL, U.K.
(+44/0)161-275 6186

Post a followup to this message

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