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
%token_prefix TK_ %token_type {int} %default_type {int} %left A B. test ::= A B. test ::= error B. %include { #include <assert.h> #include <stdlib.h> #include "repro.h" #define YYMALLOCARGTYPE size_t #define ParseTOKENTYPE int void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)); void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor); void ParseFree(void *p, void (*freeProc)(void*)); int main() { void *parser = ParseAlloc(malloc); Parse(parser, TK_B, 0); Parse(parser, TK_B, 0); ParseFree(parser, free); return 0; } }
_______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users