Ensure that character literals are always escaped by the camlp4 printer.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12463 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jérémie Dimino 2012-05-16 09:13:30 +00:00
parent 11fadf4929
commit 11741a8df7
1 changed files with 4 additions and 3 deletions

View File

@ -106,7 +106,8 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
"Cannot print %S this identifier does not respect OCaml lexing rules (%s)"
str (Lexer.Error.to_string exn)) ];
value ocaml_char x = x;
(* This is to be sure character literals are always escaped. *)
value ocaml_char x = Char.escaped (Struct.Token.Eval.char x);
value rec get_expr_args a al =
match a with
@ -556,7 +557,7 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
| <:expr< $int64:s$ >> -> o#numeric f s "L"
| <:expr< $int32:s$ >> -> o#numeric f s "l"
| <:expr< $flo:s$ >> -> o#numeric f s ""
| <:expr< $chr:s$ >> -> pp f "'%s'" s
| <:expr< $chr:s$ >> -> pp f "'%s'" (ocaml_char s)
| <:expr< $id:i$ >> -> o#var_ident f i
| <:expr< { $b$ } >> ->
pp f "@[<hv0>@[<hv2>{%a@]@ }@]" o#record_binding b
@ -666,7 +667,7 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
| <:patt< $int32:s$ >> -> o#numeric f s "l"
| <:patt< $int:s$ >> -> o#numeric f s ""
| <:patt< $flo:s$ >> -> o#numeric f s ""
| <:patt< $chr:s$ >> -> pp f "'%s'" s
| <:patt< $chr:s$ >> -> pp f "'%s'" (ocaml_char s)
| <:patt< ~ $s$ >> -> pp f "~%s" s
| <:patt< ` $uid:s$ >> -> pp f "`%a" o#var s
| <:patt< # $i$ >> -> pp f "@[<2>#%a@]" o#ident i