Re: shift-reduce conflict,

kers@hplb.hpl.hp.com (Chris Dollin)
13 Mar 1998 00:06:53 -0500

          From comp.compilers

Related articles
shift-reduce conflict, ttnguyen@eecs.uic.edu (Thinh T. Nguyen) (1998-03-07)
Re: shift-reduce conflict, kers@hplb.hpl.hp.com (1998-03-13)
Re: shift-reduce conflict, dgay@barnowl.CS.Berkeley.EDU (1998-03-15)
Re: shift-reduce conflict, kers@hplb.hpl.hp.com (1998-03-18)
| List of all articles for this month |

From: kers@hplb.hpl.hp.com (Chris Dollin)
Newsgroups: comp.compilers
Date: 13 Mar 1998 00:06:53 -0500
Organization: Hewlett-Packard Laboratories, Bristol, UK.
References: 98-03-070
Keywords: parse, yacc

"Thinh T. Nguyen" <ttnguyen@eecs.uic.edu> writes:


> I am writing a parser file (input to bison) for a toy JAVA compiler and
> am running into a shift-reduce conflict that could not be resolved. The
> problem involves
>
> <cast-expression> -> '(' <type> ')' <expression>
>
> where <type> could be any ID. The problem arises when bison parses
> something like '(string)' and confuses whether to reduce it to an
> expression or keep on parsing because it could be a cast-expression.


Can you make Bison happy by allowing


        '(' <expression> ')' <expression>


as legal syntax, and then requiring that the prefix-expression denote
a type? Off the top of my head, this should be OK, shouldn't make
error reporting any more confusing, and even allows for future expansion
of the language in the direction of type-expressions :-)
--


--


Post a followup to this message

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