diff options
| author | Jon French | 2018-06-14 15:29:38 +0100 |
|---|---|---|
| committer | Jon French | 2018-06-14 15:29:49 +0100 |
| commit | b58c7dd97ab2a22002cc34ab25a558057834c31c (patch) | |
| tree | 84d6e424e2046614db119b5c85938a823ac8c958 /src | |
| parent | 015c424a4bb181da32cd94b60f1ab04ac5147727 (diff) | |
provide impl of int_of_string_opt in Sail_lib to support older Ocaml versions
Diffstat (limited to 'src')
| -rw-r--r-- | src/sail_lib.ml | 7 |
1 files changed, 7 insertions, 0 deletions
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 () |
