if (p.next.sym == TK_out) {
if (p.stack[p.tos-1].indents > p.stack[p.tos-1].starts_indented ||
(p.stack[p.tos-1].indents == 1 &&
- states[p.next.state].reduce_size > 1)) {
+ states[p.next.state].reduce_size != 1)) {
p.stack[p.tos-1].indents -= 1;
if (p.stack[p.tos-1].indents == p.stack[p.tos-1].starts_indented) {
// no internal indent any more, reassess 'newline_permitted'
}
if (states[p.next.state].reduce_prod >= 0) {
void **body;
+ void *res;
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);
- shift(&p, memdup(buf, bufsize), states);
+ res = memdup(buf, bufsize);
memset(buf, 0, bufsize);
- if (prod == 0)
+ if (!shift(&p, res, states)) {
+ if (prod != 0) abort();
accepted = 1;
+ ret = res;
+ }
continue;
}
if (tk->num == TK_out) {
break;
}
free(tk);
- 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;