]> ocean-lang.org Git - ocean/commitdiff
parsergen - don't completely hide non-critical conflicts.
authorNeilBrown <neil@brown.name>
Wed, 5 Jun 2019 08:09:59 +0000 (18:09 +1000)
committerNeilBrown <neil@brown.name>
Wed, 5 Jun 2019 08:09:59 +0000 (18:09 +1000)
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>
csrc/parsergen.mdc

index a7330351d767b52f52ba7b14a802e1b2556dd842..2fdbf453c8114746843e5b3f95ee2ab07b570932 100644 (file)
@@ -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) {