Commit 0da7c513 authored by POTTIER Francois's avatar POTTIER Francois

Cleanup, and a better error message when two productions in a group

do not define the same identifiers.
parent 0135407c
......@@ -31,27 +31,28 @@ let defined_identifiers producers =
List.fold_right defined_identifiers producers IdSet.empty
let check_production_group right_hand_sides =
begin
match right_hand_sides with
| [] ->
assert false
| (producers, _, _, _) :: right_hand_sides ->
let ids = defined_identifiers producers in
List.iter (fun (producers, _, _, _) ->
let ids' = defined_identifiers producers in
try
let id =
IdSet.choose (IdSet.union
(IdSet.diff ids ids')
(IdSet.diff ids' ids))
in
Error.error [Positions.position id]
"two productions that share a semantic action must define\n\
exactly the same identifiers."
with Not_found ->
()
) right_hand_sides
end
match right_hand_sides with
| [] ->
(* A production group cannot be empty. *)
assert false
| (producers, _, _, _) :: right_hand_sides ->
let ids = defined_identifiers producers in
List.iter (fun (producers, _, _, _) ->
let ids' = defined_identifiers producers in
try
let id =
IdSet.choose (IdSet.union
(IdSet.diff ids ids')
(IdSet.diff ids' ids))
in
Error.error [Positions.position id]
"two productions that share a semantic action must define exactly\n\
the same identifiers. Here, \"%s\" is defined\n\
in one production, but not in all of them."
(Positions.value id)
with Not_found ->
()
) right_hand_sides
(* [normalize_producer i p] assigns a name of the form [_i]
to the unnamed producer [p]. *)
......
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