+2001-11-19 Akim Demaille <akim@epita.fr>
+
+ * src/lalr.c (F): New macro to access to the variable F.
+ Adjust.
+
2001-11-19 Akim Demaille <akim@epita.fr>
* src/lalr.h (LA): New macro to access to the variable LA.
static int infinity;
static int maxrhs;
static int ngotos;
-static unsigned *F;
+
+/* And for the famous F variable, which named is so descriptive that a
+ comment is hardly needed. <grin>. */
+static unsigned *F = NULL;
+#define F(Rule) (F + (Rule) * tokensetsize)
+
static short **includes;
static shorts **lookback;
static short **R;
VERTICES[++top] = i;
INDEX[i] = height = top;
- base = F + i * tokensetsize;
- fp3 = base + tokensetsize;
+ base = F (i);
+ fp3 = F (i + 1);
rp = R[i];
if (rp)
INDEX[i] = INDEX[j];
fp1 = base;
- fp2 = F + j * tokensetsize;
+ fp2 = F (j);
while (fp1 < fp3)
*fp1++ |= *fp2++;
break;
fp1 = base;
- fp2 = F + j * tokensetsize;
+ fp2 = F (j);
while (fp1 < fp3)
*fp2++ = *fp1++;
INDEX[i] = 0;
for (i = 0; i < ngotos; i++)
- {
- if (INDEX[i] == 0 && R[i])
- traverse (i);
- }
+ if (INDEX[i] == 0 && R[i])
+ traverse (i);
XFREE (INDEX);
XFREE (VERTICES);
digraph (reads);
for (i = 0; i < ngotos; i++)
- {
- if (reads[i])
- XFREE (reads[i]);
- }
+ XFREE (reads[i]);
XFREE (reads);
XFREE (edge);
digraph (includes);
for (i = 0; i < ngotos; i++)
- {
- if (includes[i])
- XFREE (includes[i]);
- }
+ XFREE (includes[i]);
XFREE (includes);
}
compute_lookaheads (void)
{
int i;
- int n;
- unsigned *fp1;
- unsigned *fp2;
- unsigned *fp3;
shorts *sp;
- shorts *sptmp; /* JF */
for (i = 0; i < state_table[nstates].lookaheads; i++)
- {
- fp3 = LA (i + 1);
- for (sp = lookback[i]; sp; sp = sp->next)
- {
- fp1 = LA (i);
- fp2 = F + tokensetsize * sp->value;
- while (fp1 < fp3)
- *fp1++ |= *fp2++;
- }
- }
+ for (sp = lookback[i]; sp; sp = sp->next)
+ {
+ unsigned *fp1 = LA (i);
+ unsigned *fp2 = F (sp->value);
+ while (fp1 < LA (i + 1))
+ *fp1++ |= *fp2++;
+ }
+ /* Free LOOKBACK. */
for (i = 0; i < state_table[nstates].lookaheads; i++)
{
- /* JF removed ref to freed storage */
+ shorts *sptmp;
for (sp = lookback[i]; sp; sp = sptmp)
{
sptmp = sp->next;