This works very well. Thank you very much for the example.
On a related note, I was trying to understand how these new syntax
filters work, and I am a bit confused by how I'm supposed to use
Camlp4Tracer. I tried compiling a simple test program with:
camlp4 -parser ocaml -filter tracer -printer ocaml
It complained about an unknown value "Debug.mode", which I figured out
was in the Camlp4 library, so I added that library and the line:
module Debug = Camlp4.Debug
to my program. Then it complained about an unbound value "exc". I looked
at the Camlp4Tracer.ml to discover that it expects an exception named
"exc" to be in scope with every function. I'm not sure what this is for,
but I was able to get it to compile by creating a toplevel variable. My
test program looks like the following now:
(*pp camlp4 -parser ocaml -filter tracer -printer ocaml *)
module Debug = Camlp4.Debug
let exc = Not_found
let test () =
print_endline "this is output"
let () =
test ()
And my Makefile looks like this:
OCAMLMAKEFILE := OCamlMakefile
SOURCES := main.ml
USE_CAMLP4 := yes
PACKS := camlp4.lib
RESULT := main
include $(OCAMLMAKEFILE)
Now, I can get tracing output:
% CAMLP4_DEBUG=* ./main
camlp4-debug: tracer: Not_found at File "main.ml", line 8, characters 16-32
this is output
So, is this the way it's supposed to work? Is this exception supposed to
be some sort of marker for logging purposes? It seems like maybe the
Printexc stuff was accidentally pasted in from the
Camlp4ExceptionTracer, but without any docs, it's hard to tell for sure.
Dave
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs