help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can't to remove shift/reduce


From: Pavel Stehule
Subject: Re: can't to remove shift/reduce
Date: Fri, 23 Nov 2007 17:11:01 +0100

Hello

this part of PostgreSQL grammar is hack and ambiguous. Output tree is
transformated in next step, so I needed only correct parsing.

I played with precedences and found solution (I can't to speak I
understand well, but it just works).

%left           '[' ']'
%nonassoc       ATTR_NAME               /* dummy for attr_name */
%left           '(' ')'
%left           TYPECAST
%left           '.'

column_method:
                        column_method_name %prec ATTR_NAME
                                {
                                        elog(NOTICE, "attr name");
                                }
                        | column_method_name '(' ')'
                                {
                                        elog(NOTICE, "method()");
                                        $$ = (Node *) makeString("*");
                                }
                        | column_method_name '(' expr_list ')'
                                {
                                        elog(NOTICE, "method(...)");
                                        $$ = (Node *) makeString("*");
                                }
                ;

Thank You very much for advices.

Nice a day
Pavel Stehule


On 23/11/2007, Evan Lavelle <address@hidden> wrote:
> It's too big to make much sense of, but here's a couple of things you
> can try:
>
> >> I'd be surprised if it works. Have you tried column_method_name both
> >> with and without brackets? The default is to ignore the brackets - what
> >> happens then? How are the brackets interpreted?
> >>
> > without brackets it is relation or variable atribute. With brackets it
> > is methods.
>
> The grammar produces no code for the no-brackets case ("relation or
> variable attribute"). It doesn't reduce; it assumes that you wanted the
> shift, so it assumes "with brackets it is methods". Is this acceptable,
> or not? Have you got any test input that explicitly requires the
> no-brackets "relation or variable attribute" case?
>
> >> You need to post everything that can come after 'column_method'. Is it
> >> ever possible to have a '(' character after a column_method, apart from
> >> the 2 ways you have shown?
>
> To rephrase this: if your intention is to allow both of these two things:
>
> 1 - column_method, with no following '(' (ie. "relation or variable
> attribute"), *but* some other part of the grammar allows you to put in a
> following '(' anyway, AND
>
> 2 - column_method with a following '(' (ie. "with brackets it is
> methods"), THEN
>
> you have a language ambiguity that you need to fix. At first sight, it
> seems that perhaps you may want case 1, because (at least) both
> func_name and qualified_name can be followed by '('. If you don't know
> the answer, you need to go right through the grammar to find out if case
> 1 is a requirement.
>
> Evan
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]