---
name: "menhir"
section: "1"
platform: "linux"
package: "menhir"
version: "20240715+ds-1+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/menhir"
---

# menhir(1)

an LR(1) parser generator for OCaml

## NAME

menhir - an LR(1) parser generator for OCaml

## SYNOPSIS

**menhir** \[*options*\] *files*

## DESCRIPTION

**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)](/ocamlyacc/1.md).

## OPTIONS

- **-h, --help**

  Show summary of options.

- **-b, --base** *basename*

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

- **--canonical**

  Construct a canonical Knuth LR(1) automaton.

- **--cmly**

  Write the grammar and automaton to *basename*.cmly.

- **--comment**

  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.

- **--coq**

  Generate a formally verified parser, in Coq.

- **--coq-lib-path** *path*

  How to qualify references to MenhirLib.

- **--coq-lib-no-path**

  Do not qualify references to MenhirLib.

- **--coq-no-actions**

  Ignore semantic actions in the Coq output.

- **--coq-no-complete**

  Do not generate a proof of completeness.

- **--depend**

  Invoke ocamldep and display dependencies.

- **--dump**

  Describe the automaton in the file *basename*.automaton.

- **--dump-resolved**

  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.

- **--exn-carries-state**

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

- **--explain**

  Explain conflicts in *basename*.conflicts.

- **--external-tokens** *module*

  Import token type definition from *module*.

- **--fixed-exception**

  Declares Error = Parsing.Parse\_error.

- **--infer**

  Invoke ocamlc to do type inference.

- **--infer-protocol-supported**

  Stop with exit code 0.

- **--infer-write-query** *file*

  Write mock .ml file.

- **--infer-read-reply** *file*

  Read inferred .mli file.

- **--inspection**

  Generate the inspection API.

- **--interpret**

  Interpret the sentences provided on stdin.

- **--interpret-show-cst**

  Show a concrete syntax tree upon acceptance.

- **--interpret-error**

  Interpret an error sentence provided on stdin.

- **--lalr**

  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.

- **--list-errors**

  Produce a list of erroneous inputs.

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

  Merge two .messages files.

- **--no-dollars**

  Disallow the use of $i notation.

- **--no-inline**

  Ignore the %inline keyword.

- **--no-stdlib**

  Do not load the standard library.

- **--ocamlc** *command*

  Specifies how ocamlc should be invoked.

- **--ocamldep** *command*

  Specifies how ocamldep should be invoked.

- **--only-preprocess**

  Print a simplified grammar and exit.

- **--only-preprocess-for-ocamlyacc**

  Print grammar in ocamlyacc format and exit.

- **--only-preprocess-u**

  Print grammar with unit actions and exit.

- **--only-preprocess-uu**

  Print grammar with unit actions and tokens and exit.

- **--only-tokens**

  Generate token type definition only, no code.

- **--random-seed** *seed*

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

- **--random-self-init**

  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.

- **--raw-depend**

  Invoke ocamldep and echo its raw output.

- **--require-aliases**

  Check that every terminal symbol has a token alias.

- **--strategy** *strategy*

  Choose how to deal with the error token.

- **--strict**

  Warnings about the grammar are errors.

- **--suggest-comp-flags**

  Suggest compilation flags for ocaml{c,opt}.

- **--suggest-link-flags-byte**

  Suggest link flags for ocamlc.

- **--suggest-link-flags-opt**

  Suggest link flags for ocamlopt.

- **--suggest-menhirLib**

  Suggest where MenhirLib was installed in source form.

- **-t, --table**

  Use the table-based back-end.

- **--timings**

  Display internal timings.

- **--timings-to** *file*

  Dump internal timings into *file*.

- **--trace**

  Include tracing instructions in the generated code.

- **--unused-precedence-levels**

  Do not warn about unused precedence levels.

- **--unused-token** *token*

  Do not warn that *token* is unused.

- **--unused-tokens**

  Do not warn about any unused token.

- **--update-errors** *file*

  Update auto-comments in a .messages file.

- **--version**

  Show version number and exit.

- **-v**

  Synonymous with **--dump --explain**.

## SEE ALSO

[**ocaml**(1)](/ocaml/1.md).

## AUTHOR

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

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