[Top][All Lists]

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

Re: $<out of range>

From: Florian Krohm
Subject: Re: $<out of range>
Date: Thu, 25 Apr 2002 17:42:35 -0400

On Thursday 25 April 2002 17:13, Paul Eggert wrote:
> On further thought I agree with you.  Both byacc and Solaris yacc
> reject your test case.  So even if POSIX requires the behavior (which
> now seems to be quite debatable), its use is not portable in practice.

AIX and HP yacc reject the grammar, too.

> > POSIX lost its mind.  There is a rule reduction here, so Bison pops
> > the stack and pushes $$.  What was written in $3 is popped even more.
> > Either I'm missing something obvious, or really, POSIX asks us to
> > rewrite the mid-rule actions to use $$.
> On rereading the standard, I found another sentence that I had
> missed the first time:
>   Actions can occur anywhere in a rule (not just at the end); an
>   action can access values returned by actions to its left, and in
>   turn the value it returns can be accessed by actions to its right.

It also says:

  An action appearing in the middle of a rule shall be equivalent to
  replacing the action with a new non-terminal symbol and adding an
  empty rule with that non-terminal symbol on the laft-hand side. The semantic
  action associated with the new rule shall be equivalent to the original

Equivalence of rules is not specified AFAICT. It is probably valid to
assume, that "identical" was meant here. Which would render the GCC grammar

> This sentence implies that this mid-rule action cannot access $3,
> since the action cannot be to the left of itself.  So Bison is correct
> to reject the C++ grammar.
Yes, if "access" means "read/write access". 
That would be my interpretation, too.


reply via email to

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