mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
* lib/timevar.c (get_time): Include children time.
* src/lalr.h (LA, LArule): Don't export them: used with the state_t. * src/lalr.c (LA, LArule): Static. * src/lalr.h, src/lalr.c (lalr_free): New. * src/main.c (main): Call it. * src/tables.c (pack_vector): Check whether loc is >= to the table_size, not >. (pack_tables): Don't free froms, tos, conflict_tos, and pos... (tables_generate): do it, since that's also it which allocates them. Don't free LA and LArule, main does.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2002-08-01 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/timevar.c (get_time): Include children time.
|
||||
* src/lalr.h (LA, LArule): Don't export them: used with the
|
||||
state_t.
|
||||
* src/lalr.c (LA, LArule): Static.
|
||||
* src/lalr.h, src/lalr.c (lalr_free): New.
|
||||
* src/main.c (main): Call it.
|
||||
* src/tables.c (pack_vector): Check whether loc is >= to the
|
||||
table_size, not >.
|
||||
(pack_tables): Don't free froms, tos, conflict_tos, and pos...
|
||||
(tables_generate): do it, since that's also it which allocates
|
||||
them.
|
||||
Don't free LA and LArule, main does.
|
||||
|
||||
2002-07-31 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Separate parser tables computation and output.
|
||||
|
||||
@@ -208,14 +208,17 @@ get_time (now)
|
||||
#ifdef USE_TIMES
|
||||
struct tms tms;
|
||||
now->wall = times (&tms) * ticks_to_msec;
|
||||
now->user = tms.tms_utime * ticks_to_msec;
|
||||
now->sys = tms.tms_stime * ticks_to_msec;
|
||||
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
|
||||
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
|
||||
#endif
|
||||
#ifdef USE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
getrusage (RUSAGE_SELF, &rusage);
|
||||
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
getrusage (RUSAGE_CHILDREN, &rusage);
|
||||
now->user += rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys += rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
now->user = clock () * clocks_to_msec;
|
||||
|
||||
32
src/lalr.c
32
src/lalr.c
@@ -52,8 +52,22 @@ typedef struct goto_list_s
|
||||
} goto_list_t;
|
||||
|
||||
|
||||
rule_t **LArule = NULL;
|
||||
bitsetv LA = NULL;
|
||||
/* LARULE is a vector which records the rules that need lookahead in
|
||||
various states. The elements of LARULE that apply to state S are
|
||||
those from LOOKAHEADS[S] through LOOKAHEADS[S+1]-1.
|
||||
|
||||
If LR is the length of LArule, then a number from 0 to LR-1 can
|
||||
specify both a rule and a state where the rule might be applied.
|
||||
*/
|
||||
|
||||
static rule_t **LArule = NULL;
|
||||
|
||||
/* LA is a LR by NTOKENS matrix of bits. LA[l, i] is 1 if the rule
|
||||
LArule[l] is applicable in the appropriate state when the next
|
||||
token is symbol i. If LA[l, i] and LA[l, j] are both 1 for i != j,
|
||||
it is a conflict. */
|
||||
|
||||
static bitsetv LA = NULL;
|
||||
size_t nLA;
|
||||
|
||||
|
||||
@@ -460,3 +474,17 @@ lalr (void)
|
||||
if (trace_flag & trace_sets)
|
||||
lookaheads_print (stderr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
lalr_free (void)
|
||||
{
|
||||
state_number_t s;
|
||||
for (s = 0; s < nstates; ++s)
|
||||
{
|
||||
states[s]->lookaheads = NULL;
|
||||
states[s]->lookaheads_rule = NULL;
|
||||
}
|
||||
bitsetv_free (LA);
|
||||
free (LArule);
|
||||
}
|
||||
|
||||
26
src/lalr.h
26
src/lalr.h
@@ -21,8 +21,8 @@
|
||||
#ifndef LALR_H_
|
||||
# define LALR_H_
|
||||
|
||||
#include "bitset.h"
|
||||
#include "bitsetv.h"
|
||||
# include "bitset.h"
|
||||
# include "bitsetv.h"
|
||||
|
||||
/* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
|
||||
# include "state.h"
|
||||
@@ -36,6 +36,11 @@
|
||||
|
||||
void lalr PARAMS ((void));
|
||||
|
||||
/* Release the information related to lookaheads. Can be performed
|
||||
once the action tables are computed. */
|
||||
|
||||
void lalr_free PARAMS ((void));
|
||||
|
||||
|
||||
/* lalr() builds these data structures. */
|
||||
|
||||
@@ -56,22 +61,5 @@ extern goto_number_t *goto_map;
|
||||
extern state_number_t *from_state;
|
||||
extern state_number_t *to_state;
|
||||
|
||||
/* LARULE is a vector which records the rules that need lookahead in
|
||||
various states. The elements of LARULE that apply to state S are
|
||||
those from LOOKAHEADS[S] through LOOKAHEADS[S+1]-1.
|
||||
|
||||
If LR is the length of LArule, then a number from 0 to LR-1 can
|
||||
specify both a rule and a state where the rule might be applied.
|
||||
*/
|
||||
|
||||
extern rule_t **LArule;
|
||||
|
||||
/* LA is a LR by NTOKENS matrix of bits. LA[l, i] is 1 if the rule
|
||||
LAruleno[l] is applicable in the appropriate state when the next
|
||||
token is symbol i. If LA[l, i] and LA[l, j] are both 1 for i != j,
|
||||
it is a conflict. */
|
||||
|
||||
extern bitsetv LA;
|
||||
|
||||
|
||||
#endif /* !LALR_H_ */
|
||||
|
||||
@@ -137,6 +137,11 @@ main (int argc, char *argv[])
|
||||
tables_generate ();
|
||||
timevar_pop (TV_ACTIONS);
|
||||
|
||||
/* Lookaheads are no longer needed. */
|
||||
timevar_push (TV_FREE);
|
||||
lalr_free ();
|
||||
timevar_pop (TV_FREE);
|
||||
|
||||
/* Output the tables and the parser to ftable. In file output. */
|
||||
timevar_push (TV_PARSER);
|
||||
output ();
|
||||
|
||||
27
src/tables.c
27
src/tables.c
@@ -732,7 +732,7 @@ pack_vector (vector_number_t vector)
|
||||
for (k = 0; ok && k < t; k++)
|
||||
{
|
||||
loc = j + state_number_as_int (from[k]);
|
||||
if (loc > (int) table_size)
|
||||
if (loc >= (int) table_size)
|
||||
table_grow (loc);
|
||||
|
||||
if (table[loc] != 0)
|
||||
@@ -839,16 +839,6 @@ pack_table (void)
|
||||
base_ninf = table_ninf_remap (base, nvectors, BASE_MIN);
|
||||
table_ninf = table_ninf_remap (table, high + 1, ACTION_MIN);
|
||||
|
||||
for (i = 0; i < nvectors; i++)
|
||||
{
|
||||
XFREE (froms[i]);
|
||||
XFREE (tos[i]);
|
||||
XFREE (conflict_tos[i]);
|
||||
}
|
||||
|
||||
free (froms);
|
||||
free (tos);
|
||||
free (conflict_tos);
|
||||
free (pos);
|
||||
}
|
||||
|
||||
@@ -862,6 +852,8 @@ pack_table (void)
|
||||
void
|
||||
tables_generate (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* That's a poor way to make sure the sizes are properly corelated,
|
||||
in particular the signedness is not taking into account, but it's
|
||||
not useless. */
|
||||
@@ -877,8 +869,6 @@ tables_generate (void)
|
||||
width = XCALLOC (base_t, nvectors);
|
||||
|
||||
token_actions ();
|
||||
bitsetv_free (LA);
|
||||
free (LArule);
|
||||
|
||||
goto_actions ();
|
||||
XFREE (goto_map + ntokens);
|
||||
@@ -892,6 +882,17 @@ tables_generate (void)
|
||||
|
||||
free (tally);
|
||||
free (width);
|
||||
|
||||
for (i = 0; i < nvectors; i++)
|
||||
{
|
||||
XFREE (froms[i]);
|
||||
XFREE (tos[i]);
|
||||
XFREE (conflict_tos[i]);
|
||||
}
|
||||
|
||||
free (froms);
|
||||
free (tos);
|
||||
free (conflict_tos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user