Commits

camlspotter  committed 66d1a5f

merged from p4hack

  • Participants
  • Parent commits 4a2a99b

Comments (0)

Files changed (9)

     sexplib
     spotlib
 
-OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax
-OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax
-# OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax -ppopt pa_bind_inline/pa_bind_inline.cmo
-# OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax -ppopt pa_bind_inline/pa_bind_inline.cmo
+%.out.ml: %.ml pa_bind_inline/pa_bind_inline.cmo
+	camlp4o -printer OCaml pa_bind_inline/pa_bind_inline.cmo $< > $@
+
+OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax -ppopt pa_bind_inline/pa_bind_inline.cmo
+OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax -ppopt pa_bind_inline/pa_bind_inline.cmo
 
 # OCamlGeneratedFiles(parser.ml lexer.ml)
 
 
 Subdirs()
 # Subdirs_except(ocaml) # If you are not interested in ocaml parser example
+
+# This must be after Subdirs(), so that it does not affect the build of pa_build_inline
+.SCANNER: scan-ocaml-%: pa_bind_inline/pa_bind_inline.cmo
+
 open Stream_intf
 
+(* CR jfuruse: stdlib's Hashtbl access is by compare_val. Too slow! *)
 (* CR jfuruse: Evil ugly. Need to be fixed. Just exists since it is indispensable for efficiency *)
 type memo = (Obj.t (* key... :-) *), [`Done of Obj.t | `Exn of exn]) Hashtbl.t
 (* It's evil but type-safe!, AFA key string is unique for each function. *)

File ocaml/OMakefile

     sexplib
 
 # camlp4o ../pa_monad_custom/pa_monad.cmo ../pa_bind_inline/pa_bind_inline.cmo lex.ml
-%.out.ml: %.ml ../pa_monad_custom/pa_monad.cmo ../pa_bind_inline/pa_bind_inline.cmo
-	camlp4o -printer OCaml ../pa_monad_custom/pa_monad.cmo ../planck/pa_bind_inline/pa_bind_inline.cmo $< > $@
+%.out.ml: %.ml ../../pa_monad_custom/pa_monad.cmo ../pa_bind_inline/pa_bind_inline.cmo
+	camlp4o -printer OCaml ../../pa_monad_custom/pa_monad.cmo ../pa_bind_inline/pa_bind_inline.cmo $< > $@
 
-OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax,monad
-OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax,monad
+OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax,monad -ppopt ../pa_bind_inline/pa_bind_inline.cmo
+OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax,monad -ppopt ../pa_bind_inline/pa_bind_inline.cmo
+# OCAMLDEPFLAGS= -syntax camlp4o -package sexplib.syntax,monad
+# OCAMLPPFLAGS= -syntax camlp4o -package sexplib.syntax,monad
 
 FILES[] = 
    ../planck

File ocaml/plphelper.ml

       in
       fold [] (!rhs_counter - 1)
 
-(*
-let case (name : string) (t : (unit -> 'a) Token.Parser.t) : ('a * Planck.Position.Region.t) Token.Parser.t = fun st -> 
-  Profile.incr ();
-  if !do_debug then prerr_endline (String.make (!level*2) ' ' ^ "-> " ^ name);
-  let st_start = if !do_debug then Some st else None in (* Make [st] GCed as early as possible *) 
-
-  incr level;
-
-  let t = perform
-    last_pos <-- last_position; (* bad for nonleftrec... *)
-    f <-- t;
-    let poses = get_poses () in
-    (* action require symbol_rloc_ref is set *)
-    let symbol_rloc = calc_symbol_rloc last_pos poses in 
-    \ symbol_rloc_ref := symbol_rloc;
-    return (f (), 
-            calc_rhs_loc last_pos poses)
-  in
-
-  (result t >>= fun res ->
-   
-   decr level;
-
-   match res with
-   | Result.Ok (_, rhs_loc as v) -> 
-       if !do_debug then begin perform
-         st' <-- stream;
-         \ begin match st_start with
-         | None -> assert false
-         | Some st -> 
-             let elts = List.map fst (Token.Stream.between st st') in
-             Format.eprintf "%s<- %s : %s@."
-               (String.make (!level*2) ' ') 
-               name 
-               (Sexplib.Sexp.to_string_hum (Sexplib.Conv.sexp_of_list Token.sexp_of_t elts));
-             Format.eprintf "%s   symbol_rloc: %a@."
-               (String.make (!level*2) ' ') 
-              Planck.Position.Region.format !symbol_rloc_ref;
-             Format.eprintf "%s   rhs_loc:     %a@."
-               (String.make (!level*2) ' ') 
-               Planck.Position.Region.format rhs_loc;
-             match !rhs_tbl_stack with
-             | [] -> assert false
-             | (rhs_counter, rhs_tbl, _) :: _ ->
-                 for i = 1 to !rhs_counter-1 do
-                   Format.eprintf "%s   %d : %a@."
-                     (String.make (!level*2) ' ') 
-                     i
-                     Planck.Position.Region.format 
-                     (try Hashtbl.find rhs_tbl i with Not_found -> Position.Region.none);
-                 done;
-                 Format.eprintf "%s   END@." (String.make (!level*2) ' ') 
-         end;
-         return v
-       end else return v
-
-  | Result.Error err ->
-      if !do_debug then prerr_endline (String.make (!level*2) ' ' ^ "X- " ^ name);
-      throw err
-
-  ) st
-*)
 let case (name : string) (t : (unit -> 'a) Token.Parser.t) : ('a * Planck.Position.Region.t) Token.Parser.t = fun st -> 
   Profile.incr ();
   if !do_debug then prerr_endline (String.make (!level*2) ' ' ^ "-> " ^ name);