diff --git a/src/parser.mly b/src/parser.mly index 4722140..7cd039a 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -204,7 +204,13 @@ node_content: (Format.asprintf "The node %s is already defined." node_name, current_location())) - else Hashtbl.add defined_nodes node_name n; n }; + else + if vars_distinct e_in e_out (snd $10) + then (Hashtbl.add defined_nodes node_name n; n) + else raise (MyParsingError + ("There is a conflict between the names of local, input \ + or output variables.", + current_location())) }; node_body: | /* empty */ { ([], []) } diff --git a/src/utils.ml b/src/utils.ml index fa769a1..ae46399 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -22,6 +22,18 @@ let rec list_chk v = function | [] -> false | h :: t -> if h = v then true else list_chk v t +let rec vars_distinct lv lv' lv'' = + match lv, lv', lv'' with + | [], [], _ -> true + | [], h :: t , l'' -> + if List.mem h l'' + then false + else vars_distinct [] t l'' + | h :: t, l', l'' -> + if List.mem h l' || List.mem h l'' + then false + else vars_distinct t l' l'' + exception MyParsingError of (string * location) let type_const = function