%define api.value.automove false doesn't work (fix email format)

"Z. Majeed" <[email protected]> Sat, 12 Jul 2025 13:35:45 +0000 (UTC)
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
My first email from yesterday appears messed up - this is attempt 2
The api.value.automove directive doesn't honor an explicit false setting.
-------------------------------------------
// test_automove.y
%skeleton "lalr1.cc"%require "3.8"%language "c++"
%define api.value.automove false
%token <int> VAL%nterm <int> x
%%
x: VAL
-------------------------------------------
bison -o test_automove.cpp test_automove.y
grep -B2 "yylhs.value.int" test_automove.cpp
=C2=A0 case 2: // x: VAL#line 14 "test_automove.y"=C2=A0 =C2=A0{ (yylhs.val=
ue.int) =3D YY_MOVE ((yystack_[0].value.int)); }

bison --versionbison (GNU Bison) 3.8.2
-------------------------------------------
The problem is in skeletons/lalr1.cc where b4_percent_define_ifdef applies =
YY_MOVE as long as api.value.automove is defined without considering its va=
lue
The default value of api.value.automove is false - omitting the directive d=
oes prevent YY_MOVE from being applied
m4_define([b4_rhs_value],[b4_percent_define_ifdef([api.value.automove],=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0[YY_MOVE (_b4_rhs_value($@))],=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[_b4_rhs_value($=
@)])])
-------------------------------------------
b4_percent_define_ifdef is defined in skeletons/bison.m4
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])# ----------------=
--------------------------------------# If the %define variable VARIABLE is=
 defined, expand IF-TRUE, else expand# IF-FALSE.=C2=A0 Don't record usage o=
f VARIABLE.
-------------------------------------------
I'll send a fix for lalr1.cc shortly to bison-patches that looks like this
111a112,114> # api.value.automove boolean default value false> b4_percent_d=
efine_default([[api.value.automove]], [[false]])>113,115c116,118< [b4_perce=
nt_define_ifdef([api.value.automove],<=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [YY_MOVE (_b4_rhs_v=
alue($@))],<=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [_b4_rhs_value($@)])])---> [b4_percent_define_f=
lag_if([api.value.automove],>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [YY_MOVE (_b4_rhs_value($@))]=
,>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 [b4_rhs_value($@)])])
Zartaj