]> git.saurik.com Git - bison.git/commitdiff
In GLR grammars, $N and @N now yield non-modifiable lvalues.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 5 Oct 2003 06:46:53 +0000 (06:46 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 5 Oct 2003 06:46:53 +0000 (06:46 +0000)
ChangeLog
data/glr.c
doc/bison.texinfo

index f4ea6e4aeb2e89eca1a05267ad9d86e510ed6bb6..6af09b7b8cf254a60e59c39ee423b6a4048ee864 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-10-04  Paul Eggert  <eggert@twinsun.com>
+
+       * 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.
+
 2003-10-01  Paul Eggert  <eggert@twinsun.com>
 
        * src/parse-gram.h (PERCENT_NO_DEFAULT_PREC): New token.
index 17634dbadaee1eb01b890b8da78089bd461bf1fd..f2173854c890edd124e2cffee7b8891e75312f51 100644 (file)
@@ -111,7 +111,7 @@ m4_define([b4_lhs_value],
 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
 # symbols on RHS.
 m4_define([b4_rhs_value],
-[yyvsp@{YYFILL (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.
 m4_define([b4_rhs_location],
-[yyvsp@{YYFILL (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.
 m4_changecom()
index a6e2ee37011f443b9fb9133df0d5784431412357..8476176073f2fa51fc66a07fdb3db683cfc20a02 100644 (file)
@@ -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 @code{$@var{n}}, 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
-file.)
+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: