Example of menhir + sedlex parser using the error states generation

I wrote a very simple json parser using menhir incremental api, sedlex, and new menhir error api for a quick demo of menhir capabilities. As i didn’t find any simple example anywhere tying everything together, i’m posting it here in case it could be useful for anyone.

A few lines of code of the main loop runing the incremental parser have been copy pasted from some repo by François Pottier, but i don’t remember which :slight_smile:.
Side note : the error api is wonderful.
Side question : how to update and maintain the error messages file when you update the grammar is unclear to me.

18 Likes

Hey, I’d like to say thank you for this. I was trying to accomplish this during the weekend and this example saved me hours.