--- /dev/null
+patch_list='Bison Patches <bison-patches@gnu.org>'
+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.
{
#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->wall = times (&tms) * 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;
} 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;
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);
+}
#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"
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. */
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_ */
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 ();
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)
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);
}
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. */
width = XCALLOC (base_t, nvectors);
token_actions ();
- bitsetv_free (LA);
- free (LArule);
goto_actions ();
XFREE (goto_map + ntokens);
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);
}