Commits

Anonymous committed d2cfead

printing logic written

Comments (0)

Files changed (2)

 exception Not_supported;;
 exception Unknown_type;;
 
-let print_bin bin = 
-  let rec print_ n =
-    if n < String.length bin then begin 
-      Printf.printf "%.2X " (int_of_char (String.get bin n));
-      print_ (n+1);
-    end else 
-      print_endline ""
-  in
-    print_string "binary: ";
-    print_ 0;;
-
 let make_small_bigint bin len =
   let rec make_small_bigint_ i prod v = 
     if i < len then
       | _ -> raise Unknown_type;
     end;;
 
+let print_binary_string bin = 
+  let rec print_ n =
+    if n < String.length bin then begin 
+      Printf.printf "%.2X " (int_of_char (String.get bin n));
+      print_ (n+1);
+    end else 
+      print_endline ""
+  in
+    print_string "binary: ";
+    print_ 0;;
+
 let print_binary bin = 
   let rec p_bin i =
     if i < (String.length bin) then begin
-      Printf.printf " %c" (String.get bin i);
+      Printf.printf "%.2x," (int_of_char (String.get bin i));
       p_bin (i+1)
     end in
-    p_bin 0 ;;
+    print_string "<<";
+    p_bin 0;
+    print_string ">>";;
 
 let print_erlterm term = 
   let rec print_termlist rhs list =
       | String(str)->
 	  print_string str;
       | Binary(bin)-> begin
-	  print_string "<<";
 	  print_binary bin ;
-	  print_string ">>";
 	end;
 (*      | None ->
 	  print_string "Nil"; *)
     Printf.printf "reading %s: \n" filename;
     begin match result with
       | Bert.Ok(term, remain)->
-	  Bert.print_bin bin;
+	  Bert.print_binary_string bin;
 	  Bert.print_erlterm term;
 	  print_endline "\n==all read.";
       | _->