Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] autoconf and caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: pa_ifdef [Was: Re: [Caml-list] autoconf and caml]
Hi,

On Fri, Sep 06, 2002 at 02:31:17PM +0200, Stefano Zacchiroli wrote:

> BTW, last time I used it I was a bit annoyed because you can "ifdef"
> only on type declaration or single "let" bindings IIRC while if you are
> using such a tool you usually expect to be able to "ifdef" on a whole
> block of code in a C-like fashion.
> 
> I don't know if such an extension to the pa_ifdef module is feasible
> with camlp4 ...

Yes, it is possible. In pa_ifdef.ml, there is a call to the grammar
entry Pcaml.str_item:
      | si = Pcaml.str_item -> SdStr si

If you want it to work in "normal" syntax, just change the rule into:
      | sil = LIST1 Pcaml.str_item ->
          SdStr
            (match sil with
             [ [x] -> x
             | _ -> <:str_item< declare $list:sil$ end >> ])

If you prefer the "revised syntax", the syntax rule must be:
      | sil = LIST1 [ x = Pcaml.str_item; ";" -> x ] ->

I did not implement it in pa_ifdef.ml because of this difference
between "normal" and "revised" syntax.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners