terminal that could be shifted is in the lookahead set of some
reducable item, then set check if the reducable item also have
`TK_newline` in its lookahead set. If it does, then a newline will
-force and reduction, but anything else can reasonably be shifts, so
+force the reduction, but anything else can reasonably be shifted, so
that isn't really a conflict. Such apparent conflicts do not get
-reported. This will not affect a "tradtional" grammar that does not
-include newlines as token.
+counted, and are reported as non-critical. This will not affect a
+"traditional" grammar that does not include newlines as token.
static int conflicts_slr(struct grammar *g, enum grammar_type type)
{
int k;
for (k = 0; k < la.cnt; k++) {
int pos = symset_find(&shifts, la.syms[k]);
- if (pos >= 0 && symset_find(&la, TK_newline) < 0) {
- printf(" State %d has SHIFT/REDUCE conflict on ", i);
+ if (pos >= 0) {
+ if (symset_find(&la, TK_newline) < 0) {
+ printf(" State %d has SHIFT/REDUCE conflict on ", i);
+ cnt++;
+ } else
+ printf(" State %d has non-critical SHIFT/REDUCE conflict on ", i);
prtxt(g->symtab[la.syms[k]]->name);
printf(":\n");
report_item(g, shifts.data[pos]);
report_item(g, itm);
- cnt++;
}
pos = symset_find(&reduce, la.syms[k]);
if (pos < 0) {