From: NeilBrown Date: Mon, 19 Feb 2018 05:31:14 +0000 (+1100) Subject: parsergen: be careful shifting TK_error X-Git-Tag: StoneyCreek~8 X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=d28c54dc30f0b4322ffb2ecbbfcee9a566052d4b 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 --- 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) {