Commit 339d6f81 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Produce an error message when --inspection is set but the type [nonterminal]

cannot be generated because the type of some nonterminal symbol is unknown.
parent 84348b9a
......@@ -19,12 +19,13 @@ let tnonterminalgadtdata nt =
(* This is the definition of the nonterminal GADT. Here, the data
constructors have no value argument, but have a type index. *)
exception MissingOCamlType
exception MissingOCamlType of string
let nonterminalgadtdef grammar =
assert Settings.inspection;
let comment, datadefs =
"The indexed type of nonterminal symbols.",
List.fold_left (fun defs nt ->
let index =
......@@ -32,7 +33,7 @@ let nonterminalgadtdef grammar =
| Some t ->
TypTextual t
| None ->
raise MissingOCamlType
raise (MissingOCamlType nt)
dataname = tnonterminalgadtdata nt;
......@@ -40,14 +41,28 @@ let nonterminalgadtdef grammar =
datatypeparams = Some [ index ]
} :: defs
) [] (nonterminals grammar)
with MissingOCamlType ->
with MissingOCamlType nt ->
(* If the type of some nonterminal symbol is unknown, give up
and define ['a nonterminal] as an abstract type. This is
useful when we are in [--(raw)-depend] mode and we do not
wish to fail. Instead, we produce a mock [.mli] file that
is an approximation of the real [.mli] file. *)
is an approximation of the real [.mli] file. When we are
not in [--(raw)-depend] mode, though, this is a problem.
We display an error message and stop. *)
match Settings.depend with
| Settings.OMRaw
| Settings.OMPostprocess ->
"The indexed type of nonterminal symbols (mock!).",
| Settings.OMNone ->
Error.error [] (Printf.sprintf "\
the type of the nonterminal symbol %s is unknown.\n\
When --inspection is set, the type of every nonterminal symbol must be known.\n\
Please use --infer or specify the type of every symbol via %%type declarations."
IIComment comment;
Supports Markdown
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