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