From: NeilBrown Date: Wed, 5 Jun 2019 08:09:59 +0000 (+1000) Subject: parsergen - don't completely hide non-critical conflicts. X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=f5e50e504ef5724ed7d9f13c411fff28d2b17a1e parsergen - don't completely hide non-critical conflicts. 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 --- diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index a733035..2fdbf45 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -1776,10 +1776,10 @@ As a special case, if we find a SHIFT/REDUCE conflict, where a 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) { @@ -1826,13 +1826,16 @@ include newlines as token. 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) {