Commit 6a23aac9 authored by fpottier's avatar fpottier

Added a new option --fixed-exception for better ocamlyacc compatibility.

git-svn-id: svn+ssh:// 0f8b5475-4b4e-0410-85a8-ee3154a6bfe7
parent ac7e538a
......@@ -105,6 +105,7 @@
......@@ -129,6 +129,10 @@ the user to define module $T$ and to make sure that it exports a suitable
\token type. Module $T$ can be hand-written. It can also be automatically generated
out of a grammar specification using the \oonlytokens switch.
\docswitch{\ofixedexc} This switch causes the exception \texttt{Error} to be
declared equal to \texttt{Parsing.Parse\_error}. This helps increase Menhir's
compatibility with \ocamlyacc. There is otherwise no reason to use it.
\docswitch{\ograph} This switch causes a description of the grammar's
dependency graph to be written to the file \nt{basename}\dott. The graph's
vertices are the grammar's nonterminal symbols. There is a directed edge from
......@@ -10,7 +10,7 @@ let excname =
let excdef = {
excname = excname;
exceq = None;
exceq = (if Settings.fixedexc then Some "Parsing.Parse_error" else None);
let excredef = {
......@@ -583,15 +583,16 @@ let directive f = function
let directives =
pdefs directive nothing nothing
let excdef f def =
match def.exceq with
| None ->
let excdef in_intf f def =
match in_intf, def.exceq with
| _, None
| true, Some _ ->
fprintf f "%s%t%t" def.excname nl nl
| Some s ->
| false, Some s ->
fprintf f "%s = %s%t%t" def.excname s nl nl
let excdefs =
pdefs excdef exc exc
let excdefs in_intf =
pdefs (excdef in_intf) exc exc
let functorparams intf body b f params =
match params with
......@@ -609,7 +610,7 @@ let structure f p =
indent 2 (fun f p ->
fprintf f "%t%a%a%a"
excdefs p.struct_excdefs
(excdefs false) p.struct_excdefs
typedefs p.struct_typedefs
nonrecvaldefs p.struct_nonrecvaldefs
......@@ -629,7 +630,7 @@ let moduledef f d =
let program f p =
fprintf f "%a%a"
excdefs p.excdefs
(excdefs false) p.excdefs
typedefs p.typedefs;
List.iter (stretch false f) p.prologue;
fprintf f "%a%a%a"
......@@ -642,7 +643,7 @@ let valdecl f (x, ts) =
fprintf f "val %s: %a" x typ ts.body
let interface f i =
fprintf f "%a%a%a%!" excdefs i.excdecls typedefs i.typedecls (list valdecl nl) i.valdecls
fprintf f "%a%a%a%!" (excdefs true) i.excdecls typedefs i.typedecls (list valdecl nl) i.valdecls
let program p =
functorparams false program p X.f p.paramdefs
......@@ -143,6 +143,9 @@ let coq_no_actions =
let strict =
ref false
let fixedexc =
ref false
type suggestion =
| SuggestNothing
| SuggestCompFlags
......@@ -163,6 +166,7 @@ let options = Arg.align [
"--error-recovery", Arg.Set recovery, " Attempt recovery by discarding tokens after errors";
"--explain", Arg.Set explain, " Explain conflicts in <basename>.conflicts";
"--external-tokens", Arg.String codeonly, "<module> Import token type definition from <module>";
"--fixed-exception", Arg.Set fixedexc, " Declares Error = Parsing.Parse_error";
"--follow-construction", Arg.Set follow, " (undocumented)";
"--graph", Arg.Set graph, " Write grammar's dependency graph to <basename>.dot";
"--infer", Arg.Set infer, " Invoke ocamlc for ahead of time type inference";
......@@ -363,3 +367,6 @@ let coq_no_actions =
let strict =
let fixedexc =
......@@ -154,3 +154,11 @@ val coq_no_actions : bool
val strict: bool
(* This flag causes the exception [Error] should be declared equal to
[Parsing.Parse_error]. This is useful when full compatibility with
ocamlyacc is desired. In particular, this is used when building
Menhir itself, since Menhir is compiled first using ocamlyacc, then
using Menhir. *)
val fixedexc: bool
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment