Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-announce] new OcamlMakefile with preprocessing support
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@m...>
Subject: [Caml-announce] new OcamlMakefile with preprocessing support
Hello,

I have just released a new major version (3.00) of OcamlMakefile. The
most important new feature is support for automatic preprocessing.
But be aware that it requires OCaml-3.03, which has not yet been
released! The current CVS-version of OCaml already incorporates the
necessary change, i.e. a -pp flag for ocamldep. If you feel daring,
check out the CVS-version of OCaml, otherwise wait until the new version
is released (will probably not take too long, it seems).

You can get OcamlMakefile here:

  http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html

To quickly demonstrate its new capabilities, let's take a look at the
new example in the distribution, which implements the "repeat ... until"
construct as described in the camlp4-tutorial:

file: main.ml
---------------------------------------------------------------------------
(*pp camlp4o -I . repeat_syn.cmo *)

let _ =
  let i = ref 0 in
  repeat print_int !i; incr i until !i = 10;
  print_newline ()
---------------------------------------------------------------------------

The first line in the upper file tells OcamlMakefile how to run the
preprocessor.

file: repeat_syn.ml
---------------------------------------------------------------------------
(*pp camlp4o pa_extend.cmo q_MLast.cmo *)

open Pcaml;;

EXTEND
  expr: LEVEL "top"
    [[ "repeat"; e1 = expr; "until"; e2 = expr ->
      <:expr< do { $e1$; while not $e2$ do { $e1$; } } >> ]];
END
---------------------------------------------------------------------------

Here, too, we need the preprocessor to implement the new construct.

Finally, here is the Makefile (assuming that OcamlMakefile is visible to
"make"):

file: Makefile
---------------------------------------------------------------------------
SOURCES := main.ml
PRE_TARGETS := repeat_syn.cmi repeat_syn.cmo
USE_CAMLP4 := yes
RESULT := main

-include OcamlMakefile
---------------------------------------------------------------------------

Then just enter "make"...

All the other "make"-targets, e.g. for building native code libraries,
byte code with debug information, etc., all work as usual.

This seems to be about as simple as it can get. I hope this will make
the complexity of correctly applying camlp4 (or other preprocessors)
less of an obstacle to developers who want to learn implementing syntax
extensions.

Thanks to all people on the list who gave me advice on how to best
implement this feature into OcamlMakefile!

Have fun!

Best regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus