Re: Re: [GENERAL] A rare error - Mailing list pgsql-hackers

From Ian Lance Taylor
Subject Re: Re: [GENERAL] A rare error
Date
Msg-id 20001027075028.21680.qmail@daffy.airs.com
Whole thread Raw
In response to Re: Re: [GENERAL] A rare error  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Date: Thu, 26 Oct 2000 20:49:22 -0400  From: Tom Lane <tgl@sss.pgh.pa.us>
  Right.  Also, I believe it's possible that such a grammar will behave  differently depending on which yacc you
processit with, which would be  bad.  (We have not yet taken the step of insisting that pgsql's grammar  is bison-only,
andI don't want to.)  So ensuring that we get no shift/  reduce conflicts has been a shop rule around here all along.
 

Actually, even the earliest version of yacc had very simple rules,
which are inherited by all versions.  In a shift/reduce conflict,
always shift.  In a reduce/reduce conflict, always reduce by the rule
which appears first in the grammar file.  shift/shift conflicts
indicate a grammer which is not LALR(1).

I'm pretty sure that all versions of yacc also support %left, %right,
and %nonassoc, which are simply techniques to eliminate shift/reduce
conflicts in arithmetic and other expressions.

I believe it is always possible to rewrite a grammer to eliminate all
conflicts.  But the rewrite can require an explosion in the number of
rules.

Reduce/reduce conflicts can be risky because it is easy to
accidentally change the ordering of the rules while editing.  But
shift/reduce conflicts are not risky.  The C parser in gcc, for
example, written and maintained by parser experts, has 53 shift/reduce
conflicts.

Ian


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Re: [GENERAL] 7.0 vs. 7.1 (was: latest version?)
Next
From: "Kevin O'Gorman"
Date:
Subject: Select syntax (broken in current CVS tree)