Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 0a0f45f1 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Moved more code from [Calc] to [Printers].

parent 235c1b47
......@@ -9,7 +9,7 @@ endif
# We assume that menhirLib has been installed in such a
# way that ocamlfind knows about it.
MENHIRFLAGS := --table --inspection
MENHIRFLAGS := --table --inspection -v -la 2
# -- infer is automatically added by ocamlbuild.
OCAMLBUILD := ocamlbuild -use-ocamlfind -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS)" -package menhirLib
......
......@@ -10,6 +10,7 @@ module Make
let arrow = " -> "
let dot = "."
let space = " "
let newline = "\n"
open User
......@@ -33,18 +34,6 @@ module Make
print_symbols (i - 1) symbols
end
(* Printing an item. *)
let print_item (prod, i) =
print_symbol (I.lhs prod);
print arrow;
print_symbols i (I.rhs prod)
(* Printing a production (without a dot). *)
let print_production prod =
print_item (prod, -1)
(* Printing an element as a symbol. *)
let print_element_as_symbol element =
......@@ -71,5 +60,31 @@ module Make
print space
) stack ()
(* Printing an item. *)
let print_item (prod, i) =
print_symbol (I.lhs prod);
print arrow;
print_symbols i (I.rhs prod);
print newline
(* Printing a production (without a dot). *)
let print_production prod =
print_item (prod, -1)
(* Printing the current LR(1) state. *)
let print_current_state env =
print "Current LR(1) state: ";
match Lazy.force (I.stack env) with
| I.Nil ->
print "<some initial state>";
print newline
| I.Cons (I.Element (current, _, _, _), _) ->
print (string_of_int (Obj.magic current)); (* TEMPORARY safe conversion needed *)
print newline;
List.iter print_item (I.items current)
end
......@@ -33,13 +33,19 @@ module Make
val print_stack: I.stack -> unit
(* Printing an item. *)
(* Printing an item. (Ending with a newline.) *)
val print_item: I.item -> unit
(* Printing a production. *)
(* Printing a production. (Ending with a newline.) *)
val print_production: I.production -> unit
(* Printing the current LR(1) state. The current state is first displayed
as a number; then the list of its LR(0) items is printed. (Ending with
a newline.) *)
val print_current_state: I.env -> unit
end
......@@ -75,18 +75,8 @@ module P =
let dump env =
P.print_stack (I.stack env);
Printf.fprintf stderr "\n%!";
begin match Lazy.force (I.stack env) with
| I.Nil ->
()
| I.Cons (I.Element (current, _, _, _), _) ->
Printf.fprintf stderr "Current state: %d\n%!" (Obj.magic current);
let items = I.items current in
List.iter (fun item ->
P.print_item item;
Printf.fprintf stderr "\n%!"
) items
end;
print_newline()
P.print_current_state env;
Printf.fprintf stderr "\n%!"
(* The loop which drives the parser. At each iteration, we analyze a
result produced by the parser, and act in an appropriate manner. *)
......
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