Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Good examples for a Camlp4 beginner?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile STARYNKEVITCH <basile@s...>
Subject: [Caml-list] Good examples for a Camlp4 beginner?
>>>>> "Matt" == Matt Gushee <mgushee@havenrock.com> writes:

    Matt> Hello, all-- Over the past couple of weeks I have been
    Matt> learning about the various OCaml parsing and lexing tools,
    Matt> with an emphasis on Camlp4. It's fascinating, and I've
    Matt> learned a lot, but I am still having trouble grasping how
    Matt> the different components fit together. I think what I need
    Matt> now is to look at some examples of working, real-world code
    Matt> that use Camlp4 ... something non-trivial, but not
    Matt> enormously complex. Can anyone suggest a good place to
    Matt> start?

Yes, you might look into the tracing facilities of Poesia monitor;

get the following files (under CVS) from
http://www2.poesia-filter.org:8000/cgi-bin/cvsweb.cgi/PoesiaSoft/PoesiaMonIcap/

README.trace
pa_trace.ml

trace.ml
trace.mli

In a few words, the pa_trace.ml preprocessing file transform
expressions like
   trace FOO "x=%d y=%d" x y tracend
into
  begin
    if Trace.flags.foo then
        Trace.tracer Trace.FOO  [filename]  [lineno]  [colno]
          (Printf.sprintf "x=%d y=%d" x y
  end

where [filename] is actually the string of the source filename, eg
"foobar.ml", [lineno] is the line number, eg 43, etc.

Even if I coded some camlp4 stuff, I definitely do not claim to be a
camlp4 expert. In particular, I never coded any pretty printer.

Of course you could have a look into the Coq proof system, which
(IIRC) initated the development of camlp4 and which is probably the
major camlp4 user.

Regards.
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners