Hello, since lemon is maintained as an integral part of sqlite, I am posting my report here.
* I am using the latest available lemon.c and lempar.c [ 20180421 and 20180423 resp.] The documentation states:"The error recoverystrategy is to begin popping the parsers stack until it enters astate where it is permitted to shift a special non-terminal symbolnamed ``error''. It then shifts this non-terminal and continuesparsing. But the %syntax_error routine will not be called againuntil at least three new tokens have been successfully shifted.If the parser pops its stack until the stack is empty, and it stillis unable to shift the error symbol, then the %parse_failed routineis invoked and the parser resets itself to its start state, readyto begin parsing a new file. This is what will happen at the veryfirst syntax error, of course, if there are no instances of the ``error'' non-terminal in your grammar." This is definitely not what I observe. Two cases need to be distinguished (1) the non-terminal "error" symbol is not used in the grammar. What happens: ----------------- when a syntax error is encountered, the %syntax_error code is invoked. The parser then does not attempt to shift the special error symbol. Rather, it discards the current token and proceeds with the next one. For example, assuming a simple calculator grammar, the input string 1+*1 triggers a syntax error when the "*" token is encountered. This '**" is rejected and 1+1 is parsed. parse_fail is never invoked. Expected behavior ------------------------- 1+*1 triggers a syntax error. Since the error symbol is not used in the grammar, the parser cannot shift the error and as a result the parser ignores all subsequent tokens until the end of input is reached. parse_fail is invoked. (2) the non-terminal "error" symbol *is used* in the grammar. Consider the following grammar, .... statements :: statement. statements :: statements statement. .... statement ::= error. When a syntax error occurs , one would expect the parser to call %syntax_error, shift the error symbol and invoke the "statement ::= error." rule. Subsequent tokens should then get discarded until the parser can successfully perform 3 sequential shifts. What actually happens: The error symbol is shifted. The parser then crashes with the following error: unsigned char yy_reduce(yyParser*, unsigned int, int, Token*): Assertion `yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0])' failed A trivial working example of error handling would be most helpful. -Francois _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users