summaryrefslogtreecommitdiff
path: root/TODO
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-06-28 16:09:13 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-06-29 19:36:41 +0200
commit330552ea499ca474f65967160e9d4e50265f9631 (patch)
treecbfb334fdae9bdfa4a0348a48b2f050f78e4b7f3 /TODO
parent7c609859ee3fd7c40c7685df7b811a50a4071ace (diff)
downloadbison-330552ea499ca474f65967160e9d4e50265f9631.tar.gz
yacc.c: push: don't clear the parser state when accepting/rejecting
Currently when a push parser finishes its parsing (i.e., it did not return YYPUSH_MORE), it also clears its state. It is therefore impossible to see if it had parse errors. In the context of autocompletion, because error recovery might have fired, the parser is actually already in a different state. For instance on `(1 + + <TAB>` in the bistromathic, because there's a `exp: "(" error ")"` recovery rule, `1 + +` tokens have already been popped, replaced by `error`, and autocompletions think we are ready for the closing ")". So here, we would like to see if there was a syntax error, yet `yynerrs` was cleared. In the case of a successful parse, we still have a problem: if error recovery succeeded, we won't know it, since, again, `yynerrs` is clearer. It seems much more natural to leave the parser state available for analysis when there is a failure. To reuse the parser, we should either: 1. provide an explicit means to reinitialize a parser state for future parses. 2. automatically reset the parser state when it is used in a new parse. Option 2 requires to check whether we need to reinitialize the parser each time we call `yypush_parse`, i.e., each time we give a new token. This seems expensive compared to Option 1, but benchmarks revealed no difference. Option 1 is incompatible with the documentation ("After `yypush_parse` returns a status other than `YYPUSH_MORE`, the parser instance `yyps` may be reused for a new parse."). So Option 2 wins, reusing the private `yynew` member to record that a parse was finished, and therefore that the state must reset in the next call to `yypull_parse`. While at it, this implementation now reuses the previously enlarged stacks from one parse to another. * data/skeletons/yacc.c (yypstate_new): Set up the stacks in their initial configurations (setting their bottom to the stack array), and use yypstate_clear to reset them (moving their top to their bottom). (yypstate_delete): Adjust. (yypush_parse): At the beginning, clear yypstate if needed, and at the end, record when yypstate needs to be clearer. * examples/c/bistromathic/parse.y (expected_tokens): Do not propose autocompletion when there are parse errors. * examples/c/bistromathic/bistromathic.test: Check that case.
Diffstat (limited to 'TODO')
-rw-r--r--TODO2
1 files changed, 0 insertions, 2 deletions
diff --git a/TODO b/TODO
index 31734891..25ad2b5c 100644
--- a/TODO
+++ b/TODO
@@ -37,8 +37,6 @@ Unless we play it dumb (little structure).
examples about conflicts in the reports.
** Bistromathic
-- Hitting tab on a line with a syntax error is ugly
-
- How about not evaluating incomplete lines when the text is not finished
(as shells do).