Commits

Sébastien Ferré committed dc8d928

Add of combinator 'enum'.

  • Participants
  • Parent commits f08163b

Comments (0)

Files changed (1)

 
 let check = new check
 
+class ['res,'str,'msg] enum (name : string) (f : unit -> 'res list) (str : 'str) =
+  object (self)
+    val mutable state : 'res list = None
+
+    method next =
+      match state with
+      | None ->
+	  state <- Some (f ());
+	  self#next
+      | Some [] ->
+	  let s, p, coord = str # params in
+	  let msg = Msg.make name [||] (Msg.Locator.Point coord) in
+	  Failed [msg]
+      | Some (x::xs) ->
+	  state <- Some xs;
+	  Parsed (x, str)
+  end
+
+let enum = new enum
+
 (*
 class ['str, 'msg] eps (str : 'str) =
   object (self)