"Garrett Rooney" <[EMAIL PROTECTED]> wrote: > On 6/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > "Garrett Rooney" <[EMAIL PROTECTED]> wrote: > > > I've been using lemon as the parser generator for ETL > > > and we've been running into some problems with recent > > > versions. The first problem is in revision 1.17 of lempar.c. You > > > removed an if( yymajor==0 ) return; from Parse, > > > > The EOF token is necessary. But I think Lemon is correct as > > stands - as far as I can tell. Can you please tell me more about > > the circumstances of your segfault - specifically where it is > > happening. > > Well, it doesn't manifest itself in all my test cases, but with the > ones that do crash it's because they end up in a %syntax_error block > with the %extra_argument set to NULL. With the if( yymajor==0 ) check > they parse just fine, never falling into the syntax error block at > all.
Your grammer does not generate an empty string. That means if you call the parser with an EOF token first, without any prior tokens, you are going to get a syntax error. The "yymajor==0" test was removed in order to get this to work correctly. Geert Janssen at IBM found this bug back in November - his grammar does not generate an empty string but lemon was not giving him a syntax error like it should if he passed in an empty string. If I add the yymajor==0 test back, it will reintroduce the bug. Perhaps you are calling Parse() with EOF twice in a row when you should only be calling it once? That would trigger the syntax error. Or perhaps you should adjust your grammar to accept an empty string? The %extra_argument that gets passed to the %syntax_error procedure should be the %extra_argument that got passed into with the call to Parse() that contained the EOF token. If that %extra_argument was NULL, then the %syntax_error procedure will get a NULL. Perhaps you can either pass in a non-null parameter to Parse or check for NULL in %syntax_error and branch accordingly. -- D. Richard Hipp <[EMAIL PROTECTED]>