From 58c84c7457ecc82710909ae5f15a39ad16434659 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 2 Oct 2014 20:51:01 +1000 Subject: [PATCH 1/1] parsergen: revise "newline_permitted" definition. This is in line with "new" approach. A newline is permitted/expected if a starts_line state is closer to top of stack than an indent. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 7859a98..573f6de 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2517,16 +2517,16 @@ So we walk down: * sizeof(p->asn_stack[0])); } next->state = newstate; - next->newline_permitted = 0; - if (p->tos) - next->newline_permitted = - (p->stack[p->tos-1].newline_permitted?:-1)+1; - if (next->indents > next->starts_indented) - next->newline_permitted = 0; - if (next->indents && next->newline_permitted > 2) - next->newline_permitted = 0; if (states[newstate].starts_line) next->newline_permitted = 1; + else if (next->indents) + next->newline_permitted = 0; + else if (p->tos) + next->newline_permitted = + p->stack[p->tos-1].newline_permitted; + else + next->newline_permitted = 0; + if (next->since_newline) { if (p->tos) next->since_newline = p->stack[p->tos-1].since_newline + 1; @@ -2667,7 +2667,9 @@ since the last state which could have been at the start of a line. if (states[tos->state].starts_line) tos->newline_permitted = 1; else if (p.tos > 1) - tos->newline_permitted = (p.stack[p.tos-2].newline_permitted ?:-1)+1; + tos->newline_permitted = p.stack[p.tos-2].newline_permitted; + else + tos->newline_permitted = 0; } free(tk); tk = NULL; @@ -2678,7 +2680,7 @@ since the last state which could have been at the start of a line. // will fail). } if (next.sym == TK_newline) { - if (! tos->newline_permitted) { + if (!tos->newline_permitted) { free(tk); tk = NULL; parser_trace_action(trace, "Discard"); -- 2.43.0