[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Follow-up on: [PATCH] - UPDATED fix for variadic declaration of yyerror(
From: |
Jeannot Langlois |
Subject: |
Follow-up on: [PATCH] - UPDATED fix for variadic declaration of yyerror() and yylex() function prototypes |
Date: |
Sat, 08 Oct 2005 10:30:28 -0400 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
Hi Paul, Hi Akim,
In June of this year I have contributed to Bison by sending a patch
(that would add the necessary m4 macros and C code to deal with the
yyerror prototypes generation) as described below. However, I recently
downloaded the sources of Bison 2.1 and didn't spot any of the hunks I
had contributed in the new sources.
Could the patch have not been applied to Bison-2.0a when I last sent it?
In any case, I have reattached the patch (for bison-2.0a):
yylex_yyerror_autogeneration_20050619.diff
In case the patch was not applied, let me know why and if I need to
generate a new patch for Bison-2.1.
What could have happened?
Thanks,
Hi Paul,
Hi Akim,
Since I didn't get any feedback yet from the posting I have made to
the mailing list about the problems I have encountered with older
version of my development tools corrupting the testsuite (and the fact
that I'll be away for a few days), here's my newest patch anyways.
Please disregard (or revert from the bison-2.0a tree, if necessary)
the previous patch I had posted (yylex_yyerror_autogeneration.diff)
and use this new one: yylex_yyerror_autogeneration_20050619.diff.
This latest patch:
1) takes care of generating the proper function prototypes
declarations for yyerror() and yylex().
2) modifies the proper .at files so the generated testsuite passes all
testcases properly.
The attached patch should be applied within Bison-2.0a's base
directory using "patch -p0 < yylex_yyerror_autogeneration_20050619.diff".
Regards,
--
*Jeannot Langlois*
B. Sc. Computer Science / B. Sc. Informatique
Software Developer / Programmeur-Analyste
System/Network Administrator / Administrateur Système/Réseau
*jeannot12 AT linuxmail DOT org
*icq : 1-5-2-6-2-8-9-1
msn : jeannot12 AT hotmail DOT com
LINUX_LOGO
diff -u -r data/c.m4 data/c.m4
--- data/c.m4 2005-05-14 02:52:28.000000000 -0400
+++ data/c.m4 2005-06-19 13:39:44.000000000 -0400
@@ -322,6 +322,14 @@
[[#]line $1 $2])])
+# b4_yacc_flag
+# Expand IF-TRUE, if yacc_flag, IF-FALSE otherwise
+# ------------------------------------------------
+m4_define([b4_yyyacc_mode_if],
+[m4_if(b4_yacc_flag, [1], [$1], [$2])]
+)
+
+
# b4_symbol_actions(FILENAME, LINENO,
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
diff -u -r data/glr.c data/glr.c
--- data/glr.c 2005-05-22 01:25:16.000000000 -0400
+++ data/glr.c 2005-06-19 13:39:44.000000000 -0400
@@ -49,6 +49,17 @@
m4_define([b4_user_formals],
[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
+# b4_alt_user_formals
+# -------------------------
+m4_define([b4_alt_user_formals],
+[m4_ifset([b4_parse_param], [b4_c_ansi_formals(b4_parse_param), ])])
+
+# b4_yyerror_params
+# -----------------
+m4_define([b4_yyerror_params],
+[b4_pure_if([b4_location_if([YYLTYPE *yylocationp,
])[]b4_alt_user_formals[]])]dnl
+[const char* yymsg]dnl
+)
# b4_yyerror_args
# ---------------
@@ -412,10 +423,19 @@
]b4_stos[
};
-
+
/* Prevent warning if -Wmissing-prototypes. */
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
+/* Prevent warning if -Wmissing-prototypes. */
+]b4_c_ansi_function_decl([yylex], [int], b4_lex_param)[
+
+/* Prevent warning if -Wmissing-prototypes. */
+]b4_yyyacc_mode_if(
+[]b4_c_function_decl([yyerror], [int], b4_yyerror_params)[],
+[]b4_c_function_decl([yyerror], [void], b4_yyerror_params)[]
+)[
+
/* Error token number */
#define YYTERROR 1
diff -u -r data/yacc.c data/yacc.c
--- data/yacc.c 2005-05-21 13:12:32.000000000 -0400
+++ data/yacc.c 2005-06-19 13:39:44.000000000 -0400
@@ -63,6 +63,15 @@
m4_ifdef([b4_lex_param], b4_lex_param)))
+# b4_yyerror_params
+# ----------------
+m4_define([b4_yyecho_pp], $1)
+
+m4_define([b4_yyerror_params],
+[b4_Pure_if([b4_location_if([YYLTYPE *yylocationp, ])]dnl
+m4_ifset([b4_parse_param], [[m4_map_sep([b4_yyecho_pp], [, ],
m4_dquote(m4_map_sep([b4_yyecho_pp], [, ], m4_dquote(b4_parse_param))))]][[,
]]))]dnl
+[const char* yymsg]dnl
+)
## ------------ ##
## Data Types. ##
@@ -742,6 +751,24 @@
#endif /* ! YYPARSE_PARAM */
+/* Prevent warnings from -Wmissing-prototypes. */
+
+#ifdef YYLEX_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yylex (void *YYLEX_PARAM);
+# else
+int yylex ();
+# endif
+#else
+b4_c_function_decl([yylex], [int], b4_lex_param)
+#endif /* ! YYLEX_PARAM */
+
+/* Prevent warnings from -Wmissing-prototypes. */
+b4_yyyacc_mode_if(
+b4_c_function_decl([yyerror], [int], b4_yyerror_params),
+b4_c_function_decl([yyerror], [void], b4_yyerror_params)
+)
+
m4_divert_push([KILL])# ======================== M4 code.
# b4_declare_parser_variables
# ---------------------------
diff -u -r src/output.c src/output.c
--- src/output.c 2005-05-14 02:52:29.000000000 -0400
+++ src/output.c 2005-06-19 13:39:44.000000000 -0400
@@ -599,6 +599,7 @@
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
MUSCLE_INSERT_BOOL ("pure", pure_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
+ MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
/* File names. */
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");
diff -u -r tests/calc.at tests/calc.at
--- tests/calc.at 2005-05-22 01:06:07.000000000 -0400
+++ tests/calc.at 2005-06-19 15:16:30.000000000 -0400
@@ -72,7 +72,8 @@
[/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
-static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
+static AT_YACCMODE_IF([int], [void])
+yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s
);])[
@@ -144,7 +145,7 @@
return parser.parse ();
}
],
-[static void
+[static AT_YACCMODE_IF([int], [void])
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s)
@@ -161,6 +162,7 @@
AT_LOC.last_column - 1);
fprintf (stderr, ": ");])
fprintf (stderr, "%s\n", s);
+ AT_YACCMODE_IF([return 0;], [])
}])[
diff -u -r tests/cxx-type.at tests/cxx-type.at
--- tests/cxx-type.at 2005-05-14 02:52:29.000000000 -0400
+++ tests/cxx-type.at 2005-06-19 15:18:06.000000000 -0400
@@ -55,7 +55,7 @@
# define ERROR_PARAMETERS char const *s
#endif
int yylex (LEX_PARAMETERS);
- int yyerror (ERROR_PARAMETERS);
+ ]AT_YACCMODE_IF([int], [void])[ yyerror (ERROR_PARAMETERS);
%}
%token TYPENAME ID
@@ -188,7 +188,7 @@
}
}
-int
+]AT_YACCMODE_IF([int], [void])[
yyerror (ERROR_PARAMETERS)
{
#if YYPURE && YYLSP_NEEDED
@@ -197,7 +197,7 @@
abort ();
#endif
fprintf (stderr, "%s\n", s);
- return 0;
+ ]AT_YACCMODE_IF([return 0;], [])[
}
diff -u -r tests/glr-regression.at tests/glr-regression.at
--- tests/glr-regression.at 2005-05-22 01:12:23.000000000 -0400
+++ tests/glr-regression.at 2005-06-19 15:18:31.000000000 -0400
@@ -34,7 +34,7 @@
#define YYSTYPE int
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
int yylex (void);
-int yyerror (char const *msg);
+]AT_YACCMODE_IF([int], [void])[ yyerror (char const *msg);
%}
@@ -70,11 +70,11 @@
return yyparse ();
}
-int
+]AT_YACCMODE_IF([int], [void])[
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
- exit (4);
+ ]AT_YACCMODE_IF([exit(4);], [])[
}
diff -u -r tests/local.at tests/local.at
--- tests/local.at 2005-05-14 02:52:29.000000000 -0400
+++ tests/local.at 2005-06-19 14:44:40.000000000 -0400
@@ -45,6 +45,9 @@
[m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])
m4_pushdef([AT_GLR_IF],
[m4_bmatch([$3], [%glr-parser], [$1], [$2])])
+# Using %yacc?
+m4_pushdef([AT_YACCMODE_IF],
+[m4_bmatch([$3], [%yacc], [$1], [$2])])
# Using yacc.c?
m4_pushdef([AT_YACC_IF],
[m4_bmatch([$3], [%glr-parser\|%skeleton], [$2], [$1])])
@@ -121,6 +124,7 @@
m4_popdef([AT_LOCATION_IF])
m4_popdef([AT_PARAM_IF])
m4_popdef([AT_YACC_IF])
+m4_popdef([AT_YACCMODE_IF])
m4_popdef([AT_GLR_IF])
m4_popdef([AT_LALR1_CC_IF])
])# AT_BISON_OPTION_POPDEFS
- Follow-up on: [PATCH] - UPDATED fix for variadic declaration of yyerror() and yylex() function prototypes,
Jeannot Langlois <=