Kill GCC warnings.

* src/reduce.c (nonterminals_reduce): Don't loop over RITEM: loop
over the RHS of each rule.
* src/gram.h, src/gram.c (nritems): Is `unsigned int', not int.
* src/state.h (state_t): Member `nitems' is unsigned short.
* src/LR0.c (get_state): Adjust.
* src/reader.c (packgram): Likewise.
* src/output.c (GENERATE_MUSCLE_INSERT_TABLE): `max' is of type
`Type'.
(muscle_insert_int_table): Remove, unused.
(prepare_rules): Remove `max'.
This commit is contained in:
Akim Demaille
2002-05-07 08:07:32 +00:00
parent e41fdc9310
commit 0c2d3f4cba
8 changed files with 35 additions and 15 deletions

View File

@@ -1,3 +1,18 @@
2002-05-07 Akim Demaille <akim@epita.fr>
Kill GCC warnings.
* src/reduce.c (nonterminals_reduce): Don't loop over RITEM: loop
over the RHS of each rule.
* src/gram.h, src/gram.c (nritems): Is `unsigned int', not int.
* src/state.h (state_t): Member `nitems' is unsigned short.
* src/LR0.c (get_state): Adjust.
* src/reader.c (packgram): Likewise.
* src/output.c (GENERATE_MUSCLE_INSERT_TABLE): `max' is of type
`Type'.
(muscle_insert_int_table): Remove, unused.
(prepare_rules): Remove `max'.
2002-05-06 Akim Demaille <akim@epita.fr> 2002-05-06 Akim Demaille <akim@epita.fr>
* src/closure.c (print_firsts): Display of the symbol tags. * src/closure.c (print_firsts): Display of the symbol tags.

View File

@@ -231,7 +231,7 @@ static int
get_state (token_number_t symbol, size_t core_size, item_number_t *core) get_state (token_number_t symbol, size_t core_size, item_number_t *core)
{ {
int key; int key;
int i; size_t i;
state_t *sp; state_t *sp;
if (trace_flag) if (trace_flag)

View File

@@ -29,7 +29,7 @@
/* comments for these variables are in gram.h */ /* comments for these variables are in gram.h */
item_number_t *ritem = NULL; item_number_t *ritem = NULL;
int nritems = 0; unsigned int nritems = 0;
rule_t *rules = NULL; rule_t *rules = NULL;
int nrules = 0; int nrules = 0;
@@ -70,7 +70,7 @@ rule_rhs_length (rule_t *rule)
void void
ritem_print (FILE *out) ritem_print (FILE *out)
{ {
int i; unsigned int i;
fputs ("RITEM\n", out); fputs ("RITEM\n", out);
for (i = 0; i < nritems; ++i) for (i = 0; i < nritems; ++i)
if (ritem[i] >= 0) if (ritem[i] >= 0)

View File

@@ -110,7 +110,7 @@ extern int nvars;
#define ITEM_NUMBER_MAX INT_MAX #define ITEM_NUMBER_MAX INT_MAX
typedef int item_number_t; typedef int item_number_t;
extern item_number_t *ritem; extern item_number_t *ritem;
extern int nritems; extern unsigned int nritems;
/* There is weird relationship between item_number_t and /* There is weird relationship between item_number_t and
token_number_t: we store token_number_t in item_number_t, but in token_number_t: we store token_number_t in item_number_t, but in

View File

@@ -184,7 +184,7 @@ Name (const char *name, \
int begin, \ int begin, \
int end) \ int end) \
{ \ { \
long int max = first; \ Type max = first; \
int i; \ int i; \
int j = 1; \ int j = 1; \
\ \
@@ -209,10 +209,10 @@ Name (const char *name, \
/* Build `NAME_max' in the obstack. */ \ /* Build `NAME_max' in the obstack. */ \
obstack_fgrow1 (&format_obstack, "%s_max", name); \ obstack_fgrow1 (&format_obstack, "%s_max", name); \
obstack_1grow (&format_obstack, 0); \ obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), max); \ MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), \
(long int) max); \
} }
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_short_table, short) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_short_table, short)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_token_number_table, token_number_t) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_token_number_table, token_number_t)
@@ -285,7 +285,6 @@ prepare_tokens (void)
static void static void
prepare_rules (void) prepare_rules (void)
{ {
long int max;
int r; int r;
unsigned int i = 0; unsigned int i = 0;
item_number_t *rhs = XMALLOC (item_number_t, nritems); item_number_t *rhs = XMALLOC (item_number_t, nritems);

View File

@@ -1736,7 +1736,7 @@ packsymbols (void)
static void static void
packgram (void) packgram (void)
{ {
int itemno; unsigned int itemno;
int ruleno; int ruleno;
symbol_list *p; symbol_list *p;

View File

@@ -306,11 +306,17 @@ nonterminals_reduce (void)
free (symbols_sorted + ntokens); free (symbols_sorted + ntokens);
} }
for (i = 0; i < nritems; ++i) {
if (ISVAR (ritem[i])) int r;
ritem[i] = token_number_as_item_number (nontermmap[ritem[i]]); for (r = 1; r < nrules + 1; ++r)
{
start_symbol = nontermmap[start_symbol]; item_number_t *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = token_number_as_item_number (nontermmap[*rhsp]);
}
start_symbol = nontermmap[start_symbol];
}
nsyms -= nuseless_nonterminals; nsyms -= nuseless_nonterminals;
nvars -= nuseless_nonterminals; nvars -= nuseless_nonterminals;

View File

@@ -185,7 +185,7 @@ typedef struct state_s
int nlookaheads; int nlookaheads;
/* Its items. */ /* Its items. */
short nitems; unsigned short nitems;
item_number_t items[1]; item_number_t items[1];
} state_t; } state_t;