From: Akim Demaille Date: Mon, 19 Nov 2001 10:08:54 +0000 (+0000) Subject: * src/lalr.h (LA): New macro to access to the variable LA. X-Git-Tag: before-m4-back-end~303 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/bb527fc2715bf579a512b8a4c7787b4f09954bf9 * src/lalr.h (LA): New macro to access to the variable LA. * src/output.c, src/lalr.c, src/print_graph.c, src/conflicts.c: * src/lalr.c: Adjust. --- diff --git a/ChangeLog b/ChangeLog index b3df6f0c..dae2642c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-19 Akim Demaille + + * src/lalr.h (LA): New macro to access to the variable LA. + * src/output.c, src/lalr.c, src/print_graph.c, src/conflicts.c: + * src/lalr.c: Adjust. + 2001-11-19 Akim Demaille * src/lalr.c (initialize_LA): Only initialize LA. Let... diff --git a/src/conflicts.c b/src/conflicts.c index 77520ade..a0c0986d 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -97,7 +97,7 @@ resolve_sr_conflict (int state, int lookaheadnum) redprec = rprec[LAruleno[lookaheadnum]]; mask = 1; - fp1 = LA + lookaheadnum * tokensetsize; + fp1 = LA (lookaheadnum); fp2 = lookaheadset; for (i = 0; i < ntokens; i++) { @@ -219,7 +219,7 @@ set_conflicts (int state) for (i = state_table[state].lookaheads; i < k; i++) if (rprec[LAruleno[i]]) { - fp1 = LA + i * tokensetsize; + fp1 = LA (i); fp2 = fp1; fp3 = lookaheadset; @@ -238,7 +238,7 @@ set_conflicts (int state) for conflicts not resolved above. */ for (i = state_table[state].lookaheads; i < k; i++) { - fp1 = LA + i * tokensetsize; + fp1 = LA (i); fp2 = fp1; fp3 = lookaheadset; @@ -314,7 +314,7 @@ count_sr_conflicts (int state) for (i = state_table[state].lookaheads; i < k; i++) { - fp1 = LA + i * tokensetsize; + fp1 = LA (i); fp2 = lookaheadset; while (fp2 < fp3) @@ -366,7 +366,7 @@ count_rr_conflicts (int state) return 0; mask = 1; - baseword = LA + m * tokensetsize; + baseword = LA (m); for (i = 0; i < ntokens; i++) { unsigned *wordp = baseword; @@ -572,7 +572,7 @@ print_reductions (FILE *out, int state) { default_rule = LAruleno[m]; - fp1 = LA + m * tokensetsize; + fp1 = LA (m); fp2 = shiftset; fp3 = lookaheadset; fp4 = lookaheadset + tokensetsize; @@ -609,7 +609,7 @@ print_reductions (FILE *out, int state) if (!nodefault) for (i = m; i < n; i++) { - fp1 = LA + i * tokensetsize; + fp1 = LA (i); fp2 = shiftset; fp3 = lookaheadset; @@ -664,7 +664,7 @@ print_reductions (FILE *out, int state) } mask = 1; - fp1 = LA + m * tokensetsize; + fp1 = LA (m); fp2 = shiftset; for (i = 0; i < ntokens; i++) { diff --git a/src/lalr.c b/src/lalr.c index ce076d4d..46ec2eef 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -141,6 +141,11 @@ digraph (short **relation) XFREE (VERTICES); } + +/*--------------------. +| Build STATE_TABLE. | +`--------------------*/ + static void set_state_table (void) { @@ -643,22 +648,18 @@ compute_lookaheads (void) unsigned *fp2; unsigned *fp3; shorts *sp; - unsigned *rowp; shorts *sptmp; /* JF */ - rowp = LA; for (i = 0; i < state_table[nstates].lookaheads; i++) { - fp3 = rowp + tokensetsize; + fp3 = LA (i + 1); for (sp = lookback[i]; sp; sp = sp->next) { - fp1 = rowp; + fp1 = LA (i); fp2 = F + tokensetsize * sp->value; while (fp1 < fp3) *fp1++ |= *fp2++; } - - rowp = fp3; } for (i = 0; i < state_table[nstates].lookaheads; i++) diff --git a/src/lalr.h b/src/lalr.h index 00137154..f9941afa 100644 --- a/src/lalr.h +++ b/src/lalr.h @@ -66,6 +66,7 @@ extern short *LAruleno; it is a conflict. */ extern unsigned *LA; +#define LA(Rule) (LA + (Rule) * tokensetsize) /* A structure decorating a state, with additional information. */ diff --git a/src/output.c b/src/output.c index 3a7f0817..8ae1cff9 100644 --- a/src/output.c +++ b/src/output.c @@ -354,7 +354,7 @@ action_row (int state) for (i = n - 1; i >= m; i--) { rule = -LAruleno[i]; - wordp = LA + i * tokensetsize; + wordp = LA (i); mask = 1; /* and find each token which the rule finds acceptable