Commit ebec66e3 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Use [pvarlocated] when creating the mock file, so that warnings or errors...

Use [pvarlocated] when creating the mock file, so that warnings or errors about unused semantic values are reported in the .mly file.
parent 4c046071
......@@ -144,7 +144,8 @@ let actiondef grammar symbol branch =
let formals =
List.fold_left (fun formals producer ->
let symbol = producer_symbol producer
and id = producer_identifier producer in
and lid = producer_identifier_located producer in
let id = Positions.value lid in
let startp, endp, starto, endo, loc =
Printf.sprintf "_startpos_%s_" id,
Printf.sprintf "_endpos_%s_" id,
......@@ -152,12 +153,20 @@ let actiondef grammar symbol branch =
Printf.sprintf "_endofs_%s_" id,
Printf.sprintf "_loc_%s_" id
let pid =
(* We use [PVarLocated] in preference to [PVar] so that this binding
can be accurately in the source file (not in the generated file)
by the OCaml compiler. This is important when a variable declared
by the user turns out to be unused in a semantic action. We want
the unused-variable warning (or error) to be correctly located. *)
pvarlocated lid
let pid =
PAnnot (PVar id, tokentype grammar symbol)
PAnnot (pid, tokentype grammar symbol)
with Not_found ->
(* Symbol is a nonterminal. *)
annotate_pat grammar (PVar id) symbol
annotate_pat grammar pid symbol
pid ::
PAnnot (PVar startp, tposition) ::
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