]> ocean-lang.org Git - ocean/commitdiff
parsergen.mdc: remove tracking of left-recursive symbols.
authorNeilBrown <neil@brown.name>
Fri, 5 Mar 2021 08:24:11 +0000 (19:24 +1100)
committerNeilBrown <neil@brown.name>
Wed, 10 Mar 2021 01:00:30 +0000 (12:00 +1100)
left-recursive symbols are no longer interesting, so remove the code and
descriptions.

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

index a913cb912c77cf5a977e835b4bd1ec8ac212929b..2da1d65bb7b2f962af024ef6b7d7f20a9e2e1f3e 100644 (file)
@@ -417,21 +417,6 @@ means that the value (usually a reference) is being moved out, so it
 will not automatically be freed.  The effect of using '<' is that the
 variable is cleareed to all-zeros.
 
 will not automatically be freed.  The effect of using '<' is that the
 variable is cleareed to all-zeros.
 
-Symbols that are left-recursive are a little special.  These are symbols
-that both the head of a production and the first body symbol of the same
-production.  They are problematic when they appear in other productions
-elsewhere than at the end, and when indenting is used to describe
-structure.  In this case there is no way for a smaller indent to ensure
-the left-recursive symbol cannot be extended.  When it appears at the
-end of a production, that production can be reduced to ensure the symbol
-isn't extended.  So we record left-recursive symbols while reading the
-grammar, and produce a warning when reporting the grammar if they are
-found in an unsuitable place.
-
-A symbol that is only left recursive in a production where it is
-followed by newline does not cause these problems because the newline
-will effectively terminate it.
-
 While building productions we will need to add to an array which needs to
 grow dynamically.
 
 While building productions we will need to add to an array which needs to
 grow dynamically.
 
@@ -492,7 +477,6 @@ Now we have all the bits we need to parse a full production.
 
 ###### symbol fields
        int first_production;
 
 ###### symbol fields
        int first_production;
-       int left_recursive;
 
 ###### functions
        static char *parse_production(struct grammar *g,
 
 ###### functions
        static char *parse_production(struct grammar *g,
@@ -554,10 +538,6 @@ Now we have all the bits we need to parse a full production.
                        }
                        tk = token_next(state);
                }
                        }
                        tk = token_next(state);
                }
-               if (p.body_size >= 2 &&
-                   p.body[0] == p.head &&
-                   p.body[1]->num != TK_newline)
-                       p.head->left_recursive = 1;
 
                if (tk.num != TK_newline && tk.num != TK_eof) {
                        err = "stray tokens at end of line";
 
                if (tk.num != TK_newline && tk.num != TK_eof) {
                        err = "stray tokens at end of line";
@@ -1622,7 +1602,7 @@ all the tables that have been generated, plus a description of any conflicts.
                if (g->follow)
                        report_follow(g);
                report_itemsets(g);
                if (g->follow)
                        report_follow(g);
                report_itemsets(g);
-               return report_conflicts(g, type) + report_left_recursive(g);
+               return report_conflicts(g, type);
        }
 
 Firstly we have the complete list of symbols, together with the
        }
 
 Firstly we have the complete list of symbols, together with the
@@ -1944,42 +1924,6 @@ but handled internally.
        }
 
 
        }
 
 
-### Reporting non-final left-recursive symbols.
-
-Left recursive symbols are a problem for parses that honour indentation
-when they appear other than at the end of the production.  So we need to
-report these when asked.
-
-###### functions
-
-       static int report_left_recursive(struct grammar *g)
-       {
-               int p;
-               int bad_left_recursive = 0;
-
-               for (p = 0; p < g->production_count; p++) {
-                       struct production *pr = g->productions[p];
-                       int sn;
-
-                       for (sn = 0; sn < pr->body_size - 1; sn++) {
-                               struct symbol *s = pr->body[sn];
-
-                               if (s->left_recursive == 1 &&
-                                   s != pr->head) {
-                                       if (!bad_left_recursive) {
-                                               bad_left_recursive = 1;
-                                               printf("Misplaced left recursive symbols.\n");
-                                       }
-                                       printf("  ");
-                                       prtxt(s->name);
-                                       printf(" in production [%d]\n", p);
-                                       s->left_recursive = 2;
-                               }
-                       }
-               }
-               return bad_left_recursive;
-       }
-
 ## Generating the parser
 
 The exported part of the parser is the `parse_XX` function, where the name
 ## Generating the parser
 
 The exported part of the parser is the `parse_XX` function, where the name