Re: How to build a new grammer for pg?
Re: How to build a new grammer for pg?
От:
Julien Rouhaud <rjuju123@gmail.com>
Дата:
Hi, On Tue, Aug 01, 2023 at 07:36:36PM +0800, jacktby wrote: > Hi, I’m trying to develop a new grammar for pg, can +you give me a code example to reference? It's unclear to me whether you want to entirely replace the flex/bison parser with something else or just add some new bison rule. If the latter, it really depends on what you change to achieve exactly. I guess you could just look at the gram.y git history until you find something close enough to your use case and get inspiration from that.
Re: How to build a new grammer for pg?
От:
Chapman Flack <chap@anastigmatix.net>
Дата:
On 2023-08-01 07:58, Julien Rouhaud wrote: > On Tue, Aug 01, 2023 at 07:36:36PM +0800, jacktby wrote: >> Hi, I’m trying to develop a new grammar for pg > > It's unclear to me whether you want to entirely replace the flex/bison > parser > with something else or just add some new bison rule. Or express a grammar matching PG's in some other parser-generator language, to enable some other tool to parse PG productions? Regards, -Chap
Re: How to build a new grammer for pg?
От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
On 2023-08-01 Tu 12:50, Chapman Flack wrote:
On 2023-08-01 07:58, Julien Rouhaud wrote:On Tue, Aug 01, 2023 at 07:36:36PM +0800, jacktby wrote:Hi, I’m trying to develop a new grammar for pg
It's unclear to me whether you want to entirely replace the flex/bison parser
with something else or just add some new bison rule.
Or express a grammar matching PG's in some other parser-generator
language, to enable some other tool to parse PG productions?
Or to enable some language other than SQL (QUEL anyone?)
cheers
andrew
-- Andrew Dunstan EDB: https://www.enterprisedb.com
Re: How to build a new grammer for pg?
От:
"Jonah H. Harris" <jonah.harris@gmail.com>
Дата:
On Tue, Aug 1, 2023 at 3:45 PM Andrew Dunstan <andrew@dunslane.net> wrote:
Or to enable some language other than SQL (QUEL anyone?)
A few years ago, I got a minimal POSTQUEL working again to release as a patch for April Fools' Day, which I never did. I should dig that up somewhere :)
Anyway, as far as OP's original question regarding replacing the grammar, there are a couple of such implementations floating around that have done that. But, I actually think the pluggable parser patches were good examples of how to integrate a replacement parser that generates the expected parse tree nodes for anyone who wants to do their own custom parser. See Julien Rouhaud's SQLOL in the "Hook for extensible parsing" thread and Jim Mlodgenski's "Parser Hook" thread.
Jonah H. Harris
Re: How to build a new grammer for pg?
От:
Hannu Krosing <hannuk@google.com>
Дата:
I would look at how Babelfish DB did it when adding SQL Server compatibility https://babelfishpg.org/ and https://github.com/babelfish-for-postgresql/ another source to inspect could be https://github.com/IvorySQL/IvorySQL for "oracle compatible PostgreSQL" On Tue, Aug 1, 2023 at 10:07 PM Jonah H. Harris wrote: > > On Tue, Aug 1, 2023 at 3:45 PM Andrew Dunstan wrote: >> >> Or to enable some language other than SQL (QUEL anyone?) > > > A few years ago, I got a minimal POSTQUEL working again to release as a patch for April Fools' Day, which I never did. I should dig that up somewhere :) > > Anyway, as far as OP's original question regarding replacing the grammar, there are a couple of such implementations floating around that have done that. But, I actually think the pluggable parser patches were good examples of how to integrate a replacement parser that generates the expected parse tree nodes for anyone who wants to do their own custom parser. See Julien Rouhaud's SQLOL in the "Hook for extensible parsing" thread and Jim Mlodgenski's "Parser Hook" thread. > > -- > Jonah H. Harris >