From: Akim Demaille Date: Fri, 21 Nov 2008 20:41:47 +0000 (+0100) Subject: b4_args is more general than only C++. X-Git-Tag: v2.7.90~1002 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/e0c653e7e660c353c59b054de571474450aa4c92 b4_args is more general than only C++. * data/lalr1.cc (b4_args, _b4_args): Move to... * data/bison.m4: here. --- diff --git a/ChangeLog b/ChangeLog index 7b3358ca..31560f1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-25 Akim Demaille + + b4_args is more general than only C++. + * data/lalr1.cc (b4_args, _b4_args): Move to... + * data/bison.m4: here. + 2008-11-21 Di-an Jan Implement no-XXX arguments for --warnings, --report, --trace. diff --git a/data/bison.m4 b/data/bison.m4 index c7392b38..e7376c6c 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -221,6 +221,29 @@ m4_define([b4_subtract], [m4_eval([$1 - $2])], [($1) - ($2)])]) +# b4_args(ARG1, ...) +# _b4_args(ARG1, ...) +# ------------------- +# Join with comma, skipping empty arguments. +# b4_args calls itself recursively until it sees the first non-empty +# argument, then calls _b4_args which prepends each non-empty argument +# with a comma. +m4_define([b4_args], +[m4_if([$#$1], + [1], [], + [m4_ifval([$1], + [$1[]_$0(m4_shift($@))], + [$0(m4_shift($@))])])]) + +# _b4_args(ARGS1, ...) +# -------------------- +m4_define([_b4_args], +[m4_if([$#$1], + [1], [], + [m4_ifval([$1], [, $1])[]$0(m4_shift($@))])]) + + + ## ------------------ ## ## Decoding options. ## diff --git a/data/lalr1.cc b/data/lalr1.cc index 58ebe94c..40430905 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -18,27 +18,6 @@ m4_include(b4_pkgdatadir/[c++.m4]) -# b4_args(ARG1, ...) -# _b4_args(ARG1, ...) -# ------------------- -# Join with comma, skipping empty arguments. -# b4_args calls itself recursively until it sees the first non-empty -# argument, then calls _b4_args which prepends each non-empty argument -# with a comma. -m4_define([b4_args], -[m4_if([$#$1], - [1], [], - [m4_ifval([$1], - [$1[]_$0(m4_shift($@))], - [$0(m4_shift($@))])])]) - -# _b4_args(ARGS1, ...) -# -------------------- -m4_define([_b4_args], -[m4_if([$#$1], - [1], [], - [m4_ifval([$1], [, $1])[]$0(m4_shift($@))])]) - # b4_table_define(TABLE-NAME, CONTENT) # ------------------------------------