From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id A94C2BC69 for ; Mon, 20 Aug 2007 15:29:27 +0200 (CEST) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.186]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7KDTPm4006178 for ; Mon, 20 Aug 2007 15:29:26 +0200 Received: by rv-out-0910.google.com with SMTP id k20so1004218rvb for ; Mon, 20 Aug 2007 06:29:25 -0700 (PDT) Received: by 10.114.15.1 with SMTP id 1mr1798938wao.1187616564681; Mon, 20 Aug 2007 06:29:24 -0700 (PDT) Received: by 10.64.150.4 with HTTP; Mon, 20 Aug 2007 06:29:24 -0700 (PDT) Message-ID: <89aa9c440708200629y50797475h521bad4e530e0b43@mail.gmail.com> Date: Mon, 20 Aug 2007 15:29:24 +0200 From: "Massimiliano Brocchini" To: "Loup Vaillant" Subject: Re: [Caml-list] How can I generate an AST? Cc: "Caml mailing list" In-Reply-To: <6f9f8f4a0708200624x1b09dc40u2d5fa76b4a70faf7@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_103204_24472466.1187616564519" References: <6f9f8f4a0708191039o2119f94bm10959175cc887eef@mail.gmail.com> <20070819181634.GA797@yquem.inria.fr> <6f9f8f4a0708200122k710b2f3dnd723a7244140575e@mail.gmail.com> <20070820111350.GA22843@yquem.inria.fr> <6f9f8f4a0708200624x1b09dc40u2d5fa76b4a70faf7@mail.gmail.com> X-Miltered: at discorde with ID 46C99735.005 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; rauglaudre:01 rauglaudre:01 0200,:01 camlp:01 camlp:01 ocaml:01 syntax:01 ocaml:01 parser:01 syntax:01 parser:01 mli:01 compiler:01 utils:01 impl:01 ------=_Part_103204_24472466.1187616564519 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Debian or Archlinux you have the "ocaml-compiler-libs" package which contains what you need. Massimiliano Brocchini On 8/20/07, Loup Vaillant wrote: > > 2007/8/20, Daniel de Rauglaudre : > > On Mon, Aug 20, 2007 at 10:22:17AM +0200, Loup Vaillant wrote: > > > > > This may be a better approach. However, I am not eager to use camlp*, > > > for it will introduce a additional dependency. I may choose this > > > however, if the camlp* AST is simpler than the Ocaml AST. Where can I > > > find it? > > > > Solution using camlp5: > > [...] > > But, well, you need to know camlp5, understand the quotation system, > > perhaps the revised syntax too, in one word, read the doc, and I can > > understand that if you did not use camlp5 before, it is some work... > > Indeed. I didn't work with camlp* before, so the learning curve may be > a problem, I don't know. > > > Other solution not using camlp*: > > > > Read the ocaml sources, file "parsing/parser.mly" to understand how > > the ocaml syntax tree works. Program your parser to generate this > > syntax tree. > > I have already read "parsing/parstree.mli", so I assume half the work > is done! (well, I hope so, for I don't know .mly files...) > > > Once done, to give your syntax tree directly to the > > ocaml compiler, output: > > > > 1/ the magic number you can find in ocaml sources at utils/config.ml > > - ast_impl_magic_number for an implementation > > ast_intf_magic_number for an interface > > 2/ your input file name > > 3/ your syntax tree in binary with "output_value" > > That, is what I need. Thank you. I'll notify the list once I managed > to produce some output. > > I have still one problem, though : how should I access this code? It > is not part of the standard library, so I can't just "open Config;;". > I can't hard-copy this code, either, that is too ugly. Maybe there is > a way to install a "development package" of Ocaml so I can link it? > > Thanks, > Loup > > _______________________________________________ > 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 > ------=_Part_103204_24472466.1187616564519 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Debian or Archlinux you have the "ocaml-compiler-libs" package which contains what you need.

Massimiliano Brocchini

On 8/20/07, Loup Vaillant <loup.vaillant@gmail.com> wrote:
2007/8/20, Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>:
> On Mon, Aug 20, 2007 at 10:22:17AM +0200, Loup Vaillant wrote:
>
> > This may be a better approach. However, I am not eager to use camlp*,
> > for it will introduce a additional dependency. I may choose this
> > however, if the camlp* AST is simpler than the Ocaml AST. Where can I
> > find it?
>
> Solution using camlp5:
> [...]
>  But, well, you need to know camlp5, understand the quotation system,
>  perhaps the revised syntax too, in one word, read the doc, and I can
>  understand that if you did not use camlp5 before, it is some work...

Indeed. I didn't work with camlp* before, so the learning curve may be
a problem, I don't know.

> Other solution not using camlp*:
>
>  Read the ocaml sources, file "parsing/parser.mly" to understand how
>  the ocaml syntax tree works. Program your parser to generate this
>  syntax tree.

I have already read "parsing/parstree.mli", so I assume half the work
is done! (well, I hope so, for I don't know .mly files...)

> Once done, to give your syntax tree directly to the
>  ocaml compiler, output:
>
>  1/ the magic number you can find in ocaml sources at utils/config.ml
>       - ast_impl_magic_number for an implementation
>         ast_intf_magic_number for an interface
>  2/ your input file name
>  3/ your syntax tree in binary with "output_value"

That, is what I need. Thank you. I'll notify the list once I managed
to produce some output.

I have still one problem, though : how should I access this code? It
is not part of the standard library, so I can't just "open Config;;".
I can't hard-copy this code, either, that is too ugly. Maybe there is
a way to install a "development package" of Ocaml so I can link it?

Thanks,
Loup

_______________________________________________
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

------=_Part_103204_24472466.1187616564519--