MENHIR(1) General Commands Manual MENHIR(1)

# [NAME](#NAME)

menhir - an [LR(1)](/man/enterprise-packages/ocaml4-menhir/LR.1) parser generator for OCaml

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#DESCRIPTION)

**menhir** is an [LR(1)](/man/enterprise-packages/ocaml4-menhir/LR.1) parser generator for the OCaml programming language. That is, Menhir compiles [LR(1)](/man/enterprise-packages/ocaml4-menhir/LR.1) grammar specifications down to OCaml code. It is mostly compatible with [**ocamlyacc**(1)](/man/enterprise-packages/ocaml4-menhir/ocamlyacc.1).

# [OPTIONS](#OPTIONS)

[**-h, --help**](#h,)

Show summary of options.

[**-b, --base basename**](#b,)

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

[**--canonical**](#canonical)

Construct a canonical Knuth [LR(1)](/man/enterprise-packages/ocaml4-menhir/LR.1) automaton.

[**--cmly**](#cmly)

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

[**--comment**](#comment)

Include comments in the generated code.

[**--compare-errors file1 --compare-errors file2**](#compare)

Compare two .messages files.

[**--compile-errors file**](#compile)

Compile a .messages file to OCaml code.

[**--coq**](#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**](#depend)

Invoke ocamldep and display dependencies.

[**--dump**](#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)

Echo the sentences stored in the .messages file *file*.

[**--echo-errors-concrete file**](#echo~2)

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

[**--exn-carries-state**](#exn)

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

[**--explain**](#explain)

Explain conflicts in *basename*.conflicts.

[**--external-tokens module**](#external)

Import token type definition from *module*.

[**--fixed-exception**](#fixed)

Declares Error = Parsing.Parse\_error.

[**--infer**](#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**](#inspection)

Generate the inspection API.

[**--interpret**](#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**](#lalr)

Construct an [LALR(1)](/man/enterprise-packages/ocaml4-menhir/LALR.1) automaton.

[**-la, --log-automaton level**](#la,)

Log information about the automaton.

[**-lc, --log-code level**](#lc,)

Log information about the generated code.

[**-lg, --log-grammar level**](#lg,)

Log information about the grammar.

[**--list-errors**](#list)

Produce a list of erroneous inputs.

[**--merge-errors file1 --merge-errors file2**](#merge)

Merge two .messages files.

[**--no-dollars**](#no)

Disallow the use of $i notation.

[**--no-inline**](#no~2)

Ignore the %inline keyword.

[**--no-stdlib**](#no~3)

Do not load the standard library.

[**--ocamlc command**](#ocamlc)

Specifies how ocamlc should be invoked.

[**--ocamldep command**](#ocamldep)

Specifies how ocamldep should be invoked.

[**--only-preprocess**](#only)

Print a simplified grammar and exit.

[**--only-preprocess-for-ocamlyacc**](#only~2)

Print grammar in ocamlyacc format and exit.

[**--only-preprocess-u**](#only~3)

Print grammar with unit actions and exit.

[**--only-preprocess-uu**](#only~4)

Print grammar with unit actions and tokens and exit.

[**--only-tokens**](#only~5)

Generate token type definition only, no code.

[**--random-seed seed**](#random)

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

[**--random-self-init**](#random~2)

Automatically set the seed used by the random sentence generator.

[**--random-sentence-length length**](#random~3)

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

[**--random-sentence symbol**](#random~4)

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

[**--random-sentence-concrete symbol**](#random~5)

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

[**--raw-depend**](#raw)

Invoke ocamldep and echo its raw output.

[**--require-aliases**](#require)

Check that every terminal symbol has a token alias.

[**--strategy strategy**](#strategy)

Choose how to deal with the error token.

[**--strict**](#strict)

Warnings about the grammar are errors.

[**--suggest-comp-flags**](#suggest)

Suggest compilation flags for ocaml{c,opt}.

[**--suggest-link-flags-byte**](#suggest~2)

Suggest link flags for ocamlc.

[**--suggest-link-flags-opt**](#suggest~3)

Suggest link flags for ocamlopt.

[**--suggest-menhirLib**](#suggest~4)

Suggest where MenhirLib was installed in source form.

[**-t, --table**](#t,)

Use the table-based back-end.

[**--timings**](#timings)

Display internal timings.

**--timings-to file**

Dump internal timings into *file*.

[**--trace**](#trace)

Include tracing instructions in the generated code.

[**--unused-precedence-levels**](#unused)

Do not warn about unused precedence levels.

[**--unused-token token**](#unused~2)

Do not warn that *token* is unused.

[**--unused-tokens**](#unused~3)

Do not warn about any unused token.

[**--update-errors file**](#update)

Update auto-comments in a .messages file.

[**--version**](#version)

Show version number and exit.

[**-v**](#v)

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

# [SEE ALSO](#SEE_ALSO)

[**ocaml**(1)](/man/enterprise-packages/ocaml4-menhir/ocaml.1).

# [AUTHOR](#AUTHOR)

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

This manual page was originally written by Samuel Mimram &lt;smimram@debian.org&gt; for the Debian project (but may be used by others).

July 3, 2018

---

Document: menhir-4(1) from ocaml4-menhir 20230608-r5 (Chainguard OS)
Source: https://gitlab.inria.fr/fpottier/menhir.git
