From b58c7dd97ab2a22002cc34ab25a558057834c31c Mon Sep 17 00:00:00 2001 From: Jon French Date: Thu, 14 Jun 2018 15:29:38 +0100 Subject: provide impl of int_of_string_opt in Sail_lib to support older Ocaml versions --- src/sail_lib.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/sail_lib.ml b/src/sail_lib.ml index 8430ef86..6c880e8d 100644 --- a/src/sail_lib.ml +++ b/src/sail_lib.ml @@ -502,6 +502,13 @@ let string_length str = Big_int.of_int (String.length str) let string_append (s1, s2) = s1 ^ s2 +(* int_of_string_opt is in Ocaml stdlib but not in older versions *) +let int_of_string_opt s = + try + Some (int_of_string s) + with + | Failure "int_of_string" -> None + (* highly inefficient recursive implementation *) let rec maybe_int_of_prefix = function | "" -> ZNone () -- cgit v1.2.3