Commit ff076c7d authored by POTTIER Francois's avatar POTTIER Francois

[Printers]: avoid depending on deprecated types and functions (streams).

parent ef816e6a
...@@ -66,13 +66,20 @@ module Make ...@@ -66,13 +66,20 @@ module Make
| None -> | None ->
print_element_as_symbol print_element_as_symbol
(* Printing a stack as a list of symbols. *) (* Printing a stack as a list of symbols. Stack bottom on the left,
stack top on the right. *)
let print_stack stack =
General.foldr (fun element () -> let rec print_stack env =
print_element element; match top env, pop env with
print space | Some element, Some env ->
) stack (); print_stack env;
print space;
print_element element
| _, _ ->
()
let print_stack env =
print_stack env;
print newline print newline
(* Printing an item. *) (* Printing an item. *)
...@@ -97,17 +104,17 @@ module Make ...@@ -97,17 +104,17 @@ module Make
let print_current_state env = let print_current_state env =
print "Current LR(1) state: "; print "Current LR(1) state: ";
match Lazy.force (stack env) with match top env with
| General.Nil -> | None ->
print "<some initial state>"; print "<some initial state>"; (* TEMPORARY unsatisfactory *)
print newline print newline
| General.Cons (Element (current, _, _, _), _) -> | Some (Element (current, _, _, _)) ->
print (string_of_int (number current)); print (string_of_int (number current));
print newline; print newline;
List.iter print_item (items current) List.iter print_item (items current)
let print_env env = let print_env env =
print_stack (stack env); print_stack env;
print_current_state env; print_current_state env;
print newline print newline
......
...@@ -52,7 +52,7 @@ module Make ...@@ -52,7 +52,7 @@ module Make
printer. It uses [print_element] if provided by the user; otherwise printer. It uses [print_element] if provided by the user; otherwise
it uses [print_element_as_symbol]. (Ending with a newline.) *) it uses [print_element_as_symbol]. (Ending with a newline.) *)
val print_stack: stack -> unit val print_stack: 'a env -> unit
(* Printing an item. (Ending with a newline.) *) (* Printing an item. (Ending with a newline.) *)
......
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