Commits

camlspotter  committed 490630e

preparing 2.1.0

  • Participants
  • Parent commits 50a1489

Comments (0)

Files changed (25)

 	- bug fixes
 	- refactored module types lot
 	- refactored the operator precedence resolution: op_prec.ml
+        - Changed using Spotlib.Result monad
 
 v.2.0.1
 	- opam fixes
 XCustomBuild: yes no | omake --install; PREFIX=$prefix omake
 XCustomInstall: PREFIX=$prefix omake install
 XCustomUninstall: PREFIX=$prefix omake uninstall
+XCustomBuildClean: PREFIX=$prefix omake clean
 BuildTools: omake
-# OASIS_START
-# DO NOT EDIT (digest: 8e57f046ce034f177cd68b56a3bde28f)
 version = "2.1.0"
 description
  =
 archive(byte) = "planck.cma"
 archive(native) = "planck.cmxa"
 exists_if = "planck.cma"
-# OASIS_STOP
 
+
+version = "@version@"
+description
+ =
+ "Planck(Parser LANguage Combinator Kit): a small parser combinator library"
+requires = "sexplib, spotlib"
+archive(byte) = "planck.cma"
+archive(native) = "planck.cmxa"
+exists_if = "planck.cma"
+
+

File lib/OMakefile

 
 LIBFILES[] =
    position
-   result
    elem
    stream_intf
    stream

File lib/pbase.ml

 open Spotlib.Spot
-open Result
 
 module type S = sig
 
 
     type 'a t = 'a _t
   
-    let return v = fun st -> Ok (v, st)
+    let return v = fun st -> `Ok (v, st)
   
     let bind t f = fun st ->
       Profile.incr ();
       match t st with
-      | Ok (r, st') -> f r st' 
-      | Error s -> Error s
+      | `Ok (r, st') -> f r st' 
+      | `Error s -> `Error s
   end)
 
   open Open
   let take : Str.Elem.t t = fun s -> 
     Profile.incr ();
     match Str.peek s with
-    | None -> Error (Str.position s, "unexpected end of stream")
-    | Some (elem, s') -> Ok (elem, s')
+    | None -> `Error (Str.position s, "unexpected end of stream")
+    | Some (elem, s') -> `Ok (elem, s')
 
   let take_ : unit t = fun s -> 
     Profile.incr ();
     match Str.peek s with
-    | None -> Error (Str.position s, "unexpected end of stream")
-    | Some (_, s') -> Ok ((),s')
+    | None -> `Error (Str.position s, "unexpected end of stream")
+    | Some (_, s') -> `Ok ((),s')
 
-  let position : Str.Pos.t t = fun st -> Profile.incr (); Ok (Str.position st, st)
+  let position : Str.Pos.t t = fun st -> Profile.incr (); `Ok (Str.position st, st)
 
-  let error s : 'a t = fun st -> Profile.incr (); Error (Str.position st, s)
-  let throw err = fun _st -> Profile.incr (); Error err
+  let error s : 'a t = fun st -> Profile.incr (); `Error (Str.position st, s)
+  let throw err = fun _st -> Profile.incr (); `Error err
 
   let critical_error pos s = raise (Critical_error (pos, s))
 
-  let stream : Str.t t = fun st -> Profile.incr (); Ok (st, st)
+  let stream : Str.t t = fun st -> Profile.incr (); `Ok (st, st)
 
   let eos : unit t = fun s -> 
     Profile.incr ();
     match Str.peek s with
-    | Some _ -> Error (Str.position s, "end of stream expected")
-    | None -> Ok ((), s)
+    | Some _ -> `Error (Str.position s, "end of stream expected")
+    | None -> `Ok ((), s)
 
   let (<?>) : 'a t -> string -> 'a t = fun c mes st ->
     Profile.incr ();
     let res = c st in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> Error (pos, "expected " ^ mes)
+    | `Ok _ -> res
+    | `Error (pos, _) -> `Error (pos, "expected " ^ mes)
 
   let (<?!>) : 'a t -> string -> 'a t = fun c mes st ->
     Profile.incr ();
     let res = c st in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> Error (pos, mes)
+    | `Ok _ -> res
+    | `Error (pos, _) -> `Error (pos, mes)
 
   let (<?@>) : 'a t -> Str.Pos.t -> 'a t = fun c pos st ->
     Profile.incr ();
     let res = c st in
     match res with
-    | Ok _ -> res
-    | Error (_, mes) -> Error (pos, mes)
+    | `Ok _ -> res
+    | `Error (_, mes) -> `Error (pos, mes)
 
   (* [take] advances the stream. If we use [take] and some predicate to check the result,
      the error position must be fixed as the one at the use of [take]. *)
     position >>= fun pos ->
     take >>= fun elem ->
     match p elem with
-    | Ok v -> return v
-    | Error err -> error err <?@> pos
+    | `Ok v -> return v
+    | `Error err -> error err <?@> pos
 
   let token : Str.Elem.t -> unit t = fun tkn ->
     void (tokenp (fun x -> Str.Elem.equal tkn x)) <?>  Str.Elem.show tkn
   let option : 'a t -> 'a option t = fun com s ->
     Profile.incr ();
     match com s with
-    | Error _ -> return None s
-    | Ok (v, s') -> return (Some v) s'
+    | `Error _ -> return None s
+    | `Ok (v, s') -> return (Some v) s'
 
   let option_ : unit t -> unit t = fun com s ->
     Profile.incr ();
     match com s with
-    | Error _ -> return () s
-    | Ok ((), s') -> return () s'
+    | `Error _ -> return () s
+    | `Ok ((), s') -> return () s'
 
   let result : 'a t -> ('a, error) Result.t t = fun c st ->
     Profile.incr ();
     match c st with
-    | Ok (res, st) -> Ok (Ok res, st)
-    | Error e -> Ok (Error e, st)
+    | `Ok (res, st) -> `Ok (`Ok res, st)
+    | `Error e -> `Ok (`Error e, st)
 
   let try_finally : 'a t -> (('a, error) Result.t -> unit) -> 'a t = fun c f -> 
     result c >>= fun res ->
     f res;
     match res with
-    | Ok v -> return v
-    | Error err -> fun _st -> Error err
+    | `Ok v -> return v
+    | `Error err -> fun _st -> `Error err
 
   let ( ?** ) : 'a t -> 'a list t = fun com ->
     let rec aux st = fun s ->
       Profile.incr ();
       match com s with
-      | Error _ -> return (List.rev st) s
-      | Ok (v, s') -> aux (v :: st) s'
+      | `Error _ -> return (List.rev st) s
+      | `Ok (v, s') -> aux (v :: st) s'
     in
     aux []
   
     let rec aux = fun s ->
       Profile.incr ();
       match com s with
-      | Error _ -> return () s
-      | Ok (_v, s') -> aux  s'
+      | `Error _ -> return () s
+      | `Ok (_v, s') -> aux  s'
     in
     aux
   
   let critical : 'a t -> 'a t = fun t st ->
     Profile.incr ();
     match t st with
-    | (Ok _ as res) -> res
-    | Error (pos, s) -> raise (Critical_error (pos, s))
+    | (`Ok _ as res) -> res
+    | `Error (pos, s) -> raise (Critical_error (pos, s))
 
   let (<|>) : 'a t -> 'a t -> 'a t = fun c1 c2 st -> 
     Profile.incr ();
     let pos0 = Str.position st in
     let res = c1 st in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> if pos = pos0 then c2 st else res
+    | `Ok _ -> res
+    | `Error (pos, _) -> if pos = pos0 then c2 st else res
 
   (* CR jfuruse: _ is used in a different meaning than option_ *)
   let try_ : 'a t -> 'a t = fun c st ->
     let pos0 = Str.position st in
     let res = c st in
     match res with
-    | Ok _ -> res
-    | Error (_, err) -> Error (pos0, err)
+    | `Ok _ -> res
+    | `Error (_, err) -> `Error (pos0, err)
 
   let (<!>) : 'a t -> 'a t -> 'a t = fun c1 c2 st -> 
     Profile.incr ();
     Profile.start ();
     let pos = Str.position st in
     match c1 st with
-    | (Ok _ as res) -> 
+    | (`Ok _ as res) -> 
         Profile.add (Profile.stop ());
         res
-    | Error (pos', _) -> 
+    | `Error (pos', _) -> 
         if pos = pos' then Profile.add (Profile.stop ())
         else begin
           Profile.wasted := !Profile.wasted + Profile.stop ();
     let pos = Str.position st in
     let res1 = c1 st in
     match res1 with
-    | Ok _ -> 
+    | `Ok _ -> 
         Profile.add (Profile.stop ());
         res1
-    | Error (pos', _) ->
+    | `Error (pos', _) ->
         let binds_in_c1 = Profile.stop () in
         Profile.start (); 
         let res2 = c2 st in
         match res2 with
-        | Ok _ -> 
+        | `Ok _ -> 
             if pos = pos' then Profile.add binds_in_c1
             else Profile.wasted := !Profile.wasted + binds_in_c1;
             res2
-        | Error (pos'', _) -> 
+        | `Error (pos'', _) -> 
             if pos' = pos'' then Profile.add (Profile.stop ())
             else Profile.wasted := !Profile.wasted + Profile.stop ();
             res1
     fun st ->
       Profile.incr ();
       match c1 st with
-      | Ok (v, _) -> c2 v st
-      | (Error _ as res) -> res
+      | `Ok (v, _) -> c2 v st
+      | (`Error _ as res) -> res
 
 
   let rec (/**/) : 'a list t -> 'a list t -> 'a list t = fun c1 c2 ->
       | None -> return None
       | Some _ -> c2 >>= fun v -> return (Some v)
 
-  let set_stream new_st _st = Profile.incr (); Ok ((), new_st)
+  let set_stream new_st _st = Profile.incr (); `Ok ((), new_st)
 
   let run : 'a t -> Str.t -> ('a * Str.t, error) Result.t = fun t st ->
     t st

File lib/pbase.mli

 (** The basic monadic parser module. See Planck_intf.ml for more details *)
 
+open Spotlib.Spot
+
 module type S = sig
 
   module Str : Stream_intf.S

File lib/pbaseexn.ml

     position >>= fun pos ->
     take >>= fun elem ->
     match p elem with 
-    | Ok v -> return v
-    | Error mes -> error mes <?@> pos
+    | `Ok v -> return v
+    | `Error mes -> error mes <?@> pos
 
   let token : Str.Elem.t -> unit t = fun tkn ->
     void (tokenp (fun x -> tkn = x)) <?>  Str.Elem.show tkn
   let result : 'a t -> ('a, error) Result.t t = fun c st ->
     try 
       let res, st = c st in
-      ok (Ok res, st)
+      ok (`Ok res, st)
     with
-    | Exn e -> ok (Error e, st)
+    | Exn e -> ok (`Error e, st)
 
   let try_finally : 'a t -> (('a, error) Result.t -> unit) -> 'a t = fun c f -> 
     result c >>= fun res ->
     f res;
     match res with
-    | Ok v -> return v
-    | Error err -> fun _st -> throw err
+    | `Ok v -> return v
+    | `Error err -> fun _st -> throw err
 
   let ( ?** ) : 'a t -> 'a list t = fun com ->
     let rec aux st = fun s ->
 
   let set_stream new_st _st = ok ((), new_st)
 
-  let run t st = try Ok (t st) with Exn err -> Error err
+  let run t st = try `Ok (t st) with Exn err -> `Error err
 end

File lib/pbaseref.ml

     position >>= fun pos ->
     take >>= fun elem ->
     match p elem with 
-    | Ok v -> return v
-    | Error mes -> error mes <?@> pos
+    | `Ok v -> return v
+    | `Error mes -> error mes <?@> pos
 
   let token : Str.Elem.t -> unit t = fun tkn ->
     void (tokenp (fun x -> tkn = x)) <?>  Str.Elem.show tkn
     let str = get () in
     try 
       let res = c () in
-      ok (Ok res)
+      ok (`Ok res)
     with
-    | Exn e -> set str; ok (Error e)
+    | Exn e -> set str; ok (`Error e)
 
   let try_finally : 'a t -> (('a, error) Result.t -> unit) -> 'a t = fun c f -> 
     result c >>= fun res ->
     f res;
     match res with
-    | Ok v -> return v
-    | Error err -> fun _st -> throw err
+    | `Ok v -> return v
+    | `Error err -> fun _st -> throw err
 
   let ( ?** ) : 'a t -> 'a list t = fun com () ->
     let rec aux st = 
 
   let run t st = 
     set st;
-    try let res = t () in Ok (res, get ()) with Exn err -> Error err
+    try let res = t () in `Ok (res, get ()) with Exn err -> `Error err
 end

File lib/pbuffer.ml

   let string s =
     position >>= fun pos0 ->
     result (prefix (String.length s)) >>= function
-      | Result.Ok s' when s = s' -> return ()
+      | `Ok s' when s = s' -> return ()
       | _ -> throw (pos0, Printf.sprintf "expected %S" s)
 
   let matched : unit t -> string t = fun t ->
       <&> (fun res1 ->
         result (t2 >>= fun res -> stream >>= fun str -> return (res, str)) >>= fun res2 ->
         match res1, res2 with
-        | Result.Ok (res, str), Result.Error _ 
-        | Result.Error _, Result.Ok (res, str) -> set_stream str >>= fun () -> return res
-        | Result.Ok (res1, str1), Result.Ok (res2, str2) -> 
+        | `Ok (res, str), `Error _ 
+        | `Error _, `Ok (res, str) -> set_stream str >>= fun () -> return res
+        | `Ok (res1, str1), `Ok (res2, str2) -> 
             if Sbuffer.bytes str1 >= Sbuffer.bytes str2 then set_stream str1 >>= fun () -> return res1
             else  set_stream str2 >>= fun () -> return res2
-        | Result.Error (_,err1), Result.Error (_,err2) ->
+        | `Error (_,err1), `Error (_,err2) ->
             error (err1 ^ " or " ^ err2) <?@> pos0)
 
 end

File lib/pbuffer.mli

 (** Monadic parser for buffered char streams *)
 
+open Spotlib.Spot
+
 (** Extend(Str)(Base) extends Base for Str with buffered string operations
     Typical usage is:
 

File lib/pfile.ml

+open Spotlib.Spot
+
 module Stream = Sfile
 type 'a t = Stream.t -> ('a * Stream.t, Stream.Pos.t * string (* error *)) Result.t
 module Parser = Pbuffer.Make(Stream)

File lib/pfile.mli

+open Spotlib.Spot
+
 (* Stream from Sfile *)
 module Stream : Sfile.S
 

File lib/pstate.ml

 
     type 'a t = 'a _t
   
-    let return v = fun st stat -> Ok (v, st, stat)
+    let return v = fun st stat -> `Ok (v, st, stat)
   
     let bind t f = fun st stat ->
       match t st stat with
-      | Ok (r, st', stat') -> f r st' stat'
-      | Error s -> Error s
+      | `Ok (r, st', stat') -> f r st' stat'
+      | `Error s -> `Error s
   end)
 
   open Open
 
   let take : Str.Elem.t t = fun s stat -> 
     match Str.peek s with
-    | None -> Error (Str.position s, "unexpected end of stream")
-    | Some (elem, s') -> Ok (elem, s', stat)
+    | None -> `Error (Str.position s, "unexpected end of stream")
+    | Some (elem, s') -> `Ok (elem, s', stat)
 
   let take_ : unit t = fun s stat -> 
     match Str.peek s with
-    | None -> Error (Str.position s, "unexpected end of stream")
-    | Some (_, s') -> Ok ((), s', stat)
+    | None -> `Error (Str.position s, "unexpected end of stream")
+    | Some (_, s') -> `Ok ((), s', stat)
 
-  let position : Str.Pos.t t = fun st stat -> Ok (Str.position st, st, stat)
+  let position : Str.Pos.t t = fun st stat -> `Ok (Str.position st, st, stat)
 
-  let error s : 'a t = fun st _stat -> Error (Str.position st, s)
-  let throw err = fun _st _stat -> Error err
+  let error s : 'a t = fun st _stat -> `Error (Str.position st, s)
+  let throw err = fun _st _stat -> `Error err
 
   let critical_error pos s = raise (Critical_error (pos, s))
 
-  let stream : Str.t t = fun st stat -> Ok (st, st, stat)
+  let stream : Str.t t = fun st stat -> `Ok (st, st, stat)
 
   let eos : unit t = fun s stat -> 
     match Str.peek s with
-    | Some _ -> Error (Str.position s, "end of stream expected")
-    | None -> Ok ((), s, stat)
+    | Some _ -> `Error (Str.position s, "end of stream expected")
+    | None -> `Ok ((), s, stat)
 
   let (<?>) : 'a t -> string -> 'a t = fun c mes st stat ->
     let res = c st stat in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> Error (pos, "expected " ^ mes)
+    | `Ok _ -> res
+    | `Error (pos, _) -> `Error (pos, "expected " ^ mes)
 
   let (<?!>) : 'a t -> string -> 'a t = fun c mes st stat ->
     let res = c st stat in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> Error (pos, mes)
+    | `Ok _ -> res
+    | `Error (pos, _) -> `Error (pos, mes)
 
   let (<?@>) : 'a t -> Str.Pos.t -> 'a t = fun c pos st stat ->
     let res = c st stat in
     match res with
-    | Ok _ -> res
-    | Error (_, mes) -> Error (pos, mes)
+    | `Ok _ -> res
+    | `Error (_, mes) -> `Error (pos, mes)
 
   (* [take] advances the stream. If we use [take] and some predicate to check the result,
      the error position must be fixed as the one at the use of [take]. *)
     position >>= fun pos ->
     take >>= fun elem ->
     match p elem with
-    | Ok v -> return v
-    | Error err -> error err <?@> pos
+    | `Ok v -> return v
+    | `Error err -> error err <?@> pos
 
   let token : Str.Elem.t -> unit t = fun tkn ->
     void (tokenp (fun x -> Str.Elem.equal tkn x)) <?>  Str.Elem.show tkn
   
   let option : 'a t -> 'a option t = fun com s stat ->
     match com s stat with
-    | Error _ -> Ok (None, s, stat)
-    | Ok (v, s', stat') -> Ok (Some v, s', stat')
+    | `Error _ -> `Ok (None, s, stat)
+    | `Ok (v, s', stat') -> `Ok (Some v, s', stat')
 
   let option_ : unit t -> unit t = fun com s stat ->
     match com s stat with
-    | Error _ -> Ok ((), s, stat)
-    | (Ok _ as v) -> v
+    | `Error _ -> `Ok ((), s, stat)
+    | (`Ok _ as v) -> v
 
   let result : 'a t -> ('a, error) Result.t t = fun c st stat ->
     match c st stat with
-    | Ok (res, st, stat) -> Ok (Ok res, st, stat)
-    | Error e -> Ok (Error e, st, stat)
+    | `Ok (res, st, stat) -> `Ok (`Ok res, st, stat)
+    | `Error e -> `Ok (`Error e, st, stat)
 
   let try_finally : 'a t -> (('a, error) Result.t -> unit) -> 'a t = fun c f -> 
     result c >>= fun res ->
     f res;
     match res with
-    | Ok v -> return v
-    | Error err -> fun _st _stat -> Error err
+    | `Ok v -> return v
+    | `Error err -> fun _st _stat -> `Error err
 
   let ( ?** ) : 'a t -> 'a list t = fun com ->
     let rec aux st = fun s stat ->
       match com s stat with
-      | Error _ -> Ok (List.rev st, s, stat)
-      | Ok (v, s', stat') -> aux (v :: st) s' stat'
+      | `Error _ -> `Ok (List.rev st, s, stat)
+      | `Ok (v, s', stat') -> aux (v :: st) s' stat'
     in
     aux []
   
   let ( ?* ) : 'a t -> unit t = fun com ->
     let rec aux = fun s stat ->
       match com s stat with
-      | Error _ -> Ok ((), s, stat)
-      | Ok (_v, s', stat') -> aux  s' stat'
+      | `Error _ -> `Ok ((), s, stat)
+      | `Ok (_v, s', stat') -> aux  s' stat'
     in
     aux
   
   
   let critical : 'a t -> 'a t = fun t st stat ->
     match t st stat with
-    | (Ok _ as res) -> res
-    | Error (pos, s) -> raise (Critical_error (pos, s))
+    | (`Ok _ as res) -> res
+    | `Error (pos, s) -> raise (Critical_error (pos, s))
 
   let (<|>) : 'a t -> 'a t -> 'a t = fun c1 c2 st stat -> 
     let pos0 = Str.position st in
     let res = c1 st stat in
     match res with
-    | Ok _ -> res
-    | Error (pos, _) -> if pos = pos0 then c2 st stat else res
+    | `Ok _ -> res
+    | `Error (pos, _) -> if pos = pos0 then c2 st stat else res
 
   (* CR jfuruse: _ is used in a different meaning than option_ *)
   let try_ : 'a t -> 'a t = fun c st stat ->
     let pos0 = Str.position st in
     let res = c st stat in
     match res with
-    | Ok _ -> res
-    | Error (_, err) -> Error (pos0, err)
+    | `Ok _ -> res
+    | `Error (_, err) -> `Error (pos0, err)
 
   let (<!>) : 'a t -> 'a t -> 'a t = fun c1 c2 st stat -> 
     match c1 st stat with
-    | (Ok _ as res) -> 
+    | (`Ok _ as res) -> 
         res
-    | Error (_pos', _) -> 
+    | `Error (_pos', _) -> 
         c2 st stat
 
   let (<!<) : 'a t -> 'a t -> 'a t = fun c1 c2 st stat ->
     let res1 = c1 st stat in
     match res1 with
-    | Ok _ -> 
+    | `Ok _ -> 
         res1
-    | Error (_pos', _) ->
+    | `Error (_pos', _) ->
         let res2 = c2 st stat in
         match res2 with
-        | Ok _ -> 
+        | `Ok _ -> 
             res2
-        | Error (_pos'', _) -> 
+        | `Error (_pos'', _) -> 
             res1
 
   let eos_as_none : 'a t -> 'a option t = fun t ->
   let (<&>) : 'a t -> ('a -> 'b t) -> 'b t = fun c1 c2 -> 
     fun st stat ->
       match c1 st stat with
-      | Ok (v, _, stat') -> c2 v st stat'
-      | (Error _ as res) -> res
+      | `Ok (v, _, stat') -> c2 v st stat'
+      | (`Error _ as res) -> res
 
 
   let rec (/**/) : 'a list t -> 'a list t -> 'a list t = fun c1 c2 ->
       | None -> return None
       | Some _ -> c2 >>= fun v -> return (Some v)
 
-  let set_stream new_st = fun _st state -> Ok ((), new_st, state)
+  let set_stream new_st = fun _st state -> `Ok ((), new_st, state)
 
   let run _t = failwith "use run_with_state"
   let run_with_state : 'a t -> Str.t -> State.t -> ('a * Str.t * State.t, error) Result.t = 
 
   (** state manipulation *)
 
-  let get : State.t t = fun t st -> Ok (st, t, st)
-  let put : State.t -> unit t = fun st -> fun t _ -> Ok ((), t, st)
+  let get : State.t t = fun t st -> `Ok (st, t, st)
+  let put : State.t -> unit t = fun st -> fun t _ -> `Ok ((), t, st)
 end

File lib/result.ml

-open Spotlib.Spot
-
-type ('a, 'error) t =
-  | Ok of 'a
-  | Error of 'error
-with sexp
-
-include Monad.Make2(struct
-  type ('a, 'error) _t = ('a, 'error) t (* stupid way of avoiding default rec of type *)
-  type ('a, 'error) t = ('a, 'error) _t
-  let return v = Ok v
-  let bind v f = match v with
-    | Ok v -> f v
-    | Error e -> Error e
-end)
-let fail e = Error e
-
-
-

File lib/result.mli

-(** Result monad: Haskell's Either but with ``Right'' names. *)
-
-open Spotlib.Spot
-
-type ('a, 'error) t = 
-  | Ok of 'a
-  | Error of 'error
-with sexp
-
-include Monad_intf.T2 with type ('a, 'error) t := ('a, 'error) t
-
-val fail : 'error -> ('a, 'error) t

File lib/smemo.ml

         try Hashtbl.find m id with
         | Not_found ->
             let res = 
-              try Ok (Obj.repr (f str)) with
-              | exn -> Error exn
+              try `Ok (Obj.repr (f str)) with
+              | exn -> `Error exn
             in
             Hashtbl.replace m id res;
             res
       in
       match res with
-      | Ok res -> Obj.obj res
-      | Error exn -> raise exn
+      | `Ok res -> Obj.obj res
+      | `Error exn -> raise exn
   end
 
 end

File lib/stoken.ml

    With memoization.
 *)
 
+module Result = Spotlib.Spot.Result
+
 module type S = sig
 
   module Under : Planck_intf.S
   let create (m : ('a option * Pos.t) P.t) = fun st ->
     let rec f last_pos st = lazy begin
       match P.run m st with
-      | Result.Ok ((None, pos), _st') -> 
+      | `Ok ((None, pos), _st') -> 
           null_desc { Attr.last_position = last_pos; 
                       position      = pos; 
                       memo          = Smemo.create () } (* EOS case *)
-      | Result.Ok ((Some v, pos), st') -> 
+      | `Ok ((Some v, pos), st') -> 
           cons_desc v { Attr.last_position = last_pos;
                         position = pos;
                         memo = Smemo.create () } (f (Some pos) st')
-      | Result.Error (pos, s) -> raise (P.Critical_error (pos, s))
+      | `Error (pos, s) -> raise (P.Critical_error (pos, s))
     end
     in
     f None st

File lib/stoken.mli

 (** Create a stream from a result of a parser *)
 
+open Spotlib.Spot
+
 module type S = sig
 
   module Under : Planck_intf.S

File opam/planck.1.0.1/descr

+A small monadic parser combinator library
+Parser LANguage Combinator Kit A LL(n) parser monadic combinator
+library in OCaml. It includes a big example of lexer+parser for OCaml
+syntax.

File opam/planck.1.0.1/url

+archive: "https://bitbucket.org/camlspotter/planck/get/1.0.1.tar.gz"

File opam/planck.2.1.0/opam

 remove: [
   ["ocaml" "setup.ml" "-uninstall"]
 ]
-depends: ["ocamlfind" "sexplib" {>= "108.07.00"} "spotlib" {>= "2.0.1"} "omake"]
-ocaml-version: [>= "4.00.0"]
+depends: ["ocamlfind" "sexplib" {>= "108.07.00"} "spotlib" {>= "2.1.2"} "omake"]
+ocaml-version: [>= "4.00.1"]

File opam/template/opam

-depends: ["ocamlfind" "sexplib" {>= "108.07.00"} "spotlib" {>= "2.0.0"} "omake"]
-ocaml-version: [>= "4.00.0"]
+depends: ["ocamlfind" "sexplib" {>= "108.07.00"} "spotlib" {>= "2.1.2"} "omake"]
+ocaml-version: [>= "4.00.1"]
 (* setup.ml generated for the first time by OASIS v0.2.0 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 52b2fe44d6660d86da4efdf3589896db) *)
+(* DO NOT EDIT (digest: 2c0f869218627758587a72d3bad59f41) *)
 (*
    Regenerated by OASIS v0.3.0
    Visit http://oasis.forge.ocamlcore.org for more information and
    documentation about functions used in this file.
 *)
 module OASISGettext = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISGettext.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISGettext.ml"
 
   let ns_ str =
     str
 end
 
 module OASISContext = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISContext.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISContext.ml"
 
   open OASISGettext
 
 end
 
 module OASISString = struct
-# 1 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISString.ml"
+# 1 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISString.ml"
 
 
 
 end
 
 module OASISUtils = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISUtils.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISUtils.ml"
 
   open OASISGettext
 
 end
 
 module PropList = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml"
 
   open OASISGettext
 
     let clear t =
       Hashtbl.clear t
 
-# 71 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml"
+# 71 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml"
   end
 
   module Schema =
 end
 
 module OASISMessage = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISMessage.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISMessage.ml"
 
 
   open OASISGettext
 end
 
 module OASISVersion = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISVersion.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISVersion.ml"
 
   open OASISGettext
 
 end
 
 module OASISLicense = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISLicense.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISLicense.ml"
 
   (** License for _oasis fields
       @author Sylvain Le Gall
 end
 
 module OASISExpr = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExpr.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISExpr.ml"
 
 
 
 end
 
 module OASISTypes = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml"
 
 
 
 
   type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list
 
-# 102 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml"
+# 102 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml"
 
   type 'a conditional = 'a OASISExpr.choices 
 
 end
 
 module OASISUnixPath = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISUnixPath.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISUnixPath.ml"
 
   type unix_filename = string
   type unix_dirname = string
 end
 
 module OASISHostPath = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISHostPath.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISHostPath.ml"
 
 
   open Filename
 end
 
 module OASISSection = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISSection.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISSection.ml"
 
   open OASISTypes
 
 end
 
 module OASISBuildSection = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISBuildSection.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISBuildSection.ml"
 
 end
 
 module OASISExecutable = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExecutable.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISExecutable.ml"
 
   open OASISTypes
 
 end
 
 module OASISLibrary = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISLibrary.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISLibrary.ml"
 
   open OASISTypes
   open OASISUtils
 end
 
 module OASISFlag = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISFlag.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISFlag.ml"
 
 end
 
 module OASISPackage = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISPackage.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISPackage.ml"
 
 end
 
 module OASISSourceRepository = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISSourceRepository.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISSourceRepository.ml"
 
 end
 
 module OASISTest = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTest.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISTest.ml"
 
 end
 
 module OASISDocument = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISDocument.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISDocument.ml"
 
 end
 
 module OASISExec = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExec.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISExec.ml"
 
   open OASISGettext
   open OASISUtils
 end
 
 module OASISFileUtil = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISFileUtil.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/oasis/OASISFileUtil.ml"
 
   open OASISGettext
 
 
 # 2142 "setup.ml"
 module BaseEnvLight = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseEnvLight.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseEnvLight.ml"
 
   module MapString = Map.Make(String)
 
 
 # 2240 "setup.ml"
 module BaseContext = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseContext.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseContext.ml"
 
   open OASISContext
 
 end
 
 module BaseMessage = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseMessage.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseMessage.ml"
 
   (** Message to user, overrid for Base
       @author Sylvain Le Gall
 end
 
 module BaseEnv = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseEnv.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseEnv.ml"
 
   open OASISGettext
   open OASISUtils
 end
 
 module BaseArgExt = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseArgExt.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseArgExt.ml"
 
   open OASISUtils
   open OASISGettext
 end
 
 module BaseCheck = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseCheck.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseCheck.ml"
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseOCamlcConfig = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseOCamlcConfig.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseOCamlcConfig.ml"
 
 
   open BaseEnv
 end
 
 module BaseStandardVar = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseStandardVar.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseStandardVar.ml"
 
 
   open OASISGettext
 end
 
 module BaseFileAB = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseFileAB.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseFileAB.ml"
 
   open BaseEnv
   open OASISGettext
 end
 
 module BaseLog = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseLog.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseLog.ml"
 
   open OASISUtils
 
 end
 
 module BaseBuilt = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseBuilt.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseBuilt.ml"
 
   open OASISTypes
   open OASISGettext
 end
 
 module BaseCustom = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseCustom.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseCustom.ml"
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseDynVar = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseDynVar.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseDynVar.ml"
 
 
   open OASISTypes
 end
 
 module BaseTest = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseTest.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseTest.ml"
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseDoc = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseDoc.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseDoc.ml"
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseSetup = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseSetup.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/base/BaseSetup.ml"
 
   open BaseEnv
   open BaseMessage
 
 # 4480 "setup.ml"
 module InternalConfigurePlugin = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalConfigurePlugin.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalConfigurePlugin.ml"
 
   (** Configure using internal scheme
       @author Sylvain Le Gall
 end
 
 module InternalInstallPlugin = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalInstallPlugin.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalInstallPlugin.ml"
 
   (** Install using internal scheme
       @author Sylvain Le Gall
 
 # 5233 "setup.ml"
 module CustomPlugin = struct
-# 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/custom/CustomPlugin.ml"
+# 21 "/somewhere/.opam/system/build/oasis.0.3.0/src/plugins/custom/CustomPlugin.ml"
 
   (** Generate custom configure/build/doc/test/install system
       @author
                         "omake"
                      ]))
               ];
-            cmd_clean = [(OASISExpr.EBool true, None)];
+            cmd_clean =
+              [
+                 (OASISExpr.EBool true,
+                   Some (("PREFIX=$prefix", ["omake"; "clean"])))
+              ];
             cmd_distclean = [(OASISExpr.EBool true, None)];
             };
      test = [];
                            "omake"
                         ]))
                  ];
-               cmd_clean = [(OASISExpr.EBool true, None)];
+               cmd_clean =
+                 [
+                    (OASISExpr.EBool true,
+                      Some (("PREFIX=$prefix", ["omake"; "clean"])))
+                 ];
                cmd_distclean = [(OASISExpr.EBool true, None)];
                };
           CustomPlugin.clean
                            "omake"
                         ]))
                  ];
-               cmd_clean = [(OASISExpr.EBool true, None)];
+               cmd_clean =
+                 [
+                    (OASISExpr.EBool true,
+                      Some (("PREFIX=$prefix", ["omake"; "clean"])))
+                 ];
                cmd_distclean = [(OASISExpr.EBool true, None)];
                };
           CustomPlugin.distclean
           ocaml_version = None;
           findlib_version = None;
           name = "planck";
-          version = "2.0.2";
+          version = "2.1.0";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
           };
      oasis_fn = Some "_oasis";
      oasis_version = "0.3.0";
-     oasis_digest = Some "\030h\n-\225\210\147\012\149\203\022\217@K\255\025";
+     oasis_digest =
+       Some "\215\0186\189\180\016\197\234\196\131\226J\253\026\002\178";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false;
 
 let setup () = BaseSetup.setup setup_t;;
 
-# 5577 "setup.ml"
+# 5590 "setup.ml"
 (* OASIS_STOP *)
 let () = setup ();;

File test/expr.ml

   Format.eprintf "input=%S@." s;
   let stream = Stream.from_string ~filename:"stdin" s in
   match expr stream with
-  | Result.Ok (res, _) -> 
+  | `Ok (res, _) -> 
       (* Check whether the original and parsed are identical *)
       (* Check of computed values are done outside of this program. See OMakefile. *)
       Format.eprintf "%s@." (Tree.show res);
       let n = Tree.eval res in
       Format.printf "assert (%s = %d);;@." s n;
 
-  | Result.Error (pos, s) ->
+  | `Error (pos, s) ->
       Format.eprintf "%a: syntax error: %s@." Position.File.format pos s;
       raise Exit