Skip to content

Commit 4afabeb

Browse files
committed
yacc.c: push: undefine the pstate macros for the epilogue
* data/skeletons/yacc.c (b4_macro_define, b4_macro_undef) (b4_pstate_macro_define, b4_parse_state_variable_macros): New. Use them. * examples/c/bistromathic/parse.y: Remove now useless undefs.
1 parent a7a93f9 commit 4afabeb

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

data/skeletons/yacc.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,38 @@ m4_define([b4_initialize_parser_state_variables],
241241
]])
242242

243243

244+
m4_define([b4_macro_define],
245+
[[#]define $1 $2])
246+
247+
m4_define([b4_macro_undef],
248+
[[#]undef $1])
249+
250+
m4_define([b4_pstate_macro_define],
251+
[b4_macro_define([$1], [yyps->$1])])
252+
253+
# b4_parse_state_variable_macros(b4_macro_define|b4_macro_undef)
254+
# --------------------------------------------------------------
255+
m4_define([b4_parse_state_variable_macros],
256+
[b4_pure_if([$1([b4_prefix[]nerrs])])
257+
$1([yystate])
258+
$1([yyerrstatus])
259+
$1([yyssa])
260+
$1([yyss])
261+
$1([yyssp])
262+
$1([yyvsa])
263+
$1([yyvs])
264+
$1([yyvsp])[]b4_locations_if([
265+
$1([yylsa])
266+
$1([yyls])
267+
$1([yylsp])
268+
$1([yyerror_range])])
269+
$1([yystacksize])[]b4_lac_if([
270+
$1([yyesa])
271+
$1([yyes])
272+
$1([yyes_capacity])])])
273+
274+
275+
244276

245277
# _b4_declare_yyparse_push
246278
# ------------------------
@@ -1447,23 +1479,7 @@ yypull_parse (yypstate *yyps]b4_user_formals[)
14471479
return yystatus;
14481480
}]])[
14491481

1450-
]b4_pure_if([[#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
1451-
#define yystate yyps->yystate
1452-
#define yyerrstatus yyps->yyerrstatus
1453-
#define yyssa yyps->yyssa
1454-
#define yyss yyps->yyss
1455-
#define yyssp yyps->yyssp
1456-
#define yyvsa yyps->yyvsa
1457-
#define yyvs yyps->yyvs
1458-
#define yyvsp yyps->yyvsp]b4_locations_if([[
1459-
#define yylsa yyps->yylsa
1460-
#define yyls yyps->yyls
1461-
#define yylsp yyps->yylsp
1462-
#define yyerror_range yyps->yyerror_range]])[
1463-
#define yystacksize yyps->yystacksize]b4_lac_if([[
1464-
#define yyesa yyps->yyesa
1465-
#define yyes yyps->yyes
1466-
#define yyes_capacity yyps->yyes_capacity]])[
1482+
]b4_parse_state_variable_macros([b4_pstate_macro_define])[
14671483

14681484
/* Initialize the parser data structure. */
14691485
void
@@ -2064,6 +2080,7 @@ yypushreturn:]])[
20642080
YYSTACK_FREE (yymsg);]])[
20652081
return yyresult;
20662082
}
2083+
]b4_push_if([b4_parse_state_variable_macros([b4_macro_undef])])[
20672084
]b4_percent_code_get([[epilogue]])[]dnl
20682085
b4_epilogue[]dnl
20692086
b4_output_end

examples/c/bistromathic/parse.y

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ exp:
139139
// End of grammar.
140140
%%
141141

142-
#undef yyssp
143-
#undef yyesa
144-
#undef yyes
145-
#undef yyes_capacity
146-
147142
/*------------.
148143
| Functions. |
149144
`------------*/

0 commit comments

Comments
 (0)