[parser] avoid conflicts between local, input and output variables

This commit is contained in:
dsac 2022-12-15 21:42:21 +01:00
parent bc8c752649
commit 97c6020414
2 changed files with 19 additions and 1 deletions

View File

@ -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 */ { ([], []) }

View File

@ -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