caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-announce] new OcamlMakefile with preprocessing support
@ 2001-09-05 13:54 Markus Mottl
  0 siblings, 0 replies; only message in thread
From: Markus Mottl @ 2001-09-05 13:54 UTC (permalink / raw)
  To: caml-announce

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-09-06  9:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-05 13:54 [Caml-announce] new OcamlMakefile with preprocessing support Markus Mottl

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).