[ANN] New release of Menhir (20260122)

I am pleased to announce a new version of Menhir.

opam update && opam install menhir.20260122

The main new feature is a brand new GLR back-end. This back-end is selected by the command line switch --GLR. GLR is a non-deterministic parsing algorithm; it is useful when the grammar lies outside the class LR(1), either because the grammar is unambiguous but requires more than one token of lookahead, or because the grammar is truly ambiguous. For more information on GLR, please read the manual.

There are also many minor changes in this release; please see the change log for details.

Happy parsing,

François.

9 Likes

At this time, in GLR mode, only the monolithic API (§9.1) is supported. The incremental API, the inspection API, and the unparsing API are not supported.

Do you plan to have GLR support the incremental API ?

In the future, maybe there could be an incremental API for the GLR engine, but it would likely not be compatible with the current incremental API of the LR engine, as the two engines are quite different internally.

Anyway, I need to find out whether GLR is useful, and what people use it for, before attempting to develop an incremental API.

I would like to use it to parse JavaScript. I think it would allow me to simplify the parsing of arrow functions (x,y,z) => e where I currently need to see the => to decide how to parse (x,y,z) - as an expression or a list of parameters.

I currently rely on the incremental API to “rewind” to the opening parenthesis and convert it to a special token LPAREN_ARROW, which solves the conflict.

I can’t use GLR yet as I need to keep the incremental API for a few other reasons:

If you’re curious, you can look at the parser js_of_ocaml/compiler/lib/js_parser.mly at master · ocsigen/js_of_ocaml · GitHub and its incremental driver js_of_ocaml/compiler/lib/parse_js.ml at master · ocsigen/js_of_ocaml · GitHub

Thanks for your reply! This is helpful, and I will look into it when there is time.