Commits

camlspotter committed 5fd5829

removing unused functions

  • Participants
  • Parent commits 08ef359

Comments (0)

Files changed (6)

 let parse_ch ch = run_ch (json()) ch
 
 let parse s = run_string (json()) s
+
+let parse_function f = run_function (json()) f

File lib/json.mli

 
 val parse_ch : in_channel -> t
 val parse : string -> t
+val parse_function : (string -> int -> int) -> t

File lib/llist.ml

 let of_string =
   of_stream $ Stream.of_string
 
+let rec of_function f =
+  let buf = String.create 1024 in
+  
+  let rec fill () = 
+    let read = f buf 1024 in
+    if read = 0 then Nil
+    else Cons (buf.[0], lazy (use read 1))
+  
+  and use read pos = 
+    if read <= pos then fill ()
+    else Cons (buf.[pos], lazy (use read (pos+1)))
+
+  in
+  
+  fill ()
+
+      
+            
+  
+  

File lib/llist.mli

 type 'a llist = Nil | Cons of 'a * 'a llist Lazy.t
+(** It is a lazy list, but the first element is already forced *)
 
 val hd : 'a llist -> 'a
 val tl : 'a llist -> 'a llist
 val of_stream : 'a Stream.t -> 'a llist
 val sllist : ?items:int -> string -> ('a -> string) -> 'a llist -> string
 val of_string : string -> char llist
+
+val of_function : (string -> int -> int) -> char llist
+(** [of_function f]: [f buf len] is a filler, a function to fill [buf]
+    with at most [len] chars. If it reaches the end of the input it returns [0].
+*)

File lib/parserMonad.ml

 
 let run_string p s =
   run p init_state (Llist.of_string s)
+
+let run_function p f =
+  run p init_state (Llist.of_function f)
+

File lib/parserMonad.mli

 val run_stdin : 'a t -> 'a
 val run_file : 'a t -> string -> 'a
 val run_string : 'a t -> string -> 'a
+val run_function : 'a t -> (string -> int -> int) -> 'a