Обсуждение: Help with gram.y (UNDER)
Can someone give be a bit of help with gram.y to get this UNDER syntax
right? I did what I though was the obvious syntax, but it no longer
accepts a plain create table after this change...
OptUnder: UNDER relation_name_list { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ;
CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '('
OptTableElementList ')' OptInherit { /*etc */ } ;
The full patch is here...
ftp://ftp.tech.com.au/pub/diff.x
It seems like bison is confused by having that '(' just after an
optional syntax (UNION). If I place something after OptUnder (USING just
to pick a token), then everything works fine (except of course the
spurious USING becomes part of the syntax).
Does the '(' have some kind of second-class status as a token that would
cause this wierdness?
Chris Bitmead wrote:
>
> Can someone give be a bit of help with gram.y to get this UNDER syntax
> right? I did what I though was the obvious syntax, but it no longer
> accepts a plain create table after this change...
>
> OptUnder: UNDER relation_name_list { $$ = $2; }
> | /*EMPTY*/ { $$ = NIL; }
> ;
>
> CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '('
> OptTableElementList ')' OptInherit
> {
> /*etc */
> }
> ;
>
> The full patch is here...
> ftp://ftp.tech.com.au/pub/diff.x
Chris Bitmead wrote:
>
> It seems like bison is confused by having that '(' just after an
> optional syntax (UNION).
I mean the optional UNDER
> If I place something after OptUnder (USING just
I mean USING;
i.e. CreateStmt: CREATE OptTemp TABLE relation_name OptUnder USING '('
OptTableElementList ')' OptInherit
This will accept "CREATE TABLE foo USING (aa text);"
but this...
CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '('
OptTableElementList ')' OptInherit
won't accept "CREATE TABLE foo (aa text);"
> to pick a token), then everything works fine (except of course the
> spurious USING becomes part of the syntax).
>
> Does the '(' have some kind of second-class status as a token that would
> cause this wierdness?
>
> Chris Bitmead wrote:
> >
> > Can someone give be a bit of help with gram.y to get this UNDER syntax
> > right? I did what I though was the obvious syntax, but it no longer
> > accepts a plain create table after this change...
> >
> > OptUnder: UNDER relation_name_list { $$ = $2; }
> > | /*EMPTY*/ { $$ = NIL; }
> > ;
> >
> > CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '('
> > OptTableElementList ')' OptInherit
> > {
> > /*etc */
> > }
> > ;
> >
> > The full patch is here...
> > ftp://ftp.tech.com.au/pub/diff.x
Chris Bitmead <chris@bitmead.com> writes:
> Does the '(' have some kind of second-class status as a token that would
> cause this wierdness?
No ... very bizarre. I think you must be introducing some kind of
ambiguity into the grammar, but I can't quite see what. Are you
getting any sort of warnings out of bison?
Might be worth turning on the logfile option (forget if it's -v or -l)
and looking at the interpreted productions just to make sure bison
is reading things the same way you thought you wrote them.
regards, tom lane