[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nicolas Pouillard <nicolas.pouillard@g...> |
| Subject: | Re: [Caml-list] Which camlp variant? |
Excerpts from tmp123's message of Wed Nov 07 19:25:59 +0100 2007: > Hello, > > The module "pa_log" proposed by Mr. Conway seems very near to the > objective of my previuos post. > > The objective now is expand a line like: DEBUG 3 "%d\n" 14 > to: if debug.val then logint 3 ( fun () -> Printf.printf "%d\" 14 ) > else (); > > However, it is necessary to migrate the module to new camlpx . > > Please, could someone give any advice about the current options: camlp4 > or camlp5? PreCast? Functorial? I would recommend camlp4+PreCast because it's easier. However camlp4 already have a builtin module very similar (called Camlp4DebugParser). Here is a brief introduction... (* * No debugging code at all: * $ camlp4o -parser Camlp4DebugParser debug_extension.ml * true * Debugging code for lexing: * $ STATIC_CAMLP4_DEBUG='lexing' camlp4o -parser Camlp4DebugParser debug_extension.ml * let () = * if Camlp4.Debug.mode "lexing" * then Debug.printf "lexing" "TOKEN: Int %d" (2 * 21) * else () * in true * * Debugging code for lexing and parsing: * $ STATIC_CAMLP4_DEBUG='lexing:parsing' camlp4o -parser Camlp4DebugParser debug_extension.ml * let () = * if Camlp4.Debug.mode "lexing" * then Debug.printf "lexing" "TOKEN: Int %d" (2 * 21) * else () in * let () = * if Camlp4.Debug.mode "parsing" * then Debug.printf "parsing" "RULE: ..." * else () * in true * * Debugging code for any section: * $ STATIC_CAMLP4_DEBUG='*' camlp4o -parser Camlp4DebugParser debug_extension.ml * ... same output as above ... * * When you program is compiled you can use the CAMLP4_DEBUG variable to * activate some debugging sections. * * CAMLP4_DEBUG_FILE manage where messages goes (default is stderr). *) camlp4_debug lexing "TOKEN: Int %d" (2 * 21) in camlp4_debug parsing "RULE: ..." in true -- Nicolas Pouillard aka Ertai