mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
yacc.c: support "%define api.pure full"
This makes the interface for yyerror() pure without the need for a spurious parse_param. * data/yacc.c (b4_pure_if, b4_pure_flag): New definition, accept three states. (b4_yacc_pure_if): Rename as... (b4_yyerror_arg_loc_if): This, and use b4_pure_flag. * tests/actions.at (%define api.pure): Modernize. * test/calc.at (Simple LALR Calculator): Modernize. * tests/local.at (AT_YYERROR_ARG_LOC_IF): Adjust.
This commit is contained in:
34
data/yacc.c
34
data/yacc.c
@@ -65,24 +65,36 @@ m4_define_default([b4_stack_depth_init], [200])
|
||||
## ------------------------ ##
|
||||
|
||||
b4_percent_define_default([[api.pure]], [[false]])
|
||||
b4_define_flag_if([pure])
|
||||
m4_define([b4_pure_flag],
|
||||
[b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])
|
||||
b4_percent_define_check_values([[[[api.pure]],
|
||||
[[false]], [[true]], [[]], [[full]]]])
|
||||
|
||||
# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
|
||||
# ----------------------------------
|
||||
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
|
||||
m4_define([b4_yacc_pure_if],
|
||||
[b4_pure_if([m4_ifset([b4_parse_param],
|
||||
[$1], [$2])],
|
||||
[$2])])
|
||||
m4_define([b4_pure_flag], [[0]])
|
||||
m4_case(b4_percent_define_get([[api.pure]]),
|
||||
[false], [m4_define([b4_pure_flag], [[0]])],
|
||||
[true], [m4_define([b4_pure_flag], [[1]])],
|
||||
[], [m4_define([b4_pure_flag], [[1]])],
|
||||
[full], [m4_define([b4_pure_flag], [[2]])])
|
||||
|
||||
m4_define([b4_pure_if],
|
||||
[m4_case(b4_pure_flag,
|
||||
[0], [$2],
|
||||
[1], [$1],
|
||||
[2], [$1])])
|
||||
[m4_fatal([invalid api.pure value: ]$1)])])
|
||||
|
||||
# b4_yyerror_arg_loc_if(ARG)
|
||||
# --------------------------
|
||||
# Expand ARG iff yyerror is to be given a location as argument.
|
||||
m4_define([b4_yyerror_arg_loc_if],
|
||||
[b4_locations_if([m4_case(b4_pure_flag,
|
||||
[1], [m4_ifset([b4_parse_param], [$1])],
|
||||
[2], [$1])])])
|
||||
|
||||
# b4_yyerror_args
|
||||
# ---------------
|
||||
# Arguments passed to yyerror: user args plus yylloc.
|
||||
m4_define([b4_yyerror_args],
|
||||
[b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl
|
||||
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
|
||||
m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user