From bb3b912b0a43b8b740a05ad1d15686e68f8e3f39 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 5 May 2012 11:30:01 +0200 Subject: [PATCH 01/34] maint: s/strncpy/memcpy/, when equivalent * src/output.c (output_skeleton): Use memcpy, not strncpy, since the source is known to fit in the destination buffer. * src/parse-gram.y (%skeleton): Likewise. --- src/output.c | 2 +- src/parse-gram.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index c481e14e..e0d6ed3a 100644 --- a/src/output.c +++ b/src/output.c @@ -512,7 +512,7 @@ output_skeleton (void) full_skeleton = xmalloc (pkgdatadirlen + 1 + (skeleton_size < sizeof m4sugar ? sizeof m4sugar : skeleton_size)); - strncpy (full_skeleton, pkgdatadir, pkgdatadirlen); + memcpy (full_skeleton, pkgdatadir, pkgdatadirlen); full_skeleton[pkgdatadirlen] = '/'; strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar); full_m4sugar = xstrdup (full_skeleton); diff --git a/src/parse-gram.y b/src/parse-gram.y index 33b802ed..1968e310 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -322,7 +322,7 @@ prologue_declaration: xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); if (dir_length > 0) { - strncpy (skeleton_build, current_file, dir_length); + memcpy (skeleton_build, current_file, dir_length); skeleton_build[dir_length++] = '/'; } strcpy (skeleton_build + dir_length, skeleton_user); From 60457f308d3cbe377472b610aafcb86e194081a4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 3 May 2012 23:01:05 +0200 Subject: [PATCH 02/34] maint: simplify parse-gram.y * src/parse-gram.y (add_param): Use xmemdup0 in place of xmalloc+memcpy, and strspn in place of an open-coded loop. Co-authored-by: Akim Demaille --- src/parse-gram.y | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/parse-gram.y b/src/parse-gram.y index 1968e310..8d745491 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -733,17 +733,7 @@ add_param (char const *type, char *decl, location loc) complain_at (loc, _("missing identifier in parameter declaration")); else { - char *name; - size_t name_len; - - for (name_len = 1; - memchr (alphanum, name_start[name_len], sizeof alphanum); - name_len++) - continue; - - name = xmalloc (name_len + 1); - memcpy (name, name_start, name_len); - name[name_len] = '\0'; + char *name = xmemdup0 (name_start, strspn (name_start, alphanum)); muscle_pair_list_grow (type, decl, name); free (name); } From 9c883a6bb04d0fdfeee9ca7ff2446dfb6dd0fe22 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 3 May 2012 23:07:56 +0200 Subject: [PATCH 03/34] maint: regen src/parse-gram.[ch] --- src/parse-gram.c | 346 ++++++++++++++++++++++++----------------------- src/parse-gram.h | 10 +- 2 files changed, 179 insertions(+), 177 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 9d1427db..85d96e51 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5.66-427a. */ +/* A Bison parser, made by GNU Bison 2.5.118-ae42b. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5.66-427a" +#define YYBISON_VERSION "2.5.118-ae42b" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -169,7 +169,15 @@ current_lhs(symbol *sym, location loc, named_ref *ref) /* Line 268 of yacc.c */ -#line 173 "../../../src/parse-gram.c" +#line 173 "parse-gram.c" + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif /* Enabling traces. */ #ifndef YYDEBUG @@ -319,7 +327,7 @@ current_lhs(symbol *sym, location loc, named_ref *ref) typedef union YYSTYPE { -/* Line 293 of yacc.c */ +/* Line 295 of yacc.c */ #line 113 "parse-gram.y" symbol *symbol; @@ -334,8 +342,8 @@ typedef union YYSTYPE -/* Line 293 of yacc.c */ -#line 339 "../../../src/parse-gram.c" +/* Line 295 of yacc.c */ +#line 347 "parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -359,8 +367,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 343 of yacc.c */ -#line 364 "../../../src/parse-gram.c" +/* Line 345 of yacc.c */ +#line 372 "parse-gram.c" #ifdef short # undef short @@ -707,7 +715,7 @@ static const char *const yytname[] = "generic_symlist_item", "symbol_def", "symbol_defs.1", "grammar", "rules_or_grammar_declaration", "rules", "$@3", "rhses.1", "rhs", "named_ref.opt", "variable", "content.opt", "braceless", "id", - "id_colon", "symbol", "string_as_id", "epilogue.opt", 0 + "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULL }; #endif @@ -1036,6 +1044,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) YYLTYPE const * const yylocationp; #endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; YYUSE (yylocationp); @@ -1049,165 +1059,165 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) { case 3: /* "\"string\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 203 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; -/* Line 821 of yacc.c */ -#line 1058 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1068 "parse-gram.c" break; case 4: /* "\"integer\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 215 "parse-gram.y" { fprintf (stderr, "%d", (yyvaluep->integer)); }; -/* Line 821 of yacc.c */ -#line 1067 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1077 "parse-gram.c" break; case 43: /* "\"{...}\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 205 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; -/* Line 821 of yacc.c */ -#line 1076 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1086 "parse-gram.c" break; case 44: /* "\"[identifier]\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 210 "parse-gram.y" { fprintf (stderr, "[%s]", (yyvaluep->uniqstr)); }; -/* Line 821 of yacc.c */ -#line 1085 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1095 "parse-gram.c" break; case 45: /* "\"char\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 197 "parse-gram.y" { fputs (char_name ((yyvaluep->character)), stderr); }; -/* Line 821 of yacc.c */ -#line 1094 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1104 "parse-gram.c" break; case 46: /* "\"epilogue\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 205 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 821 of yacc.c */ -#line 1103 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1113 "parse-gram.c" break; case 48: /* "\"identifier\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 209 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 821 of yacc.c */ -#line 1112 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1122 "parse-gram.c" break; case 49: /* "\"identifier:\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 211 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; -/* Line 821 of yacc.c */ -#line 1121 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1131 "parse-gram.c" break; case 52: /* "\"%{...%}\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 205 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 821 of yacc.c */ -#line 1130 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1140 "parse-gram.c" break; case 54: /* "\"type\"" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 212 "parse-gram.y" { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; -/* Line 821 of yacc.c */ -#line 1139 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1149 "parse-gram.c" break; case 71: /* "symbol.prec" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 218 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 821 of yacc.c */ -#line 1148 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1158 "parse-gram.c" break; case 84: /* "variable" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 209 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 821 of yacc.c */ -#line 1157 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1167 "parse-gram.c" break; case 85: /* "content.opt" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 205 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 821 of yacc.c */ -#line 1166 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1176 "parse-gram.c" break; case 86: /* "braceless" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 205 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 821 of yacc.c */ -#line 1175 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1185 "parse-gram.c" break; case 87: /* "id" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 218 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 821 of yacc.c */ -#line 1184 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1194 "parse-gram.c" break; case 88: /* "id_colon" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 219 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; -/* Line 821 of yacc.c */ -#line 1193 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1203 "parse-gram.c" break; case 89: /* "symbol" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 218 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 821 of yacc.c */ -#line 1202 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1212 "parse-gram.c" break; case 90: /* "string_as_id" */ -/* Line 821 of yacc.c */ +/* Line 823 of yacc.c */ #line 218 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 821 of yacc.c */ -#line 1211 "../../../src/parse-gram.c" +/* Line 823 of yacc.c */ +#line 1221 "parse-gram.c" break; default: break; @@ -1690,12 +1700,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyesa, yytype_int16 **yyes, YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1753,7 +1763,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1998,7 +2008,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1592 of yacc.c */ +/* Line 1594 of yacc.c */ #line 105 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -2007,8 +2017,8 @@ YYLTYPE yylloc; boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1592 of yacc.c */ -#line 2012 "../../../src/parse-gram.c" +/* Line 1594 of yacc.c */ +#line 2022 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2202,7 +2212,7 @@ yyreduce: { case 6: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 244 "parse-gram.y" { code_props plain_code; @@ -2217,14 +2227,14 @@ yyreduce: case 7: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 253 "parse-gram.y" { debug_flag = true; } break; case 8: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 255 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), @@ -2234,14 +2244,14 @@ yyreduce: case 9: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 259 "parse-gram.y" { defines_flag = true; } break; case 10: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 261 "parse-gram.y" { defines_flag = true; @@ -2251,42 +2261,42 @@ yyreduce: case 11: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 265 "parse-gram.y" { error_verbose = true; } break; case 12: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 266 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 267 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 268 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 269 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 271 "parse-gram.y" { nondeterministic_parser = true; @@ -2296,7 +2306,7 @@ yyreduce: case 17: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 276 "parse-gram.y" { code_props action; @@ -2310,77 +2320,77 @@ yyreduce: case 18: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 284 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 285 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 286 "parse-gram.y" { locations_flag = true; } break; case 21: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 287 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 288 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 289 "parse-gram.y" { no_lines_flag = true; } break; case 24: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 290 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 291 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 292 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 293 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 295 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use @@ -2400,14 +2410,14 @@ yyreduce: case 29: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 309 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 311 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); @@ -2423,7 +2433,7 @@ yyreduce: xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); if (dir_length > 0) { - strncpy (skeleton_build, current_file, dir_length); + memcpy (skeleton_build, current_file, dir_length); skeleton_build[dir_length++] = '/'; } strcpy (skeleton_build + dir_length, skeleton_user); @@ -2436,28 +2446,28 @@ yyreduce: case 31: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 334 "parse-gram.y" { token_table_flag = true; } break; case 32: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 335 "parse-gram.y" { report_flag |= report_states; } break; case 33: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 336 "parse-gram.y" { yacc_flag = true; } break; case 37: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 344 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); @@ -2466,7 +2476,7 @@ yyreduce: case 38: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 348 "parse-gram.y" { symbol_list *list; @@ -2478,7 +2488,7 @@ yyreduce: case 39: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 355 "parse-gram.y" { symbol_list *list; @@ -2490,7 +2500,7 @@ yyreduce: case 40: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 362 "parse-gram.y" { default_prec = true; @@ -2499,7 +2509,7 @@ yyreduce: case 41: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 366 "parse-gram.y" { default_prec = false; @@ -2508,7 +2518,7 @@ yyreduce: case 42: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 370 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes @@ -2520,7 +2530,7 @@ yyreduce: case 43: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 377 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2530,21 +2540,21 @@ yyreduce: case 44: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 391 "parse-gram.y" {} break; case 45: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 392 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 397 "parse-gram.y" { union_seen = true; @@ -2555,14 +2565,14 @@ yyreduce: case 47: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 408 "parse-gram.y" { current_class = nterm_sym; } break; case 48: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 409 "parse-gram.y" { current_class = unknown_sym; @@ -2572,14 +2582,14 @@ yyreduce: case 49: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 413 "parse-gram.y" { current_class = token_sym; } break; case 50: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 414 "parse-gram.y" { current_class = unknown_sym; @@ -2589,7 +2599,7 @@ yyreduce: case 51: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 419 "parse-gram.y" { symbol_list *list; @@ -2602,7 +2612,7 @@ yyreduce: case 52: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 430 "parse-gram.y" { symbol_list *list; @@ -2619,126 +2629,126 @@ yyreduce: case 53: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 444 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 445 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 446 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 450 "parse-gram.y" { current_type = NULL; } break; case 57: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 451 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 457 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 459 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 60: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 463 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 464 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } break; case 62: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 470 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 472 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 64: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 476 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 477 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 66: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 481 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 67: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 482 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 68: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 483 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 484 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 490 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); @@ -2748,7 +2758,7 @@ yyreduce: case 71: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 495 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); @@ -2758,7 +2768,7 @@ yyreduce: case 72: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 500 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2769,7 +2779,7 @@ yyreduce: case 73: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 506 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2780,7 +2790,7 @@ yyreduce: case 74: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 512 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); @@ -2792,7 +2802,7 @@ yyreduce: case 81: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 542 "parse-gram.y" { yyerrok; @@ -2801,14 +2811,14 @@ yyreduce: case 82: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 548 "parse-gram.y" { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); } break; case 83: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 549 "parse-gram.y" { /* Free the current lhs. */ @@ -2818,21 +2828,21 @@ yyreduce: case 84: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 556 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 557 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 563 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } @@ -2840,77 +2850,77 @@ yyreduce: case 88: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 566 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 89: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 568 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 90: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 570 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 572 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 574 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 578 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 580 "parse-gram.y" { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 96: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 592 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 597 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 598 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 609 "parse-gram.y" { code_props plain_code; @@ -2924,14 +2934,14 @@ yyreduce: case 101: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 629 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 631 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); @@ -2942,14 +2952,14 @@ yyreduce: case 103: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 639 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 651 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); @@ -2959,7 +2969,7 @@ yyreduce: case 108: -/* Line 1808 of yacc.c */ +/* Line 1810 of yacc.c */ #line 660 "parse-gram.y" { code_props plain_code; @@ -2973,8 +2983,8 @@ yyreduce: -/* Line 1808 of yacc.c */ -#line 2978 "../../../src/parse-gram.c" +/* Line 1810 of yacc.c */ +#line 2988 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3223,7 +3233,7 @@ yyreturn: -/* Line 2069 of yacc.c */ +/* Line 2071 of yacc.c */ #line 670 "parse-gram.y" @@ -3291,16 +3301,8 @@ add_param (char const *type, char *decl, location loc) complain_at (loc, _("missing identifier in parameter declaration")); else { - char *name; - size_t name_len; - - for (name_len = 1; - memchr (alphanum, name_start[name_len], sizeof alphanum); - name_len++) - continue; - - name = xmalloc (name_len + 1); - memcpy (name, name_start, name_len); + size_t name_len = strspn (name_start, alphanum); + char *name = xmemdup (name_start, name_len + 1); name[name_len] = '\0'; muscle_pair_list_grow (type, decl, name); free (name); diff --git a/src/parse-gram.h b/src/parse-gram.h index bad02455..06a37dd8 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5.66-427a. */ +/* A Bison parser, made by GNU Bison 2.5.118-ae42b. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -160,7 +160,7 @@ typedef union YYSTYPE { -/* Line 2070 of yacc.c */ +/* Line 2072 of yacc.c */ #line 113 "parse-gram.y" symbol *symbol; @@ -175,8 +175,8 @@ typedef union YYSTYPE -/* Line 2070 of yacc.c */ -#line 180 "../../../src/parse-gram.h" +/* Line 2072 of yacc.c */ +#line 180 "parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ From 355e5a7255e1959825a273ef0733226fa1189f3e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 09:37:10 +0200 Subject: [PATCH 04/34] build: AC_PROG_LEX: use more readable variable names. * m4/flex.m4 (AC_PROG_LEX): Prefer LEX_IS_FLEX to FLEX. Prefer true/false to yes/no for such variables. * configure.ac: Adjust. --- configure.ac | 4 +--- m4/flex.m4 | 14 ++++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 704f5aaa..3c3fa421 100644 --- a/configure.ac +++ b/configure.ac @@ -114,9 +114,7 @@ AC_SUBST([YACC_LIBRARY]) # Checks for programs. AC_PROG_LEX -if test "$FLEX" != yes; then - AC_MSG_ERROR([Flex is required]) -fi +$LEX_IS_FLEX || AC_MSG_ERROR([Flex is required]) AC_PROG_YACC AC_PROG_RANLIB AC_PROG_GNU_M4 diff --git a/m4/flex.m4 b/m4/flex.m4 index 2073a0dc..984c5143 100644 --- a/m4/flex.m4 +++ b/m4/flex.m4 @@ -1,4 +1,4 @@ -# flex.m4 serial 1 +# flex.m4 serial 2 # Copyright (C) 2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -24,7 +24,7 @@ fi]) # and whether Lex declares yytext as a char * by default. m4_define([_AC_PROG_LEX_YYTEXT_DECL], [AC_CACHE_CHECK([whether lex is flex], - [ac_cv_prog_flex], + [ac_cv_prog_lex_is_flex], [cat >conftest.l <<_ACEOF[ %option debug nodefault noinput nounput noyywrap never-interactive %x SC_CONF_TEST @@ -32,15 +32,13 @@ m4_define([_AC_PROG_LEX_YYTEXT_DECL], a { BEGIN SC_CONF_TEST; } ]_ACEOF if _AC_DO_VAR([LEX conftest.l]); then - ac_cv_prog_flex=yes + ac_cv_prog_lex_is_flex=yes else - ac_cv_prog_flex=no + ac_cv_prog_lex_is_flex=no fi ]) -FLEX= -if test $ac_cv_prog_flex = yes; then - AC_SUBST([FLEX], [yes])dnl -fi +AC_SUBST([LEX_IS_FLEX], + [`test "$ac_cv_prog_lex_is_flex" = yes && echo true || echo false`])dnl cat >conftest.l <<_ACEOF[ %% From 47dcfd5a5c87b3f61fde4d30ba2a582e8500dce0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 09:43:43 +0200 Subject: [PATCH 05/34] maint: ignore files imported by autopoint. * m4/.gitignore: here. --- m4/.gitignore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/m4/.gitignore b/m4/.gitignore index 90e5ae15..9291b691 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -38,6 +38,7 @@ /getdtablesize.m4 /getopt.m4 /gettext.m4 +/glibc2.m4 /glibc21.m4 /gnulib-cache.m4 /gnulib-common.m4 @@ -47,7 +48,11 @@ /iconv.m4 /include_next.m4 /inline.m4 +/intdiv0.m4 +/intl.m4 +/intldir.m4 /intlmacosx.m4 +/intmax.m4 /intmax_t.m4 /inttypes-pri.m4 /inttypes.m4 @@ -61,6 +66,7 @@ /javacomp.m4 /javaexec.m4 /largefile.m4 +/lcmessage.m4 /ldexp.m4 /ldexpl.m4 /lib-ld.m4 @@ -71,6 +77,7 @@ /locale-fr.m4 /locale-ja.m4 /locale-zh.m4 +/lock.m4 /longlong.m4 /malloc.m4 /math_h.m4 @@ -145,13 +152,16 @@ /sys_socket_h.m4 /sys_stat_h.m4 /sys_wait_h.m4 +/sysexits.m4 /threadlib.m4 /time_h.m4 +/uintmax_t.m4 /unistd-safer.m4 /unistd_h.m4 /unlocked-io.m4 /vasnprintf.m4 /vfprintf-posix.m4 +/visibility.m4 /vsnprintf-posix.m4 /vsnprintf.m4 /vsprintf-posix.m4 @@ -167,4 +177,3 @@ /xalloc.m4 /xsize.m4 /xstrndup.m4 -/sysexits.m4 From 85557aa1cb8e518650beaa4fb5a9e44cd02f24db Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 10:04:47 +0200 Subject: [PATCH 06/34] maint: remove left-over gnulib modules. * bootstrap.conf (gnulib_modules): Remove pipe-posix. * lib/.gitignore, m4/.gitignore: Remove files that we no longer use. --- bootstrap.conf | 2 +- lib/.gitignore | 51 +++++++++++++++++++++++++------------------------- m4/.gitignore | 1 - 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 2dbcb057..e1fd5484 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -22,7 +22,7 @@ gnulib_modules=' gettext git-version-gen gitlog-to-changelog gpl-3.0 hash inttypes isnan javacomp-script javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr - mbswidth obstack perror pipe-posix progname + mbswidth obstack perror progname quote quotearg realloc-posix spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp unistd unistd-safer unlocked-io update-copyright unsetenv verify diff --git a/lib/.gitignore b/lib/.gitignore index c1c7c06c..43f26284 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -22,6 +22,7 @@ /c-ctype.h /c-strcase.h /c-strcasecmp.c +/c-strcaseeq.h /c-strncasecmp.c /calloc.c /charset.alias @@ -29,7 +30,11 @@ /cloexec.h /close-hook.c /close-hook.h +/close-stream.c +/close-stream.h /close.c +/closeout.c +/closeout.h /config.charset /config.h /config.hin @@ -53,19 +58,25 @@ /fcntl.c /fcntl.h /fcntl.in.h +/fd-hook.c +/fd-hook.h /fd-safer-flag.c /fd-safer.c /float+.h +/float.c /float.h /float.in.h /fopen-safer.c /fopen.c +/fpending.c +/fpending.h /fprintf.c /fpucw.h /frexp.c /frexpl.c /fseterr.c /fseterr.h +/fstat.c /getdtablesize.c /getopt.c /getopt.h @@ -88,6 +99,7 @@ /isnanl-nolibm.h /isnanl.c /iswblank.c +/itold.c /ldexpl.c /localcharset.c /localcharset.h @@ -105,14 +117,18 @@ /mbuiter.h /memchr.c /memchr.valgrind +/msvc-inval.c +/msvc-inval.h +/msvc-nothrow.c +/msvc-nothrow.h /nonblocking.c /nonblocking.h /obstack.c /obstack.h /open.c +/pathmax.h /perror.c /pipe-safer.c -/pipe.c /pipe2-safer.c /pipe2.c /printf-args.c @@ -124,10 +140,13 @@ /printf-parse.c /printf-parse.h /printf.c +/progname.c +/progname.h /quote.c /quote.h /quotearg.c /quotearg.h +/raise.c /rawmemchr.c /rawmemchr.valgrind /realloc.c @@ -185,7 +204,10 @@ /strchrnul.valgrind /strdup.c /streq.h +/strerror-override.c +/strerror-override.h /strerror.c +/strerror_r.c /string.h /string.in.h /stripslash.c @@ -205,6 +227,7 @@ /sys_stat.in.h /sys_wait.h /sys_wait.in.h +/sysexits.in.h /time.h /time.in.h /unistd--.h @@ -236,33 +259,9 @@ /wctype.in.h /wcwidth.c /xalloc-die.c +/xalloc-oversized.h /xalloc.h /xmalloc.c /xsize.h /xstrndup.c /xstrndup.h -/c-strcaseeq.h -/fd-hook.c -/fd-hook.h -/float.c -/fstat.c -/itold.c -/msvc-inval.c -/msvc-inval.h -/msvc-nothrow.c -/msvc-nothrow.h -/pathmax.h -/raise.c -/strerror-override.c -/strerror-override.h -/strerror_r.c -/xalloc-oversized.h -/close-stream.c -/close-stream.h -/closeout.c -/closeout.h -/fpending.c -/fpending.h -/sysexits.in.h -/progname.c -/progname.h diff --git a/m4/.gitignore b/m4/.gitignore index 9291b691..8f413605 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -98,7 +98,6 @@ /open.m4 /pathmax.m4 /perror.m4 -/pipe.m4 /pipe2.m4 /po.m4 /posix_spawn.m4 From e54ec80c0c163e7a9e24fc2eee6c42a61cbe4316 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 10:20:43 +0200 Subject: [PATCH 07/34] maint: import the xmemdup0 gnulib module. * bootstrap.conf: Require this module. * src/parse-gram.y: Include xmemdup0.h. --- bootstrap.conf | 3 ++- lib/.gitignore | 2 ++ src/parse-gram.y | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index e1fd5484..3303ef37 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -26,7 +26,8 @@ gnulib_modules=' quote quotearg realloc-posix spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp unistd unistd-safer unlocked-io update-copyright unsetenv verify - warnings xalloc xalloc-die xstrndup + warnings + xalloc xalloc-die xmemdup0 xstrndup fprintf-posix printf-posix snprintf-posix sprintf-posix vsnprintf-posix vsprintf-posix diff --git a/lib/.gitignore b/lib/.gitignore index 43f26284..915a29b6 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -265,3 +265,5 @@ /xsize.h /xstrndup.c /xstrndup.h +/xmemdup0.c +/xmemdup0.h diff --git a/src/parse-gram.y b/src/parse-gram.y index 8d745491..eb034b08 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -32,6 +32,7 @@ #include "symlist.h" #include "scan-gram.h" #include "scan-code.h" +#include "xmemdup0.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); From 45aab21d7764f05b57450d61599fd83fa39ed71e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 10:29:43 +0200 Subject: [PATCH 08/34] maint: regen. * src/parse-gram.c, src/parse-gram.h: Regen. --- src/parse-gram.c | 295 +++++++++++++++++++++++------------------------ src/parse-gram.h | 4 +- 2 files changed, 149 insertions(+), 150 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 85d96e51..81da5160 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.118-ae42b. */ +/* A Bison parser, made by GNU Bison 2.5.127-8555-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5.118-ae42b" +#define YYBISON_VERSION "2.5.127-8555-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -109,6 +109,7 @@ #include "symlist.h" #include "scan-gram.h" #include "scan-code.h" +#include "xmemdup0.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); @@ -169,7 +170,7 @@ current_lhs(symbol *sym, location loc, named_ref *ref) /* Line 268 of yacc.c */ -#line 173 "parse-gram.c" +#line 174 "parse-gram.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -328,7 +329,7 @@ typedef union YYSTYPE { /* Line 295 of yacc.c */ -#line 113 "parse-gram.y" +#line 114 "parse-gram.y" symbol *symbol; symbol_list *list; @@ -343,7 +344,7 @@ typedef union YYSTYPE /* Line 295 of yacc.c */ -#line 347 "parse-gram.c" +#line 348 "parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -368,7 +369,7 @@ typedef struct YYLTYPE /* Line 345 of yacc.c */ -#line 372 "parse-gram.c" +#line 373 "parse-gram.c" #ifdef short # undef short @@ -675,17 +676,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 228, 228, 236, 238, 242, 243, 253, 254, 259, - 260, 265, 266, 267, 268, 269, 270, 275, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 309, - 310, 334, 335, 336, 337, 341, 342, 343, 347, 354, - 361, 365, 369, 376, 391, 392, 396, 408, 408, 413, - 413, 418, 429, 444, 445, 446, 450, 451, 456, 458, - 463, 464, 469, 471, 476, 477, 481, 482, 483, 484, - 489, 494, 499, 505, 511, 522, 523, 532, 533, 539, - 540, 541, 548, 548, 556, 557, 558, 563, 565, 567, - 569, 571, 573, 578, 580, 591, 592, 597, 598, 599, - 608, 628, 630, 639, 644, 645, 650, 657, 659 + 0, 229, 229, 237, 239, 243, 244, 254, 255, 260, + 261, 266, 267, 268, 269, 270, 271, 276, 285, 286, + 287, 288, 289, 290, 291, 292, 293, 294, 295, 310, + 311, 335, 336, 337, 338, 342, 343, 344, 348, 355, + 362, 366, 370, 377, 392, 393, 397, 409, 409, 414, + 414, 419, 430, 445, 446, 447, 451, 452, 457, 459, + 464, 465, 470, 472, 477, 478, 482, 483, 484, 485, + 490, 495, 500, 506, 512, 523, 524, 533, 534, 540, + 541, 542, 549, 549, 557, 558, 559, 564, 566, 568, + 570, 572, 574, 579, 581, 592, 593, 598, 599, 600, + 609, 629, 631, 640, 645, 646, 651, 658, 660 }; #endif @@ -1060,164 +1061,164 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) case 3: /* "\"string\"" */ /* Line 823 of yacc.c */ -#line 203 "parse-gram.y" +#line 204 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; /* Line 823 of yacc.c */ -#line 1068 "parse-gram.c" +#line 1069 "parse-gram.c" break; case 4: /* "\"integer\"" */ /* Line 823 of yacc.c */ -#line 215 "parse-gram.y" +#line 216 "parse-gram.y" { fprintf (stderr, "%d", (yyvaluep->integer)); }; /* Line 823 of yacc.c */ -#line 1077 "parse-gram.c" +#line 1078 "parse-gram.c" break; case 43: /* "\"{...}\"" */ /* Line 823 of yacc.c */ -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; /* Line 823 of yacc.c */ -#line 1086 "parse-gram.c" +#line 1087 "parse-gram.c" break; case 44: /* "\"[identifier]\"" */ /* Line 823 of yacc.c */ -#line 210 "parse-gram.y" +#line 211 "parse-gram.y" { fprintf (stderr, "[%s]", (yyvaluep->uniqstr)); }; /* Line 823 of yacc.c */ -#line 1095 "parse-gram.c" +#line 1096 "parse-gram.c" break; case 45: /* "\"char\"" */ /* Line 823 of yacc.c */ -#line 197 "parse-gram.y" +#line 198 "parse-gram.y" { fputs (char_name ((yyvaluep->character)), stderr); }; /* Line 823 of yacc.c */ -#line 1104 "parse-gram.c" +#line 1105 "parse-gram.c" break; case 46: /* "\"epilogue\"" */ /* Line 823 of yacc.c */ -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; /* Line 823 of yacc.c */ -#line 1113 "parse-gram.c" +#line 1114 "parse-gram.c" break; case 48: /* "\"identifier\"" */ /* Line 823 of yacc.c */ -#line 209 "parse-gram.y" +#line 210 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; /* Line 823 of yacc.c */ -#line 1122 "parse-gram.c" +#line 1123 "parse-gram.c" break; case 49: /* "\"identifier:\"" */ /* Line 823 of yacc.c */ -#line 211 "parse-gram.y" +#line 212 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; /* Line 823 of yacc.c */ -#line 1131 "parse-gram.c" +#line 1132 "parse-gram.c" break; case 52: /* "\"%{...%}\"" */ /* Line 823 of yacc.c */ -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; /* Line 823 of yacc.c */ -#line 1140 "parse-gram.c" +#line 1141 "parse-gram.c" break; case 54: /* "\"type\"" */ /* Line 823 of yacc.c */ -#line 212 "parse-gram.y" +#line 213 "parse-gram.y" { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; /* Line 823 of yacc.c */ -#line 1149 "parse-gram.c" +#line 1150 "parse-gram.c" break; case 71: /* "symbol.prec" */ /* Line 823 of yacc.c */ -#line 218 "parse-gram.y" +#line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; /* Line 823 of yacc.c */ -#line 1158 "parse-gram.c" +#line 1159 "parse-gram.c" break; case 84: /* "variable" */ /* Line 823 of yacc.c */ -#line 209 "parse-gram.y" +#line 210 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; /* Line 823 of yacc.c */ -#line 1167 "parse-gram.c" +#line 1168 "parse-gram.c" break; case 85: /* "content.opt" */ /* Line 823 of yacc.c */ -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; /* Line 823 of yacc.c */ -#line 1176 "parse-gram.c" +#line 1177 "parse-gram.c" break; case 86: /* "braceless" */ /* Line 823 of yacc.c */ -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; /* Line 823 of yacc.c */ -#line 1185 "parse-gram.c" +#line 1186 "parse-gram.c" break; case 87: /* "id" */ /* Line 823 of yacc.c */ -#line 218 "parse-gram.y" +#line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; /* Line 823 of yacc.c */ -#line 1194 "parse-gram.c" +#line 1195 "parse-gram.c" break; case 88: /* "id_colon" */ /* Line 823 of yacc.c */ -#line 219 "parse-gram.y" +#line 220 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; /* Line 823 of yacc.c */ -#line 1203 "parse-gram.c" +#line 1204 "parse-gram.c" break; case 89: /* "symbol" */ /* Line 823 of yacc.c */ -#line 218 "parse-gram.y" +#line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; /* Line 823 of yacc.c */ -#line 1212 "parse-gram.c" +#line 1213 "parse-gram.c" break; case 90: /* "string_as_id" */ /* Line 823 of yacc.c */ -#line 218 "parse-gram.y" +#line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; /* Line 823 of yacc.c */ -#line 1221 "parse-gram.c" +#line 1222 "parse-gram.c" break; default: break; @@ -2009,7 +2010,7 @@ YYLTYPE yylloc; /* User initialization code. */ /* Line 1594 of yacc.c */ -#line 105 "parse-gram.y" +#line 106 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default location is needed. */ @@ -2018,7 +2019,7 @@ YYLTYPE yylloc; } /* Line 1594 of yacc.c */ -#line 2022 "parse-gram.c" +#line 2023 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2213,7 +2214,7 @@ yyreduce: case 6: /* Line 1810 of yacc.c */ -#line 244 "parse-gram.y" +#line 245 "parse-gram.y" { code_props plain_code; code_props_plain_init (&plain_code, (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); @@ -2228,14 +2229,14 @@ yyreduce: case 7: /* Line 1810 of yacc.c */ -#line 253 "parse-gram.y" +#line 254 "parse-gram.y" { debug_flag = true; } break; case 8: /* Line 1810 of yacc.c */ -#line 255 "parse-gram.y" +#line 256 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); @@ -2245,14 +2246,14 @@ yyreduce: case 9: /* Line 1810 of yacc.c */ -#line 259 "parse-gram.y" +#line 260 "parse-gram.y" { defines_flag = true; } break; case 10: /* Line 1810 of yacc.c */ -#line 261 "parse-gram.y" +#line 262 "parse-gram.y" { defines_flag = true; spec_defines_file = xstrdup ((yyvsp[(2) - (2)].chars)); @@ -2262,42 +2263,42 @@ yyreduce: case 11: /* Line 1810 of yacc.c */ -#line 265 "parse-gram.y" +#line 266 "parse-gram.y" { error_verbose = true; } break; case 12: /* Line 1810 of yacc.c */ -#line 266 "parse-gram.y" +#line 267 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: /* Line 1810 of yacc.c */ -#line 267 "parse-gram.y" +#line 268 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: /* Line 1810 of yacc.c */ -#line 268 "parse-gram.y" +#line 269 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: /* Line 1810 of yacc.c */ -#line 269 "parse-gram.y" +#line 270 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: /* Line 1810 of yacc.c */ -#line 271 "parse-gram.y" +#line 272 "parse-gram.y" { nondeterministic_parser = true; glr_parser = true; @@ -2307,7 +2308,7 @@ yyreduce: case 17: /* Line 1810 of yacc.c */ -#line 276 "parse-gram.y" +#line 277 "parse-gram.y" { code_props action; code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); @@ -2321,77 +2322,77 @@ yyreduce: case 18: /* Line 1810 of yacc.c */ -#line 284 "parse-gram.y" +#line 285 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: /* Line 1810 of yacc.c */ -#line 285 "parse-gram.y" +#line 286 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: /* Line 1810 of yacc.c */ -#line 286 "parse-gram.y" +#line 287 "parse-gram.y" { locations_flag = true; } break; case 21: /* Line 1810 of yacc.c */ -#line 287 "parse-gram.y" +#line 288 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: /* Line 1810 of yacc.c */ -#line 288 "parse-gram.y" +#line 289 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: /* Line 1810 of yacc.c */ -#line 289 "parse-gram.y" +#line 290 "parse-gram.y" { no_lines_flag = true; } break; case 24: /* Line 1810 of yacc.c */ -#line 290 "parse-gram.y" +#line 291 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: /* Line 1810 of yacc.c */ -#line 291 "parse-gram.y" +#line 292 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: /* Line 1810 of yacc.c */ -#line 292 "parse-gram.y" +#line 293 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: /* Line 1810 of yacc.c */ -#line 293 "parse-gram.y" +#line 294 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: /* Line 1810 of yacc.c */ -#line 295 "parse-gram.y" +#line 296 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use `%define api.pure' in a backward-compatible manner here. First, don't @@ -2411,14 +2412,14 @@ yyreduce: case 29: /* Line 1810 of yacc.c */ -#line 309 "parse-gram.y" +#line 310 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: /* Line 1810 of yacc.c */ -#line 311 "parse-gram.y" +#line 312 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); if (mbschr (skeleton_user, '/')) @@ -2447,28 +2448,28 @@ yyreduce: case 31: /* Line 1810 of yacc.c */ -#line 334 "parse-gram.y" +#line 335 "parse-gram.y" { token_table_flag = true; } break; case 32: /* Line 1810 of yacc.c */ -#line 335 "parse-gram.y" +#line 336 "parse-gram.y" { report_flag |= report_states; } break; case 33: /* Line 1810 of yacc.c */ -#line 336 "parse-gram.y" +#line 337 "parse-gram.y" { yacc_flag = true; } break; case 37: /* Line 1810 of yacc.c */ -#line 344 "parse-gram.y" +#line 345 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } @@ -2477,7 +2478,7 @@ yyreduce: case 38: /* Line 1810 of yacc.c */ -#line 348 "parse-gram.y" +#line 349 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2489,7 +2490,7 @@ yyreduce: case 39: /* Line 1810 of yacc.c */ -#line 355 "parse-gram.y" +#line 356 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2501,7 +2502,7 @@ yyreduce: case 40: /* Line 1810 of yacc.c */ -#line 362 "parse-gram.y" +#line 363 "parse-gram.y" { default_prec = true; } @@ -2510,7 +2511,7 @@ yyreduce: case 41: /* Line 1810 of yacc.c */ -#line 366 "parse-gram.y" +#line 367 "parse-gram.y" { default_prec = false; } @@ -2519,7 +2520,7 @@ yyreduce: case 42: /* Line 1810 of yacc.c */ -#line 370 "parse-gram.y" +#line 371 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ @@ -2531,7 +2532,7 @@ yyreduce: case 43: /* Line 1810 of yacc.c */ -#line 377 "parse-gram.y" +#line 378 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); code_scanner_last_string_free (); @@ -2541,21 +2542,21 @@ yyreduce: case 44: /* Line 1810 of yacc.c */ -#line 391 "parse-gram.y" +#line 392 "parse-gram.y" {} break; case 45: /* Line 1810 of yacc.c */ -#line 392 "parse-gram.y" +#line 393 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: /* Line 1810 of yacc.c */ -#line 397 "parse-gram.y" +#line 398 "parse-gram.y" { union_seen = true; muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2566,14 +2567,14 @@ yyreduce: case 47: /* Line 1810 of yacc.c */ -#line 408 "parse-gram.y" +#line 409 "parse-gram.y" { current_class = nterm_sym; } break; case 48: /* Line 1810 of yacc.c */ -#line 409 "parse-gram.y" +#line 410 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2583,14 +2584,14 @@ yyreduce: case 49: /* Line 1810 of yacc.c */ -#line 413 "parse-gram.y" +#line 414 "parse-gram.y" { current_class = token_sym; } break; case 50: /* Line 1810 of yacc.c */ -#line 414 "parse-gram.y" +#line 415 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2600,7 +2601,7 @@ yyreduce: case 51: /* Line 1810 of yacc.c */ -#line 419 "parse-gram.y" +#line 420 "parse-gram.y" { symbol_list *list; tag_seen = true; @@ -2613,7 +2614,7 @@ yyreduce: case 52: /* Line 1810 of yacc.c */ -#line 430 "parse-gram.y" +#line 431 "parse-gram.y" { symbol_list *list; ++current_prec; @@ -2630,126 +2631,126 @@ yyreduce: case 53: /* Line 1810 of yacc.c */ -#line 444 "parse-gram.y" +#line 445 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: /* Line 1810 of yacc.c */ -#line 445 "parse-gram.y" +#line 446 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: /* Line 1810 of yacc.c */ -#line 446 "parse-gram.y" +#line 447 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: /* Line 1810 of yacc.c */ -#line 450 "parse-gram.y" +#line 451 "parse-gram.y" { current_type = NULL; } break; case 57: /* Line 1810 of yacc.c */ -#line 451 "parse-gram.y" +#line 452 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: /* Line 1810 of yacc.c */ -#line 457 "parse-gram.y" +#line 458 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: /* Line 1810 of yacc.c */ -#line 459 "parse-gram.y" +#line 460 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 60: /* Line 1810 of yacc.c */ -#line 463 "parse-gram.y" +#line 464 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: /* Line 1810 of yacc.c */ -#line 464 "parse-gram.y" +#line 465 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } break; case 62: /* Line 1810 of yacc.c */ -#line 470 "parse-gram.y" +#line 471 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: /* Line 1810 of yacc.c */ -#line 472 "parse-gram.y" +#line 473 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 64: /* Line 1810 of yacc.c */ -#line 476 "parse-gram.y" +#line 477 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: /* Line 1810 of yacc.c */ -#line 477 "parse-gram.y" +#line 478 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 66: /* Line 1810 of yacc.c */ -#line 481 "parse-gram.y" +#line 482 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 67: /* Line 1810 of yacc.c */ -#line 482 "parse-gram.y" +#line 483 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 68: /* Line 1810 of yacc.c */ -#line 483 "parse-gram.y" +#line 484 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: /* Line 1810 of yacc.c */ -#line 484 "parse-gram.y" +#line 485 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: /* Line 1810 of yacc.c */ -#line 490 "parse-gram.y" +#line 491 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; @@ -2759,7 +2760,7 @@ yyreduce: case 71: /* Line 1810 of yacc.c */ -#line 495 "parse-gram.y" +#line 496 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)])); @@ -2769,7 +2770,7 @@ yyreduce: case 72: /* Line 1810 of yacc.c */ -#line 500 "parse-gram.y" +#line 501 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2780,7 +2781,7 @@ yyreduce: case 73: /* Line 1810 of yacc.c */ -#line 506 "parse-gram.y" +#line 507 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2791,7 +2792,7 @@ yyreduce: case 74: /* Line 1810 of yacc.c */ -#line 512 "parse-gram.y" +#line 513 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)])); @@ -2803,7 +2804,7 @@ yyreduce: case 81: /* Line 1810 of yacc.c */ -#line 542 "parse-gram.y" +#line 543 "parse-gram.y" { yyerrok; } @@ -2812,14 +2813,14 @@ yyreduce: case 82: /* Line 1810 of yacc.c */ -#line 548 "parse-gram.y" +#line 549 "parse-gram.y" { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); } break; case 83: /* Line 1810 of yacc.c */ -#line 549 "parse-gram.y" +#line 550 "parse-gram.y" { /* Free the current lhs. */ current_lhs (0, (yylsp[(1) - (4)]), 0); @@ -2829,21 +2830,21 @@ yyreduce: case 84: /* Line 1810 of yacc.c */ -#line 556 "parse-gram.y" +#line 557 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: /* Line 1810 of yacc.c */ -#line 557 "parse-gram.y" +#line 558 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: /* Line 1810 of yacc.c */ -#line 563 "parse-gram.y" +#line 564 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } break; @@ -2851,77 +2852,77 @@ yyreduce: case 88: /* Line 1810 of yacc.c */ -#line 566 "parse-gram.y" +#line 567 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 89: /* Line 1810 of yacc.c */ -#line 568 "parse-gram.y" +#line 569 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 90: /* Line 1810 of yacc.c */ -#line 570 "parse-gram.y" +#line 571 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: /* Line 1810 of yacc.c */ -#line 572 "parse-gram.y" +#line 573 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: /* Line 1810 of yacc.c */ -#line 574 "parse-gram.y" +#line 575 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: /* Line 1810 of yacc.c */ -#line 578 "parse-gram.y" +#line 579 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: /* Line 1810 of yacc.c */ -#line 580 "parse-gram.y" +#line 581 "parse-gram.y" { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 96: /* Line 1810 of yacc.c */ -#line 592 "parse-gram.y" +#line 593 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: /* Line 1810 of yacc.c */ -#line 597 "parse-gram.y" +#line 598 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: /* Line 1810 of yacc.c */ -#line 598 "parse-gram.y" +#line 599 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: /* Line 1810 of yacc.c */ -#line 609 "parse-gram.y" +#line 610 "parse-gram.y" { code_props plain_code; (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n'; @@ -2935,14 +2936,14 @@ yyreduce: case 101: /* Line 1810 of yacc.c */ -#line 629 "parse-gram.y" +#line 630 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: /* Line 1810 of yacc.c */ -#line 631 "parse-gram.y" +#line 632 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2953,14 +2954,14 @@ yyreduce: case 103: /* Line 1810 of yacc.c */ -#line 639 "parse-gram.y" +#line 640 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: /* Line 1810 of yacc.c */ -#line 651 "parse-gram.y" +#line 652 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2970,7 +2971,7 @@ yyreduce: case 108: /* Line 1810 of yacc.c */ -#line 660 "parse-gram.y" +#line 661 "parse-gram.y" { code_props plain_code; code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); @@ -2984,7 +2985,7 @@ yyreduce: /* Line 1810 of yacc.c */ -#line 2988 "parse-gram.c" +#line 2989 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3234,7 +3235,7 @@ yyreturn: /* Line 2071 of yacc.c */ -#line 670 "parse-gram.y" +#line 671 "parse-gram.y" @@ -3301,9 +3302,7 @@ add_param (char const *type, char *decl, location loc) complain_at (loc, _("missing identifier in parameter declaration")); else { - size_t name_len = strspn (name_start, alphanum); - char *name = xmemdup (name_start, name_len + 1); - name[name_len] = '\0'; + char *name = xmemdup0 (name_start, strspn (name_start, alphanum)); muscle_pair_list_grow (type, decl, name); free (name); } diff --git a/src/parse-gram.h b/src/parse-gram.h index 06a37dd8..2f2c75f5 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.118-ae42b. */ +/* A Bison parser, made by GNU Bison 2.5.127-8555-dirty. */ /* Bison interface for Yacc-like parsers in C @@ -161,7 +161,7 @@ typedef union YYSTYPE { /* Line 2072 of yacc.c */ -#line 113 "parse-gram.y" +#line 114 "parse-gram.y" symbol *symbol; symbol_list *list; From db0054f7e6add2be825481bfa2f2dd2bb938aff3 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 6 May 2012 10:29:53 +0200 Subject: [PATCH 09/34] maint: fix the generation of the synclines for bison's parser. * tests/bison.in: Import from master the changes that make this script generate synclines that are independant of the builddir/srcdir user's set up. --- tests/bison.in | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/bison.in b/tests/bison.in index 1ae8ffad..4dfeb791 100644 --- a/tests/bison.in +++ b/tests/bison.in @@ -17,7 +17,39 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +abs_top_srcdir='@abs_top_srcdir@' +abs_top_builddir='@abs_top_builddir@' +: ${PERL=perl} + # Use the shipped files, not those installed. -BISON_PKGDATADIR='@abs_top_srcdir@/data' +BISON_PKGDATADIR=$abs_top_srcdir/data export BISON_PKGDATADIR -exec $PREBISON '@abs_top_builddir@/src/bison' ${1+"$@"} + +$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"} +status=$? + +# As a special dark magic, if we are actually using this wrapper to +# compile Bison's src/parse-gram.y, post-process the synclines to +# avoid dependencies on the user's set up (srcdir vs. builddir). +for i +do + case $i in + */parse-gram.y) + if $PERL --version >/dev/null; then + # We are called by ylwrap which still uses y.tab.*, and + # post-processes the synclines on y.tab.c itself. Don't let it + # do it. Besides, it leaves "parse-gram.y" as the source, + # dropping the src/ part. + $PERL -pi -e 's{"y\.tab\.}{"parse-gram.}g;' \ + -e 's{".*/(parse-gram\.y)"}{"$1"}g;' \ + y.tab.[ch] + fi + ;; + esac +done + +exit $status + +# Local Variables: +# mode: shell-script +# End: From e2eb03d4e9306f8ec5fa15c47c2016409c5fca9d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 8 May 2012 10:17:46 +0200 Subject: [PATCH 10/34] maint: we no longer maintain the ChangeLog. * .gitattributes: No need to merge it. * README-hacking: Update release instructions. --- .gitattributes | 2 +- README-hacking | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.gitattributes b/.gitattributes index e8495d51..8b137891 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -ChangeLog merge=merge-changelog + diff --git a/README-hacking b/README-hacking index 31a036ba..e481da75 100644 --- a/README-hacking +++ b/README-hacking @@ -15,25 +15,16 @@ First, if it is a large change, you must make sure they have signed the appropriate paperwork. Second, be sure to add their name and email address to THANKS. -** If a change fixes a test, mention the test in the ChangeLog entry. +** If a change fixes a test, mention the test in the log entry. ** Bug reports -If somebody reports a new bug, mention his name in the ChangeLog entry +If somebody reports a new bug, mention his name in the log entry and in the test case you write. Put him into THANKS. The correct response to most actual bugs is to write a new test case which demonstrates the bug. Then fix the bug, re-run the test suite, and check everything in. -** You may find it useful to install the git-merge-changelog merge driver: - - http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/git-merge-changelog.c - -When following the generic installation instructions there, keep in mind that -your clone of Bison's git repository already contains appropriate -.gitattributes files, and running Bison's bootstrap script will make the -necessary changes to .git/config. - * Hacking @@ -169,7 +160,7 @@ The autoconf files we use are currently: lib/m4sugar/m4sugar.m4 lib/m4sugar/foreach.m4 -These files don't change very often in autoconf, so it should be +These files don't change very often in Autoconf, so it should be relatively straight-forward to examine the differences in order to decide whether to update. @@ -250,12 +241,13 @@ occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac. The version number, *and* the date of the release (including for betas). -** Update ChangeLog -Should have an entry similar to `Version 1.49b.'. +** Mention the release name in a commit log +Should have an entry similar to `Version 2.3b.'. ** Tag the release -Before Bison will build with the right version number, you must tag the release -in git. Do this after all other changes. The command is similar to: +Before Bison will build with the right version number, you must tag +the release in git. Do this after all other changes. The command is +similar to: git tag -a v2.3b From 0b7fba1335c0c3fde1eab89e265cbcecf20885a8 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 8 May 2012 10:27:34 +0200 Subject: [PATCH 11/34] command line: fix minor leaks. * src/getargs.c (getargs): Free pointers before allocating them new content. --- src/getargs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/getargs.c b/src/getargs.c index 1185e409..3fa2a7af 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -606,13 +606,19 @@ getargs (int argc, char *argv[]) /* Here, the -d and --defines options are differentiated. */ defines_flag = true; if (optarg) - spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_defines_file); + spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'g': graph_flag = true; if (optarg) - spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_graph_file); + spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'h': @@ -649,7 +655,10 @@ getargs (int argc, char *argv[]) case 'x': xml_flag = true; if (optarg) - spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_xml_file); + spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'y': @@ -669,6 +678,7 @@ getargs (int argc, char *argv[]) exit (EXIT_SUCCESS); case REPORT_FILE_OPTION: + free (spec_verbose_file); spec_verbose_file = xstrdup (AS_FILE_NAME (optarg)); break; From 7de42e52bfad5af2dbf15a05909e8734e468580c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 8 May 2012 12:06:49 +0200 Subject: [PATCH 12/34] maint: prefer "commit message" to "log entry". * README-hacking: here. Suggested by Stefano Lattarini. --- README-hacking | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README-hacking b/README-hacking index e481da75..70f346a3 100644 --- a/README-hacking +++ b/README-hacking @@ -15,10 +15,10 @@ First, if it is a large change, you must make sure they have signed the appropriate paperwork. Second, be sure to add their name and email address to THANKS. -** If a change fixes a test, mention the test in the log entry. +** If a change fixes a test, mention the test in the commit message. ** Bug reports -If somebody reports a new bug, mention his name in the log entry +If somebody reports a new bug, mention his name in the commit message and in the test case you write. Put him into THANKS. The correct response to most actual bugs is to write a new test case @@ -241,7 +241,7 @@ occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac. The version number, *and* the date of the release (including for betas). -** Mention the release name in a commit log +** Mention the release name in a commit message Should have an entry similar to `Version 2.3b.'. ** Tag the release @@ -251,7 +251,7 @@ similar to: git tag -a v2.3b -The log message can be simply: +The commit message can be simply: Bison 2.3b From dc584206f9803feea502fe99071c38bb4d00cd60 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 8 May 2012 11:01:18 +0200 Subject: [PATCH 13/34] maint: shush a syntax-check. * cfg.mk: lib/timevar is not planned to be gnulib'ed, as it comes from GCC. --- cfg.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/cfg.mk b/cfg.mk index b21383e7..a208fe9c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -62,6 +62,7 @@ $(call exclude, \ bindtextdomain=^lib/main.c$$ \ program_name=^lib/main.c$$ \ prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \ + prohibit_always-defined_macros+=?|^lib/timevar.c$$ \ prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \ prohibit_always-defined_macros+=?|^tests/regression.at$$ \ prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \ From a0cd287e64e2d53bc5896e0a7c5ad072cb8bf469 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 8 May 2012 12:04:24 +0200 Subject: [PATCH 14/34] maint: maintainer-release-check. * tests/Makefile.am (maintainer-release-check): New. * Makefile.am (MAINTAINER_CHECKS): New. Support maintainer-release-check. * README-hacking: Document it, and syntax-check too. --- Makefile.am | 17 +++++++---------- README-hacking | 6 ++++++ tests/Makefile.am | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index f2b6b207..47c68369 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,16 +30,13 @@ EXTRA_DIST = .prev-version .version \ djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \ djgpp/fnchange.lst djgpp/testsuite.sed -.PHONY: maintainer-check -maintainer-check: - $(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ - -.PHONY: maintainer-push-check -maintainer-push-check: - $(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ - -.PHONY: maintainer-xml-check -maintainer-xml-check: +MAINTAINER_CHECKS = \ + maintainer-check \ + maintainer-push-check \ + maintainer-xml-check \ + maintainer-release-check +.PHONY: $(MAINTAINER_CHECKS) +$(MAINTAINER_CHECKS): $(AM_V_GEN)cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ # See comments in build-aux/git-version-gen. However, we make .version depend diff --git a/README-hacking b/README-hacking index 70f346a3..97c73a80 100644 --- a/README-hacking +++ b/README-hacking @@ -180,6 +180,9 @@ release: - Build with -DGNULIB_POSIXCHECK. It suggests gnulib modules that can fix portability issues. +- Check with `make syntax-check' if there are issues diagnosed by + gnulib. + - run `make maintainer-check' which: - runs `valgrind -q bison' to run Bison under Valgrind. - runs the parsers under Valgrind. @@ -197,6 +200,9 @@ release: Bison's included XSLT style sheets with the output of --report=all and --graph. +- running `make maintainer-release-check' takes care of running + maintainer-check, maintainer-push-check and maintainer-xml-check. + - Change tests/atlocal/CFLAGS to add your preferred options. For instance, `-traditional' to check that the parsers are K&R. Note that it does not make sense for glr.c, which should be ANSI, diff --git a/tests/Makefile.am b/tests/Makefile.am index 7a2139df..e3e46a4f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -100,3 +100,6 @@ maintainer-push-check: .PHONY: maintainer-xml-check maintainer-xml-check: BISON_TEST_XML=1 $(MAKE) $(AM_MAKEFLAGS) maintainer-check + +.PHONY: maintainer-release-check +maintainer-release-check: maintainer-check maintainer-push-check maintainer-xml-check From aebb55eb926ae6374c96c0ed561f7a9dabcc71fe Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 9 Jan 2011 11:06:23 +0100 Subject: [PATCH 15/34] glr.c: reduce variable scopes. * data/glr.c: Where appropriate, fuse variable declarations followed by assignments by variable declarations with a value. Where appropriate, introduce new scopes to limit variable spans. --- data/glr.c | 84 ++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/data/glr.c b/data/glr.c index 97efff4c..5f7aac84 100644 --- a/data/glr.c +++ b/data/glr.c @@ -868,9 +868,8 @@ static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__)); static void yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) { - yyGLRState* s; int i; - s = yyvsp[yylow0].yystate.yypred; + yyGLRState *s = yyvsp[yylow0].yystate.yypred; for (i = yylow0-1; i >= yylow1; i -= 1) { YYASSERT (s->yyresolved); @@ -1198,9 +1197,9 @@ yyexpandGLRStack (yyGLRStack* yystackp) { yyGLRStackItem* yynewItems; yyGLRStackItem* yyp0, *yyp1; - size_t yysize, yynewSize; + size_t yynewSize; size_t yyn; - yysize = yystackp->yynextFree - yystackp->yyitems; + size_t yysize = yystackp->yynextFree - yystackp->yyitems; if (YYMAXDEPTH - YYHEADROOM < yysize) yyMemoryExhausted (yystackp); yynewSize = 2*yysize; @@ -1223,7 +1222,7 @@ yyexpandGLRStack (yyGLRStack* yystackp) YYRELOC (yyp0, yyp1, yys0->yypred, yystate); if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL) yys1->yysemantics.yyfirstVal = - YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); + YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); } else { @@ -1509,8 +1508,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL) { - yyGLRState* yyp, *yysplit = yystackp->yysplitPoint; - yyp = yystackp->yytops.yystates[yyi]; + yyGLRState *yysplit = yystackp->yysplitPoint; + yyGLRState *yyp = yystackp->yytops.yystates[yyi]; while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn) { if (yyp->yylrState == yynewLRState && yyp->yypred == yys) @@ -1623,10 +1622,8 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) } else { - yySemanticOption** yyz0p; - yySemanticOption* yyz1; - yyz0p = &yys0->yysemantics.yyfirstVal; - yyz1 = yys1->yysemantics.yyfirstVal; + yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal; + yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal; while (YYID (yytrue)) { if (yyz1 == *yyz0p || yyz1 == YY_NULL) @@ -1707,14 +1704,9 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, YYSTYPE* yyvalp]b4_locuser_formals[) { yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; - int yynrhs; - int yychar_current; - YYSTYPE yylval_current;]b4_locations_if([ - YYLTYPE yylloc_current;])[ - YYRESULTTAG yyflag; - - yynrhs = yyrhsLength (yyopt->yyrule); - yyflag = yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); + int yynrhs = yyrhsLength (yyopt->yyrule); + YYRESULTTAG yyflag = + yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); if (yyflag != yyok) { yyGLRState *yys; @@ -1727,18 +1719,20 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, if (yynrhs == 0) /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ - yychar_current = yychar; - yylval_current = yylval;]b4_locations_if([ - yylloc_current = yylloc;])[ - yychar = yyopt->yyrawchar; - yylval = yyopt->yyval;]b4_locations_if([ - yylloc = yyopt->yyloc;])[ - yyflag = yyuserAction (yyopt->yyrule, yynrhs, - yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, - yystackp, yyvalp]b4_locuser_args[); - yychar = yychar_current; - yylval = yylval_current;]b4_locations_if([ - yylloc = yylloc_current;])[ + { + int yychar_current = yychar; + YYSTYPE yylval_current = yylval;]b4_locations_if([ + YYLTYPE yylloc_current = yylloc;])[ + yychar = yyopt->yyrawchar; + yylval = yyopt->yyval;]b4_locations_if([ + yylloc = yyopt->yyloc;])[ + yyflag = yyuserAction (yyopt->yyrule, yynrhs, + yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, + yystackp, yyvalp]b4_locuser_args[); + yychar = yychar_current; + yylval = yylval_current;]b4_locations_if([ + yylloc = yylloc_current;])[ + } return yyflag; } @@ -1822,13 +1816,9 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[); if (!yys1->yyresolved) { - yySemanticOption *yyoption; yyGLRStackItem yyrhsloc[1 + YYMAXRHS]; int yynrhs; - int yychar_current; - YYSTYPE yylval_current; - YYLTYPE yylloc_current; - yyoption = yys1->yysemantics.yyfirstVal; + yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal; YYASSERT (yyoption != YY_NULL); yynrhs = yyrhsLength (yyoption->yyrule); if (yynrhs > 0) @@ -1854,16 +1844,18 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, yyGLRState *yyprevious = yyoption->yystate; yyrhsloc[0].yystate.yyloc = yyprevious->yyloc; } - yychar_current = yychar; - yylval_current = yylval; - yylloc_current = yylloc; - yychar = yyoption->yyrawchar; - yylval = yyoption->yyval; - yylloc = yyoption->yyloc; - YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); - yychar = yychar_current; - yylval = yylval_current; - yylloc = yylloc_current; + { + int yychar_current = yychar; + YYSTYPE yylval_current = yylval; + YYLTYPE yylloc_current = yylloc; + yychar = yyoption->yyrawchar; + yylval = yyoption->yyval; + yylloc = yyoption->yyloc; + YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); + yychar = yychar_current; + yylval = yylval_current; + yylloc = yylloc_current; + } } } }]])[ From 08ab0101bdd996270d28e572be15ddf8a4203365 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 9 May 2012 10:14:25 +0200 Subject: [PATCH 16/34] build: move silent rules. * tests/Makefile.am: In the generation of the test suite. --- tests/Makefile.am | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index e3e46a4f..0d70030f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,14 +27,15 @@ MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) ## ------------ ## $(srcdir)/package.m4: $(top_srcdir)/configure - { \ + $(AM_V_GEN) { \ echo '# Signature of the current package.'; \ echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \ echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \ echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \ echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \ echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \ - } >$(srcdir)/package.m4 + } >$@.tmp + $(AM_V_at) mv $@.tmp $@ ## ------------ ## ## Test suite. ## @@ -57,8 +58,8 @@ TESTSUITE = $(srcdir)/testsuite AUTOTEST = $(AUTOM4TE) --language=autotest $(TESTSUITE): $(srcdir)/package.m4 $(TESTSUITE_AT) - $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp - mv $@.tmp $@ + $(AM_V_GEN) $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp + $(AM_V_at) mv $@.tmp $@ atconfig: $(top_builddir)/config.status cd $(top_builddir) && ./config.status tests/$@ From 91fd2b60b66a8a63297bf43850d6709bdcbd74dc Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 9 May 2012 11:00:32 +0200 Subject: [PATCH 17/34] build: config.in.h. Historically we used config.hin (where everybody else used config.h.in) to please DOS. Now that we use gnulib, there are already tons of files with several dots, especially *.in.h. * configure.ac: Rename config.hin as config.in.h. --- configure.ac | 2 +- lib/.gitignore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 3c3fa421..93955685 100644 --- a/configure.ac +++ b/configure.ac @@ -49,7 +49,7 @@ AM_INIT_AUTOMAKE([1.11.1 dist-xz silent-rules] m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]], [gnu], [gnits])) AM_SILENT_RULES([yes]) -AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) +AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h]) # Checks for the compiler. AC_PROG_CC_STDC diff --git a/lib/.gitignore b/lib/.gitignore index 915a29b6..5ba545b7 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -37,7 +37,7 @@ /closeout.h /config.charset /config.h -/config.hin +/config.in.h /configmake.h /dirname-lgpl.c /dirname.c From b2c4c25d4ad3aa6795a527a53ab1e5bb4a9d442c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 9 May 2012 10:13:58 +0200 Subject: [PATCH 18/34] maint: update gnulib. * bootstrap, gnulib: Update. --- bootstrap | 42 ++++++++++++++++++++++++++++++++++++++---- gnulib | 2 +- lib/.gitignore | 1 + m4/.gitignore | 2 ++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/bootstrap b/bootstrap index 16dc15c9..c496d29f 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-04-16.16; # UTC +scriptversion=2012-04-26.13; # UTC # Bootstrap this package from checked-out sources. @@ -36,6 +36,10 @@ nl=' LC_ALL=C export LC_ALL +# Ensure that CDPATH is not set. Otherwise, the output from cd +# would cause trouble in at least one use below. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + local_gl_dir=gl me=$0 @@ -429,6 +433,22 @@ check_versions() { GZIP) ;; # Do not use $GZIP: it contains gzip options. *) eval "app=\${$appvar-$app}" ;; esac + + # Handle the still-experimental Automake-NG programs specially. + # They remain named as the mainstream Automake programs ("automake", + # and "aclocal") to avoid gratuitous incompatibilities with + # pre-existing usages (by, say, autoreconf, or custom autogen.sh + # scripts), but correctly identify themselves (as being part of + # "GNU automake-ng") when asked their version. + case $app in + automake-ng|aclocal-ng) + app=`echo "$app" | sed 's/-ng$//'` + ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || { + echo "$me: Error: '$app' not found or not from Automake-NG" >&2 + ret=1 + continue + } ;; + esac if [ "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved # so we have to rely on $? rather than get_version. @@ -758,9 +778,15 @@ fi # Autoreconf runs aclocal before libtoolize, which causes spurious # warnings if the initial aclocal is confused by the libtoolized # (or worse out-of-date) macro directory. +# libtoolize 1.9b added the --install option; but we support back +# to libtoolize 1.5.22, where the install action was default. if test $use_libtool = 1; then - echo "running: $LIBTOOLIZE --copy --install" - $LIBTOOLIZE --copy --install + install= + case $($LIBTOOLIZE --help) in + *--install*) install=--install ;; + esac + echo "running: $LIBTOOLIZE $install --copy" + $LIBTOOLIZE $install --copy fi version_controlled_file() { @@ -863,7 +889,15 @@ if test $with_gettext = yes; then } ' po/Makevars.template >po/Makevars || exit 1 - cat $GNULIB_SRCDIR/build-aux/po/Makefile.in.in > po/Makefile.in.in || exit 1 + # If the 'gettext' module is in use, grab the latest Makefile.in.in. + # If only the 'gettext-h' module is in use, assume autopoint already + # put the correct version of this file into place. + case $gnulib_modules in + *gettext-h*) ;; + *gettext*) + cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1 + ;; + esac if test -d runtime-po; then # Similarly for runtime-po/Makevars, but not quite the same. diff --git a/gnulib b/gnulib index 1a0e0aef..1f96aa01 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 1a0e0aefd4b1fbef0c6e5d990bc01499fd153a0d +Subproject commit 1f96aa01f72bba8c9a0600280594a1a92bb505fc diff --git a/lib/.gitignore b/lib/.gitignore index 5ba545b7..5eec7430 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -267,3 +267,4 @@ /xstrndup.h /xmemdup0.c /xmemdup0.h +/sys_types.in.h diff --git a/m4/.gitignore b/m4/.gitignore index 8f413605..d47aee02 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -176,3 +176,5 @@ /xalloc.m4 /xsize.m4 /xstrndup.m4 +/off_t.m4 +/sys_types_h.m4 From 7e3510e6dd3baa34fcb985173befdafbbf3569a5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 9 May 2012 11:20:18 +0200 Subject: [PATCH 19/34] build: do not enable c++ warnings on 0 when nullptr is not supported. * configure.ac (WARN_CXXFLAGS): Enable -Wzero-as-null-pointer-constant only when nullptr is supported.. --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 93955685..6a75d7b4 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ if test "$enable_gcc_warnings" = yes; then -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings' warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wstrict-prototypes' - warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant' + warn_cxx='-Wnoexcept' AC_LANG_PUSH([C]) for i in $warn_common $warn_c; do @@ -87,6 +87,8 @@ if test "$enable_gcc_warnings" = yes; then do gl_WARN_ADD([$i], [WARN_CXXFLAGS]) done + gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS], + [AC_LANG_PROGRAM([], [nullptr])]) gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS]) # Warnings for the test suite only. gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST]) From 7f7fdba418c416d106a996c4d88eb9c57146ae75 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 11 May 2012 14:59:29 +0200 Subject: [PATCH 20/34] tests: honor TESTSUITEFLAGS in all the check targets. * tests/Makefile.am (installcheck-local): Simplify. (maintainer-check-posix, maintainer-check-valgrind): Honor $(TESTSUITEFLAGS). --- tests/Makefile.am | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0d70030f..7f5fd167 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -74,22 +74,23 @@ check_SCRIPTS = bison # Run the test suite on the *installed* tree. installcheck-local: - $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS) + $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS) # Be real mean with it. .PHONY: maintainer-check-g++ maintainer-check-g++: $(TESTSUITE) - $(TESTSUITE) --compile-c-with-cxx + $(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx .PHONY: maintainer-check-posix maintainer-check-posix: $(TESTSUITE) - $(TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 + $(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 .PHONY: maintainer-check-valgrind maintainer-check-valgrind: $(TESTSUITE) - test -z '$(VALGRIND)' || \ - VALGRIND_OPTS='--leak-check=full --show-reachable=yes' \ - $(TESTSUITE) PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' + test -z '$(VALGRIND)' || \ + $(TESTSUITE) $(TESTSUITEFLAGS) \ + PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \ + VALGRIND_OPTS='--leak-check=full --show-reachable=yes' .PHONY: maintainer-check maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++ From 5192fd5d508ba4bf1bf4aabb59861f9227e99f09 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 11 May 2012 16:55:30 +0200 Subject: [PATCH 21/34] tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES. Some of our macros play with expout and other Autotest special files, which may break their callers (e.g., currently TESTSUITEFLAGS='248 BISON_TEST_XML=1' fails). There is already some support for this. Expand it to be ready to use it elsewhere. * tests/local.at (AT_RESTORE_SPECIAL_FILES, AT_SAVE_SPECIAL_FILES) (at_save_special_files, at_restore_special_files): New. (AT_BISON_CHECK_NO_XML): Use them. --- tests/local.at | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/tests/local.at b/tests/local.at index 7e88408f..ee451ad5 100644 --- a/tests/local.at +++ b/tests/local.at @@ -37,6 +37,33 @@ printf "$count\n";' $1], [0], [$3 ])]) +# AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES +# ------------------------------------------------ +# Don't interfere with caller's files. +m4_divert_text([PREPARE_TESTS], +[at_save_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak + done +} + +at_restore_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f at-bison-check-$at_save_file.bak || + mv at-bison-check-$at_save_file.bak $at_save_file + done +} +]) + +m4_define([AT_SAVE_SPECIAL_FILES], [at_save_special_files]) +m4_define([AT_RESTORE_SPECIAL_FILES], [at_restore_special_files]) + + + ## ------------------------------- ## ## Macros decoding Bison options. ## ## ------------------------------- ## @@ -283,10 +310,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # are added after the grammar file name, so skip these checks # in that case. if test -z "${POSIXLY_CORRECT+set}"; then - # Don't interfere with caller's files. - if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi - if test -f experr; then mv experr at-bison-check-experr.bak; fi - if test -f expout; then mv expout at-bison-check-expout.bak; fi + ]AT_SAVE_SPECIAL_FILES[ # To avoid expanding it repeatedly, store specified stdout. ]AT_DATA([expout], [$3])[ @@ -338,16 +362,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \ -Werror]], [[0]], [expout])[ - # Restore caller's files. - if test -f at-bison-check-expout.bak; then - mv at-bison-check-expout.bak expout - fi - if test -f at-bison-check-experr.bak; then - mv at-bison-check-experr.bak experr - fi - if test -f at-bison-check-stderr.bak; then - mv at-bison-check-stderr.bak stderr - fi + ]AT_RESTORE_SPECIAL_FILES[ fi ]]) ]) From 035810ed2ef420450f3085ff5596f0ab0c33c850 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 11 May 2012 17:11:09 +0200 Subject: [PATCH 22/34] tests: save/restore Autotest special files when checking XML support. Currently the test 248, "parse-gram.y: LALR = IELR", fails BISON_TEST_XML is set. * tests/local.at (AT_BISON_CHECK_XML): Belt: Save/restore files. * tests/regression.at (parse-gram.y: LALR = IELR): Suspenders: Don't rely on expout. Each one of these changes suffices. --- tests/local.at | 10 ++++++---- tests/regression.at | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/local.at b/tests/local.at index ee451ad5..65e528f9 100644 --- a/tests/local.at +++ b/tests/local.at @@ -373,8 +373,9 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # defined. It doesn't make sense to invoke this macro if Bison is expected to # have a non-zero exit status. m4_define([AT_BISON_CHECK_XML], -[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then - mkdir xml-tests] +[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then] + AT_SAVE_SPECIAL_FILES + [mkdir xml-tests] m4_pushdef([AT_BISON_ARGS], [m4_bpatsubsts([[$1]], [--report(-file)?=[^][ ]*], [], @@ -396,8 +397,9 @@ m4_define([AT_BISON_CHECK_XML], AT_CHECK([[$XSLTPROC \ `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \ xml-tests/test.xml]], [[0]], [expout]) - [rm -rf xml-tests expout -fi]]) + [rm -rf xml-tests expout] + AT_RESTORE_SPECIAL_FILES +[fi]]) # AT_QUELL_VALGRIND # ----------------- diff --git a/tests/regression.at b/tests/regression.at index 584c541b..f5603eae 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -1266,10 +1266,12 @@ AT_SETUP([[parse-gram.y: LALR = IELR]]) # have the same name. [cp $abs_top_srcdir/src/parse-gram.y input.y] AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]]) -[mv input.c expout] +[mv input.c lalr.c] +AT_CAPTURE_FILE([lalr.c]) AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]]) [mv input.c ielr.c] -AT_CHECK([[cat ielr.c]], [[0]], [[expout]]) +AT_CAPTURE_FILE([ielr.c]) +AT_CHECK([[diff lalr.c ielr.c]], [[0]]) AT_CLEANUP From 1ef57c947d095b3874748fffc2b0dcb1a41ad567 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 14 May 2012 14:17:20 +0200 Subject: [PATCH 23/34] Bison 2.5.1_rc1. * NEWS: Update. * src/parse-gram.c, src/parse-gram.h: Regen. --- NEWS | 5 +++-- src/parse-gram.c | 4 ++-- src/parse-gram.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f6cc360a..b56746e6 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,12 @@ Bison News ---------- -* Changes in version 2.5.1 (????-??-??): +* Changes in version 2.5.1_rc1 (2012-05-14): ** Future changes: - The next major release will drop support for K&R C. + The next major release will drop support for generating parsers in + K&R C. ** yacc.c: YYBACKUP works as expected. diff --git a/src/parse-gram.c b/src/parse-gram.c index 81da5160..fe6299b0 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.127-8555-dirty. */ +/* A Bison parser, made by GNU Bison 2.5.1_rc1-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5.127-8555-dirty" +#define YYBISON_VERSION "2.5.1_rc1-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" diff --git a/src/parse-gram.h b/src/parse-gram.h index 2f2c75f5..ab45cad4 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.127-8555-dirty. */ +/* A Bison parser, made by GNU Bison 2.5.1_rc1-dirty. */ /* Bison interface for Yacc-like parsers in C From 7fb72c6e53f25f2d0b10fc9e0b412b8c7cde9101 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 15 May 2012 10:03:48 +0200 Subject: [PATCH 24/34] build: fix ChangeLog generation. * Makefile.am (gen-ChangeLog): Fix for VPATH builds. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 47c68369..eaafcaac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,7 +66,7 @@ update-package-copyright-year: gen_start_date = 2012-01-16 .PHONY: gen-ChangeLog gen-ChangeLog: - $(AM_V_GEN)if test -d .git; then \ + $(AM_V_GEN)if test -d $(srcdir)/.git; then \ $(top_srcdir)/build-aux/gitlog-to-changelog \ --no-cluster \ --amend=$(srcdir)/build-aux/git-log-fix \ From 86b08b49b3b1b9fc27a3c64d8421a6f30c12d942 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 15 May 2012 11:22:34 +0200 Subject: [PATCH 25/34] build: do not prototype flex-generated functions. Some versions of Flex, possibly modified by the distribution package maintainers, have incompatible signatures. Since newer versions of Flex prototype their functions, avoid the conflicts in that case. Reported by Stefano Lattarini. . * src/flex-scanner.h (FLEX_VERSION_GT): New. Use it to issue prototypes for flex-generated functions only for versions up to 2.5.31, in accordance with the comment. See commit dc9701e848f27ae64b6ddcf809580998667d60f2. Use it to define yylex_destroy when needed. --- NEWS | 8 +++++++- src/flex-scanner.h | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index b56746e6..f554b9ff 100644 --- a/NEWS +++ b/NEWS @@ -59,7 +59,13 @@ Bison News format. Incorrect index entries were fixed. Some other errors were fixed. -** Changes to the build system: +** Building bison: + +*** Conflicting prototypes with recent/modified Flex. + + Fixed build problems with the current, unreleased, version of Flex, + and some modified versions of 2.5.35, which have modified function + prototypes. *** Warnings during the build procedure have been eliminated. diff --git a/src/flex-scanner.h b/src/flex-scanner.h index 23a266ac..f27938dc 100644 --- a/src/flex-scanner.h +++ b/src/flex-scanner.h @@ -21,7 +21,20 @@ # error "FLEX_PREFIX not defined" #endif +/* Whether this version of Flex is (strictly) greater than + Major.Minor.Subminor. */ +#define FLEX_VERSION_GT(Major, Minor, Subminor) \ + (defined YY_FLEX_MAJOR_VERSION \ + && (Major < YY_FLEX_MAJOR_VERSION \ + || (Major == YY_FLEX_MAJOR_VERSION \ + && (defined YY_FLEX_MINOR_VERSION \ + && (Minor < YY_FLEX_MINOR_VERSION \ + || (Minor == YY_FLEX_MINOR_VERSION \ + && defined YY_FLEX_SUBMINOR_VERSION \ + && Subminor < YY_FLEX_SUBMINOR_VERSION)))))) + /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ +# if ! FLEX_VERSION_GT (2, 5, 31) int FLEX_PREFIX (get_lineno) (void); FILE *FLEX_PREFIX (get_in) (void); FILE *FLEX_PREFIX (get_out) (void); @@ -33,6 +46,7 @@ void FLEX_PREFIX (set_out) (FILE *); int FLEX_PREFIX (get_debug) (void); void FLEX_PREFIX (set_debug) (int); int FLEX_PREFIX (lex_destroy) (void); +#endif #define last_string FLEX_PREFIX (last_string) @@ -51,12 +65,7 @@ int FLEX_PREFIX (lex_destroy) (void); versions according to the Flex manual) leak memory if yylex_destroy is not invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give an implementation here that at least appears to work with Flex 2.5.4. */ -#if !defined YY_FLEX_MAJOR_VERSION || YY_FLEX_MAJOR_VERSION < 2 \ - || (YY_FLEX_MAJOR_VERSION == 2 \ - && (!defined YY_FLEX_MINOR_VERSION || YY_FLEX_MINOR_VERSION < 5 \ - || (YY_FLEX_MINOR_VERSION == 5 \ - && (!defined YY_FLEX_SUBMINOR_VERSION \ - || YY_FLEX_SUBMINOR_VERSION < 9)))) +#if ! FLEX_VERSION_GT (2, 5, 9) # define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER) #endif From 08f6341c0110fa96fd4f0c31ca3cdad8edbf5258 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 15 May 2012 17:15:59 +0200 Subject: [PATCH 26/34] space changes. * src/flex-scanner.h: Indent nested cpp directives. --- src/flex-scanner.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flex-scanner.h b/src/flex-scanner.h index f27938dc..99798411 100644 --- a/src/flex-scanner.h +++ b/src/flex-scanner.h @@ -82,16 +82,16 @@ int FLEX_PREFIX (lex_destroy) (void); static struct obstack obstack_for_string; -#define STRING_GROW \ +# define STRING_GROW \ obstack_grow (&obstack_for_string, yytext, yyleng) -#define STRING_FINISH \ +# define STRING_FINISH \ do { \ obstack_1grow (&obstack_for_string, '\0'); \ last_string = obstack_finish (&obstack_for_string); \ } while (0) -#define STRING_FREE \ +# define STRING_FREE \ obstack_free (&obstack_for_string, last_string) #endif From e4ab12542b8819c7333377c3fd16f2bd6329b572 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 21 May 2012 15:52:17 +0200 Subject: [PATCH 27/34] news: convert to double quotes. * NEWS: Convert from `quoted' to "quoted". Reported by Stefano Lattarini. http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00039.html --- NEWS | 275 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 137 insertions(+), 138 deletions(-) diff --git a/NEWS b/NEWS index f554b9ff..27c4974a 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,7 @@ Bison News ** Future changes: - The next major release will drop support for generating parsers in - K&R C. + The next major release will drop support for generating parsers in K&R C. ** yacc.c: YYBACKUP works as expected. @@ -14,29 +13,29 @@ Bison News *** Location support is eliminated when not requested: - GLR parsers used to include location-related code even when - locations were not requested, and therefore not even usable. + GLR parsers used to include location-related code even when locations were + not requested, and therefore not even usable. *** __attribute__ is preserved: - __attribute__ is no longer disabled when __STRICT_ANSI__ is defined - (i.e., when -std is passed to GCC). + __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e., + when -std is passed to GCC). ** lalr1.java: several fixes: - The Java parser no longer throws ArrayIndexOutOfBoundsException if - the first token leads to a syntax error. Some minor clean ups. + The Java parser no longer throws ArrayIndexOutOfBoundsException if the + first token leads to a syntax error. Some minor clean ups. ** C++11 compatibility: - C and C++ parsers use nullptr instead of 0 when __cplusplus is - 201103L or higher. + C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L + or higher. ** C++ locations: - The position and location constructors (and their initialize - methods) accept new arguments for line and column. Several issues - in the documentation were fixed. + The position and location constructors (and their initialize methods) + accept new arguments for line and column. Several issues in the + documentation were fixed. ** liby is no longer asking for "rpl_fprintf" on some platforms. @@ -44,41 +43,37 @@ Bison News *** %printer is documented - The %printer directive, supported since at least Bison 1.50, is - finally documented. The %mfcalc example is extended to demonstrate - its use of printer. + The "%printer" directive, supported since at least Bison 1.50, is finally + documented. The "mfcalc" example is extended to demonstrate it. - The C++ parsers now also support yyoutput (as an alias to - debug_stream ()) for consistency with the C skeletons. + For consistency with the C skeletons, the C++ parsers now also support + "yyoutput" (as an alias to "debug_stream ()"). *** Several improvements have been made: - The layout for grammar excerpts was changed to a more compact - scheme. Named references are motivated. The description of the - automaton description file (*.output) is updated to the current - format. Incorrect index entries were fixed. Some other errors were - fixed. + The layout for grammar excerpts was changed to a more compact scheme. + Named references are motivated. The description of the automaton + description file (*.output) is updated to the current format. Incorrect + index entries were fixed. Some other errors were fixed. ** Building bison: *** Conflicting prototypes with recent/modified Flex. - Fixed build problems with the current, unreleased, version of Flex, - and some modified versions of 2.5.35, which have modified function - prototypes. + Fixed build problems with the current, unreleased, version of Flex, and + some modified versions of 2.5.35, which have modified function prototypes. *** Warnings during the build procedure have been eliminated. *** Several portability problems in the test suite have been fixed: - This includes warnings with some compilers, unexpected behavior of - tools such as diff, warning messages from the test suite itself, - etc. + This includes warnings with some compilers, unexpected behavior of tools + such as diff, warning messages from the test suite itself, etc. *** The install-pdf target work properly: - Running "make install-pdf" (or -dvi, -html, -info, and -ps) no - longer halts in the middle of its course. + Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer + halts in the middle of its course. * Changes in version 2.5 (2011-05-14): @@ -137,8 +132,8 @@ Bison News %define lr.type canonical-lr The default-reduction optimization in the parser tables can also be - adjusted using `%define lr.default-reductions'. For details on both - of these features, see the new section `Tuning LR' in the Bison + adjusted using "%define lr.default-reductions". For details on both + of these features, see the new section "Tuning LR" in the Bison manual. These features are experimental. More user feedback will help to @@ -154,7 +149,7 @@ Bison News cause error recovery to begin in a different syntactic context than the one in which the invalid token was encountered. Second, when verbose error messages are enabled (with %error-verbose or the - obsolete `#define YYERROR_VERBOSE'), the expected token list in the + obsolete "#define YYERROR_VERBOSE"), the expected token list in the syntax error message can both contain invalid tokens and omit valid tokens. @@ -179,7 +174,7 @@ Bison News %define parse.lac full - See the new section `LAC' in the Bison manual for additional + See the new section "LAC" in the Bison manual for additional details including a few caveats. LAC is an experimental feature. More user feedback will help to @@ -204,7 +199,7 @@ Bison News except that the manner in which Bison processes multiple definitions for the same NAME differs. Most importantly, -F and --force-define quietly override %define, but -D and --define do not. For further - details, see the section `Bison Options' in the Bison manual. + details, see the section "Bison Options" in the Bison manual. *** Variables renamed: @@ -262,8 +257,8 @@ Bison News Similarly to the C parsers, the C++ parsers now define the YYRHSLOC macro and use it in the default YYLLOC_DEFAULT. You are encouraged - to use it. If, for instance, your location structure has `first' - and `last' members, instead of + to use it. If, for instance, your location structure has "first" + and "last" members, instead of # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ @@ -334,7 +329,7 @@ Bison News ** Verbose syntax error message fixes: - When %error-verbose or the obsolete `#define YYERROR_VERBOSE' is + When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is specified, syntax error messages produced by the generated parser include the unexpected token as well as a list of expected tokens. The effect of %nonassoc on these verbose messages has been corrected @@ -345,7 +340,7 @@ Bison News in order to detect a syntax error. Because no unexpected token or expected tokens can then be reported, the verbose syntax error message described above is suppressed, and the parser instead - reports the simpler message, `syntax error'. Previously, this + reports the simpler message, "syntax error". Previously, this suppression was sometimes erroneously triggered by %nonassoc when a lookahead was actually required. Now verbose messages are suppressed only when all previous lookaheads have already been @@ -381,7 +376,7 @@ Bison News ** -W/--warnings fixes: -*** Bison now properly recognizes the `no-' versions of categories: +*** Bison now properly recognizes the "no-" versions of categories: For example, given the following command line, Bison now enables all warnings except warnings for incompatibilities with POSIX Yacc: @@ -392,7 +387,7 @@ Bison News Previously, conflict reports were independent of Bison's normal warning system. Now, Bison recognizes the warning categories - `conflicts-sr' and `conflicts-rr'. This change has important + "conflicts-sr" and "conflicts-rr". This change has important consequences for the -W and --warnings command-line options. For example: @@ -406,16 +401,16 @@ Bison News expected number of conflicts is not reported, so -W and --warning then have no effect on the conflict report. -*** The `none' category no longer disables a preceding `error': +*** The "none" category no longer disables a preceding "error": For example, for the following command line, Bison now reports errors instead of warnings for incompatibilities with POSIX Yacc: bison -Werror,none,yacc gram.y -*** The `none' category now disables all Bison warnings: +*** The "none" category now disables all Bison warnings: - Previously, the `none' category disabled only Bison warnings for + Previously, the "none" category disabled only Bison warnings for which there existed a specific -W/--warning category. However, given the following command line, Bison is now guaranteed to suppress all warnings: @@ -460,7 +455,7 @@ Bison News errors should no longer cause M4 to report a broken pipe on the affected platforms. -** `%prec IDENTIFIER' requires IDENTIFIER to be defined separately. +** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately. POSIX specifies that an error be reported for any identifier that does not appear on the LHS of a grammar rule and that is not defined by @@ -515,7 +510,7 @@ Bison News that YYFAIL will automatically invoke yyerror to report the syntax error so that you don't have to. However, there are several other subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from - inherent flaws when %error-verbose or `#define YYERROR_VERBOSE' is + inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is used. For a more detailed discussion, see: http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html @@ -526,7 +521,7 @@ Bison News Bison features compatible with it. Thus, during parser generation, Bison 2.5 will produce a warning whenever it discovers YYFAIL in a rule action. In a later release, YYFAIL will be disabled for - %error-verbose and `#define YYERROR_VERBOSE'. Eventually, YYFAIL will + %error-verbose and "#define YYERROR_VERBOSE". Eventually, YYFAIL will be removed altogether. There exists at least one case where Bison 2.5's YYFAIL warning will @@ -534,7 +529,7 @@ Bison News Bison-defined macros for the sole purpose of suppressing C preprocessor warnings (from GCC cpp's -Wunused-macros, for example). To avoid Bison's future warning, such YYFAIL uses can be moved to the - epilogue (that is, after the second `%%') in the Bison input file. In + epilogue (that is, after the second "%%") in the Bison input file. In this release (2.4.2), Bison already generates its own code to suppress C preprocessor warnings for YYFAIL, so projects can remove their own phony uses of YYFAIL if compatibility with Bison releases prior to @@ -562,7 +557,7 @@ Bison News exp: exp "+" exp { $$ = $1 + $3; }; - Some grammars still depend on this `feature'. Bison 2.4.1 restores + Some grammars still depend on this "feature". Bison 2.4.1 restores the previous behavior in the case of C output (specifically, when neither %language or %skeleton or equivalent command-line options are used) to leave more time for grammars depending on the old @@ -593,7 +588,7 @@ Bison News %define NAME "VALUE" -** The directive `%pure-parser' is now deprecated in favor of: +** The directive "%pure-parser" is now deprecated in favor of: %define api.pure @@ -603,15 +598,15 @@ Bison News ** Push Parsing Bison can now generate an LALR(1) parser in C with a push interface. That - is, instead of invoking `yyparse', which pulls tokens from `yylex', you can - push one token at a time to the parser using `yypush_parse', which will + is, instead of invoking "yyparse", which pulls tokens from "yylex", you can + push one token at a time to the parser using "yypush_parse", which will return to the caller after processing each token. By default, the push interface is disabled. Either of the following directives will enable it: %define api.push_pull "push" // Just push; does not require yylex. %define api.push_pull "both" // Push and pull; requires yylex. - See the new section `A Push Parser' in the Bison manual for details. + See the new section "A Push Parser" in the Bison manual for details. The current push parsing interface is experimental and may evolve. More user feedback will help to stabilize it. @@ -623,10 +618,10 @@ Bison News ** Java Bison can now generate an LALR(1) parser in Java. The skeleton is - `data/lalr1.java'. Consider using the new %language directive instead of + "data/lalr1.java". Consider using the new %language directive instead of %skeleton to select it. - See the new section `Java Parsers' in the Bison manual for details. + See the new section "Java Parsers" in the Bison manual for details. The current Java interface is experimental and may evolve. More user feedback will help to stabilize it. @@ -641,7 +636,7 @@ Bison News ** XML Automaton Report Bison can now generate an XML report of the LALR(1) automaton using the new - `--xml' option. The current XML schema is experimental and may evolve. More + "--xml" option. The current XML schema is experimental and may evolve. More user feedback will help to stabilize it. ** The grammar file may now specify the name of the parser header file using @@ -673,31 +668,31 @@ Bison News %define lr.keep_unreachable_states - See the %define entry in the `Bison Declaration Summary' in the Bison manual + See the %define entry in the "Bison Declaration Summary" in the Bison manual for further discussion. -** Lookahead Set Correction in the `.output' Report +** Lookahead Set Correction in the ".output" Report - When instructed to generate a `.output' file including lookahead sets - (using `--report=lookahead', for example), Bison now prints each reduction's + When instructed to generate a ".output" file including lookahead sets + (using "--report=lookahead", for example), Bison now prints each reduction's lookahead set only next to the associated state's one item that (1) is associated with the same rule as the reduction and (2) has its dot at the end of its RHS. Previously, Bison also erroneously printed the lookahead set next to all of the state's other items associated with the same rule. This - bug affected only the `.output' file and not the generated parser source + bug affected only the ".output" file and not the generated parser source code. -** --report-file=FILE is a new option to override the default `.output' file +** --report-file=FILE is a new option to override the default ".output" file name. -** The `=' that used to be required in the following directives is now +** The "=" that used to be required in the following directives is now deprecated: %file-prefix "parser" %name-prefix "c_" %output "parser.c" -** An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}' +** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}" Bison 2.3a provided a new set of directives as a more flexible alternative to the traditional Yacc prologue blocks. Those have now been consolidated into @@ -705,14 +700,14 @@ Bison News the purpose of the code and thus the location(s) where Bison should generate it: - 1. `%code {CODE}' replaces `%after-header {CODE}' - 2. `%code requires {CODE}' replaces `%start-header {CODE}' - 3. `%code provides {CODE}' replaces `%end-header {CODE}' - 4. `%code top {CODE}' replaces `%before-header {CODE}' + 1. "%code {CODE}" replaces "%after-header {CODE}" + 2. "%code requires {CODE}" replaces "%start-header {CODE}" + 3. "%code provides {CODE}" replaces "%end-header {CODE}" + 4. "%code top {CODE}" replaces "%before-header {CODE}" - See the %code entries in section `Bison Declaration Summary' in the Bison - manual for a summary of the new functionality. See the new section `Prologue - Alternatives' for a detailed discussion including the advantages of %code + See the %code entries in section "Bison Declaration Summary" in the Bison + manual for a summary of the new functionality. See the new section "Prologue + Alternatives" for a detailed discussion including the advantages of %code over the traditional Yacc prologues. The prologue alternatives are experimental. More user feedback will help to @@ -735,24 +730,24 @@ Bison News sometimes prove to be false alarms in existing grammars employing the Yacc constructs $0 or $-N (where N is some positive integer). - To enable these warnings, specify the option `--warnings=midrule-values' or - `-W', which is a synonym for `--warnings=all'. + To enable these warnings, specify the option "--warnings=midrule-values" or + "-W", which is a synonym for "--warnings=all". -** Default %destructor or %printer with `<*>' or `<>' +** Default %destructor or %printer with "<*>" or "<>" Bison now recognizes two separate kinds of default %destructor's and %printer's: - 1. Place `<*>' in a %destructor/%printer symbol list to define a default + 1. Place "<*>" in a %destructor/%printer symbol list to define a default %destructor/%printer for all grammar symbols for which you have formally declared semantic type tags. - 2. Place `<>' in a %destructor/%printer symbol list to define a default + 2. Place "<>" in a %destructor/%printer symbol list to define a default %destructor/%printer for all grammar symbols without declared semantic type tags. - Bison no longer supports the `%symbol-default' notation from Bison 2.3a. - `<*>' and `<>' combined achieve the same effect with one exception: Bison no + Bison no longer supports the "%symbol-default" notation from Bison 2.3a. + "<*>" and "<>" combined achieve the same effect with one exception: Bison no longer applies any %destructor to a mid-rule value if that mid-rule value is not actually ever referenced using either $$ or $n in a semantic action. @@ -760,11 +755,11 @@ Bison News feedback will help to determine whether they should become permanent features. - See the section `Freeing Discarded Symbols' in the Bison manual for further + See the section "Freeing Discarded Symbols" in the Bison manual for further details. ** %left, %right, and %nonassoc can now declare token numbers. This is required - by POSIX. However, see the end of section `Operator Precedence' in the Bison + by POSIX. However, see the end of section "Operator Precedence" in the Bison manual for a caveat concerning the treatment of literal strings. ** The nonfunctional --no-parser, -n, and %no-parser options have been @@ -798,17 +793,17 @@ Bison News %destructor { } guarantees that, when the parser discards any user-defined symbol that has a - semantic type tag other than `', it passes its semantic value to - `free'. However, when the parser discards a `STRING1' or a `string1', it - also prints its line number to `stdout'. It performs only the second - `%destructor' in this case, so it invokes `free' only once. + semantic type tag other than "", it passes its semantic value to + "free". However, when the parser discards a "STRING1" or a "string1", it + also prints its line number to "stdout". It performs only the second + "%destructor" in this case, so it invokes "free" only once. [Although we failed to mention this here in the 2.3a release, the default %destructor's and %printer's were experimental, and they were rewritten in future versions.] -** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with `-y', - `--yacc', or `%yacc'), Bison no longer generates #define statements for +** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y", + "--yacc", or "%yacc"), Bison no longer generates #define statements for associating token numbers with token names. Removing the #define statements helps to sanitize the global namespace during preprocessing, but POSIX Yacc requires them. Bison still generates an enum for token names in all cases. @@ -817,7 +812,7 @@ Bison News potentially incompatible with previous releases of Bison. As before, you declare prologue blocks in your grammar file with the - `%{ ... %}' syntax. To generate the pre-prologue, Bison concatenates all + "%{ ... %}" syntax. To generate the pre-prologue, Bison concatenates all prologue blocks that you've declared before the first %union. To generate the post-prologue, Bison concatenates all prologue blocks that you've declared after the first %union. @@ -846,7 +841,7 @@ Bison News * the code file before the contents of the header file. It does *not* * insert it into the header file. This is a good place to put * #include's that you want at the top of your code file. A common - * example is `#include "system.h"'. */ + * example is '#include "system.h"'. */ } %start-header { /* Bison inserts this block into both the header file and the code file. @@ -880,13 +875,13 @@ Bison News [Although we failed to mention this here in the 2.3a release, the prologue alternatives were experimental, and they were rewritten in future versions.] -** The option `--report=look-ahead' has been changed to `--report=lookahead'. +** The option "--report=look-ahead" has been changed to "--report=lookahead". The old spelling still works, but is not documented and may be removed in a future release. * Changes in version 2.3, 2006-06-05: -** GLR grammars should now use `YYRECOVERING ()' instead of `YYRECOVERING', +** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING", for compatibility with LALR(1) grammars. ** It is now documented that any definition of YYSTYPE or YYLTYPE should @@ -952,7 +947,7 @@ Bison News The %parse-params are available in the destructors (and the experimental printers) as per the documentation. -** Bison now warns if it finds a stray `$' or `@' in an action. +** Bison now warns if it finds a stray "$" or "@" in an action. ** %require "VERSION" This specifies that the grammar file depends on features implemented @@ -961,16 +956,16 @@ Bison News ** lalr1.cc: The token and value types are now class members. The tokens were defined as free form enums and cpp macros. YYSTYPE was defined as a free form union. They are now class members: - tokens are enumerations of the `yy::parser::token' struct, and the - semantic values have the `yy::parser::semantic_type' type. + tokens are enumerations of the "yy::parser::token" struct, and the + semantic values have the "yy::parser::semantic_type" type. If you do not want or can update to this scheme, the directive - `%define "global_tokens_and_yystype" "1"' triggers the global + '%define "global_tokens_and_yystype" "1"' triggers the global definition of tokens and YYSTYPE. This change is suitable both for previous releases of Bison, and this one. If you wish to update, then make sure older version of Bison will - fail using `%require "2.2"'. + fail using '%require "2.2"'. ** DJGPP support added. @@ -1038,10 +1033,10 @@ Bison News - A new directive "%expect-rr N" specifies the expected number of reduce/reduce conflicts in GLR parsers. - - %token numbers can now be hexadecimal integers, e.g., `%token FOO 0x12d'. + - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d". This is a GNU extension. - - The option `--report=lookahead' was changed to `--report=look-ahead'. + - The option "--report=lookahead" was changed to "--report=look-ahead". [However, this was changed back after 2.3.] - Experimental %destructor support has been added to lalr1.cc. @@ -1089,10 +1084,10 @@ Bison News This reverts to the behavior of Bison 1.33 and earlier, and improves compatibility with Yacc. - - `parse error' -> `syntax error' - Bison now uniformly uses the term `syntax error'; formerly, the code - and manual sometimes used the term `parse error' instead. POSIX - requires `syntax error' in diagnostics, and it was thought better to + - "parse error" -> "syntax error" + Bison now uniformly uses the term "syntax error"; formerly, the code + and manual sometimes used the term "parse error" instead. POSIX + requires "syntax error" in diagnostics, and it was thought better to be consistent. - The documentation now emphasizes that yylex and yyerror must be @@ -1105,7 +1100,7 @@ Bison News output as "foo\\bar.y". - Yacc command and library now available - The Bison distribution now installs a `yacc' command, as POSIX requires. + The Bison distribution now installs a "yacc" command, as POSIX requires. Also, Bison now installs a small library liby.a containing implementations of Yacc-compatible yyerror and main functions. This library is normally not useful, but POSIX requires it. @@ -1118,20 +1113,20 @@ Bison News ** Other compatibility issues - - %union directives can now have a tag before the `{', e.g., the - directive `%union foo {...}' now generates the C code - `typedef union foo { ... } YYSTYPE;'; this is for Yacc compatibility. - The default union tag is `YYSTYPE', for compatibility with Solaris 9 Yacc. - For consistency, YYLTYPE's struct tag is now `YYLTYPE' not `yyltype'. + - %union directives can now have a tag before the "{", e.g., the + directive "%union foo {...}" now generates the C code + "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility. + The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc. + For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype". This is for compatibility with both Yacc and Bison 1.35. - - `;' is output before the terminating `}' of an action, for + - ";" is output before the terminating "}" of an action, for compatibility with Bison 1.35. - Bison now uses a Yacc-style format for conflict reports, e.g., - `conflicts: 2 shift/reduce, 1 reduce/reduce'. + "conflicts: 2 shift/reduce, 1 reduce/reduce". - - `yystype' and `yyltype' are now obsolescent macros instead of being + - "yystype" and "yyltype" are now obsolescent macros instead of being typedefs or tags; they are no longer documented and are planned to be withdrawn in a future release. @@ -1139,13 +1134,13 @@ Bison News - GLR and inline Users of Bison have to decide how they handle the portability of the - C keyword `inline'. + C keyword "inline". - - `parsing stack overflow...' -> `parser stack overflow' - GLR parsers now report `parser stack overflow' as per the Bison manual. + - "parsing stack overflow..." -> "parser stack overflow" + GLR parsers now report "parser stack overflow" as per the Bison manual. ** Bison now warns if it detects conflicting outputs to the same file, - e.g., it generates a warning for `bison -d -o foo.h foo.y' since + e.g., it generates a warning for "bison -d -o foo.h foo.y" since that command outputs both code and header to foo.h. ** #line in output files @@ -1202,8 +1197,8 @@ Bison News ** Output Directory When not in Yacc compatibility mode, when the output file was not - specified, running `bison foo/bar.y' created `foo/bar.c'. It - now creates `bar.c'. + specified, running "bison foo/bar.y" created "foo/bar.c". It + now creates "bar.c". ** Undefined token The undefined token was systematically mapped to 2 which prevented @@ -1220,11 +1215,11 @@ Bison News will be mapped onto another number. ** Verbose error messages - They no longer report `..., expecting error or...' for states where + They no longer report "..., expecting error or..." for states where error recovery is possible. ** End token - Defaults to `$end' instead of `$'. + Defaults to "$end" instead of "$". ** Error recovery now conforms to documentation and to POSIX When a Bison-generated parser encounters a syntax error, it now pops @@ -1261,7 +1256,7 @@ Bison News Rules that can never be reduced because of conflicts are now reported. -** Incorrect `Token not used' +** Incorrect "Token not used" On a grammar such as %token useless useful @@ -1269,7 +1264,7 @@ Bison News exp: '0' %prec useful; where a token was used to set the precedence of the last rule, - bison reported both `useful' and `useless' as useless tokens. + bison reported both "useful" and "useless" as useless tokens. ** Revert the C++ namespace changes introduced in 1.31 as they caused too many portability hassles. @@ -1283,7 +1278,7 @@ Bison News ** Token end-of-file The token end of file may be specified by the user, in which case, the user symbol is used in the reports, the graphs, and the verbose - error messages instead of `$end', which remains being the default. + error messages instead of "$end", which remains being the default. For instance %token MYEOF 0 or @@ -1297,7 +1292,10 @@ Bison News Croatian, thanks to Denis Lackovic. ** Incorrect token definitions - When given `%token 'a' "A"', Bison used to output `#define 'a' 65'. + When given + %token 'a' "A" + bison used to output + #define 'a' 65 ** Token definitions as enums Tokens are output both as the traditional #define's, and, provided @@ -1309,7 +1307,7 @@ Bison News produces additional information: - itemset complete the core item sets with their closure - - lookahead [changed to `look-ahead' in 1.875e through 2.3, but changed back] + - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back] explicitly associate lookahead tokens to items - solved describe shift/reduce conflicts solving. @@ -1347,9 +1345,9 @@ Bison News ** File name clashes are detected $ bison foo.y -d -o foo.x - fatal error: header and parser would both be named `foo.x' + fatal error: header and parser would both be named "foo.x" -** A missing `;' at the end of a rule triggers a warning +** A missing ";" at the end of a rule triggers a warning In accordance with POSIX, and in agreement with other Yacc implementations, Bison will mandate this semicolon in the near future. This eases the implementation of a Bison parser of Bison @@ -1388,7 +1386,7 @@ Bison News GNU Gettext asserts 10 s/r conflicts, but there are 7. Now that Bison dies on incorrect %expectations, we fear there will be too many bug reports for Gettext, so _for the time being_, %expect - does not trigger an error when the input file is named `plural.y'. + does not trigger an error when the input file is named "plural.y". ** Use of alloca in parsers If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use @@ -1465,15 +1463,15 @@ Bison News New. ** --output - New, aliasing `--output-file'. + New, aliasing "--output-file". * Changes in version 1.30, 2001-10-26: -** `--defines' and `--graph' have now an optional argument which is the - output file name. `-d' and `-g' do not change; they do not take any +** "--defines" and "--graph" have now an optional argument which is the + output file name. "-d" and "-g" do not change; they do not take any argument. -** `%source_extension' and `%header_extension' are removed, failed +** "%source_extension" and "%header_extension" are removed, failed experiment. ** Portability fixes. @@ -1483,9 +1481,9 @@ Bison News ** The output file does not define const, as this caused problems when used with common autoconfiguration schemes. If you still use ancient compilers that lack const, compile with the equivalent of the C compiler option - `-Dconst='. Autoconf's AC_C_CONST macro provides one way to do this. + "-Dconst=". Autoconf's AC_C_CONST macro provides one way to do this. -** Added `-g' and `--graph'. +** Added "-g" and "--graph". ** The Bison manual is now distributed under the terms of the GNU FDL. @@ -1497,18 +1495,18 @@ Bison News ** Added the old Bison reference card. -** Added `--locations' and `%locations'. +** Added "--locations" and "%locations". -** Added `-S' and `--skeleton'. +** Added "-S" and "--skeleton". -** `%raw', `-r', `--raw' is disabled. +** "%raw", "-r", "--raw" is disabled. ** Special characters are escaped when output. This solves the problems of the #line lines with path names including backslashes. ** New directives. - `%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose', - `%debug', `%source_extension' and `%header_extension'. + "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose", + "%debug", "%source_extension" and "%header_extension". ** @$ Automatic location tracking. @@ -1625,4 +1623,5 @@ along with this program. If not, see . Local Variables: mode: outline +fill-column: 76 End: From a9b67b5b1e99b3ec3849c45fe42e5ecb382a314d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 21 May 2012 11:53:03 +0200 Subject: [PATCH 28/34] lalr1.cc: extract stack.hh. See commit 51bacae6b58fd5c6cce861f00440dc917384625e. * data/stack.hh: New, extracted from... * data/lalr1.cc: here. * data/Makefile.am: Adjust. --- data/Makefile.am | 2 +- data/lalr1.cc | 102 +-------------------------------------- data/stack.hh | 121 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 102 deletions(-) create mode 100644 data/stack.hh diff --git a/data/Makefile.am b/data/Makefile.am index 5c2955af..c2231886 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -15,7 +15,7 @@ dist_pkgdata_DATA = README bison.m4 \ c-skel.m4 c.m4 yacc.c glr.c \ - c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc \ + c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \ java-skel.m4 java.m4 lalr1.java m4sugardir = $(pkgdatadir)/m4sugar diff --git a/data/lalr1.cc b/data/lalr1.cc index 76a83504..c63e66de 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -28,6 +28,7 @@ b4_percent_define_ifdef([[location_type]], [], [# Backward compatibility. m4_define([b4_location_constructors]) m4_include(b4_pkgdatadir/[location.cc])]) +m4_include(b4_pkgdatadir/[stack.hh]) # We do want M4 expansion after # for CPP macros. m4_changecom() @@ -1139,106 +1140,5 @@ b4_error_verbose_if([int yystate, int yytoken], const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; ]b4_namespace_close[ - ]b4_epilogue -dnl -@output(b4_dir_prefix[]stack.hh@)@ -b4_copyright([Stack handling for Bison parsers in C++], - [2002-2012])[ - -#ifndef BISON_STACK_HH -# define BISON_STACK_HH - -#include - -]b4_namespace_open[ - template > - class stack - { - public: - - // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; - - stack () : seq_ () - { - } - - stack (unsigned int n) : seq_ (n) - { - } - - inline - T& - operator [] (unsigned int i) - { - return seq_[i]; - } - - inline - const T& - operator [] (unsigned int i) const - { - return seq_[i]; - } - - inline - void - push (const T& t) - { - seq_.push_front (t); - } - - inline - void - pop (unsigned int n = 1) - { - for (; n; --n) - seq_.pop_front (); - } - - inline - unsigned int - height () const - { - return seq_.size (); - } - - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { return seq_.rend (); } - - private: - - S seq_; - }; - - /// Present a slice of the top of a stack. - template > - class slice - { - public: - - slice (const S& stack, - unsigned int range) : stack_ (stack), - range_ (range) - { - } - - inline - const T& - operator [] (unsigned int i) const - { - return stack_[range_ - i]; - } - - private: - - const S& stack_; - unsigned int range_; - }; -]b4_namespace_close[ - -#endif // not BISON_STACK_HH[]dnl -] m4_divert_pop(0) diff --git a/data/stack.hh b/data/stack.hh new file mode 100644 index 00000000..e785e808 --- /dev/null +++ b/data/stack.hh @@ -0,0 +1,121 @@ +# C++ skeleton for Bison + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +m4_pushdef([b4_copyright_years], + [2002-2012]) + +# We do want M4 expansion after # for CPP macros. +m4_changecom() +m4_divert_push(0)dnl +@output(b4_dir_prefix[]stack.hh@)@ +b4_copyright([Stack handling for Bison parsers in C++], + [2002-2012])[ + +#ifndef BISON_STACK_HH +# define BISON_STACK_HH + +# include + +]b4_namespace_open[ + template > + class stack + { + public: + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + slice (const S& stack, unsigned int range) + : stack_ (stack) + , range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + const S& stack_; + unsigned int range_; + }; +]b4_namespace_close[ + +#endif // not BISON_STACK_HH[]dnl +] +m4_divert_pop(0) +m4_popdef([b4_copyright_years])dnl +m4_changecom([#]) From 03f1b545b94c6699ee637b517c4941afb76eb0d9 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 21 May 2012 11:40:42 +0200 Subject: [PATCH 29/34] lalr1.cc: improve Doxygen documentation. * data/location.cc: Qualify file names with directory name. --- data/lalr1.cc | 5 +++++ data/location.cc | 4 ++-- data/stack.hh | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/lalr1.cc b/data/lalr1.cc index c63e66de..0fe3aeed 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -39,6 +39,11 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], [2002-2012]) dnl FIXME: This is wrong, we want computed header guards. [ +/** + ** \file ]b4_spec_defines_file[ + ** Define the ]b4_namespace_ref[::parser class. + */ + /* C++ LALR(1) parser skeleton written by Akim Demaille. */ #ifndef PARSER_HEADER_H diff --git a/data/location.cc b/data/location.cc index cb0f1f91..0ee02c28 100644 --- a/data/location.cc +++ b/data/location.cc @@ -23,7 +23,7 @@ b4_copyright([Positions for Bison parsers in C++], [2002-2007, 2009-2012])[ /** - ** \file position.hh + ** \file ]b4_dir_prefix[position.hh ** Define the ]b4_namespace_ref[::position class. */ @@ -154,7 +154,7 @@ b4_copyright([Locations for Bison parsers in C++], [2002-2007, 2009-2012])[ /** - ** \file location.hh + ** \file ]b4_dir_prefix[location.hh ** Define the ]b4_namespace_ref[::location class. */ diff --git a/data/stack.hh b/data/stack.hh index e785e808..52933774 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -25,6 +25,11 @@ m4_divert_push(0)dnl b4_copyright([Stack handling for Bison parsers in C++], [2002-2012])[ +/** + ** \file ]b4_dir_prefix[stack.hh + ** Define the ]b4_namespace_ref[::stack class. + */ + #ifndef BISON_STACK_HH # define BISON_STACK_HH From a19728cbb5efdac48c97ef6e6c997f2534c03391 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 21 May 2012 13:12:34 +0200 Subject: [PATCH 30/34] skeletons: remove support for unused directive. * src/scan-skel.l (@dir_prefix@): Remove support, has never been used, not even in the commit that introduced it, 2b81e969ea04c1a6502928ba7e847ec8ff7dcb2f. --- src/scan-skel.l | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scan-skel.l b/src/scan-skel.l index 5fd9b20d..24339057 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -77,7 +77,6 @@ static void fail_for_invalid_at (char const *at); "@oline@" fprintf (yyout, "%d", out_lineno + 1); "@ofile@" QPUTS (outname); -"@dir_prefix@" QPUTS (dir_prefix); @[a-z_]+"(" { yytext[yyleng-1] = '\0'; From 22172d473180c53755290f13ebd2d53e12e74fe0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 21 May 2012 14:21:51 +0200 Subject: [PATCH 31/34] c++: compute the header guards. This is a frequent request. Recently pointed out by Wei Song, . * data/c.m4 (b4_tocpp, b4_cpp_guard, b4_cpp_guard_open) (b4_cpp_guard_close): New. * data/lalr1.cc, data/location.cc, data/stack.hh: Use them. * TODO (Header Guards): Move to... * NEWS: here. Formatting changes. --- NEWS | 27 +++++++++++++++++++++++++-- THANKS | 1 + TODO | 4 ---- data/c.m4 | 27 +++++++++++++++++++++++++++ data/lalr1.cc | 11 ++++------- data/location.cc | 10 ++++------ data/stack.hh | 6 ++---- 7 files changed, 63 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index 27c4974a..4fadf4e5 100644 --- a/NEWS +++ b/NEWS @@ -26,12 +26,35 @@ Bison News The Java parser no longer throws ArrayIndexOutOfBoundsException if the first token leads to a syntax error. Some minor clean ups. -** C++11 compatibility: +** Changes for C++: + +*** C++11 compatibility: C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L or higher. -** C++ locations: +*** Header guards + + The header files such as "parser.hh", "location.hh", etc. used a constant + name for preprocessor guards, for instance: + + #ifndef BISON_LOCATION_HH + # define BISON_LOCATION_HH + ... + #endif // !BISON_LOCATION_HH + + The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower + case characters are converted to upper case, and series of + non-alphanumerical characters are converted to an underscore. + + With "bison -o lang++/parser.cc", "location.hh" would now include: + + #ifndef YY_LANG_LOCATION_HH + # define YY_LANG_LOCATION_HH + ... + #endif // !YY_LANG_LOCATION_HH + +*** C++ locations: The position and location constructors (and their initialize methods) accept new arguments for line and column. Several issues in the diff --git a/THANKS b/THANKS index 6d0d89ee..e3bf221b 100644 --- a/THANKS +++ b/THANKS @@ -112,6 +112,7 @@ Tys Lefering gccbison@gmail.com Vin Shelton acs@alumni.princeton.edu W.C.A. Wijngaards wouter@NLnetLabs.nl Wayne Green wayne@infosavvy.com +Wei Song wsong83@gmail.com Wolfgang S. Kechel wolfgang.kechel@prs.de Wolfram Wagner ww@mpi-sb.mpg.de Wwp subscript@free.fr diff --git a/TODO b/TODO index d86d8d8b..21ef4b91 100644 --- a/TODO +++ b/TODO @@ -125,10 +125,6 @@ we do the same in yacc.c. The code bw glr.c and yacc.c is really alike, we can certainly factor some parts. -* Header guards - -From François: should we keep the directory part in the CPP guard? - * Yacc.c: CPP Macros diff --git a/data/c.m4 b/data/c.m4 index fee006a3..b49d6dc9 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -17,6 +17,33 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + +# b4_tocpp(STRING) +# ---------------- +# Convert STRING into a valid C macro name. +m4_define([b4_tocpp], +[m4_toupper(m4_bpatsubst(m4_quote($1), [[^a-zA-Z0-9]+], [_]))]) + + +# b4_cpp_guard(FILE) +# ------------------ +# A valid C macro name to use as a CPP header guard for FILE. +m4_define([b4_cpp_guard], +[b4_tocpp(m4_defn([b4_prefix])/[$1])]) + + +# b4_cpp_guard_open(FILE) +# b4_cpp_guard_close(FILE) +# ------------------------ +# Open/close CPP inclusion guards for FILE. +m4_define([b4_cpp_guard_open], +[#ifndef b4_cpp_guard([$1]) +# define b4_cpp_guard([$1])]) + +m4_define([b4_cpp_guard_close], +[#endif b4_comment([!b4_cpp_guard([$1])])]) + + ## ---------------- ## ## Identification. ## ## ---------------- ## diff --git a/data/lalr1.cc b/data/lalr1.cc index 0fe3aeed..4f0b2688 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -37,7 +37,6 @@ b4_defines_if( [@output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], [2002-2012]) -dnl FIXME: This is wrong, we want computed header guards. [ /** ** \file ]b4_spec_defines_file[ @@ -46,8 +45,7 @@ dnl FIXME: This is wrong, we want computed header guards. /* C++ LALR(1) parser skeleton written by Akim Demaille. */ -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H +]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_percent_code_get([[requires]])[ @@ -283,10 +281,9 @@ b4_user_stype /* Redirection for backward compatibility. */ # define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type #endif -]) -b4_percent_code_get([[provides]])[]dnl - -[#endif /* ! defined PARSER_HEADER_H */] +])[ +]b4_percent_code_get([[provides]])[ +]b4_cpp_guard_close([b4_spec_defines_file]) ])dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], diff --git a/data/location.cc b/data/location.cc index 0ee02c28..f45f634e 100644 --- a/data/location.cc +++ b/data/location.cc @@ -27,8 +27,7 @@ b4_copyright([Positions for Bison parsers in C++], ** Define the ]b4_namespace_ref[::position class. */ -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH +]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[ # include # include @@ -148,7 +147,7 @@ b4_copyright([Positions for Bison parsers in C++], } ]b4_namespace_close[ -#endif // not BISON_POSITION_HH] +]b4_cpp_guard_close([b4_dir_prefix[]position.hh]) @output(b4_dir_prefix[]location.hh@)@ b4_copyright([Locations for Bison parsers in C++], [2002-2007, 2009-2012])[ @@ -158,8 +157,7 @@ b4_copyright([Locations for Bison parsers in C++], ** Define the ]b4_namespace_ref[::location class. */ -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH +]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[ # include # include @@ -295,6 +293,6 @@ b4_copyright([Locations for Bison parsers in C++], ]b4_namespace_close[ -#endif // not BISON_LOCATION_HH] +]b4_cpp_guard_close([b4_dir_prefix[]location.hh]) m4_divert_pop(0) m4_changecom([#]) diff --git a/data/stack.hh b/data/stack.hh index 52933774..ddedc79b 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -30,8 +30,7 @@ b4_copyright([Stack handling for Bison parsers in C++], ** Define the ]b4_namespace_ref[::stack class. */ -#ifndef BISON_STACK_HH -# define BISON_STACK_HH +]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[ # include @@ -119,8 +118,7 @@ b4_copyright([Stack handling for Bison parsers in C++], }; ]b4_namespace_close[ -#endif // not BISON_STACK_HH[]dnl -] +]b4_cpp_guard_close([b4_dir_prefix[]stack.hh]) m4_divert_pop(0) m4_popdef([b4_copyright_years])dnl m4_changecom([#]) From 3f32a0d287afe7ab91603cfc133256deca09f144 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 22 May 2012 16:47:08 +0200 Subject: [PATCH 32/34] build: fix ChangeLog generation. * gnulib: Update to get newest gitlog-to-changelog. * bootstrap: Update. * Makefile.am (gen-ChangeLog): Fix for Bison's git log style. --- Makefile.am | 20 ++++---- bootstrap | 137 +++++++++++++++++++++++++++++++--------------------- gnulib | 2 +- 3 files changed, 93 insertions(+), 66 deletions(-) diff --git a/Makefile.am b/Makefile.am index eaafcaac..eef413fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,8 +56,8 @@ dist-hook: gen-ChangeLog .PHONY: update-b4-copyright update-package-copyright-year update-b4-copyright: - $(AM_V_GEN)find data -type f \ - | grep -v -E '^data/bison.m4$$' \ + $(AM_V_GEN) find data -type f \ + | grep -v -E '^data/bison.m4$$' \ | xargs $(build_aux)/$@ @echo 'warning: src/parse-gram.[hc] may need to be regenerated.' update-package-copyright-year: @@ -66,11 +66,13 @@ update-package-copyright-year: gen_start_date = 2012-01-16 .PHONY: gen-ChangeLog gen-ChangeLog: - $(AM_V_GEN)if test -d $(srcdir)/.git; then \ - $(top_srcdir)/build-aux/gitlog-to-changelog \ - --no-cluster \ - --amend=$(srcdir)/build-aux/git-log-fix \ - --since=$(gen_start_date) > $(distdir)/cl-t; \ - rm -f $(distdir)/ChangeLog; \ - mv $(distdir)/cl-t $(distdir)/ChangeLog; \ + $(AM_V_GEN)if test -d $(srcdir)/.git; then \ + $(top_srcdir)/build-aux/gitlog-to-changelog \ + --strip-tab \ + --strip-cherry-picked \ + --no-cluster \ + --amend=$(srcdir)/build-aux/git-log-fix \ + --since=$(gen_start_date) > $(distdir)/cl-t; \ + rm -f $(distdir)/ChangeLog; \ + mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/bootstrap b/bootstrap index c496d29f..ce37a2c0 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-04-26.13; # UTC +scriptversion=2012-05-15.06; # UTC # Bootstrap this package from checked-out sources. @@ -130,7 +130,7 @@ extract_package_name=' p } ' -package=`sed -n "$extract_package_name" configure.ac` || exit +package=$(sed -n "$extract_package_name" configure.ac) || exit gnulib_name=lib$package build_aux=build-aux @@ -256,7 +256,7 @@ do usage exit;; --gnulib-srcdir=*) - GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;; + GNULIB_SRCDIR=${option#--gnulib-srcdir=};; --skip-po) SKIP_PO=t;; --force) @@ -307,7 +307,7 @@ insert_sorted_if_absent() { file=$1 str=$2 test -f $file || touch $file - echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \ + echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \ || { echo "$str" | sort_patterns - $file > $file.bak \ && mv $file.bak $file; } \ || exit 1 @@ -323,7 +323,7 @@ insert_vc_ignore() { # A .gitignore entry that does not start with '/' applies # recursively to subdirectories, so prepend '/' to every # .gitignore entry. - pattern=`echo "$pattern" | sed s,^,/,`;; + pattern=$(echo "$pattern" | sed s,^,/,);; esac insert_sorted_if_absent "$vc_ignore_file" "$pattern" } @@ -427,7 +427,7 @@ check_versions() { $use_git || continue fi # Honor $APP variables ($TAR, $AUTOCONF, etc.) - appvar=`echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_'` + appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_') test "$appvar" = TAR && appvar=AMTAR case $appvar in GZIP) ;; # Do not use $GZIP: it contains gzip options. @@ -442,7 +442,7 @@ check_versions() { # "GNU automake-ng") when asked their version. case $app in automake-ng|aclocal-ng) - app=`echo "$app" | sed 's/-ng$//'` + app=${app%-ng} ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || { echo "$me: Error: '$app' not found or not from Automake-NG" >&2 ret=1 @@ -512,10 +512,8 @@ esac # When we can deduce that gnulib-tool will require patch, # and when patch is not already listed as a prerequisite, add it, too. -if test ! -d "$local_gl_dir" \ - || find "$local_gl_dir" -name '*.diff' -exec false {} +; then - : -else +if test -d "$local_gl_dir" \ + && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then case $buildreq in *patch*) ;; *) buildreq="patch - @@ -559,7 +557,7 @@ git_modules_config () { test -f .gitmodules && git config --file .gitmodules "$@" } -gnulib_path=`git_modules_config submodule.gnulib.path` +gnulib_path=$(git_modules_config submodule.gnulib.path) test -z "$gnulib_path" && gnulib_path=gnulib # Get gnulib files. @@ -632,10 +630,10 @@ download_po_files() { subdir=$1 domain=$2 echo "$me: getting translations into $subdir for $domain..." - cmd=`printf "$po_download_command_format" "$domain" "$subdir"` + cmd=$(printf "$po_download_command_format" "$domain" "$subdir") eval "$cmd" && return # Fallback to HTTP. - cmd=`printf "$po_download_command_format2" "$subdir" "$domain"` + cmd=$(printf "$po_download_command_format2" "$subdir" "$domain") eval "$cmd" } @@ -658,7 +656,7 @@ update_po_files() { && ls "$ref_po_dir"/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return - langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'` + langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g') test "$langs" = '*' && langs=x for po in $langs; do case $po in x) continue;; esac @@ -695,18 +693,18 @@ symlink_to_dir() # If the destination directory doesn't exist, create it. # This is required at least for "lib/uniwidth/cjk.h". - dst_dir=`dirname "$dst"` + dst_dir=$(dirname "$dst") if ! test -d "$dst_dir"; then mkdir -p "$dst_dir" # If we've just created a directory like lib/uniwidth, # tell version control system(s) it's ignorable. # FIXME: for now, this does only one level - parent=`dirname "$dst_dir"` + parent=$(dirname "$dst_dir") for dot_ig in x $vc_ignore; do test $dot_ig = x && continue ig=$parent/$dot_ig - insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'` + insert_vc_ignore $ig "${dst_dir##*/}" done fi @@ -730,10 +728,10 @@ symlink_to_dir() # so that broken tools aren't confused into skipping needed builds. See # . test -h "$dst" && - src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && - dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && + src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && + dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && test "$src_i" = "$dst_i" && - both_ls=`ls -dt "$src" "$dst"` && + both_ls=$(ls -dt "$src" "$dst") && test "X$both_ls" = "X$dst$nl$src" || { dot_dots= case $src in @@ -756,6 +754,22 @@ symlink_to_dir() } } +version_controlled_file() { + parent=$1 + file=$2 + if test -d .git; then + git rm -n "$file" > /dev/null 2>&1 + elif test -d .svn; then + svn log -r HEAD "$file" > /dev/null 2>&1 + elif test -d CVS; then + grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null | + grep '^/[^/]*/[0-9]' > /dev/null + else + echo "$me: no version control for $file?" >&2 + false + fi +} + # NOTE: we have to be careful to run both autopoint and libtoolize # before gnulib-tool, since gnulib-tool is likely to provide newer # versions of files "installed" by these two programs. @@ -768,43 +782,54 @@ with_gettext=yes grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ with_gettext=no -if test $with_gettext = yes; then - # Released autopoint has the tendency to install macros that have been - # obsoleted in current gnulib, so run this before gnulib-tool. - echo "$0: $AUTOPOINT --force" - $AUTOPOINT --force || exit -fi +if test $with_gettext = yes || test $use_libtool = 1; then -# Autoreconf runs aclocal before libtoolize, which causes spurious -# warnings if the initial aclocal is confused by the libtoolized -# (or worse out-of-date) macro directory. -# libtoolize 1.9b added the --install option; but we support back -# to libtoolize 1.5.22, where the install action was default. -if test $use_libtool = 1; then - install= - case $($LIBTOOLIZE --help) in - *--install*) install=--install ;; - esac - echo "running: $LIBTOOLIZE $install --copy" - $LIBTOOLIZE $install --copy -fi + tempbase=.bootstrap$$ + trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15 -version_controlled_file() { - dir=$1 - file=$2 - found=no - if test -d CVS; then - grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | - grep '^/[^/]*/[0-9]' > /dev/null && found=yes - elif test -d .git; then - git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes - elif test -d .svn; then - svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes - else - echo "$me: no version control for $dir/$file?" >&2 + > $tempbase.0 > $tempbase.1 && + find . ! -type d -print | sort > $tempbase.0 || exit + + if test $with_gettext = yes; then + # Released autopoint has the tendency to install macros that have been + # obsoleted in current gnulib, so run this before gnulib-tool. + echo "$0: $AUTOPOINT --force" + $AUTOPOINT --force || exit fi - test $found = yes -} + + # Autoreconf runs aclocal before libtoolize, which causes spurious + # warnings if the initial aclocal is confused by the libtoolized + # (or worse out-of-date) macro directory. + # libtoolize 1.9b added the --install option; but we support back + # to libtoolize 1.5.22, where the install action was default. + if test $use_libtool = 1; then + install= + case $($LIBTOOLIZE --help) in + *--install*) install=--install ;; + esac + echo "running: $LIBTOOLIZE $install --copy" + $LIBTOOLIZE $install --copy + fi + + find . ! -type d -print | sort >$tempbase.1 + old_IFS=$IFS + IFS=$nl + for file in $(comm -13 $tempbase.0 $tempbase.1); do + IFS=$old_IFS + parent=${file%/*} + version_controlled_file "$parent" "$file" || { + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_vc_ignore "$ig" "${file##*/}" + done + } + done + IFS=$old_IFS + + rm -f $tempbase.0 $tempbase.1 + trap - 1 2 13 15 +fi # Import from gnulib. @@ -868,7 +893,7 @@ AUTOPOINT=true LIBTOOLIZE=true \ for file in $gnulib_extra_files; do case $file in */INSTALL) dst=INSTALL;; - build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; + build-aux/*) dst=$build_aux/${file#build-aux/};; *) dst=$file;; esac symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit diff --git a/gnulib b/gnulib index 1f96aa01..338dd5d4 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 1f96aa01f72bba8c9a0600280594a1a92bb505fc +Subproject commit 338dd5d4362fdf5fb29b843d4d8a8f845bc750de From 188867ac65e5141ce20454ba6604900c923ba983 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 22 May 2012 17:29:38 +0200 Subject: [PATCH 33/34] doc: fixes. * doc/bison.texinfo: Fix errors spotted by syntax-check. --- doc/bison.texinfo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 33375513..97b32734 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -7607,7 +7607,7 @@ calls @code{yyerror} and then returns 2. Because Bison parsers have growing stacks, hitting the upper limit usually results from using a right recursion instead of a left -recursion, @xref{Recursion, ,Recursive Rules}. +recursion, see @ref{Recursion, ,Recursive Rules}. @vindex YYMAXDEPTH By defining the macro @code{YYMAXDEPTH}, you can control how deep the @@ -10471,8 +10471,8 @@ My parser returns with error with a @samp{memory exhausted} message. What can I do? @end quotation -This question is already addressed elsewhere, @xref{Recursion, -,Recursive Rules}. +This question is already addressed elsewhere, see @ref{Recursion, ,Recursive +Rules}. @node How Can I Reset the Parser @section How Can I Reset the Parser From 3cd7c0bfce1635ea344947aaf8fda4000b817a80 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 22 May 2012 22:47:41 +0200 Subject: [PATCH 34/34] Bison 2.5.1_rc2. * NEWS: Update. --- NEWS | 2 +- src/parse-gram.c | 4 ++-- src/parse-gram.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4fadf4e5..14f51b3e 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ Bison News ---------- -* Changes in version 2.5.1_rc1 (2012-05-14): +* Changes in version 2.5.1_rc2 (2012-05-23): ** Future changes: diff --git a/src/parse-gram.c b/src/parse-gram.c index fe6299b0..989c91c2 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.1_rc1-dirty. */ +/* A Bison parser, made by GNU Bison 2.5.1_rc2. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5.1_rc1-dirty" +#define YYBISON_VERSION "2.5.1_rc2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" diff --git a/src/parse-gram.h b/src/parse-gram.h index ab45cad4..2beec477 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.1_rc1-dirty. */ +/* A Bison parser, made by GNU Bison 2.5.1_rc2. */ /* Bison interface for Yacc-like parsers in C