I'm trying to generate parser error messages. To do this, I want to use the last token and the last state seen.
I can output the last token using this method.
However, the states are generated by Menhir, so I've found no way of outputting the last state upon error without tampering with Menhir's source.
Is there anyway to extract the state from Menhir generated parsers programatically? i.e. outputting the state where error occurs; state where error token is produced.