bug-bison
[Top][All Lists]

## Re: Locations and mid-rule actions

 From: Frank Heckenbach Subject: Re: Locations and mid-rule actions Date: Wed, 22 Dec 2004 02:21:25 +0100 User-agent: semail 20041018

```Paul Eggert wrote:

>
> > Now I see that the current behaviour can also be useful. Since the
> > location of the mid-rule action will be a part of the final
> > location, it seems reasonable to leave it empty.
>
> Also, it is more consistent with the POSIX-required behavior that a
> mid-rule action be (roughly) equivalent to an action on an empty rule.
> Empty rules have empty locations, so....

Yes, roughly equivalent, but not completely, e.g. they can access
`\$n' (and address@hidden') of the previous symbols. So they're special beasts
anyway.

> > it might not hurt if the mid-rule action has a location that spans
> > the previous symbols.
>
> Why would that help?  If a mid-rule action wants the location of a
> previous symbol (say, symbol number 3 for that rule), can't it get it

Basically yes. But say I want to get the "location" of the mid-rule
action itself. Though maybe YYRHSLOC(yyRhs, 0) will help me. I'll
have to look at it some more (I implemented my locations before it
was available, so I'm not really familiar with its usage yet).

BTW, the documentation (changes of 12 Dec, sorry if it's been
updated meanwhile) seems a bit unclear on whether or not it is only
defined if N = 0:

: where @code{YYRHSLOC (rhs, k)} is the location of the @var{k}th symbol
: in @var{rhs} when @var{k} is positive, and the location of the symbol
: just before the reduction when @var{k} is zero.

This doesn't say that N = 0 is required.

: For consistency with semantic actions, valid indexes within the
: right hand side range from 1 to @var{n}.  When @var{n} is zero, only 0 is a
: valid index, and it refers to the symbol just before the reduction.

But this would imply so. So which one is true?

Anyway, for a mid-rule action, having N = 0 always now, I suppose
YYRHSLOC(yyRhs, 0) is always available, isn't it?

Frank

--