caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@mail4.ai.univie.ac.at>
To: caml-announce <caml-announce@inria.fr>
Subject: [Caml-announce] new OcamlMakefile with preprocessing support
Date: Wed, 5 Sep 2001 15:54:16 +0200	[thread overview]
Message-ID: <20010905155416.A22112@chopin.ai.univie.ac.at> (raw)

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


                 reply	other threads:[~2001-09-06  9:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010905155416.A22112@chopin.ai.univie.ac.at \
    --to=markus@mail4.ai.univie.ac.at \
    --cc=caml-announce@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).