Version française
Home     About     Download     Resources     Contact us    
Browse thread
New camlp4 and q_MLast
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joel Reymont <joelr1@g...>
Subject: Re: [Caml-list] New camlp4 and q_MLast

On Apr 1, 2007, at 5:56 PM, Nicolas Pouillard wrote:

> Not gone just renamed (by some very descriptive long name).
>
> Generally one now should use camlp4*f commands (f for full)

I'm trying to translate this command line:

$(OCAMLC) -c -I +camlp4 -pp '$(CAMLP4O) q_MLast.cmo -loc loc' $<

I guess I'll have to go through all the recent camlp4 threads since I  
need to translate the following bits:

(* Build basic ASTs *)

let str_ast a = <:expr< $str:a$ >> ;;

let tuple_ast (a,b) = <:expr< ($a$,$b$) >> ;;

let str_tuple_ast (a,b) = <:expr< ($str:a$,$str:b$) >> ;;

let list_ast el =
         List.fold_right (fun x l -> <:expr< [$x$ :: $l$] >>) el  
<:expr< [] >>
;;

(* Translate TAL expression to method-send expression AST *)

let rec translate_expression ?(base=None) s =
         let extend_base x = match base with
                 | Some (e,var) -> (<:expr< $e$#$x$ >>,var)
                 | None -> (<:expr< $lid:x$ >>, x)

let xml_element_ast e attr children =
         <:expr< Xml.Element ($str:e$, $attr$, $children$) >>
;;

let exp = list_ast exps in
                         <:expr< List.flatten $exp$ >>

let tagast = xml_element_ast e vattrs <:expr< subtags_octalvar__
 >> in
                 let taglistast = list_ast [ tagast ] in
                 (<:expr<
                         let subtags_octalvar__ = $childrenast$ in
                         if $exp$ then subtags_octalvar__ else  
$taglistast$
                 >>,nvars,true)

                 let repexp = <:expr< List.map (fun $lid:itemname$ ->  
$sub$) $exp
$ >> in
                 if sublist then
                         (<:expr< List.flatten $repexp$ >>,fvars,true)

etc.

This all part of the Octal package. Any help will be appreciated! :D

	Thanks, Joel


--
http://wagerlabs.com/