menhir - Man Page

an LR(1) parser generator for OCaml


menhir [options] files


menhir is an LR(1) parser generator for the OCaml programming language. That is, Menhir compiles LR(1) grammar specifications down to OCaml code. It is mostly compatible with ocamlyacc(1).


-h,  --help

Show summary of options.

-b--base basename

Specifies a base name for the output file(s).


Construct a canonical Knuth LR(1) automaton.


Write the grammar and automaton to basename.cmly.


Include comments in the generated code.

--compare-errors file1 --compare-errors file2

Compare two .messages files.

--compile-errors file

Compile a .messages file to OCaml code.


Generate a formally verified parser, in Coq.

--coq-lib-path path

How to qualify references to MenhirLib.


Do not qualify references to MenhirLib.


Ignore semantic actions in the Coq output.


Do not generate a proof of completeness.


Invoke ocamldep and display dependencies.


Describe the automaton in the file basename.automaton.


Describe the automaton, after conflict resolution, in the file basename.automaton.resolved.

--echo-errors file

Echo the sentences stored in the .messages file file.

--echo-errors-concrete file

Echo the sentences stored in the .messages file file in concrete syntax.


Declares Error of int. The exception Error then carries the number of the state where a syntax error is detected.


Explain conflicts in basename.conflicts.

--external-tokens module

Import token type definition from module.


Declares Error = Parsing.Parse_error.


Invoke ocamlc to do type inference.


Stop with exit code 0.

--infer-write-query file

Write mock .ml file.

--infer-read-reply file

Read inferred .mli file.


Generate the inspection API.


Interpret the sentences provided on stdin.


Show a concrete syntax tree upon acceptance.


Interpret an error sentence provided on stdin.


Construct an LALR(1) automaton.

-la--log-automaton level

Log information about the automaton.

-lc--log-code level

Log information about the generated code.

-lg--log-grammar level

Log information about the grammar.


Produce a list of erroneous inputs.

--merge-errors file1 --merge-errors file2

Merge two .messages files.


Disallow the use of $i notation.


Ignore the %inline keyword.


Do not load the standard library.

--ocamlc command

Specifies how ocamlc should be invoked.

--ocamldep command

Specifies how ocamldep should be invoked.


Print a simplified grammar and exit.


Print grammar in ocamlyacc format and exit.


Print grammar with unit actions and exit.


Print grammar with unit actions and tokens and exit.


Generate token type definition only, no code.

--random-seed seed

Set the seed used by the random sentence generator to seed.


Automatically set the seed used by the random sentence generator.

--random-sentence-length length

Ask the random sentence generator for a sentence of length at most length.

--random-sentence symbol

Produce a random sentence that is generated by the nonterminal symbol symbol.

--random-sentence-concrete symbol

Produce a random sentence that is generated by the nonterminal symbol symbol, and print this sentence in concrete syntax.


Invoke ocamldep and echo its raw output.


Check that every terminal symbol has a token alias.

--strategy strategy

Choose how to deal with the error token.


Warnings about the grammar are errors.


Suggest compilation flags for ocaml{c,opt}.


Suggest link flags for ocamlc.


Suggest link flags for ocamlopt.


Suggest where MenhirLib was installed in source form.

-t,  --table

Use the table-based back-end.


Display internal timings.

--timings-to file

Dump internal timings into file.


Include tracing instructions in the generated code.


Do not warn about unused precedence levels.

--unused-token token

Do not warn that token is unused.


Do not warn about any unused token.

--update-errors file

Update auto-comments in a .messages file.


Show version number and exit.


Synonymous with --dump --explain.

See Also



menhir was written by François Pottier and Yann Régis-Gianas.

This manual page was originally written by Samuel Mimram <> for the Debian project (but may be used by others).


July 03, 2018