|shift/reduce conflict issues email@example.com (2003-09-04)|
|Re: shift/reduce conflict issues firstname.lastname@example.org (Mykola Rabchevskiy) (2003-09-09)|
|Re: shift/reduce conflict issues email@example.com (2003-09-09)|
|Re: shift/reduce conflict issues firstname.lastname@example.org (2003-09-09)|
|Re: shift/reduce conflict issues email@example.com (Pete Jinks) (2003-09-09)|
|From:||Pete Jinks <firstname.lastname@example.org>|
|Date:||9 Sep 2003 23:05:53 -0400|
|Organization:||Computer Science Dept, University of Manchester|
|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
| MONTY_STORE MONTY_FD
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 http://www.cs.man.ac.uk/~pjj
Return to the
Search the comp.compilers archives again.