Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 pa_macro
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin_jambon@e...>
Subject: Re: [Caml-list] camlp4 pa_macro (doc request)
On Tue, 6 Sep 2005, Dmitry Bely wrote:

> Another question: is there an up-to-date Camlp4
> manual with all standard extensions (like pa_macro) properly documented?

I copy-pasted what the source file says. 
I guess I could setup a web page with examples. Of course, it would be 
better if it were included in the official documentation.

Thanks,

Martin


>From camlp4/meta/pa_macro.ml:
(*
Added statements:

   At toplevel (structure item):

      DEFINE <uident>
      DEFINE <uident> = <expression>
      DEFINE <uident> (<parameters>) = <expression>
      IFDEF <uident> THEN <structure_items> (END | ENDIF)
      IFDEF <uident> THEN <structure_items> ELSE <structure_items> (END | ENDIF)
      IFNDEF <uident> THEN <structure_items> (END | ENDIF)
      IFNDEF <uident> THEN <structure_items> ELSE <structure_items> (END | ENDIF)
      INCLUDE <string>

   In expressions:

      IFDEF <uident> THEN <expression> ELSE <expression> (END | ENDIF)
      IFNDEF <uident> THEN <expression> ELSE <expression> (END | ENDIF)
      __FILE__
      __LOCATION__

   In patterns:

      IFDEF <uident> THEN <pattern> ELSE <pattern> (END | ENDIF)
      IFNDEF <uident> THEN <pattern> ELSE <pattern> (END | ENDIF)

   As Camlp4 options:

      -D<uident>                      define <uident>
      -U<uident>                      undefine it
      -I<dir>                         add <dir> to the search path for INCLUDE'd
files

   After having used a DEFINE <uident> followed by "= <expression>", you
   can use it in expressions *and* in patterns. If the expression defining
   the macro cannot be used as a pattern, there is an error message if
   it is used in a pattern.



   The toplevel statement INCLUDE <string> can be used to include a
   file containing macro definitions; note that files included in such
   a way can not have any non-macro toplevel items.  The included files
   are looked up in directories passed in via the -I option, falling
   back to the current directory.

   The expression __FILE__ returns the current compiled file name.
   The expression __LOCATION__ returns the current location of itself.

*)