mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
* src/system.h (LIST_FREE, shortcpy): New.
* src/LR0.c: Use them. * src/output.c (free_itemsets, free_reductions, free_shifts): Remove, replaced by LIST_FREE.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/system.h (LIST_FREE, shortcpy): New.
|
||||||
|
* src/LR0.c: Use them.
|
||||||
|
* src/output.c (free_itemsets, free_reductions, free_shifts):
|
||||||
|
Remove, replaced by LIST_FREE.
|
||||||
|
|
||||||
|
|
||||||
2001-11-19 Akim Demaille <akim@epita.fr>
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/state.h (CORE_ALLOC, SHIFTS_ALLOC, ERRS_ALLOC)
|
* src/state.h (CORE_ALLOC, SHIFTS_ALLOC, ERRS_ALLOC)
|
||||||
|
|||||||
30
src/LR0.c
30
src/LR0.c
@@ -196,9 +196,6 @@ new_state (int symbol)
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
core *p;
|
core *p;
|
||||||
short *isp1;
|
|
||||||
short *isp2;
|
|
||||||
short *iend;
|
|
||||||
|
|
||||||
#if TRACE
|
#if TRACE
|
||||||
fprintf (stderr, "Entering new_state, symbol = %d, state = %d\n",
|
fprintf (stderr, "Entering new_state, symbol = %d, state = %d\n",
|
||||||
@@ -208,18 +205,14 @@ new_state (int symbol)
|
|||||||
if (nstates >= MAXSHORT)
|
if (nstates >= MAXSHORT)
|
||||||
fatal (_("too many states (max %d)"), MAXSHORT);
|
fatal (_("too many states (max %d)"), MAXSHORT);
|
||||||
|
|
||||||
isp1 = kernel_base[symbol];
|
n = kernel_end[symbol] - kernel_base[symbol];
|
||||||
iend = kernel_end[symbol];
|
|
||||||
n = iend - isp1;
|
|
||||||
|
|
||||||
p = CORE_ALLOC (n);
|
p = CORE_ALLOC (n);
|
||||||
p->accessing_symbol = symbol;
|
p->accessing_symbol = symbol;
|
||||||
p->number = nstates;
|
p->number = nstates;
|
||||||
p->nitems = n;
|
p->nitems = n;
|
||||||
|
|
||||||
isp2 = p->items;
|
shortcpy (p->items, kernel_base[symbol], n);
|
||||||
while (isp1 < iend)
|
|
||||||
*isp2++ = *isp1++;
|
|
||||||
|
|
||||||
last_state->next = p;
|
last_state->next = p;
|
||||||
last_state = p;
|
last_state = p;
|
||||||
@@ -360,21 +353,13 @@ static void
|
|||||||
save_shifts (void)
|
save_shifts (void)
|
||||||
{
|
{
|
||||||
shifts *p;
|
shifts *p;
|
||||||
short *sp1;
|
|
||||||
short *sp2;
|
|
||||||
short *send;
|
|
||||||
|
|
||||||
p = SHIFTS_ALLOC (nshifts);
|
p = SHIFTS_ALLOC (nshifts);
|
||||||
|
|
||||||
p->number = this_state->number;
|
p->number = this_state->number;
|
||||||
p->nshifts = nshifts;
|
p->nshifts = nshifts;
|
||||||
|
|
||||||
sp1 = shiftset;
|
shortcpy (p->shifts, shiftset, nshifts);
|
||||||
sp2 = p->shifts;
|
|
||||||
send = shiftset + nshifts;
|
|
||||||
|
|
||||||
while (sp1 < send)
|
|
||||||
*sp2++ = *sp1++;
|
|
||||||
|
|
||||||
if (last_shift)
|
if (last_shift)
|
||||||
{
|
{
|
||||||
@@ -603,8 +588,6 @@ static void
|
|||||||
save_reductions (void)
|
save_reductions (void)
|
||||||
{
|
{
|
||||||
short *isp;
|
short *isp;
|
||||||
short *rp1;
|
|
||||||
short *rp2;
|
|
||||||
int item;
|
int item;
|
||||||
int count;
|
int count;
|
||||||
reductions *p;
|
reductions *p;
|
||||||
@@ -630,12 +613,7 @@ save_reductions (void)
|
|||||||
p->number = this_state->number;
|
p->number = this_state->number;
|
||||||
p->nreds = count;
|
p->nreds = count;
|
||||||
|
|
||||||
rp1 = redset;
|
shortcpy (p->rules, redset, count);
|
||||||
rp2 = p->rules;
|
|
||||||
rend = rp1 + count;
|
|
||||||
|
|
||||||
for (/* nothing */; rp1 < rend; ++rp1, ++rp2)
|
|
||||||
*rp2 = *rp1;
|
|
||||||
|
|
||||||
if (last_reduction)
|
if (last_reduction)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -653,14 +653,7 @@ compute_lookaheads (void)
|
|||||||
|
|
||||||
/* Free LOOKBACK. */
|
/* Free LOOKBACK. */
|
||||||
for (i = 0; i < state_table[nstates].lookaheads; i++)
|
for (i = 0; i < state_table[nstates].lookaheads; i++)
|
||||||
{
|
LIST_FREE (shorts, lookback[i]);
|
||||||
shorts *sptmp;
|
|
||||||
for (sp = lookback[i]; sp; sp = sptmp)
|
|
||||||
{
|
|
||||||
sptmp = sp->next;
|
|
||||||
XFREE (sp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
XFREE (lookback);
|
XFREE (lookback);
|
||||||
XFREE (F);
|
XFREE (F);
|
||||||
|
|||||||
45
src/output.c
45
src/output.c
@@ -760,33 +760,6 @@ token_actions (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_shifts (void)
|
|
||||||
{
|
|
||||||
shifts *sp, *sptmp; /* JF derefrenced freed ptr */
|
|
||||||
|
|
||||||
for (sp = first_shift; sp; sp = sptmp)
|
|
||||||
{
|
|
||||||
sptmp = sp->next;
|
|
||||||
XFREE (sp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_reductions (void)
|
|
||||||
{
|
|
||||||
reductions *rp, *rptmp; /* JF fixed freed ptr */
|
|
||||||
|
|
||||||
for (rp = first_reduction; rp; rp = rptmp)
|
|
||||||
{
|
|
||||||
rptmp = rp->next;
|
|
||||||
XFREE (rp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_column (int symbol, int default_state)
|
save_column (int symbol, int default_state)
|
||||||
{
|
{
|
||||||
@@ -1136,8 +1109,8 @@ output_actions (void)
|
|||||||
width = XCALLOC (short, nvectors);
|
width = XCALLOC (short, nvectors);
|
||||||
|
|
||||||
token_actions ();
|
token_actions ();
|
||||||
free_shifts ();
|
LIST_FREE (shifts, first_shift);
|
||||||
free_reductions ();
|
LIST_FREE (reductions, first_reduction);
|
||||||
XFREE (LA);
|
XFREE (LA);
|
||||||
XFREE (LAruleno);
|
XFREE (LAruleno);
|
||||||
|
|
||||||
@@ -1306,18 +1279,6 @@ output_program (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_itemsets (void)
|
|
||||||
{
|
|
||||||
core *cp, *cptmp;
|
|
||||||
for (cp = first_state; cp; cp = cptmp)
|
|
||||||
{
|
|
||||||
cptmp = cp->next;
|
|
||||||
XFREE (cp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------.
|
/*----------------------------------------------------------.
|
||||||
| Output the parsing tables and the parser code to ftable. |
|
| Output the parsing tables and the parser code to ftable. |
|
||||||
`----------------------------------------------------------*/
|
`----------------------------------------------------------*/
|
||||||
@@ -1349,7 +1310,7 @@ output (void)
|
|||||||
if (!no_parser_flag)
|
if (!no_parser_flag)
|
||||||
obstack_sgrow (&table_obstack, "#include <stdio.h>\n\n");
|
obstack_sgrow (&table_obstack, "#include <stdio.h>\n\n");
|
||||||
|
|
||||||
free_itemsets ();
|
LIST_FREE (core, first_state);
|
||||||
output_defines ();
|
output_defines ();
|
||||||
output_token_translations ();
|
output_token_translations ();
|
||||||
/* if (semantic_parser) */
|
/* if (semantic_parser) */
|
||||||
|
|||||||
15
src/system.h
15
src/system.h
@@ -279,6 +279,21 @@ do { \
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* As memcpy, but for shorts. */
|
||||||
|
#define shortcpy(Dest, Src, Num) \
|
||||||
|
memcpy (Dest, Src, Num * sizeof (short))
|
||||||
|
|
||||||
|
/* Free a linked list. */
|
||||||
|
#define LIST_FREE(Type, List) \
|
||||||
|
do { \
|
||||||
|
Type *_node, *_next; \
|
||||||
|
for (_node = List; _node; _node = _next) \
|
||||||
|
{ \
|
||||||
|
_next = _node->next; \
|
||||||
|
XFREE (_node); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*---------------------------------.
|
/*---------------------------------.
|
||||||
| Debugging the memory allocator. |
|
| Debugging the memory allocator. |
|
||||||
`---------------------------------*/
|
`---------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user