[Top][All Lists]

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

Re: $<out of range>

From: Hans Aberg
Subject: Re: $<out of range>
Date: Fri, 26 Apr 2002 10:02:08 +0200

At 22:36 +0200 2002/04/25, Akim Demaille wrote:
>Paul> No, it's allowed.  POSIX says of `$number':
>Paul>   If number refers to an element past the current point in the
>Paul> rule, or beyond the bottom of the stack, the result is
>Paul> undefined.
>Paul> Here the "current point in the rule" is 3, so $3 is allowed.
>Are you sure the current point is not 2?  I fail to see any technical
>soundness in the consequences of the interpretation of `current point'
>you propose.

In the case at hand, when the midrule acts, formally $3 does not exist,
even though it may do that by an actual implementation, because one is then
in the action, and the semantic value of the rule has not yet been
computed. It is the same as in
  x: x_1 ... x_n { action }
Then, when in the action, the value ${n+1} does not formally exist (even
though it may exist if the stack implementation is such that memory has
been allocated, and under C++, initialized).

Therefore, from that point of view, I think that Bison is correct, and
should reject $n when referring to the midrule action one is in.

Also, when using C++ polymorphy, it may pose problems (if the polymorphy
casts are such) to use $<type>n as l-values: It may happen that only
$<type>$ is guaranteed to be a l-value.

So for C++, one should keep in mind that it might be required that $<type>n
can only be used as r-values (even though I am not sure of this yet -- it
depends on the polymorphy model being used).

  Hans Aberg

reply via email to

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