Commit 51c7e492 authored by bguillaum's avatar bguillaum

named parameters in to_dep output

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7037 7838e531-6607-4d57-9587-6c381814729c
parent 28d60fa6
......@@ -75,11 +75,14 @@ module P_feature = struct
| (Different l1, Different l2) -> Different (List_.sort_union l1 l2)
| _ -> Error.build "cannot unify heterogeneous pattern features"
let to_string = function
let to_string ?param_names = function
| (feat_name, Equal atoms) -> sprintf "%s=%s" feat_name (List_.to_string (fun x->x) "|" atoms)
| (feat_name, Different []) -> sprintf "%s=*" feat_name
| (feat_name, Different atoms) -> sprintf "%s<>%s" feat_name (List_.to_string (fun x->x) "|" atoms)
| (feat_name, Param index) -> sprintf "%s=$%d" feat_name index
| (feat_name, Param index) ->
match param_names with
| None -> sprintf "%s=$%d" feat_name index
| Some (l,_) -> sprintf "%s=%s" feat_name (List.nth l index)
let build ?pat_vars = function
| ({Ast.kind=Ast.Equality unsorted_values; name=name}, loc) ->
......@@ -180,7 +183,7 @@ module P_fs = struct
let to_string t = List_.to_string P_feature.to_string "\\n" t
let to_dep t = List_.to_string P_feature.to_string "#" t
let to_dep param_names t = List_.to_string (P_feature.to_string ~param_names) "#" t
let to_dot t = List_.to_string P_feature.to_string "\\n" t
......
......@@ -49,7 +49,7 @@ module P_fs: sig
val to_string: t -> string
val to_dep: t -> string
val to_dep: (string list * string list) -> t -> string
val to_dot: t -> string
......
......@@ -136,6 +136,7 @@ module Rule = struct
neg: pattern list;
commands: Command.t list;
param: Lex_par.t option;
param_names: (string list * string list);
loc: Loc.t;
}
......@@ -150,7 +151,9 @@ module Rule = struct
let nodes =
Pid_map.fold
(fun id node acc ->
(node, sprintf " N_%d { word=\"%s\"; subword=\"%s\"}" id (P_node.get_name node) (P_fs.to_dep (P_node.get_fs node)))
(node, sprintf " N_%d { word=\"%s\"; subword=\"%s\"}"
id (P_node.get_name node) (P_fs.to_dep t.param_names (P_node.get_fs node))
)
:: acc
) t.pos.graph [] in
......@@ -243,6 +246,7 @@ module Rule = struct
commands = build_commands ~param:(pat_vars,cmd_vars) ~locals pos pos_table rule_ast.Ast.commands;
loc = rule_ast.Ast.rule_loc;
param = param;
param_names = (pat_vars,cmd_vars)
};
type matching = {
......
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