Is there a tool to format ocamllex and menhir files?

format
ocamlformat
menhir
#1

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?

#2

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
#3

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

#4

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

by adding the line:
syntax=mll
in the .ocp-indent file.

. No support for .mly files.

Issue open (long time ago…)

#5

Thanks. Done: https://github.com/ocaml-ppx/ocamlformat/issues/830

2 Likes