Commits

camlspotter  committed e5f02ee

pcore_intf.ml

  • Participants
  • Parent commits 7014854

Comments (0)

Files changed (5)

 open Spotlib.Spot
-
-type ('a, 'pos) generator = ('a, 'pos) Stream.generator
-
-module type S = sig
-  module Str : Stream.S
-  exception Error of Str.pos * string
-  module Result : Result.S with type error = Str.pos * string
-  include Monad_intf.T with type 'a t = Str.t -> ('a * Str.t) Result.t
-  val take : Str.elem t
-  val pos : 'a t -> ('a * Str.pos) t
-  val error : string -> 'a t
-  val eos : unit t
-  val filter_map : string -> (Str.elem -> 'a option) -> 'a t
-  val token : Str.elem -> Str.elem t
-  val tokenp : (Str.elem -> string option (* error string *)) -> Str.elem t
-    (* CR jfuruse: Error instead of option ? *)
-  val one_of : Str.elem list -> Str.elem t
-  val seq' : Str.elem list -> unit t
-  val option : 'a t -> 'a option t
-  val star : 'a t -> 'a list t
-  val star_ : 'a t -> unit t
-  val plus : 'a t -> 'a list t
-  val plus_ : 'a t -> unit t
-  val surrounded : 'a t -> 'b t -> 'c t -> 'c t
-  val ( <|> ) : 'a t -> 'a t -> 'a t
-  val ( <||> ) : 'a option t -> 'a option t -> 'a option t
-  val ( <|>> ) : 'a option t -> 'a t -> 'a t
-  (* val ignore : 'a t -> unit t *)
-  val catch : 'a t -> 'a Result.t t
-  val catch_opt : 'a t -> 'a option t
-  val begin_with : 'a t -> 'b t -> 'b option t
-
-  val stream_gen : 
-    'a option t 
-    -> (Str.t -> Str.t -> 'b)  (* position calculator *)
-    -> Str.t 
-    -> ('a, 'b) generator
-end
+open Pcore_intf
 
 (* basic *)
 module Make(S : Stream.S) = struct
-type ('a, 'pos) generator = ('a, 'pos) Stream.generator
-(* CR bad escape *)
-
-module type S = sig
-  module Str : Stream.S
-  exception Error of Str.pos * string
-  module Result : Result.S with type error = Str.pos * string
-  
-  include Spotlib.Spot.Monad_intf.T with type 'a t = Str.t -> ('a * Str.t) Result.t
-
-  val take : Str.elem t
-  val pos : 'a t -> ('a * Str.pos) t
-  val error : string -> 'a t
-  val eos : unit t
-  val filter_map : string -> (Str.elem -> 'a option) -> 'a t
-  val token : Str.elem -> Str.elem t
-  val tokenp : (Str.elem -> string (* error message *) option) -> Str.elem t
-  val one_of : Str.elem list -> Str.elem t
-  val seq' : Str.elem list -> unit t
-  val option : 'a t -> 'a option t
-  val star : 'a t -> 'a list t
-  val star_ : 'a t -> unit t
-  val plus : 'a t -> 'a list t
-  val plus_ : 'a t -> unit t
-  val surrounded : 'a t -> 'b t -> 'c t -> 'c t
-  val ( <|> ) : 'a t -> 'a t -> 'a t
-  val ( <||> ) : 'a option t -> 'a option t -> 'a option t
-  val ( <|>> ) : 'a option t -> 'a t -> 'a t
-  (* val ignore : 'a t -> unit t *)
-  val catch : 'a t -> 'a Result.t t
-  val catch_opt : 'a t -> 'a option t
-  val begin_with : 'a t -> 'b t -> 'b option t
-
-  val stream_gen : 
-    'a option t 
-    -> (Str.t -> Str.t -> 'b)  (* position calculator *)
-    -> Str.t 
-    -> ('a, 'b) generator
-end
+open Pcore_intf
 
 module Make (S : Stream.S) : S 
   with module Str = S

File pcore_intf.ml

+open Spotlib.Spot
+
+type ('a, 'pos) generator = ('a, 'pos) Stream.generator
+
+module type S = sig
+  module Str : Stream.S
+  exception Error of Str.pos * string
+  module Result : Result.S with type error = Str.pos * string
+  include Monad_intf.T with type 'a t = Str.t -> ('a * Str.t) Result.t
+  val take : Str.elem t
+  val pos : 'a t -> ('a * Str.pos) t
+  val error : string -> 'a t
+  val eos : unit t
+  val filter_map : string -> (Str.elem -> 'a option) -> 'a t
+  val token : Str.elem -> Str.elem t
+  val tokenp : (Str.elem -> string option (* error string *)) -> Str.elem t
+    (* CR jfuruse: Error instead of option ? *)
+  val one_of : Str.elem list -> Str.elem t
+  val seq' : Str.elem list -> unit t
+  val option : 'a t -> 'a option t
+
+  val surrounded : 'a t -> 'b t -> 'c t -> 'c t
+
+  (** No backtrack *)
+  val star : 'a t -> 'a list t
+  val star_ : 'a t -> unit t
+  val plus : 'a t -> 'a list t
+  val plus_ : 'a t -> unit t
+
+  (** With backtracks *)    
+  val ( <|> ) : 'a t -> 'a t -> 'a t
+  val ( <||> ) : 'a option t -> 'a option t -> 'a option t
+  val ( <|>> ) : 'a option t -> 'a t -> 'a t
+
+  (* val ignore : 'a t -> unit t *)
+  val catch : 'a t -> 'a Result.t t
+  val catch_opt : 'a t -> 'a option t
+  val begin_with : 'a t -> 'b t -> 'b option t
+
+  val stream_gen : 
+    'a option t 
+    -> (Str.t -> Str.t -> 'b)  (* position calculator *)
+    -> Str.t 
+    -> ('a, 'b) generator
+end
+
 open Spotlib.Spot
 
 module type P = sig
-  include Pcore.S with type Str.elem = Sbuffer.elem
-                  and  type Str.t = Sbuffer.t
-		  and  type Str.pos = Sbuffer.pos
+  include Pcore_intf.S with type Str.elem = Sbuffer.elem
+                       and  type Str.t = Sbuffer.t
+		       and  type Str.pos = Sbuffer.pos
   val string : string -> string t
   val chars_to_string : char list t -> string t
 
 module type P = sig
-  include Pcore.S with type Str.elem = Sbuffer.elem
-                  and  type Str.t = Sbuffer.t
-		  and  type Str.pos = Sbuffer.pos
+  include Pcore_intf.S with type Str.elem = Sbuffer.elem
+                       and  type Str.t = Sbuffer.t
+		       and  type Str.pos = Sbuffer.pos
   (* From Pcore.String *)			  
   val string : string -> string t
   val chars_to_string : char list t -> string t