/* Find and resolve or report look-ahead conflicts for bison,
- Copyright (C) 1984, 1989 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
along with Bison; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-#ifdef _AIX
- #pragma alloca
-#endif
#include <stdio.h>
#include "system.h"
#include "machine.h"
-#include "new.h"
+#include "alloc.h"
#include "files.h"
#include "gram.h"
#include "state.h"
-#ifndef __GNUC__
-#undef alloca
-#define alloca __builtin_alloca
-#else
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#else
-#ifndef _AIX
-extern char *alloca ();
-#endif
-#endif
-#endif
-
extern char **tags;
extern int tokensetsize;
extern char *consistent;
register unsigned *fp1;
register unsigned *fp2;
register int redprec;
- /* Extra parens avoid errors on Ultrix 4.3. */
- errs *errp = (errs *) alloca ((sizeof(errs) + ntokens * sizeof(short)));
+ errs *errp = (errs *) xmalloc (sizeof(errs) + ntokens * sizeof(short));
short *errtokens = errp->errs;
/* find the rule to reduce by to get precedence of reduction */
{
if (sprec[i] < redprec)
{
- if (verboseflag) log_resolution(state, lookaheadnum, i, "reduce");
+ if (verboseflag) log_resolution(state, lookaheadnum, i, _("reduce"));
*fp2 &= ~mask; /* flush the shift for this token */
flush_shift(state, i);
}
else if (sprec[i] > redprec)
{
- if (verboseflag) log_resolution(state, lookaheadnum, i, "shift");
+ if (verboseflag) log_resolution(state, lookaheadnum, i, _("shift"));
*fp1 &= ~mask; /* flush the reduce for this token */
}
else
{
case RIGHT_ASSOC:
- if (verboseflag) log_resolution(state, lookaheadnum, i, "shift");
+ if (verboseflag) log_resolution(state, lookaheadnum, i, _("shift"));
break;
case LEFT_ASSOC:
- if (verboseflag) log_resolution(state, lookaheadnum, i, "reduce");
+ if (verboseflag) log_resolution(state, lookaheadnum, i, _("reduce"));
break;
case NON_ASSOC:
- if (verboseflag) log_resolution(state, lookaheadnum, i, "an error");
+ if (verboseflag) log_resolution(state, lookaheadnum, i, _("an error"));
break;
}
}
else
err_table[state] = 0;
+ free(errp);
}
char *resolution;
{
fprintf(foutput,
- "Conflict in state %d between rule %d and token %s resolved as %s.\n",
+ _("Conflict in state %d between rule %d and token %s resolved as %s.\n"),
state, LAruleno[LAno], tags[token], resolution);
}
src_total += src_count;
rrc_total += rrc_count;
- fprintf(foutput, "State %d contains", i);
+ fprintf(foutput, _("State %d contains"), i);
if (src_count == 1)
- fprintf(foutput, " 1 shift/reduce conflict");
+ fprintf(foutput, _(" 1 shift/reduce conflict"));
else if (src_count > 1)
- fprintf(foutput, " %d shift/reduce conflicts", src_count);
+ fprintf(foutput, _(" %d shift/reduce conflicts"), src_count);
if (src_count > 0 && rrc_count > 0)
- fprintf(foutput, " and");
+ fprintf(foutput, _(" and"));
if (rrc_count == 1)
- fprintf(foutput, " 1 reduce/reduce conflict");
+ fprintf(foutput, _(" 1 reduce/reduce conflict"));
else if (rrc_count > 1)
- fprintf(foutput, " %d reduce/reduce conflicts", rrc_count);
+ fprintf(foutput, _(" %d reduce/reduce conflicts"), rrc_count);
putc('.', foutput);
putc('\n', foutput);
{
/* If invoked under the name `yacc', use the output format
specified by POSIX. */
- fprintf(stderr, "conflicts: ");
+ fprintf(stderr, _("conflicts: "));
if (src_total > 0)
- fprintf(stderr, " %d shift/reduce", src_total);
+ fprintf(stderr, _(" %d shift/reduce"), src_total);
if (src_total > 0 && rrc_total > 0)
fprintf(stderr, ",");
if (rrc_total > 0)
- fprintf(stderr, " %d reduce/reduce", rrc_total);
+ fprintf(stderr, _(" %d reduce/reduce"), rrc_total);
putc('\n', stderr);
}
else
{
- fprintf(stderr, "%s contains", infile);
+ fprintf(stderr, _("%s contains"), infile);
if (src_total == 1)
- fprintf(stderr, " 1 shift/reduce conflict");
+ fprintf(stderr, _(" 1 shift/reduce conflict"));
else if (src_total > 1)
- fprintf(stderr, " %d shift/reduce conflicts", src_total);
+ fprintf(stderr, _(" %d shift/reduce conflicts"), src_total);
if (src_total > 0 && rrc_total > 0)
- fprintf(stderr, " and");
+ fprintf(stderr, _(" and"));
if (rrc_total == 1)
- fprintf(stderr, " 1 reduce/reduce conflict");
+ fprintf(stderr, _(" 1 reduce/reduce conflict"));
else if (rrc_total > 1)
- fprintf(stderr, " %d reduce/reduce conflicts", rrc_total);
+ fprintf(stderr, _(" %d reduce/reduce conflicts"), rrc_total);
putc('.', stderr);
putc('\n', stderr);
for (i = 0; i < ntokens; i++)
{
if (mask & *fp3)
- fprintf(foutput, " %-4s\t[reduce using rule %d (%s)]\n",
+ fprintf(foutput, _(" %-4s\t[reduce using rule %d (%s)]\n"),
tags[i], default_rule, tags[rlhs[default_rule]]);
mask <<= 1;
}
}
- fprintf(foutput, " $default\treduce using rule %d (%s)\n\n",
+ fprintf(foutput, _(" $default\treduce using rule %d (%s)\n\n"),
default_rule, tags[rlhs[default_rule]]);
}
else if (n - m >= 1)
fp3 = lookaheadset;
while (fp3 < fp4)
- *fp3++ = *fp1++ & ( ~ (*fp2++));
+ *fp3++ = *fp1++ & (~(*fp2++));
count = 0;
mask = 1;
if (j != default_LA)
{
rule = LAruleno[j];
- fprintf(foutput, " %-4s\treduce using rule %d (%s)\n",
+ fprintf(foutput, _(" %-4s\treduce using rule %d (%s)\n"),
tags[i], rule, tags[rlhs[rule]]);
}
else defaulted = 1;
if (defaulted)
{
rule = LAruleno[default_LA];
- fprintf(foutput, " %-4s\treduce using rule %d (%s)\n",
+ fprintf(foutput, _(" %-4s\treduce using rule %d (%s)\n"),
tags[i], rule, tags[rlhs[rule]]);
defaulted = 0;
}
rule = LAruleno[j];
- fprintf(foutput, " %-4s\t[reduce using rule %d (%s)]\n",
+ fprintf(foutput, _(" %-4s\t[reduce using rule %d (%s)]\n"),
tags[i], rule, tags[rlhs[rule]]);
}
}
if (mask == 0)
{
mask = 1;
- /* This used to be fp1, but I think fp2 is right
- because fp2 is where the words are fetched to test with mask
- in this loop. */
+ /* We tried incrementing just fp1, and just fp2; both seem wrong.
+ It seems necessary to increment both in sync. */
+ fp1++;
fp2++;
}
}
if (default_LA >= 0)
{
- fprintf(foutput, " $default\treduce using rule %d (%s)\n",
+ fprintf(foutput, _(" $default\treduce using rule %d (%s)\n"),
default_rule, tags[rlhs[default_rule]]);
}