Shift/Reduce conflicts that are likely to be resolved by
a line break are currently hidden. This is probably a good idea,
but sometimes it can be useful to see them anyway.
So report them as "non-critical" conflicts, and don't
count them - so if no other conflicts are found, the
"no conflicts" message is still generated.
Signed-off-by: NeilBrown <neil@brown.name>
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
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
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)
{
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]);
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);
prtxt(g->symtab[la.syms[k]]->name);
printf(":\n");
report_item(g, shifts.data[pos]);
report_item(g, itm);
}
pos = symset_find(&reduce, la.syms[k]);
if (pos < 0) {
}
pos = symset_find(&reduce, la.syms[k]);
if (pos < 0) {