Re: [HACKERS] shift/reduce problem with ecpg

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Michael Meskes <meskes(at)topsystem(dot)de>
Cc: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] shift/reduce problem with ecpg
Date: 1998-04-21 05:42:39
Message-ID: 353C31CF.DC75AB81@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> gram.y says:
>
> opt_indirection: ...
> | '[' a_expr ']' opt_indirection
> | '[' a_expr ':' a_expr ']' opt_indirection
> ...
>
> IMO a_expr is exactly where I have to enter C variable support.
> As you might expect this results in a shift/reduce
> conflict since there is no way to decide whether the second name is
> the indicator variable or a coloumn name.
>
> Any idea how to solve this?

Yes. If you really want to allow zero, one, or two colons, and only that
number, then you can explicitly define those cases and separate them out
from the a_expr syntax except as an argument. Look in gram.y for
"b_expr" which accomplishes a similar thing for the BETWEEN operator.
For that case, the AND usage was ambiguous since it can be used for
boolean expressions and is also used with the BETWEEN operator.

Your biggest problem is probably the case with one colon, since it could
be either an indicator variable or the second value in a range. You
might want to require three or four colons when using indicator
variables in this context. Or, as I did with the "b_expr" and "AND"
boolean expressions, you can require parens around the
variable/indicator pair. e.g.

xxx [ name : name ] -- this is a range
xxx [ (name : name) ] -- this is an indicator variable

- Tom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 1998-04-21 08:41:23 LINUX_ELF
Previous Message Jan Vicherek 1998-04-21 04:59:55 Re: Proposal for async support in libpq