Re: Grammar guidelines in Postgres - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: Grammar guidelines in Postgres
Date
Msg-id CAJ7c6TPUuwEE-Nxr=KF_ziS1nNPmKQx0Vwu1MCMHjBVPV4bWKw@mail.gmail.com
Whole thread Raw
In response to Grammar guidelines in Postgres  (Harjyot Bagga <hsbagga28.dev@gmail.com>)
Responses Re: Grammar guidelines in Postgres
List pgsql-hackers
Hi,

> Is there a guidebook, any guidelines for writing grammar in Postgres, or any suggestions to keep in mind?
> Do we have a set of guidelines to write production rules in gram.y (for the Bison Parser Generator) to make the
grammarconflict-free and extendible in the future?
 

I'm far from being an expert in compilers but my dilettante
understanding is that there are two types of conflicts. Shift/reduce
conflicts are resolved with operator priorities (e.g. does 1+2*3 mean
1+(2*3) or (1+2)*3). Reduce/reduce conflict means a "real" conflict
and Flex/Bison should (?) warn you about those. They will not happen
though as long as you use common sense. On top of that note that
generally PostgreSQL follows SQL standard.

If you look for guidelines "flex & bison" by John Levine [1] and
"Compilers: Principles, Techniques, and Tools" by Aho, Ullman et al
[2] are good reads.

I'm not entirely sure if it answers your question but I hope that it's helpful.

[1]: https://www.amazon.com/Flex-Bison-John-R-Levine/dp/0596155972/
[2]: https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811/

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: s/shm_mq_iovec/struct iovec/
Next
From: Ashutosh Bapat
Date:
Subject: Re: Wrong results with grouping sets