]> ocean-lang.org Git - ocean/commitdiff
parsergen: revert the allowance for "non-critical" conflicts.
authorNeilBrown <neil@brown.name>
Sun, 16 Jun 2019 02:37:23 +0000 (12:37 +1000)
committerNeilBrown <neil@brown.name>
Sun, 16 Jun 2019 02:37:23 +0000 (12:37 +1000)
Having improved the parsing approach, I don't get any
"non-critical" conflicts any more, and I no longer think
they aren't critical.

Conflicts can often be resolved with precendence if they cannot
be resolved any other way.

So treat all conflict, except shift/reduce on NEWLINE, as genuine
conflicts.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/parsergen.mdc

index 1981c901ac013afe1a2ab932dbc2d8742666b964..2546d7632722a0673d4c78c83f6d924310390379 100644 (file)
@@ -1790,14 +1790,10 @@ terminals to items where that terminal could be shifted and another
 which maps terminals to items that could be reduced when the terminal
 is in look-ahead.  We report when we get conflicts between the two.
 
-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 the reduction, but anything else can reasonably be shifted, so
-that isn't really a conflict.  Such apparent conflicts do not get
-counted, and are reported as non-critical.  This will not affect a
-"traditional" grammar that does not include newlines as token.
+As a special case, if we find a SHIFT/REDUCE conflict, on the NEWLINE
+terminal, we ignore it.  NEWLINES are handled specially with its own
+rules for when to shift and when to reduce.  Conflicts are expected,
+but handled internally.
 
        static int conflicts_slr(struct grammar *g, enum grammar_type type)
        {
@@ -1851,12 +1847,9 @@ counted, and are reported as non-critical.  This will not affect a
                                for (k = 0; k < la.cnt; k++) {
                                        int pos = symset_find(&shifts, la.syms[k]);
                                        if (pos >= 0 && la.syms[k] != TK_newline) {
-                                               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("  State %d has SHIFT/REDUCE conflict on ", i);
+                                               cnt++;
+                                                       prtxt(g->symtab[la.syms[k]]->name);
                                                printf(":\n");
                                                report_item(g, shifts.data[pos]);
                                                report_item(g, itm);