Commit a5846cdb by POTTIER Francois

CheckSafeParameterizedGrammar: clearer display of the graph in debugging mode.

parent 63638a8a
......@@ -90,14 +90,10 @@ let successors_parameter (f : edge -> formal -> unit) x (param : parameter) =
then there is an edge to the formal [nt, i]. Whether it is a safe
or dangerous edge depends on whether [x] occurs shallow or deep. *)
List.iteri (fun i param ->
if Parameters.occurs_shallow x param then begin
if debug then Printf.eprintf "->(safe) %s/%d\n" nt i;
if Parameters.occurs_shallow x param then
f Safe (nt, i)
end
else if Parameters.occurs_deep x param then begin
if debug then Printf.eprintf "->(dangerous) %s/%d\n" nt i;
else if Parameters.occurs_deep x param then
f Dangerous (nt, i)
end
) params
| ParameterAnonymous _ ->
assert false
......@@ -109,7 +105,6 @@ let successors_branch f x (branch : parameterized_branch) =
List.iter (successors_producer f x) branch.pr_producers
let successors f ((nt, i) : formal) =
if debug then Printf.eprintf "Edges out of %s/%d:\n" nt i;
let rule = try StringMap.find nt g.p_rules with Not_found -> assert false in
let x = try List.nth rule.pr_parameters i with Failure _ -> assert false in
List.iter (successors_branch f x) rule.pr_branches
......@@ -128,6 +123,19 @@ end
(* -------------------------------------------------------------------------- *)
(* Display the graph. *)
let () =
if debug then
G.iter (fun (x, i) ->
successors (fun edge (y, j) ->
let kind = match edge with Safe -> "safe" | Dangerous -> "dangerous" in
Printf.eprintf "%s/%d ->(%s) %s/%d\n" x i kind y j
) (x, i)
)
(* -------------------------------------------------------------------------- *)
(* Compute its strongly connected components, ignoring the distinction between
safe and dangerous edges. *)
......
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