Problem with error recovery in Lemon

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with error recovery in Lemon

Albertas Vyšniauskas
Hello everybody,

all Lemon versions after commit 7eb0198d fail to recover from errors and
instead trigger assertion failures. Attached repro.y file provides minimal
reproduction. If I execute the parser generated using this file with Lemon
compiled from 6e133054 version, then
"yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0])" assert is triggered in
function yy_reduce.

I am using the following command:
lemon repro.y && gcc repro.c && .\a.out

The problem seems to be that when ordering of actions was changed, the
condition for stack popping, before error is shifted, was not updated, and
because the condition is now incorrect, the error action is shifted into
the stack immediately. The following change should fix this:

diff --git a/tool/lempar.c b/tool/lempar.c
index 2ebc67ee5..b2d18b7fd 100644
--- a/tool/lempar.c
+++ b/tool/lempar.c
@@ -990,7 +990,7 @@ void Parse(
             && yymx != YYERRORSYMBOL
             && (yyact = yy_find_reduce_action(
                         yypParser->yytos->stateno,
-                        YYERRORSYMBOL)) >= YY_MIN_REDUCE
+                        YYERRORSYMBOL)) >= YY_MIN_SHIFTREDUCE
         ){
           yy_pop_parser_stack(yypParser);
         }

Regards
Albertas Vyšniauskas

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

repro.y (764 bytes) Download Attachment