help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exceeded limits of %dprec/%merge?


From: Joel E. Denny
Subject: Re: Exceeded limits of %dprec/%merge?
Date: Wed, 17 May 2006 00:52:35 -0400 (EDT)

On Wed, 17 May 2006, Derek M Jones wrote:

> I cannot get this ambiguity to go away without some fairly big
> changes to the grammar.  I had thought of using %dprec in
> two different sets of productions, but this does not work
> as expected.

The parser applies %dprec at merge time not at split time.  You're 
attempting to use it at split time.  You can resolve conflicts at split 
time using static precedence instead.  However, static precedence is made 
for shift-reduce conflicts, so you'll need to convert your reduce-reduce 
to shift-reduce.

Try something like this in the definitions section:

  %nonassoc IDENT
  %nonassoc PREC

Add this rule:

  prec: %prec PREC { } ;

Now, before every IDENT, place more occurrences of prec to increase the 
precedence of that rule.  This:

  direct_declarator:
               prec prec IDENT

has higher precedence than this:

  typedef_name:
               prec IDENT

Zero occurrences is also fine for the lowest possible precedence.  If the 
number of occurrences is the same, the split will happen as before.

Does that help?

> On this cut down example I also get a null pointer dereference
> at line 1616 of the generated .c file.

Thanks for the report.  I'll install a patch for this tomorrow.

Joel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]