From: Paul Eggert Date: Thu, 16 Dec 2004 20:41:54 +0000 (+0000) Subject: * data/glr.c (b4_lhs_value, b4_rhs_value, b4_rhs-location): X-Git-Tag: BISON-2_0~21 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/bc82c5a5938c88f921dc2ce1f4edb06c4097e966 * data/glr.c (b4_lhs_value, b4_rhs_value, b4_rhs-location): Parenthesize rhs to avoid obscure problems with mistakes like "foo$$bar = foo$1bar;". Problem reported by twlevo at xs4all. * data/lalr1.cc (b4_lhs_value, b4_rhs_value, b4_lhs_location, b4_rhs_location): Likewise. * data/yacc.c (b4_lhs_value, b4_rhs_value, b4_lhs_location, b4_rhs_location): Likewise. --- diff --git a/ChangeLog b/ChangeLog index e256cc54..133b2615 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-12-16 Paul Eggert + + * data/glr.c (b4_lhs_value, b4_rhs_value, b4_rhs-location): + Parenthesize rhs to avoid obscure problems with mistakes like + "foo$$bar = foo$1bar;". Problem reported by twlevo at xs4all. + * data/lalr1.cc (b4_lhs_value, b4_rhs_value, b4_lhs_location, + b4_rhs_location): Likewise. + * data/yacc.c (b4_lhs_value, b4_rhs_value, b4_lhs_location, + b4_rhs_location): Likewise. + 2004-12-16 Akim Demaille * data/lalr1.cc (yyreport_syntax_error_): Catch up with glr.c and diff --git a/data/glr.c b/data/glr.c index 5fef464f..bed15214 100644 --- a/data/glr.c +++ b/data/glr.c @@ -103,7 +103,7 @@ m4_define([b4_lpure_formals], # -------------------- # Expansion of $$. m4_define([b4_lhs_value], -[(*yyvalp)[]m4_ifval([$1], [.$1])]) +[((*yyvalp)[]m4_ifval([$1], [.$1]))]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) @@ -111,7 +111,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[((yyGLRStackItem const *)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], -[((yyGLRStackItem const *)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() diff --git a/data/lalr1.cc b/data/lalr1.cc index 8e82cb51..6a1642bc 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -35,7 +35,7 @@ m4_define_default([b4_parser_class_name], [Parser]) # -------------------- # Expansion of $$. m4_define([b4_lhs_value], -[yyval[]m4_ifval([$1], [.$1])]) +[(yyval[]m4_ifval([$1], [.$1]))]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) @@ -43,7 +43,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3])]) +[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))]) m4_define_default([b4_location_type], [Location]) @@ -51,7 +51,7 @@ m4_define_default([b4_location_type], [Location]) # ----------------- # Expansion of @$. m4_define([b4_lhs_location], -[yyloc]) +[(yyloc)]) # b4_rhs_location(RULE-LENGTH, NUM) @@ -59,7 +59,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[yylocation_stack_@{m4_eval([$1 - $2])@}]) +[(yylocation_stack_@{m4_eval([$1 - $2])@})]) # b4_parse_param_decl diff --git a/data/yacc.c b/data/yacc.c index 7331b65c..5d9b8bd1 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -93,7 +93,7 @@ m4_define([b4_int_type], # -------------------- # Expansion of $$. m4_define([b4_lhs_value], -[yyval[]m4_ifval([$1], [.$1])]) +[(yyval[]m4_ifval([$1], [.$1]))]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) @@ -101,7 +101,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3])]) +[(yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3]))]) @@ -113,7 +113,7 @@ m4_define([b4_rhs_value], # ----------------- # Expansion of @$. m4_define([b4_lhs_location], -[yyloc]) +[(yyloc)]) # b4_rhs_location(RULE-LENGTH, NUM) @@ -121,7 +121,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[yylsp@{m4_eval([$2 - $1])@}]) +[(yylsp@{m4_eval([$2 - $1])@})])