[parser] avoid conflicts between local, input and output variables
This commit is contained in:
parent
bc8c752649
commit
97c6020414
@ -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 */ { ([], []) }
|
||||
|
12
src/utils.ml
12
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
|
||||
|
Loading…
Reference in New Issue
Block a user