From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2VJxYBc030157 for ; Thu, 31 Mar 2011 21:59:34 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvgAAH3clE1V2gB5nGdsb2JhbAClagEBAQEBCAsJCRQlwEANhV4EkQCIcA X-IronPort-AV: E=Sophos;i="4.63,277,1299452400"; d="scan'208";a="91632503" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail4-smtp-sop.national.inria.fr with SMTP; 31 Mar 2011 21:59:29 +0200 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (unknown [85.218.93.111]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id 4D528834487; Thu, 31 Mar 2011 21:59:27 +0200 (CEST) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1Q5O0O-0002nn-4Q; Thu, 31 Mar 2011 21:58:08 +0200 Date: Thu, 31 Mar 2011 21:58:08 +0200 From: Guillaume Yziquel To: Jean-Baptiste Jeannin Cc: caml-list@inria.fr, Laurie Goffinon , Dexter Kozen Message-ID: <20110331195807.GV10930@localhost> References: <4D94A84F.9010108@cs.cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <4D94A84F.9010108@cs.cornell.edu> User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2VJxYBc030157 Subject: Re: [Caml-list] Camlp4 with different backend Le Thursday 31 Mar 2011 à 12:14:07 (-0400), Jean-Baptiste Jeannin a écrit : > Hello, > > We are trying to use camlp4 to replace the front-end (lexer / parser > up to building the Abstract Syntax Tree) of an experimental > interpreter for a language close to OCaml. However we would like to > keep our backend (the interpreter itself), as it behaves very > differently from a normal interpreter, and this behavior cannot be > translated into OCaml's code easily (or even at all). > > However it seems that using camlp4, we can only use OCaml's own > backend. In the camlp4 documentation, I could not find any way of > getting the abstract syntax tree to feed it to another interpreter. > Is this true or could camlp4 serve our purpose? > > Thank you, > > Jean-Baptiste Jeannin > CS department, Cornell University Not sure I fully understand, but if you want to take your own source code and generate an OCaml AST and then OCaml code, you can use printers. yziquel@seldon:~/git/ocaml/camlp4/Camlp4Printers$ ls Camlp4AstDumper.ml Camlp4NullDumper.ml Camlp4OCamlPrinter.ml Camlp4AutoPrinter.ml Camlp4OCamlAstDumper.ml Camlp4OCamlRevisedPrinter.ml Off the top of my head: Camlp4OCamlPrinter generates standard OCaml code. Camlp4OCamlOCamlRevisedPrinter generates OCaml code in the revised syntax. Camlp4OCamlAstDumper dumps the Ast in a not-so-readable format. Camlp4AutoPrinter behaves like Camlp4OCamlPrinter when the standard output is a tty, and as Camlp4OCamlAstDumper otherwise. It's the default if I'm not mistaken. That may help to replace OCaml's backend with your own interpreter. -- Guillaume Yziquel