* tests/local.at (m4_rpatsubst): New.
Use it to handle %parse-params.
* tests/calc.at: Use %parse-params with several arguments.
---
 tests/calc.at  | 27 ++++++++++++++-------------
 tests/local.at | 22 +++++++++++++++++++---
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/tests/calc.at b/tests/calc.at
index 0cd6db82..4af06afc 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -772,9 +772,10 @@ AT_CHECK_CALC_LALR([%define parse.error verbose %debug 
%locations %defines %defi
 AT_CHECK_CALC_LALR([%define api.pure full %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
 AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define 
parse.error verbose %debug %locations %defines %define api.prefix {calc} 
%verbose %yacc])
 
-AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug 
%locations %defines %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug 
%locations %defines %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result}{int *count}])
+
+AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose 
%debug %locations %defines %define api.prefix {calc} %verbose %yacc 
%parse-param {semantic_value *result}{int *count}])
 
-AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose 
%debug %locations %defines %define api.prefix {calc} %verbose %yacc 
%parse-param {semantic_value *result} %parse-param {int *count}])
 
 # ----------------------- #
 # Simple GLR Calculator.  #
@@ -812,10 +813,10 @@ AT_CHECK_CALC_GLR([%define parse.error verbose %debug 
%locations %defines %defin
 
 AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
 
-AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
-AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc %parse-param 
{semantic_value *result}{int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug 
%locations %defines %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result}{int *count}])
 
-AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose 
%debug %locations %defines %define api.prefix {calc} %verbose %yacc 
%parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose 
%debug %locations %defines %define api.prefix {calc} %verbose %yacc 
%parse-param {semantic_value *result}{int *count}])
 
 
 # ----------------------------- #
@@ -846,10 +847,10 @@ AT_CHECK_CALC_LALR1_CC([%locations %define parse.error 
verbose %debug %name-pref
 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define 
api.prefix {calc} %verbose %yacc])
 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define 
api.prefix {calc} %define api.token.prefix {TOK_} %verbose %yacc])
 
-AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}{int 
*count}])
 
-AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix 
{calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int 
*count}])
-AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug 
%define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix 
{calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}])
+AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug 
%define api.prefix {calc} %verbose %yacc %parse-param {semantic_value 
*result}{int *count}])
 
 AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file none])
 AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file 
"my-location.hh"])
@@ -884,10 +885,10 @@ AT_CHECK_CALC_GLR_CC([%debug])
 AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" 
%verbose %yacc])
 AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" 
%define api.token.prefix {TOK_} %verbose %yacc])
 
-AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
-AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug 
%define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} 
%parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug 
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}{int 
*count}])
+AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug 
%define api.prefix {calc} %verbose %yacc %parse-param {semantic_value 
*result}{int *count}])
 
-AT_CHECK_CALC_GLR_CC([%no-lines %locations %defines %define parse.error 
verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%no-lines %locations %defines %define parse.error 
verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param 
{semantic_value *result}{int *count}])
 
 
 # --------------------------- #
@@ -916,8 +917,8 @@ AT_CHECK_CALC_LALR1_D([%debug])
 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %verbose])
 #AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %define 
api.token.prefix {TOK_} %verbose])
 
-#AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %verbose 
%parse-param {semantic_value *result} %parse-param {int *count}])
-#AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %define 
api.prefix {calc} %verbose %parse-param {semantic_value *result} %parse-param 
{int *count}])
+#AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %verbose 
%parse-param {semantic_value *result}{int *count}])
+#AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %define 
api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}])
 
 m4_popdef([AT_CALC_MAIN])
 m4_popdef([AT_CALC_YYLEX])
diff --git a/tests/local.at b/tests/local.at
index f49f4733..58317f10 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -30,6 +30,18 @@ m4_define([m4_null_if],
          [$3])])
 
 
+# m4_rpatsubst(STRING, PATTERN, REPLACEMENT)
+# ------------------------------------------
+# As long as PATTERN matches STRING, replace occurrences of PATTERN by
+# REPLACEMENT.
+#
+# Contrary to m4_bpatsubst, matches PATTERN from previous replacements.
+m4_define([m4_rpatsubst],
+[m4_if(m4_bregexp([$1], [$2]),
+       [-1], [$1],
+       [m4_rpatsubst(m4_quote(m4_bpatsubst([$1], [$2], [$3])), [$2], [$3])])])
+
+
 # AT_SETUP_STRIP(TITLE)
 # ---------------------
 # Abbreviate the TITLE to be passed to AT_SETUP.  Remove new-lines
@@ -226,12 +238,16 @@ m4_pushdef([AT_LOCATION_TYPE_SPAN_IF],
 [m4_bmatch([$3], [%define \(api\.location\.type\|location_type\) \{Span\}], 
[$1], [$2])])
 m4_pushdef([AT_PARAM_IF],
 [m4_bmatch([$3], [%parse-param], [$1], [$2])])
+
 # Comma-terminated list of formals parse-parameters.
 # E.g., %parse-param { int x } %parse-param {int y} -> "int x, int y, ".
-# FIXME: Support grouped parse-param.
 m4_pushdef([AT_PARSE_PARAMS])
-m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}],
-             [m4_append([AT_PARSE_PARAMS], [\1, ])])
+m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}{ *\([^{}]*[^{} ]\) *}{ 
*\([^{}]*[^{} ]\) *}],
+             [m4_append([AT_PARSE_PARAMS], [\1, \2, \3, ])])
+m4_bpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}{ *\([^{}]*[^{} ]\) 
*}\([^{].*\)?$],
+             [m4_append([AT_PARSE_PARAMS], [\1, \2, ])])
+m4_rpatsubst([$3], [%parse-param { *\([^{}]*[^{} ]\) *}\([^{}].*\)?$],
+             [m4_append([AT_PARSE_PARAMS], [\1, ])\2])
 
 m4_pushdef([AT_PURE_IF],
 [m4_bmatch([$3], [%define  *api\.pure\|%pure-parser],
-- 
2.24.1


Reply via email to