Re: hint infrastructure setup (v3)

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: hint infrastructure setup (v3)
Date: 2004-04-03 09:31:14
Message-ID: Pine.LNX.4.58.0404031120450.1733@mordor.coelho.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


> > You *really* don't want to go there. If you want to see what the parser
> > is doing you can run "bison -r all" over the grammar and examine the
> > .output file. But please, let's not examine the internal states. Talk
> > about unmaintainability!
>
> What I was suggesting was that we might be able to extract the "follow
> set" from bison's tables, ie, the set of grammar symbols that are legal
> next inputs given the current parse state stack.

> I surely agree that we don't want code that goes like "if state is N
> then print message X" ... but the follow set should be stable

These are 2 different issues.

(1) computing the set of expected following tokens.

It is possible to do that, with some processing of bison tables.

(2) give advices based on guesses:
for what I have looked so far, it could look like:

- I'm here for rule "user_list", the previous token was ','
OR I'm here for "select_expressions_list", last token was ',' and
current token is "FROM"

=> "HINT: remove previous comma"

I don't think that (2) would be a bad idea, especially for my students.
The good point is that the cost would only be paid at error time.

> One way of describing Fabien's existing patch is that it's essentially
> keeping track of the follow set by hand :-(

Yes. I give name to existing states, and states leads to expected
follow tokens.

> > Also, I suspect that bison does a good bit of
> > optimisation by way of combining states that removes some of the
> > information you might need, but I haven't looked into it closely.
>
> That could be a showstopper if true, but it's all speculation at this
> point.

I think the information is there.

--
Fabien Coelho - coelho(at)cri(dot)ensmp(dot)fr

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Magnus Hagander 2004-04-03 12:01:19 Re: Function to kill backend
Previous Message Fabien COELHO 2004-04-03 09:20:05 Re: hint infrastructure setup (v3)