Commits

camlspotter  committed e63bee3

use of planck zlist

  • Participants
  • Parent commits c4779f8
  • Branches dev

Comments (0)

Files changed (2)

+open Spotlib.Spot
+
 open Pos
 open Reader
 module Parser = Xparser
 open Parser
 open Planck.Lazylist
 
-type info = {
-  token        : Parser.token;
-  region       : Region.t;
-  substr       : string;
-  space        : Region.t * string;
-}
+module Elem = struct
+  type t = Parser.token
+  let show = Sexplib.Sexp.to_string_hum @@ Parser.sexp_of_token
+  let format ppf= Sexplib.Sexp.pp_hum ppf @@ Parser.sexp_of_token
+  let equal = (=)
+  let compare = compare
+end
 
-type t = (info, unit) zlist * in_channel
+module Attr = struct
+  type t = {
+    region       : Region.t;
+    substr       : string;
+    space        : Region.t * string;
+  }
+end
+
+type t = (token, attr) zlist * in_channel
 
 let stream = fst
 let close (_, ic) = close_in ic
     in
     let space_between_region = (snd last_region, fst region) in
 
-    Cons ({ token; region; substr; space = space_between_region, space_between }, (),
-          match token with
-          | EOF -> null ()
-          | _ -> lazy (loop region))
+    let attr = { region; substr; space = space_between_region, space_between } in
+    match token with
+    | EOF -> null_desc attr
+    | _ -> cons_desc token attr (lazy (loop region))
   in
   lazy (loop Region.zero), ic
 

File tokenstr.mli

 open Planck.Lazylist
 open Pos
 
-type info = {
-  token  : Parser.token;     (** parsed token *)
+type token = Parser.token     (** parsed token *)
+type attr = {
   region : Region.t;         (** the position of the token *)
   substr : string;           (** the actual string for the token *)
   space  : Region.t * string (** space before the token *)
 
 type t
 
-val stream : t -> (info, unit) zlist
+val stream : t -> (token, attr) zlist (* EOF is in info *)
 val close : t -> unit
 val of_channel : in_channel -> t
 val of_path : string -> t