Commit 18f0265d authored by POTTIER Francois's avatar POTTIER Francois

Introduce [Interpret.run] and remove an artificial dependency.

parent 41e390f7
......@@ -13,7 +13,11 @@
(* Driver for the back-end. *)
module I = Interpret (* artificial dependency; ensures that [Interpret] runs first *)
(* Let [Interpret] handle the command line options [--interpret],
[--interpret-error], [--compile-errors], [--compare-errors]. *)
let () =
Interpret.run()
(* If [--list-errors] is set, produce a list of erroneous input sentences, then stop. *)
......
......@@ -426,42 +426,6 @@ let setup () : unit -> sentence option =
(* --------------------------------------------------------------------------- *)
(* If [--interpret] is set, interpret the sentences found on the standard
input channel, then stop, without generating a parser. *)
(* We read a series of sentences from the standard input channel. To allow
interactive use, we interpret each sentence as soon as it is read. *)
let () =
if Settings.interpret then
let read = setup() in
while true do
match read() with
| None ->
exit 0
| Some sentence ->
interpret sentence
done
(* --------------------------------------------------------------------------- *)
(* If [--interpret-error] is set, interpret one sentence found on the standard
input channel, then stop, without generating a parser. *)
(* We read just one sentence, confirm that this sentence ends in an error, and
(if that is the case) display the number of the state that is reached. *)
let () =
if Settings.interpret_error then
let read = setup() in
match read() with
| None ->
exit 1 (* abnormal: no input *)
| Some sentence ->
interpret_error sentence (* never returns *)
(* --------------------------------------------------------------------------- *)
(* Display an informational message about the contents of a [.messages] file. *)
let stats (runs : run or_comment list) =
......@@ -621,6 +585,49 @@ let compile_runs filename (runs : filtered_targeted_run list) : unit =
(* --------------------------------------------------------------------------- *)
(* The rest of this file is the function [run], internally written as a functor
[Run] for syntactic convenience. *)
module Run (X : sig end) = struct
(* --------------------------------------------------------------------------- *)
(* If [--interpret] is set, interpret the sentences found on the standard
input channel, then stop, without generating a parser. *)
(* We read a series of sentences from the standard input channel. To allow
interactive use, we interpret each sentence as soon as it is read. *)
let () =
if Settings.interpret then
let read = setup() in
while true do
match read() with
| None ->
exit 0
| Some sentence ->
interpret sentence
done
(* --------------------------------------------------------------------------- *)
(* If [--interpret-error] is set, interpret one sentence found on the standard
input channel, then stop, without generating a parser. *)
(* We read just one sentence, confirm that this sentence ends in an error, and
(if that is the case) display the number of the state that is reached. *)
let () =
if Settings.interpret_error then
let read = setup() in
match read() with
| None ->
exit 1 (* abnormal: no input *)
| Some sentence ->
interpret_error sentence (* never returns *)
(* --------------------------------------------------------------------------- *)
(* If [--compile-errors <filename>] is set, compile the error message
descriptions found in file [filename] down to OCaml code, then stop. *)
......@@ -775,3 +782,13 @@ let () =
exit 0
)
(* --------------------------------------------------------------------------- *)
(* End of the functor [Run]. *)
end
let run () =
let module R = Run(struct end) in
()
......@@ -11,10 +11,12 @@
(* *)
(******************************************************************************)
(* This module is in charge of handling several command line options, namely
(* [run()] is in charge of handling several command line options, namely
[--interpret], [--interpret-error], [--compile-errors], [--compare-errors].
If any of these options is present, the execution of Menhir stops here. *)
val run: unit -> unit
(* This default error message is produced by [--list-errors] when it creates a
[.messages] file, and is recognized by [--compare-errors] when it compares
two such files. *)
......@@ -31,4 +33,3 @@ open Grammar
val print_messages_item:
Nonterminal.t * Terminal.t list * ReferenceInterpreter.target -> unit
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