Version française
Home     About     Download     Resources     Contact us    
Browse thread
How can I generate an AST?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Massimiliano Brocchini <brocchini@n...>
Subject: Re: [Caml-list] How can I generate an AST?
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
>