Commit 73bec5d4 authored by POTTIER Francois's avatar POTTIER Francois

TEMPORARY Plug in StackLang. Introduce --stacklang-{dump,graph,test}.

parent 0af41907
......@@ -72,6 +72,28 @@ let () =
(* Construct and print the code using an appropriate back-end. *)
let () =
if Settings.stacklang_dump
|| Settings.stacklang_graph
|| Settings.stacklang_test then
begin
let module SL = EmitStackLang.Run() in
let program = SL.program in
StackLangTraverse.wf program;
let program = StackLangTraverse.inline program in
StackLangTraverse.wf program;
if Settings.stacklang_dump then begin
StackLangPrinter.print stdout program;
StackLangTraverse.(print (measure program));
end;
if Settings.stacklang_graph then begin
StackLangGraph.print program;
end;
if Settings.stacklang_test then begin
StackLangTester.test program;
end;
end
let () =
if Settings.table then begin
let module B = TableBackend.Run (struct end) in
......
......@@ -319,6 +319,15 @@ let set_strategy = function
eprintf "Error: --strategy should be followed with legacy | simplified.\n";
exit 1
let stacklang_dump =
ref false
let stacklang_graph =
ref false
let stacklang_test =
ref false
(* When new command line options are added, please update both the manual
in [doc/manual.tex] and the man page in [doc/menhir.1]. *)
......@@ -379,6 +388,9 @@ let options = Arg.align [
"--raw-depend", Arg.Unit enable_raw_depend, " Invoke ocamldep and echo its raw output";
"--reference-graph", Arg.Set reference_graph, " (undocumented)";
"--require-aliases", Arg.Set require_aliases, " Check that every token has a token alias";
"--stacklang-dump", Arg.Set stacklang_dump, " (undocumented)";
"--stacklang-graph", Arg.Set stacklang_graph, " (undocumented)";
"--stacklang-test", Arg.Set stacklang_test, " (undocumented)";
"--stdlib", Arg.String ignore, "<directory> Ignored (deprecated)";
"--strategy", Arg.String set_strategy, "<strategy> Choose an error-handling strategy";
"--strict", Arg.Set strict, " Warnings about the grammar are errors";
......@@ -675,3 +687,12 @@ let infer =
IMNone
| _ ->
infer
let stacklang_dump =
!stacklang_dump
let stacklang_graph =
!stacklang_graph
let stacklang_test =
!stacklang_test
......@@ -286,3 +286,18 @@ val require_aliases : bool
an explanation of the available strategies. *)
val strategy: [`Legacy | `Simplified]
(* The undocumented flag [--stacklang-dump] causes the StackLang program to be
printed. *)
val stacklang_dump: bool
(* The undocumented flag [--stacklang-graph] causes the StackLang program to be
dumped in the form of a control flow graph in the file [<basename>.dot]. *)
val stacklang_graph: bool
(* The undocumented flag [--stacklang-test] causes the StackLang program to be
tested (by comparison with the reference interpreter). *)
val stacklang_test: 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