yacc2latex translates a yacc or ocamlyacc (mly) file into an hopefully pretty EBNF grammar, and then in Latex.

For language developers, it’s rather tedious and error-prone to write and maintain a reference (printable and readable) grammar of their language. Indeed, the “actual” grammar independent from the “actual” one, often written in yacc or mlyacc.

yacc2latex allows to “compile” a yacc/mly source into a latex file that can be easily integrated into the reference manual of the language (supposing that latex is used for document processing).


Very few: yacc2latex is written in pure ocaml, and thus only an ocaml compiler is necessary. Basically, you just have to call the ocaml compiler with all the sources in the right order, plus the standard library str, see below …

Compiling and running the program

If (gnu)make is available, just type


Otherwise, take a look at the Makefile to see how to call the ocaml compiler with the right arguments.

The program yacc2latex is portable, just put it in some place belonging to your “path”.

Testing the program

“pdflatex” is required to run the provided tests.

The folder “samples” contains several examples of yacc/mlyacc files,