* data/yacc.c (b4_int_type): Use yytype_uint8, etc., so that the

user can override the types.
(short): #undef, to work around a bug in Pike 7.0.
(yytype_uint8, yytype_int8, yytype_uint16, yytype_int16): New types.
(union yyalloc.yyss): Use yytype_int16 rather than short.
All uses changed.
(yysigned_char): Remove.
* src/parse-gram.y (YYTYPE_UINT8, YYTYPE_INT8, YYTYPE_UINT16):
(YYTYPE_INT16): New macros, to test the new facility in yacc.c.
* tests/regression.at (Web2c Actions): Adjust to above changes.
This commit is contained in:
Paul Eggert
2006-01-23 07:59:42 +00:00
parent 02d12d0de2
commit d42cf84421
3 changed files with 78 additions and 38 deletions

View File

@@ -71,14 +71,15 @@ m4_ifdef([b4_lex_param], b4_lex_param)))
# b4_int_type(MIN, MAX)
# ---------------------
# Return the smallest int type able to handle numbers ranging from
# MIN to MAX (included). We overwrite the version from c.m4 which relies
# on "signed char" which is not portable to old K&R compilers.
# MIN to MAX (included). Overwrite the version from c.m4, which
# uses only C89 types, so that the user can override the shorter
# types, and so that pre-C89 compilers are handled correctly.
m4_define([b4_int_type],
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
b4_ints_in($@, [-128], [127]), [1], [yysigned_char],
[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
b4_ints_in($@, [-128], [127]), [1], [yytype_int8],
b4_ints_in($@, [0], [65535]), [1], [unsigned short int],
b4_ints_in($@, [-32768], [32767]), [1], [short int],
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
m4_eval([0 <= $1]), [1], [unsigned int],
@@ -220,6 +221,36 @@ typedef struct YYLTYPE
/* Line __line__ of yacc.c. */
b4_syncline([@oline@], [@ofile@])[
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif ]b4_c_modern[
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
@@ -337,7 +368,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
short int yyss;
yytype_int16 yyss;
YYSTYPE yyvs;
]b4_location_if([ YYLTYPE yyls;
])dnl
@@ -350,10 +381,10 @@ union yyalloc
N elements. */
]b4_location_if(
[# define YYSTACK_BYTES(N) \
((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM)],
[# define YYSTACK_BYTES(N) \
((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)])[
/* Copy COUNT objects from FROM to TO. The source and destination do
@@ -392,12 +423,6 @@ union yyalloc
#endif
#if ]b4_c_modern[
typedef signed char yysigned_char;
#else
typedef short int yysigned_char;
#endif
/* YYFINAL -- State number of the termination state. */
#define YYFINAL ]b4_final_state_number[
/* YYLAST -- Last index in YYTABLE. */
@@ -649,8 +674,8 @@ do { \
`------------------------------------------------------------------*/
]b4_c_function_def([yy_stack_print], [static void],
[[short int *bottom], [bottom]],
[[short int *top], [top]])[
[[yytype_int16 *bottom], [bottom]],
[[yytype_int16 *top], [top]])[
{
YYFPRINTF (stderr, "Stack now");
for (; bottom <= top; ++bottom)
@@ -993,9 +1018,9 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
to reallocate them elsewhere. */
/* The state stack. */
short int yyssa[YYINITDEPTH];
short int *yyss = yyssa;
short int *yyssp;
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss = yyssa;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
@@ -1082,7 +1107,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
short int *yyss1 = yyss;
yytype_int16 *yyss1 = yyss;
]b4_location_if([ YYLTYPE *yyls1 = yyls;])[
/* Each stack pointer address is followed by the size of the
@@ -1110,7 +1135,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
yystacksize = YYMAXDEPTH;
{
short int *yyss1 = yyss;
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)

View File

@@ -57,6 +57,19 @@ static uniqstr current_type = 0;
static symbol *current_lhs;
static location current_lhs_location;
static int current_prec = 0;
#ifdef UINT_FAST8_MAX
# define YYTYPE_UINT8 uint_fast8_t
#endif
#ifdef INT_FAST8_MAX
# define YYTYPE_INT8 int_fast8_t
#endif
#ifdef UINT_FAST16_MAX
# define YYTYPE_UINT16 uint_fast16_t
#endif
#ifdef INT_FAST16_MAX
# define YYTYPE_INT16 int_fast16_t
#endif
%}
%debug

View File

@@ -1,5 +1,7 @@
# Bison Regressions. -*- Autotest -*-
# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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
@@ -581,7 +583,7 @@ AT_CLEANUP
#
# It used to be wrong on yydefact only:
#
# static const short int yydefact[] =
# static const yytype_uint8 yydefact[] =
# {
# - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4,
# + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4,
@@ -611,7 +613,7 @@ AT_CHECK([bison -v -o input.c input.y])
[sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c]
AT_CHECK([[cat tables.c]], 0,
[[static const unsigned char yytranslate[] =
[[static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -641,16 +643,16 @@ AT_CHECK([[cat tables.c]], 0,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6
};
static const unsigned char yyprhs[] =
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 6, 9, 14
};
static const yysigned_char yyrhs[] =
static const yytype_int8 yyrhs[] =
{
8, 0, -1, 9, -1, -1, 10, 11, -1, 3,
4, 5, 8, -1, 6, 8, -1
};
static const unsigned char yyrline[] =
static const yytype_uint8 yyrline[] =
{
0, 2, 2, 3, 3, 4, 5
};
@@ -659,45 +661,45 @@ static const char *const yytname[] =
"$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
"\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0
};
static const unsigned short int yytoknum[] =
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261
};
static const unsigned char yyr1[] =
static const yytype_uint8 yyr1[] =
{
0, 7, 8, 9, 9, 10, 11
};
static const unsigned char yyr2[] =
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 0, 2, 4, 2
};
static const unsigned char yydefact[] =
static const yytype_uint8 yydefact[] =
{
3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
6, 5
};
static const yysigned_char yydefgoto[] =
static const yytype_int8 yydefgoto[] =
{
-1, 2, 3, 4, 8
};
static const yysigned_char yypact[] =
static const yytype_int8 yypact[] =
{
-2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
-8, -8
};
static const yysigned_char yypgoto[] =
static const yytype_int8 yypgoto[] =
{
-8, -7, -8, -8, -8
};
static const unsigned char yytable[] =
static const yytype_uint8 yytable[] =
{
10, 1, 11, 5, 6, 0, 7, 9
};
static const yysigned_char yycheck[] =
static const yytype_int8 yycheck[] =
{
7, 3, 9, 4, 0, -1, 6, 5
};
static const unsigned char yystos[] =
static const yytype_uint8 yystos[] =
{
0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
8, 8