From d28c54dc30f0b4322ffb2ecbbfcee9a566052d4b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 19 Feb 2018 16:31:14 +1100 Subject: [PATCH] parsergen: be careful shifting TK_error shift() behaved a little differently when p.tos == 0, and if the stack is completely empty, there is little point trying to shift TK_error as there is no state to work with. So rearrange the loop slightly. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 905e8f8..c25a87e 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2841,9 +2841,9 @@ one symbol for each line where newlines are allowed. short indents = 0, start_of_line; err_tk = tok_copy(*tk); - while (shift(&p, TK_error, 0, 0, - err_tk, states) == 0 - && p.tos > 0) + while (p.tos > 0 && + shift(&p, TK_error, 0, 0, + err_tk, states) == 0) // discard this state indents += pop(&p, 1, &start_of_line, do_free); if (p.tos == 0) { -- 2.43.0