From: NeilBrown <neil@brown.name> Date: Fri, 3 Oct 2014 04:30:36 +0000 (+1000) Subject: parsergen: remove special casing for pop(0). X-Git-Tag: workingparser~2 X-Git-Url: https://ocean-lang.org/code/?a=commitdiff_plain;h=a2390d266f967d37ad24a7a3b4d7f3617b5e28e1;p=ocean parsergen: remove special casing for pop(0). If pop() is asked to remove nothing from the stack, it now does exactly the right thing and returns the value that we want. So some special-casing can be removed. Signed-off-by: NeilBrown <neil@brown.name> --- diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index cdcd942..7ac1e0b 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2561,8 +2561,6 @@ collects a summary of the indents in the symbols that are being removed. It is called _after_ we reduce a production, just before we `shift` the nonterminal in. -`pop` is only called if there are entries to remove, so `num` is never zero. - ###### parser functions static int pop(struct parser *p, int num, @@ -2745,13 +2743,8 @@ since the last state which could have been at the start of a line. bufsize = do_reduce(prod, body, config, buf); - if (size) - indents = pop(&p, size, &start_of_line, - do_free); - else { - indents = 0; - start_of_line = 0; - } + indents = pop(&p, size, &start_of_line, + do_free); res = memdup(buf, bufsize); memset(buf, 0, bufsize); if (!shift(&p, nextstate->reduce_sym, @@ -2815,8 +2808,7 @@ since the last state which could have been at the start of a line. tos->indents += indents; } free(tk); - if (p.tos) - pop(&p, p.tos, NULL, do_free); + pop(&p, p.tos, NULL, do_free); free(p.asn_stack); free(p.stack); return ret;