Commit c3d13fb8 authored by bguillaum's avatar bguillaum
Browse files

More checking of feature names and feature values.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8788 7838e531-6607-4d57-9587-6c381814729c
parent 2fa9e731
......@@ -115,12 +115,22 @@ module Rule = struct
Cst_in (pid_of_name loc id, Label_cst.build ~loc ?locals label_cst)
| (Ast.Feature_eq ((node_name1, feat_name1), (node_name2, feat_name2)), loc) ->
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_eq (pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_diseq ((node_name1, feat_name1), (node_name2, feat_name2)), loc) ->
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_diseq (pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_ineq (ineq, (node_name1, feat_name1), (node_name2, feat_name2)), loc) ->
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_ineq (ineq, pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_ineq_cst (ineq, (node_name1, feat_name1), constant), loc) ->
Domain.check_feature_name ~loc feat_name1;
Feature_ineq_cst (ineq, pid_of_name loc node_name1, feat_name1, constant)
......@@ -155,18 +165,27 @@ module Rule = struct
| (Ast.Feature_eq (feat_id1, feat_id2), loc) ->
let (node_name1, feat_name1) = feat_id1
and (node_name2, feat_name2) = feat_id2 in
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_eq (pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_diseq (feat_id1, feat_id2), loc) ->
let (node_name1, feat_name1) = feat_id1
and (node_name2, feat_name2) = feat_id2 in
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_diseq (pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_ineq (ineq, feat_id1, feat_id2), loc) ->
let (node_name1, feat_name1) = feat_id1
and (node_name2, feat_name2) = feat_id2 in
Domain.check_feature_name ~loc feat_name1;
Domain.check_feature_name ~loc feat_name2;
Feature_ineq (ineq, pid_of_name loc node_name1, feat_name1, pid_of_name loc node_name2, feat_name2)
| (Ast.Feature_ineq_cst (ineq, feat_id1, constant), loc) ->
let (node_name1, feat_name1) = feat_id1 in
Domain.check_feature_name ~loc feat_name1;
Feature_ineq_cst (ineq, pid_of_name loc node_name1, feat_name1, constant)
(* It may raise [P_fs.Fail_unif] in case of contradiction on constraints *)
......
......@@ -321,7 +321,7 @@ module Domain = struct
| [] -> List.map (fun s -> String s) values
| l when List.for_all (fun x -> x.[0] = '_') l -> List.map (fun s -> String s) values
| l -> Error.build ?loc "Unknown feature values '%s' for feature name '%s'"
(List_.to_string (fun x->x) ", " l)
(List_.to_string (fun x->x) ", " l)
name
)
| _::t -> loop t in
......@@ -351,6 +351,18 @@ module Domain = struct
| _ -> false
let build_closed feature_name feature_values =
let sorted_list = List.sort Pervasives.compare feature_values in
let without_duplicate =
let rec loop = function
| [] -> []
| x::y::tail when x=y ->
Log.fwarning "In the declaration of the feature name \"%s\", the value \"%s\" appears more than once" feature_name x;
loop (y::tail)
| x::tail -> x:: (loop tail)
in loop sorted_list in
Closed (feature_name, without_duplicate)
end (* Domain *)
(* ================================================================================ *)
......
......@@ -135,6 +135,8 @@ module Domain: sig
(** [sub fn1 fn2] returns [true] iff the domain of [fn1] is a subset if the domain of [fn2]. *)
val sub: feature_name -> feature_name -> bool
val build_closed: feature_name -> feature_atom list -> feature_spec
end (* module Domain *)
(* ================================================================================ *)
......
......@@ -241,7 +241,7 @@ feature:
{
match feature_values with
| ["#"] -> Domain.Num feature_name
| _ -> Domain.Closed (feature_name, List.sort Pervasives.compare feature_values)
| _ -> Domain.build_closed feature_name feature_values
}
(* phon:* *)
......
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