bug-bison
[Top][All Lists]
Advanced

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

Re: POSIX and reduce/reduce conflicts


From: Paul Eggert
Subject: Re: POSIX and reduce/reduce conflicts
Date: Tue, 9 Apr 2002 17:50:03 -0700 (PDT)

> From: Akim Demaille <address@hidden>
> Date: 09 Apr 2002 10:35:46 +0200
> 
> Bison, in case of a reduce/reduce conflict _always_ picks up the first
> rule, no matter what precedence the rules have.  The idea was once
> raised to use precedence to help in case of conflicts.  Does POSIX
> allow this?

No.  It says that parsing conflicts are resolved as follows:

* Each rule has a precedence and associativity, given by the precedence
  and associativity of the last token or literal in the rule body, overridden
  by %prec.

* If there is a shift/reduce conflict, and both the grammar rule and 
  input symbol have precedence and associativity, resolve the conflict
  in favor of the action that has the higher precedence; or if they
  have the same precedence, use associativity.

* If there is a shift/reduce conflict that cannot be resolved by
  precedence or associativity, do a shift, but report the conflict.

* If there is a reduce/reduce conflict, reduce by the first grammar rule,
  but report the conflict.

So POSIX does not allow precedence or associativity to count for
reduce/reduce conflicts.

> But if some day Bison supports other paradigms, such as back
> tracking, then precedence can be seen as a means to order the
> search, which can be good.

Yes, but I would wait for those other paradigms before worrying about
this.

> I realize it is not clear to me whether this (using precedence in
> RR conflicts) is a feature, or a misfeature.

Given the current paradigm, I'd call it a misfeature.



reply via email to

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