Commit dbdf2786 authored by bguillaum's avatar bguillaum

check domain:

- error if there is duplicate
- handling of reserved "position"

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8104 7838e531-6607-4d57-9587-6c381814729c
parent db7a31e3
......@@ -90,6 +90,24 @@ module Ast = struct
type domain = feature_spec list
let is_defined feature_name domain =
List.exists (function
| Closed (fn,_) when fn = feature_name -> true
| Open fn when fn = feature_name -> true
| Int fn when fn = feature_name -> true
| _ -> false
) domain
let rec normalize_domain = function
| [] -> [Int "position"]
| (Int "position") :: tail -> Log.warning "[Domain] declaration of the feature name \"position\" in useless"; normalize_domain tail
| (Open "position") :: _
| (Closed ("position",_)) :: _ ->
Error.build "[Domain] The feature named \"position\" is reserved and must be types 'integer', you cannot not redefine it"
| (Int fn) :: tail | (Open fn) :: tail | Closed (fn,_) :: tail when is_defined fn tail ->
Error.build "[Domain] The feature named \"%s\" is defined several times" fn
| x :: tail -> x :: (normalize_domain tail)
type feature_kind =
| Equality of feature_value list
| Disequality of feature_value list
......
......@@ -42,6 +42,7 @@ module Ast : sig
| Int of feature_name (* position *)
type domain = feature_spec list
val normalize_domain: domain -> domain
type feature_kind =
| Equality of feature_value list
......
......@@ -21,7 +21,8 @@ module Domain = struct
let reset () = current := None
let init ast_domain = current := Some ast_domain
let init ast_domain =
current := Some (Ast.normalize_domain ast_domain)
let build ?loc name unsorted_values =
let values = List.sort Pervasives.compare unsorted_values in
......
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