Commits

Anonymous committed 3f501f6

.

Comments (0)

Files changed (1)

src/dbi/decimal.ml

 ;
 
 
-value is_decimal_point = fun [ '.' -> True | _ -> False ]
+value is_decimal_point = fun [ '.' | ',' -> True | _ -> False ]
 ;
 
 
         ;
 *)
 
+        exception ENum of string
+        ;
+
+        value num_err msg = throw_err (ENum msg)
+        ;
+
+        value is_decimal_point = fun [ '.' | ',' -> True | _ -> False ]
+        ;
+
+        value is_digit = fun c -> (c <= '9' && c >= '0')
+        ;
+
+        value num_of_string_fix_unsigned =
+          break_chars is_digit >>= fun before_point ->
+          peek >>= fun
+          [ ...  point or eon ?
+          ]
+          ...
+        ;
+
+        value num_of_string_fix =
+          peek >>= fun
+          [ None -> num_err "EOF while reading number"
+          | Some '-' -> junk >>= return (-1)
+          | Some '+' -> junk >>= return 1
+          | _ -> return 1
+          ] >>= fun sign ->
+          num_of_string_fix_unsigned >>= fun num_unsigned ->
+          return (Num.mult_num num_unsigned (Num.num_of_int sign))
+        ;
+
       end
     ;
 
     value read_num ;
 *)
 
-    value num_of_string_fix _ = raise Exit
+    value is_whitespace = fun [ ' ' | '\t' -> True | _ -> False ]
+    ;
+
+    value num_of_string_fix str =
+      match IO.runIO
+        (I.run %<< enum_string str
+          (I.drop_while is_whitespace >>= fun () -> It_add.num_of_string_fix)
+        )
+      with
+      [ `Ok r -> r
+      | `Error e ->
+          raise & match e with
+          [ I.Iteratees_err_msg e -> e
+          | e -> e
+          ]
+      ]
+    ;
+
+    value () =
+      let str = "1.23" in
+      (
+        Printf.printf "%s = %!"
+      ; try Printf.printf "%s\n%!" (Num.string_of_num (num_of_string_fix str))
+        with [e -> Printf.printf "error: %s" & Printexc.to_string e]
+      )
     ;
 
   end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.