From 896d450e1686ac2a3b71b7966f3c4562e9d02956 Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Tue, 19 May 2015 13:34:54 +0100 Subject: [PATCH] 112.35.00 - Inline some calls that js_of_ocaml was unable to recognise as tail-recursive (cf. issue #14) --- _oasis | 2 +- lib/conv.ml | 2 +- lib/pre_sexp.ml | 14 ++++++++++++-- lib_test/test_macros.ml | 6 ++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/_oasis b/_oasis index 4ae6008..ac95658 100644 --- a/_oasis +++ b/_oasis @@ -2,7 +2,7 @@ OASISFormat: 0.4 OCamlVersion: >= 4.00.0 FindlibVersion: >= 1.3.2 Name: sexplib -Version: 112.24.00 +Version: 112.35.00 Synopsis: sexplib - automated S-expression conversion Authors: Jane Street Group, LLC Copyrights: (C) 2005-2013 Jane Street Group LLC diff --git a/lib/conv.ml b/lib/conv.ml index 5b149f8..34b8009 100644 --- a/lib/conv.ml +++ b/lib/conv.ml @@ -28,7 +28,7 @@ external format_float : string -> float -> string = "caml_format_float" which was converted from a decimal (string) with <= 15 significant digits. So it's worth trying first to avoid things like "3.1400000000000001". - See comment above [to_string_round_trippable] in [base/core/kernel/lib/float.ml] for + See comment above [to_string_round_trippable] in {!Core_kernel.Float} for detailed explanation and examples. *) let default_string_of_float = ref (fun x -> diff --git a/lib/pre_sexp.ml b/lib/pre_sexp.ml index 86603f3..ad89244 100644 --- a/lib/pre_sexp.ml +++ b/lib/pre_sexp.ml @@ -744,7 +744,12 @@ let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> | '"' -> \ bump_found_atom \ bump_text_pos state str ~max_pos ~pos reg_parse_quoted \ - | c -> add_bump_pos state str ~max_pos ~pos c parse_atom \ + | c -> \ + (* This is [add_bump_pos state str ~max_pos ~pos c parse_atom] inlined by \ + hand, see https://github.com/janestreet/sexplib/pull/14 for details: *) \ + Buffer.add_char state.pbuf c; \ + bump_text_pos state; \ + parse_atom state str ~max_pos ~pos:(pos + 1) \ \ and maybe_parse_bad_atom_pipe state str ~max_pos ~pos = \ if pos > max_pos then \ @@ -789,7 +794,12 @@ let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> bump_pos_cont state str ~max_pos ~pos PARSE) \ | '\\' -> bump_pos_cont state str ~max_pos ~pos parse_escaped \ | '\010' as c -> add_bump_line state str ~max_pos ~pos c parse_quoted \ - | c -> add_bump_pos state str ~max_pos ~pos c parse_quoted \ + | c -> \ + (* This is [add_bump_pos state str ~max_pos ~pos c parse_quoted] inlined by \ + hand, see https://github.com/janestreet/sexplib/pull/14 for details: *) \ + Buffer.add_char state.pbuf c; \ + bump_text_pos state; \ + parse_quoted state str ~max_pos ~pos:(pos + 1) \ \ and parse_escaped state str ~max_pos ~pos = \ if pos > max_pos then mk_cont "parse_escaped" parse_escaped state \ diff --git a/lib_test/test_macros.ml b/lib_test/test_macros.ml index 6ac6788..e973f0a 100644 --- a/lib_test/test_macros.ml +++ b/lib_test/test_macros.ml @@ -391,11 +391,9 @@ module Make (Load : Load) = struct (Failure \"Error evaluating macros: Empty let bodies not allowed\")) (:let f ()))"] - exception Conv_error - let rec conv_error = function | Sexp.List [ Sexp.Atom "trigger"; Sexp.Atom "error" ] as t -> - raise (Pre_sexp.Of_sexp_error (Conv_error, t)) + raise (Pre_sexp.Of_sexp_error (Exit, t)) | Sexp.Atom _ -> () | Sexp.List ts -> List.iter conv_error ts @@ -409,7 +407,7 @@ module Make (Load : Load) = struct (foo bar (trigger (:use err)))" ] ~expect:["((Sexplib.Sexp.Annotated.Conv_exn DIR/include.sexp:2:18 - (\"Test_macros.Make(Load).Conv_error\")) + \"Exit\") (trigger (:use err)) (expanded (trigger error)))"] TEST_UNIT "multiple conversion errors" =