a = b = 1 just syntactic sugar?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Tue Jun 10 22:41:35 EDT 2003


Martin v. Löwis wrote:
> Actually, I believe it will chose the alternative that is earliest in
> the YACC input file (atleast bison does that).

Yes, it's notion of "best" is rather simplistic in some cases. :-)

Courageous wrote:

 > This is one of the reasons I prefer ANTRL. In ANTLR grammars, one
 > cannot continue generating the parser until one either resolves the
 > ambiguity, or deliberately suppresses it.

With Yacc/Bison, there are two kinds of ambiguities that can
occur, shift-reduce conflicts and reduce-reduce conflicts.
The former are always resolved in favour of the shift, and
in practice this seems to be almost always the "right"
thing to do, producing the result one intuitively expects.

Reduce-reduce conflicts, on the other hand, are much more
of a lottery. As Martin says, Yacc just picks the first grammar
rule, and I've never found this to be at all useful. Although
they're only warnings, I've learned to treat all reduce-reduce
conflicts as errors.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list