From: Akim Demaille Date: Mon, 1 Sep 2008 09:39:41 +0000 (+0200) Subject: Compute at M4 time some of the subtractions. X-Git-Tag: v2.7.90~1049 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/3204049e31e71c30d0dddf7cae8738c289dbd104?ds=inline Compute at M4 time some of the subtractions. * data/lalr1.cc (b4_substract): New. (b4_rhs_data): Use it. --- diff --git a/ChangeLog b/ChangeLog index 134e862d..56f39316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-13 Akim Demaille + + Compute at M4 time some of the subtractions. + * data/lalr1.cc (b4_substract): New. + (b4_rhs_data): Use it. + 2008-11-13 Akim Demaille symbol::token. diff --git a/data/lalr1.cc b/data/lalr1.cc index 15a42580..97ba371b 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -18,6 +18,15 @@ m4_include(b4_pkgdatadir/[c++.m4]) +# b4_subtract(LHS, RHS) +# --------------------- +# Evaluate LHS - RHS if they are integer literals, otherwise expand +# to (LHS) - (RHS). +m4_define([b4_subtract], +[m4_bmatch([$1$2], [^[0123456789]*$], + [m4_eval([$1 - $2])], + [($1) - ($2)])]) + # b4_args(ARG1, ...) # _b4_args(ARG1, ...) @@ -107,7 +116,7 @@ m4_define([b4_lhs_location], # Return the data corresponding to the symbol #NUM, where the current # rule has RULE-LENGTH symbols on RHS. m4_define([b4_rhs_data], - [yystack_@{($1) - ($2)@}]) + [yystack_@{b4_subtract($@)@}]) # b4_rhs_state(RULE-LENGTH, NUM)