]> ocean-lang.org Git - ocean/commitdiff
parsergen: remove symbol synthesis option.
authorNeilBrown <neil@brown.name>
Mon, 19 Feb 2018 04:32:46 +0000 (15:32 +1100)
committerNeilBrown <neil@brown.name>
Mon, 19 Feb 2018 04:32:46 +0000 (15:32 +1100)
This idea never worked, and cannot work as we cannot
magically synthesis the ast node to go with a synthesized
symbol.
If we want to synthesize something on error, we just use
a production like
   foo -> ERRROR ${ $0 = a_new_for(); }$

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

index 0d7832491444975e85ef8b28c50df7e29246f5ab..48f569168338f159598d532be78f79cd21835c10 100644 (file)
@@ -1950,7 +1950,6 @@ The go to table is stored in a simple array of `sym` and corresponding
                short reduce_prod;
                short reduce_size;
                short reduce_sym;
-               short shift_sym;
                short starts_line;
                short min_prefix;
        };
@@ -1984,23 +1983,15 @@ The go to table is stored in a simple array of `sym` and corresponding
                for (i = 0; i < g->states; i++) {
                        struct itemset *is = g->statetab[i];
                        int j, prod = -1, prod_len;
-                       int shift_sym = -1;
-                       int shift_len = 0, shift_remain = 0;
+
                        for (j = 0; j < is->items.cnt; j++) {
                                int itm = is->items.syms[j];
                                int p = item_prod(itm);
                                int bp = item_index(itm);
                                struct production *pr = g->productions[p];
 
-                               if (bp < pr->body_size) {
-                                       if (shift_sym < 0 ||
-                                           (shift_len == bp && shift_remain > pr->body_size - bp)) {
-                                               shift_sym = pr->body[bp]->num;
-                                               shift_len = bp;
-                                               shift_remain = pr->body_size - bp;
-                                       }
+                               if (bp < pr->body_size)
                                        continue;
-                               }
                                /* This is what we reduce */
                                if (prod < 0 || prod_len < pr->body_size) {
                                        prod = p;
@@ -2009,14 +2000,14 @@ The go to table is stored in a simple array of `sym` and corresponding
                        }
 
                        if (prod >= 0)
-                               fprintf(f, "\t[%d] = { %d, goto_%d, %d, %d, %d, 0, %d, %d },\n",
+                               fprintf(f, "\t[%d] = { %d, goto_%d, %d, %d, %d, %d, %d },\n",
                                        i, is->go_to.cnt, i, prod,
                                        g->productions[prod]->body_size,
                                        g->productions[prod]->head->num,
                                        is->starts_line, is->min_prefix);
                        else
-                               fprintf(f, "\t[%d] = { %d, goto_%d, -1, -1, -1, %d, %d, %d },\n",
-                                       i, is->go_to.cnt, i, shift_sym,
+                               fprintf(f, "\t[%d] = { %d, goto_%d, -1, -1, -1, %d, %d },\n",
+                                       i, is->go_to.cnt, i,
                                        is->starts_line, is->min_prefix);
                }
                fprintf(f, "};\n\n");
@@ -2822,16 +2813,6 @@ one symbol for each line where newlines are allowed.
                                parser_trace_action(trace, "Reduce");
                                continue;
                        }
-                       if (tk->num == TK_out) {
-                               // Indent problem - synthesise tokens to get us
-                               // out of here.
-                               fprintf(stderr, "Synthesize %d to handle indent problem\n", states[tos->state].shift_sym);
-                               shift(&p, states[tos->state].shift_sym,
-                                     0, 1, tok_copy(*tk), states);
-                               // FIXME need to report this error somehow
-                               parser_trace_action(trace, "Synthesize");
-                               continue;
-                       }
                        /* Error. We walk up the stack until we
                         * find a state which will accept TK_error.
                         * We then shift in TK_error and see what state