* src/muscle_tab.h (MUSCLE_INSERT_LONG_INT): New.

* src/output.c (output_table_data): Return the longest number.
(prepare_tokens): Output `token_number_max').
* data/bison.simple, data/bison.c++ (b4_sint_type, b4_uint_type):
New.
Use them to define yy_token_number_type/TokenNumberType.
Use this type for yytranslate.
* tests/torture.at (Big triangle): Push the limit from 124 to
253.
* tests/regression.at (Web2c Actions): Adjust.
This commit is contained in:
Akim Demaille
2002-04-07 17:44:59 +00:00
parent 817e9f41d1
commit 680e8701b5
11 changed files with 95 additions and 26 deletions

View File

@@ -38,7 +38,7 @@ int nsyms = 0;
int ntokens = 1;
int nvars = 0;
short *token_translations = NULL;
token_number_t *token_translations = NULL;
int start_symbol = 0;

View File

@@ -148,11 +148,11 @@ extern struct rule_s *rules;
/* Table of the symbols, indexed by the symbol number. */
extern symbol_t **symbols;
/* token translation table: indexed by a token number as returned by
the user's yylex routine, it yields the internal token number used
by the parser and throughout bison. */
extern short *token_translations;
/* TOKEN_TRANSLATION -- a table indexed by a token number as returned
by the user's yylex routine, it yields the internal token number
used by the parser and throughout bison. */
typedef short token_number_t;
extern token_number_t *token_translations;
extern int max_user_token_number;
/* SEMANTIC_PARSER is nonzero if the input file says to use the hairy

View File

@@ -40,6 +40,13 @@ const char *muscle_find PARAMS ((const char *key));
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
}
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
{ \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
}
#define MUSCLE_INSERT_STRING(Key, Value) \
{ \
obstack_sgrow (&muscle_obstack, Value); \

View File

@@ -147,15 +147,19 @@ get_lines_number (const char *s)
}
/* FIXME. */
/*----------------------------------------------------------------.
| Format the FIRST and then TABLE_DATA[BEGIN..END[ into OOUT, and |
| return the number of bits needed for its longuest value. |
`----------------------------------------------------------------*/
static inline void
static inline long int
output_table_data (struct obstack *oout,
short *table_data,
short first,
int begin,
int end)
{
long int max = first;
int i;
int j = 1;
@@ -171,8 +175,12 @@ output_table_data (struct obstack *oout,
else
++j;
obstack_fgrow1 (oout, "%6d", table_data[i]);
if (table_data[i] > max)
max = table_data[i];
}
obstack_1grow (oout, 0);
return max;
}
@@ -184,9 +192,10 @@ output_table_data (struct obstack *oout,
static void
prepare_tokens (void)
{
output_table_data (&format_obstack, token_translations,
0, 1, max_user_token_number + 1);
long int max = output_table_data (&format_obstack, token_translations,
0, 1, max_user_token_number + 1);
muscle_insert ("translate", obstack_finish (&format_obstack));
MUSCLE_INSERT_LONG_INT ("token_number_max", max);
XFREE (token_translations);
{

View File

@@ -1691,7 +1691,7 @@ token_translations_init (void)
max_user_token_number = this->user_token_number;
}
token_translations = XCALLOC (short, max_user_token_number + 1);
token_translations = XCALLOC (token_number_t, max_user_token_number + 1);
/* Initialize all entries for literal tokens to 2, the internal
token number for $undefined., which represents all invalid