freeing function. The symbol leads us to the right free function through
`do_free`.
-The `indents` count and the `starts_indented` flag track the line
-indents in the symbol. These are used to allow indent information to
-guide parsing and error recovery.
+The `indents` count tracks the line indents in the symbol. These are
+used to allow indent information to guide parsing and error recovery.
`since_newline` tracks how many stack frames since the last
start-of-line (whether indented or not). So if `since_newline` is
short newline_permitted;
short sym;
- short starts_indented;
short indents;
short since_newline;
short since_indent;
{
int i;
p->tos -= num;
- next->starts_indented =
- p->stack[p->tos].starts_indented;
next->since_newline =
p->stack[p->tos].since_newline;
next->indents = 0;
parser_trace(trace, &p, &next, tk, states, non_term, config->known_count);
if (next.sym == TK_in) {
- next.starts_indented = 1;
next.indents = 1;
next.since_newline = 0;
free(tk);
}
if (shift(&p, &next, tk, states)) {
next.since_newline = !(tk->num == TK_newline);
- next.starts_indented = 0;
next.indents = 0;
tk = NULL;
parser_trace_action(trace, "Shift");
pop(&p, size, &frame, do_free);
else {
frame.indents = next.indents;
- frame.starts_indented = frame.indents;
frame.since_newline = 1;
next.indents = 0;
- next.starts_indented = 0;
}
res = memdup(buf, bufsize);
memset(buf, 0, bufsize);
fputs(non_term[sym - TK_reserved - knowns],
trace);
if (f->indents)
- fprintf(trace, "%c%d", f->starts_indented?':':'.',
- f->indents);
+ fprintf(trace, ".%d", f->indents);
if (f->since_newline == 0)
fputs("/", trace);
fputs(" ", trace);
else
text_dump(trace, tk->txt, 20);
if (n->indents)
- fprintf(trace, "%c%d", n->starts_indented?':':'.',
- n->indents);
+ fprintf(trace, ".%d", n->indents);
if (n->since_newline == 0)
fputs("/", trace);
fputs("]", trace);