diff options
| author | Shaked Flur | 2015-05-19 16:30:42 +0100 |
|---|---|---|
| committer | Shaked Flur | 2015-05-19 16:30:42 +0100 |
| commit | a7de95f222940cbc3f341cb281932d55248325d3 (patch) | |
| tree | 47d3129db84f5f4aacb17b1a47590471a3c5f06a | |
| parent | 2e69c321a035d6ae7dfd995cb0efb3e210dc4512 (diff) | |
avoid the use of Str.regexp as it breaks js_of_ocaml
| -rw-r--r-- | src/lem_interp/printing_functions.ml | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lem_interp/printing_functions.ml b/src/lem_interp/printing_functions.ml index b4c5fa96..60e5359b 100644 --- a/src/lem_interp/printing_functions.ml +++ b/src/lem_interp/printing_functions.ml @@ -36,8 +36,17 @@ let collapse_leading s = if String.length s <= 8 then s else let first_bit = s.[0] in let templ = sprintf "%c...%c" first_bit first_bit in - let regexp = Str.regexp "^\\(000000*\\|111111*\\)" in - Str.replace_first regexp templ s + + let rec find_first_diff str cha pos = + if pos >= String.length str then None + else if str.[pos] != cha then Some pos + else find_first_diff str cha (pos+1) + in + + match find_first_diff s first_bit 0 with + | None -> templ + | Some pos when pos > 4 -> templ ^ (String.sub s pos ((String.length s)- pos)) + | _ -> s ;; let bitvec_to_string l = "0b" ^ collapse_leading (String.concat "" (List.map (function |
