Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit b839eef0 authored by POTTIER Francois's avatar POTTIER Francois

UnparameterizedPrinter: replace [let/in] with [let/and] when emitting

bindings of the form [x = $i] for ocamlyacc. This should work around a
name capture caused by the fact that ocamlyacc internally translates
[$i] to [_i] (and our own variables are often of the form [_i]).
parent 6bfd690b
......@@ -2,6 +2,8 @@
Fix in --only-preprocess-for-ocamlyacc mode: avoid printing newline characters
inside a %type declaration, as this is forbidden by ocamlyacc. (Reported by
Kenji Maillard.)
Fix in --only-preprocess-for-ocamlyacc mode: avoid variable capture caused by
ocamlyacc internally translating $i to _i. (Reported by Kenji Maillard.)
New command line switch --only-preprocess-for-ocamlyacc, supposed to print the
......@@ -148,10 +148,13 @@ let print_semantic_action f g branch =
IL.EVar (sprintf "$%d" (i + 1))
) branch.producers
(* We can use a nested sequence of [let/in] definitions, as
opposed to a single [let/and] definitions, because the
identifiers that we bind are pairwise distinct. *)
let e = IL.ELet (bindings, e) in
(* The identifiers that we bind are pairwise distinct. *)
(* We must use simultaneous bindings (that is, a [let/and] form), as
opposed to a cascade of [let] bindings. Indeed, ocamlyacc internally
translates [$i] to [_i] (just like us!), so name captures will occur
unless we restrict the use of [$i] to the outermost scope. (Reported
by Kenji Maillard.) *)
let e = CodeBits.eletand (bindings, e) in
Printer.print_expr f e
(* -------------------------------------------------------------------------- *)
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