[Top][All Lists]

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

Re: GLR: modification of $1

From: Paul Eggert
Subject: Re: GLR: modification of $1
Date: 04 Oct 2003 23:53:14 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Frank Heckenbach wrote:

> So I'd appreciate Paul's suggestion of making $1 const, so such
> problems are noticed at compile-time.

Can't hurt to try it, I suppose.  I installed this.

2003-10-04  Paul Eggert  <address@hidden>

        * data/glr.c (b4_rhs_value, b4_rhs_location): Yield a
        non-modifiable lvalue, instead of a modifiable one.
        * doc/bison.texinfo (Actions): Document that $$ can
        be assigned to.  Do not claim that $$ and $N are
        array element references: user code should not rely on this.

Index: data/glr.c
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.64
diff -p -u -r1.64 glr.c
--- data/glr.c  4 Aug 2003 19:09:15 -0000       1.64
+++ data/glr.c  5 Oct 2003 06:37:17 -0000
@@ -111,7 +111,7 @@ m4_define([b4_lhs_value],
 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
 # symbols on RHS.
address@hidden (m4_eval([$2 - 
$1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])])
+[((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - 
$1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])])
@@ -131,7 +131,7 @@ m4_define([b4_lhs_location],
 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
 # on RHS.
address@hidden (m4_eval([$2 - $1]))@}.yystate.yyloc])
+[((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc])
 # We do want M4 expansion after # for CPP macros.
Index: doc/bison.texinfo
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.113
diff -p -u -r1.113 bison.texinfo
--- doc/bison.texinfo   1 Oct 2003 21:33:23 -0000       1.113
+++ doc/bison.texinfo   5 Oct 2003 06:37:21 -0000
@@ -2797,9 +2797,10 @@ Actions, ,Actions in Mid-Rule}).
 The C code in an action can refer to the semantic values of the components
 matched by the rule with the construct @address@hidden, which stands for
 the value of the @var{n}th component.  The semantic value for the grouping
-being constructed is @code{$$}.  (Bison translates both of these constructs
-into array element references when it copies the actions into the parser
+being constructed is @code{$$}.  Bison translates both of these
+constructs into expressions of the appropriate type when it copies the
+actions into the parser file.  @code{$$} is translated to a modifiable
+lvalue, so it can be assigned to.
 Here is a typical example:

reply via email to

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