Commits

camlspotter  committed 31c5719

added with_substr

  • Participants
  • Parent commits 0cda396

Comments (0)

Files changed (2)

 
 # OCamlGeneratedFiles(parser.ml lexer.ml)
 
+OCAMLPACKS[]=
+
 LIBFILES[] =
    utils
    result
   val mark : mark t
   val string_from_mark : mark -> string t
   val substr : 'a t -> string t
+  val with_substr : 'a t -> (string * 'a) t
   val (</>) : 'a t -> 'a t -> 'a t
     (** longest match *)
 end = struct
   let substr : 'a t -> string t = fun t ->
     mark >>= fun mark ->
     t >>= fun _ ->
-    string_from_mark mark
+    string_from_mark mark 
 
-  (* longest match *)
+  let with_substr : 'a t -> (string * 'a) t = fun t ->
+    mark >>= fun mark ->
+    t >>= fun v ->
+    string_from_mark mark >>= fun string ->
+      return (string, v)
+
+  (** longest match *)
   let (</>) : 'a t -> 'a t -> 'a t = fun t1 t2 ->
     fun st ->
       match t1 st, t2 st with