Re: Remove useless associativity/precedence from parsers

Поиск
Список
Период
Сортировка
От Akim Demaille
Тема Re: Remove useless associativity/precedence from parsers
Дата
Msg-id 21B7EE24-19F5-4245-AFA6-B1F51AA5F6DD@lrde.epita.fr
обсуждение исходный текст
Ответ на Re: Remove useless associativity/precedence from parsers  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Remove useless associativity/precedence from parsers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi Tom,

> Le 19 mai 2019 à 20:27, Tom Lane <tgl@sss.pgh.pa.us> a écrit :
>
> Akim Demaille <akim@lrde.epita.fr> writes:
>> In the following two proposed patches, I remove directives that are
>> completely useless.
>
> I'm far from convinced that the proposed changes in gram.y are a good
> idea.  Both [] and . (field selection) *are* left-associative in a
> meaningful sense, so even if this change happens not to affect what
> Bison does, I think the declarations are good documentation.

I don't dispute the overall behavior of the grammar as a whole, I'm only referring to these directives.  In my
experience,leaving useless associativity and precedence directives can be misleading (since these directives have no
impact,you could put them anywhere: their contribution is not checked in any way) or even dangerous (some day, some
changeintroduces unexpected shift-reduce conflicts that someone should have studied, but because of "stray" directives,
theyare "fixed" in some uncontrolled way). 

> Would
> you have us also change the user documentation at
> https://www.postgresql.org/docs/devel/sql-syntax-lexical.html#SQL-PRECEDENCE
> ?

No, of course not!  That you define the arithmetics with an unambiguous grammar (expr/term/fact and no
associativity/precedencedirective) or with an ambiguous grammar (expr and associativity/precedence directives) still
resultsin the same behavior: the usual behavior of these operators.  And the documentation should document that, of
course.


It is for the same reasons that I would recommend not using associativity directives (%left, %right, %nonassoc) where
associativityplays no role: %precedence is made for this.  But it was introduced in Bison 2.7.1 (2013-04-15), and I
don'tknow if requiring it is acceptable to PostgreSQL. 

Cheers!


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: behaviour change - default_tablesapce + partition table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Parallel Append subplan order instability on aye-aye