]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
* data/glr.c (yy_reduce_print): Fix the $ number.
[bison.git] / data / c.m4
index 5285fcdcc6c08476d8606cf9d0ca54862685154d..1b521c283fbe99471e505dc970558d30f49b694a 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -95,7 +95,26 @@ m4_define_default([b4_parse_param])
 m4_define([b4_parse_param],
 b4_parse_param))
 
+# b4_parse_param_for(DECL, FORMAL, BODY)
+# ---------------------------------------
+# Iterate over the user parameters, binding the declaration to DECL,
+# the formal name to FORMAL, and evaluating the BODY.
+m4_define([b4_parse_param_for],
+[m4_foreach([$1_$2], m4_defn([b4_parse_param]),
+[m4_pushdef([$1], m4_fst($1_$2))dnl
+m4_pushdef([$2], m4_shift($1_$2))dnl
+$3[]dnl
+m4_popdef([$2])dnl
+m4_popdef([$1])dnl
+])])
 
+# b4_parse_param_use
+# ------------------
+# `YYUSE' all the parse-params.
+m4_define([b4_parse_param_use],
+[b4_parse_param_for([Decl], [Formal], [  YYUSE (Formal);
+])dnl
+])
 
 ## ------------ ##
 ## Data Types.  ##
@@ -342,7 +361,6 @@ m4_define([b4_c_arg],
 ## Synclines.  ##
 ## ----------- ##
 
-
 # b4_syncline(LINE, FILE)
 # -----------------------
 m4_define([b4_syncline],
@@ -350,6 +368,11 @@ m4_define([b4_syncline],
        [[#]line $1 $2])])
 
 
+
+## -------------- ##
+## User actions.  ##
+## -------------- ##
+
 # b4_symbol_actions(FILENAME, LINENO,
 #                   SYMBOL-TAG, SYMBOL-NUM,
 #                   SYMBOL-ACTION, SYMBOL-TYPENAME)
@@ -382,12 +405,15 @@ m4_define_default([b4_yydestruct_generate],
     [static void],
     [[const char *yymsg],    [yymsg]],
     [[int yytype],           [yytype]],
-    [[YYSTYPE *yyvaluep],    [yyvaluep]]b4_location_if([,
-    [[YYLTYPE *yylocationp], [yylocationp]]]))[
+    [[YYSTYPE *yyvaluep],    [yyvaluep]][]dnl
+b4_location_if(            [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
+m4_ifset([b4_parse_param], [, b4_parse_param]))[
 {
   YYUSE (yyvaluep);
 ]b4_location_if([  YYUSE (yylocationp);
-])[
+])dnl
+b4_parse_param_use[]dnl
+[
   if (!yymsg)
     yymsg = "Deleting";
   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
@@ -414,16 +440,17 @@ m4_define_default([b4_yysymprint_generate],
 
 ]$1([yysymprint],
     [static void],
-    [[FILE *yyoutput],       [yyoutput]],
-    [[int yytype],           [yytype]],
-    [[YYSTYPE *yyvaluep],    [yyvaluep]]b4_location_if([,
-    [[YYLTYPE *yylocationp], [yylocationp]]]))
+               [[FILE *yyoutput],                       [yyoutput]],
+               [[int yytype],                           [yytype]],
+               [[const YYSTYPE * const yyvaluep],       [yyvaluep]][]dnl
+b4_location_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl
+m4_ifset([b4_parse_param], [, b4_parse_param]))[
 {
   YYUSE (yyvaluep);
-b4_location_if([  YYUSE (yylocationp);
+]b4_location_if([  YYUSE (yylocationp);
 ])dnl
-[
-  if (yytype < YYNTOKENS)
+b4_parse_param_use[]dnl
+[  if (yytype < YYNTOKENS)
     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
   else
     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
@@ -443,5 +470,5 @@ b4_location_if([  YYUSE (yylocationp);
         break;
     }
   YYFPRINTF (yyoutput, ")");
-}
-]])
+}]dnl
+])