This text is extracted from the file camlp4/Camlp4Parsers/Camlp4MacroParser.ml of OCaml 3.12.0 release. Only copyright and useful comments are kept. (****************************************************************************) (* *) (* Objective Caml *) (* *) (* INRIA Rocquencourt *) (* *) (* Copyright 2006 Institut National de Recherche en Informatique et *) (* en Automatique. All rights reserved. This file is distributed under *) (* the terms of the GNU Library General Public License, with the special *) (* exception on linking described in LICENSE at the top of the Objective *) (* Caml source tree. *) (* *) (****************************************************************************) (* Authors: * - Daniel de Rauglaudre: initial version * - Nicolas Pouillard: refactoring * - Aleksey Nogin: extra features and bug fixes. * - Christopher Conway: extra feature (-D=) * - Jean-vincent Loddo: definitions inside IFs. *) (* Added statements: At toplevel (structure item): DEFINE DEFINE = DEFINE () = IFDEF THEN [ ELSE ] (END | ENDIF) IFNDEF THEN [ ELSE ] (END | ENDIF) INCLUDE At toplevel (signature item): DEFINE IFDEF THEN [ ELSE ] (END | ENDIF) IFNDEF THEN [ ELSE ] (END | ENDIF) INCLUDE In expressions: IFDEF THEN [ ELSE ] (END | ENDIF) IFNDEF THEN [ ELSE ] (END | ENDIF) DEFINE = IN __FILE__ __LOCATION__ In patterns: IFDEF THEN ELSE (END | ENDIF) IFNDEF THEN ELSE (END | ENDIF) As Camlp4 options: -D or -D=expr define with optional value -U undefine it -I add to the search path for INCLUDE'd files After having used a DEFINE followed by "= ", 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. You can also define a local macro in an expression usigng the DEFINE ... IN form. Note that local macros have lowercase names and can not take parameters. If a macro is defined to = NOTHING, and then used as an argument to a function, this will be equivalent to function taking one less argument. Similarly, passing NOTHING as an argument to a macro is equivalent to "erasing" the corresponding parameter from the macro body. The toplevel statement INCLUDE can be used to include a file containing macro definitions and also any other 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. *)