Commit b62ed354 authored by bguillaum's avatar bguillaum

add "node_matching" function for the new "grep" mode

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8889 7838e531-6607-4d57-9587-6c381814729c
parent 61fb63d0
......@@ -378,6 +378,14 @@ module Rule = struct
m_param: Lex_par.t option;
}
let node_matching pattern graph { n_match } =
Pid_map.fold
(fun pid gid acc ->
let pnode = P_graph.find pid (fst pattern).graph in
let gnode = G_graph.find gid graph in
(P_node.get_name pnode, int_of_float (G_node.get_position gnode)) :: acc
) n_match []
let empty_matching param = { n_match = Pid_map.empty; e_match = []; a_match = []; m_param = param;}
let e_comp (e1,_) (e2,_) = compare e1 e2
......
......@@ -95,6 +95,9 @@ module Rule : sig
val build_pattern: Domain.t -> Ast.pattern -> pattern
(** [node_matching pattern graph matching] return a assoc list (pid_name, gid.position) *)
val node_matching: pattern -> G_graph.t -> matching -> (string * int) list
(** [match_in_graph rule graph] returns the list of matching of the pattern of the rule into the graph *)
val match_in_graph: Domain.t -> ?param:Lex_par.t -> pattern -> G_graph.t -> matching list
......
......@@ -171,6 +171,8 @@ type t = Grew_graph.G_graph.t
let search_pattern domain pattern graph = Grew_rule.Rule.match_in_graph domain pattern graph
let node_matching pattern graph matching = Grew_rule.Rule.node_matching pattern graph matching
end
(* ==================================================================================================== *)
......
......@@ -110,6 +110,8 @@ module Graph : sig
(** [search_pattern pattern graph] returns the list of the possible matching of [pattern] in [graph] *)
val search_pattern: Domain.t -> Pattern.t -> t -> Matching.t list
val node_matching: Pattern.t -> t -> Matching.t -> (string * int) list
end
(* ==================================================================================================== *)
......
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