* Caml typed AST @ 2010-06-08 21:29 Martin Potier [not found] ` <940CD13B-5569-4B4C-9616-7AE9132EC114@gmail.com> 0 siblings, 1 reply; 3+ messages in thread From: Martin Potier @ 2010-06-08 21:29 UTC (permalink / raw) To: caml-list Dear List, I have a school research assignment about defunctionalization. I'd like to implement a defunctionalization algorithm for Caml, using Caml, that's why I'd like to know if there is a way to retrieve a typped AST from Caml. I had a look at the option -dparsetree of the Caml interpreter, but it doesn't fit my need for two reasons : first it's not typped, and second it's not easily reusable. In a way, I just want to "plug in" right after the typing of the Caml AST in order to reuse it. Does anyone know the Caml source well enough to point me to a place where a function uses a typped AST ? -- Martin Potier ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <940CD13B-5569-4B4C-9616-7AE9132EC114@gmail.com>]
* Re: [Caml-list] Caml typed AST [not found] ` <940CD13B-5569-4B4C-9616-7AE9132EC114@gmail.com> @ 2010-06-28 14:03 ` Martin Potier 2010-06-28 14:25 ` bluestorm 0 siblings, 1 reply; 3+ messages in thread From: Martin Potier @ 2010-06-28 14:03 UTC (permalink / raw) To: caml-list Thank you for your answer. I still have no clue how to use it, or even pretty-print from that AST. Is there a simple way to do so ? Is there a documentation on using basic caml elements, like building an AST from a string of ocaml code, typing, type-checking, transforming and prettyprinting from this AST ? -- Martin Le 09/06/2010 00:46, Ruslan Ledesma Garza a écrit : > Hello Martin, > > Looking at toploop.ml in 3.11.1, a line reads: > > let (str, sg, newenv) = Typemod.type_structure oldenv sstr Location.none > > I believe str contains the AST you are looking for. > > Best regards, > Ruslan. > > On Jun 8, 2010, at 11:29 PM, Martin Potier wrote: > >> Dear List, >> >> I have a school research assignment about defunctionalization. >> >> I'd like to implement a defunctionalization algorithm for Caml, using >> Caml, that's why I'd like to know if there is a way to retrieve a typped >> AST from Caml. >> >> I had a look at the option -dparsetree of the Caml interpreter, but it >> doesn't fit my need for two reasons : first it's not typped, and second >> it's not easily reusable. >> >> In a way, I just want to "plug in" right after the typing of the Caml >> AST in order to reuse it. >> >> Does anyone know the Caml source well enough to point me to a place >> where a function uses a typped AST ? >> >> -- >> Martin Potier >> >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Caml typed AST 2010-06-28 14:03 ` [Caml-list] " Martin Potier @ 2010-06-28 14:25 ` bluestorm 0 siblings, 0 replies; 3+ messages in thread From: bluestorm @ 2010-06-28 14:25 UTC (permalink / raw) To: martin.potier; +Cc: caml-list [-- Attachment #1: Type: text/plain, Size: 709 bytes --] The OCaml typedtree (post-typing AST) is rather intricate and contains details about the type inference process that you might not want to have to know about. If you don't need the full width of the OCaml language features, I would recommend starting from a smaller codebase. Rewriting a parser for a subset of the OCaml language is easy, type inference difficulty depends on the features you have in your language, but there are numerous smaller projects you could reuse. See for example [MinCaml], a minimalistic compiler for teaching purpose, or the [poly] language from the Programming Language Zoo. [MinCaml] http://min-caml.sourceforge.net/index-e.html [poly] http://andrej.com/plzoo/html/poly.html [-- Attachment #2: Type: text/html, Size: 1036 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-28 14:26 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-06-08 21:29 Caml typed AST Martin Potier [not found] ` <940CD13B-5569-4B4C-9616-7AE9132EC114@gmail.com> 2010-06-28 14:03 ` [Caml-list] " Martin Potier 2010-06-28 14:25 ` bluestorm
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox