We cannot really shift the final result onto the stack, because
there is not 'goto' for '$eof' in that final state.
So if the shift() fails, hold onto the result and ultimately return it.
This means we don't need to pop it off the stack at the end.
Signed-off-by: NeilBrown <neil@brown.name>
}
if (states[p.next.state].reduce_prod >= 0) {
void **body;
}
if (states[p.next.state].reduce_prod >= 0) {
void **body;
int prod = states[p.next.state].reduce_prod;
int size = states[p.next.state].reduce_size;
int bufsize;
int prod = states[p.next.state].reduce_prod;
int size = states[p.next.state].reduce_size;
int bufsize;
bufsize = do_reduce(prod, body, config, buf);
pop(&p, size, do_free);
bufsize = do_reduce(prod, body, config, buf);
pop(&p, size, do_free);
- shift(&p, memdup(buf, bufsize), states);
+ res = memdup(buf, bufsize);
+ if (!shift(&p, res, states)) {
+ if (prod != 0) abort();
continue;
}
if (tk->num == TK_out) {
continue;
}
if (tk->num == TK_out) {
- if (accepted)
- ret = p.asn_stack[0];
- else
- pop(&p, p.tos, do_free);
+ pop(&p, p.tos, do_free);
free(p.asn_stack);
free(p.stack);
return ret;
free(p.asn_stack);
free(p.stack);
return ret;