diff options
author | Jérémie Dimino <jeremie@dimino.org> | 2011-12-23 16:30:23 +0000 |
---|---|---|
committer | Jérémie Dimino <jeremie@dimino.org> | 2011-12-23 16:30:23 +0000 |
commit | 3bea22baaf50f90fd6ec6b51754afe9c7ba910d3 (patch) | |
tree | 4a091867651722f561d61f07c0d3806a53b9a124 | |
parent | 632cea70f81920082c1321fa2588790a6aaa37e6 (diff) |
PR#5442: strings must be escaped when the ast meta-expansed by Camlp4
Because strings in the Camlp4 Ast are escaped.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11948 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | camlp4/Camlp4/Printers/OCaml.ml | 9 | ||||
-rw-r--r-- | camlp4/boot/Camlp4Ast.ml | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/camlp4/Camlp4/Printers/OCaml.ml b/camlp4/Camlp4/Printers/OCaml.ml index a524915a3..def7f196a 100644 --- a/camlp4/Camlp4/Printers/OCaml.ml +++ b/camlp4/Camlp4/Printers/OCaml.ml @@ -106,10 +106,7 @@ 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 = - fun - [ "'" -> "\\'" - | c -> c ]; + value ocaml_char x = x; value rec get_expr_args a al = match a with @@ -559,7 +556,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'" (ocaml_char s) + | <:expr< $chr:s$ >> -> pp f "'%s'" s | <:expr< $id:i$ >> -> o#var_ident f i | <:expr< { $b$ } >> -> pp f "@[<hv0>@[<hv2>{%a@]@ }@]" o#record_binding b @@ -669,7 +666,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'" (ocaml_char s) + | <:patt< $chr:s$ >> -> pp f "'%s'" 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 diff --git a/camlp4/boot/Camlp4Ast.ml b/camlp4/boot/Camlp4Ast.ml index fb8a0a61c..dcef91e11 100644 --- a/camlp4/boot/Camlp4Ast.ml +++ b/camlp4/boot/Camlp4Ast.ml @@ -471,10 +471,10 @@ module Make (Loc : Sig.Loc) : Sig.Camlp4Ast with module Loc = Loc = value meta_loc = meta_loc_expr; module Expr = struct - value meta_string _loc s = Ast.ExStr _loc s; + value meta_string _loc s = Ast.ExStr _loc (String.escaped s); value meta_int _loc s = Ast.ExInt _loc s; value meta_float _loc s = Ast.ExFlo _loc s; - value meta_char _loc s = Ast.ExChr _loc s; + value meta_char _loc s = Ast.ExChr _loc (String.escaped s); value meta_bool _loc = fun [ False -> Ast.ExId _loc (Ast.IdUid _loc "False") |