Commits

camlspotter committed 14d096d

on going

Comments (0)

Files changed (2)

ocaml/plphelper.ml

 let level = ref 0
 let do_debug = ref false
 
-let memoize = Token.Stream.memoize 
+let memoize : string -> (Str.t -> 'a) -> Str.t -> 'a = Token.Stream.memoize 
 
 (* Non memoization: it IS REALLY SLOW *)
 (* let memoize _k f v = f v *)
     let show_elem = show
     let equal_elem x y = x = y
     module Pos = Position.Region
-    type attr = Pos.t option (* last consumed token position *) * Pos.t * string Smemo.memo
+    type attr = Pos.t option (* last consumed token position *) * Pos.t * (string * [`Done of Obj.t | `Exn of exn]) list ref
     let position_of_attr (_,pos,_) = pos
     let last_position_of_attr (last_pos,_,_) = last_pos 
-    let default_attr = None, Pos.none, Smemo.create 1
+    let default_attr = None, Pos.none, ref []
     let memo_of_attr (_,_,memo) = memo
     let buf_of_attr (_,buf,_) = buf
   end
 
   include Str
 
-  include Smemo.Extend(struct
-    include Str
-    type key = string
-    let memo st = Base.memo_of_attr (attr st)
-  end)
-
   (* CR jfuruse: generalize it and port back to Planck.Core *)
   let create (m : ('a option * Position.Region.t) Input.Parser.t) = fun st ->
     let rec f last_pos st = lazy begin
       match Input.Parser.run m st with
-      | Result.Ok ((None, pos), _st') -> null_desc (last_pos, pos, Smemo.create 107) (* EOS case *)
-      | Result.Ok ((Some v, pos), st') -> cons_desc v (last_pos, pos, Smemo.create 107) (f (Some pos) st')
+      | Result.Ok ((None, pos), _st') -> null_desc (last_pos, pos, ref []) (* EOS case *)
+      | Result.Ok ((Some v, pos), st') -> cons_desc v (last_pos, pos, ref []) (f (Some pos) st')
       | Result.Error (pos, s) -> raise (Input.Parser.Critical_error (pos, s))
     end
     in
   ;;
 
   let last_position st : Position.Region.t option = Base.last_position_of_attr (attr st)
+
+  let memoize : string -> (unit -> Str.t -> 'a) -> Str.t -> 'a = fun _ -> assert false
 end
 
 module Parser = struct