Is there a tool to format ocamllex and menhir files?


I use ocamlformat extensively and it would be awesome to have a similar tool to format lexer and parser files as well. Is there any such tool?


Glad to hear ocamlformat is working out for you! Formatting other related formats such as lex, yacc (and toplevel) scripts has come up before, and should be in scope for the core tool (since these formats spring from the core OCaml distribution). A feature request on the issue tracker would be most welcome.

1 Like

Once we have a fairly self contained grammar for lex & yacc, it will be fairly easy to add support to Merlin too.


. ocp-indent gives a very basic support for .mll files

by adding the line:
in the .ocp-indent file.

. No support for .mly files.

Issue open (long time ago…)


Thanks. Done: