caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Which camlp variant?
  2007-11-07 18:25 Which camlp variant? tmp123
@ 2007-11-07 18:20 ` Martin Jambon
  2007-11-08  0:24 ` Nicolas Pouillard
  2007-11-08  0:48 ` Christopher L Conway
  2 siblings, 0 replies; 5+ messages in thread
From: Martin Jambon @ 2007-11-07 18:20 UTC (permalink / raw)
  To: tmp123; +Cc: caml-list

On Wed, 7 Nov 2007, tmp123 wrote:

> 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?

sed?

:-)


Martin

--
http://wink.com/profile/mjambon
http://martin.jambon.free.fr


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Which camlp variant?
@ 2007-11-07 18:25 tmp123
  2007-11-07 18:20 ` [Caml-list] " Martin Jambon
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: tmp123 @ 2007-11-07 18:25 UTC (permalink / raw)
  To: caml-list

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?

Thanks a lot.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Which camlp variant?
  2007-11-07 18:25 Which camlp variant? tmp123
  2007-11-07 18:20 ` [Caml-list] " Martin Jambon
@ 2007-11-08  0:24 ` Nicolas Pouillard
  2007-11-08  0:48 ` Christopher L Conway
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2007-11-08  0:24 UTC (permalink / raw)
  To: tmp123; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Which camlp variant?
  2007-11-07 18:25 Which camlp variant? tmp123
  2007-11-07 18:20 ` [Caml-list] " Martin Jambon
  2007-11-08  0:24 ` Nicolas Pouillard
@ 2007-11-08  0:48 ` Christopher L Conway
       [not found]   ` <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com>
  2 siblings, 1 reply; 5+ messages in thread
From: Christopher L Conway @ 2007-11-08  0:48 UTC (permalink / raw)
  To: tmp123; +Cc: caml-list

pa_log is compatible with camlp5. In fact, that's what I use. Just
s/4/5/ all commands invoking camlp4.

Regards
Chris

On Nov 7, 2007 1:25 PM, tmp123 <tmp123@menta.net> wrote:
> 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?
>
> Thanks a lot.
>
> _______________________________________________
> 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
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Which camlp variant?
       [not found]   ` <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com>
@ 2007-11-09 11:34     ` tmp123
  0 siblings, 0 replies; 5+ messages in thread
From: tmp123 @ 2007-11-09 11:34 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 2345 bytes --]

Thanks a lot,

The solution from Chris covers all the requirements. A reduced 
subvariant of its "pa_log", compatible with camlp4 and adapted to this 
development has been written (probably with some errors ;-)

open Camlp4.PreCast;
open Syntax;

(* Apply a function to a list of arguments *)
value app_to_list lst _loc =
  List.fold_left
    (fun f x -> <:expr< $f$ $x$ >>)
    <:expr< Tools.log_printf >> lst;

EXTEND Gram

  expr: LEVEL "apply"
  [ [ LIDENT "log"; e = LIST0 expr LEVEL "." ->
        <:expr< Tools.log_internal ( fun () -> $app_to_list e _loc$ ) >>
       
  ] ]
;
END;


It needs the support of a module "Tools" with two functions 
"log_internal" and "log_printf". By example:

value log_active = ref False;

value log_printf = Printf.printf;

value log_internal e =
  if log_active.val then
  (
    e();
    print_newline();
    flush stdout;
  )
  else ();


The syntax in the callers is:

log "something is %d" 12;

Thanks to all persons who has colaborate in this subject.

-------------------------------------

Christopher L Conway wrote:

>This may not have been true of the version that was on the website
>previously. I've just updated it to my latest version, which does
>indeed work with camlp5.
>
>Chris
>
>On Nov 7, 2007 7:48 PM, Christopher L Conway <cconway@cs.nyu.edu> wrote:
>  
>
>>pa_log is compatible with camlp5. In fact, that's what I use. Just
>>s/4/5/ all commands invoking camlp4.
>>
>>Regards
>>Chris
>>
>>
>>On Nov 7, 2007 1:25 PM, tmp123 <tmp123@menta.net> wrote:
>>    
>>
>>>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?
>>>
>>>Thanks a lot.
>>>
>>>_______________________________________________
>>>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
>>>
>>>
>>>      
>>>
>
>  
>


[-- Attachment #2: Type: text/html, Size: 3693 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-09 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-07 18:25 Which camlp variant? tmp123
2007-11-07 18:20 ` [Caml-list] " Martin Jambon
2007-11-08  0:24 ` Nicolas Pouillard
2007-11-08  0:48 ` Christopher L Conway
     [not found]   ` <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com>
2007-11-09 11:34     ` tmp123

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).