caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Jean-Baptiste Jeannin <jeannin@cs.cornell.edu>
Cc: caml-list@inria.fr, Laurie Goffinon <lag267@cornell.edu>,
	Dexter Kozen <kozen@cs.cornell.edu>
Subject: Re: [Caml-list] Camlp4 with different backend
Date: Thu, 31 Mar 2011 21:58:08 +0200	[thread overview]
Message-ID: <20110331195807.GV10930@localhost> (raw)
In-Reply-To: <4D94A84F.9010108@cs.cornell.edu>

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


  reply	other threads:[~2011-03-31 19:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 16:14 Jean-Baptiste Jeannin
2011-03-31 19:58 ` Guillaume Yziquel [this message]
2011-03-31 21:44 ` Gabriel Scherer

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=20110331195807.GV10930@localhost \
    --to=guillaume.yziquel@citycable.ch \
    --cc=caml-list@inria.fr \
    --cc=jeannin@cs.cornell.edu \
    --cc=kozen@cs.cornell.edu \
    --cc=lag267@cornell.edu \
    /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).