When used as a library, Merlin exposes an extend protocol that allows one to support a custom syntax provided it can be parsed to an OCaml AST. The only user of this protocol, as far as I know, is Reason. So, I’ve been wondering if the editing experience for the Menhir and ocamllex DSL’s could also benefit from this plugin system by defining an extension for each of them; after all they are both transpiled to OCaml code, so, at a very high level, it should be as easy as parsing the code they generate to a Parsetree.structure and returning that structure in the parse message?
Do you think this is feasible and useful, and has anyone here tinkered with this idea before? Was the extend protocol designed with this application in mind and is mll / mly syntax a good fit for it?
Also, if one were to succeed at defining these extensions and integrating them with the editor, would Merlin then provide all its usual helpful features (jumping commands, case analysis, holes, construct…) right in the parser and lexer’s source code? (the goal of the exercise!)