]> ocean-lang.org Git - ocean/commitdiff
parsergen: remove special casing for pop(0).
authorNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 04:30:36 +0000 (14:30 +1000)
committerNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 04:30:36 +0000 (14:30 +1000)
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>
csrc/parsergen.mdc

index cdcd9424e7ce4ec69d8439c3f0ec0d019ab70bc7..7ac1e0bae1a920dc3489379bd345fb02a6db4c58 100644 (file)
@@ -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;