Suggestion for little code change

Sep 26, 2012 at 1:25 PM

I'd like to suggest to change in ShiftReduceParserCode.cs in the method Parse the code

catch (Exception x)
{
    if (x is AbortException)
        return false;
    else if (x is AcceptException)
        return true;
    else if (x is ErrorException && !ErrorRecovery())
        return false;
    else
        throw;  // Rethrow x, preserving information.
 
}

to

catch (AbortException)
{
    return false;
}
catch (AcceptException)
{
    return true;
}
catch (ErrorException)
{
    if (!ErrorRecovery())
        return false;
    else throw;
}

Both should do the same (if I made no mistake), but the latter makes it easier to find the source of exceptions in semantic actions. This is because for an exception thrown in a semantic action the debugger (when configured to break on user-unhandled exceptions) will break in the semantic action and not at the throw statement in the Parse method.

Thanks.

Coordinator
Oct 1, 2012 at 10:01 PM

Hi Martin.  Thanks for the suggestion.  Yes, this is an improvement, I will put it in the next refresh, which will be real soon now.

Coordinator
Apr 30, 2015 at 10:19 PM
Hi again Martin
Thank you for the reminder. I have installed the fix. I will get a new distribution out soon.
John
May 26, 2015 at 2:37 PM
Thank you!