Version française
Home     About     Download     Resources     Contact us    
Browse thread
printing the AST of a caml function
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: blue storm <bluestorm.dylc@g...>
Subject: Re: [Caml-list] printing the AST of a caml function
I'm not sure this is the cleanest way (i'd rather use something like
-nostdlib), but your two last "lexing.cmx" and "format.cmx" are
actually the same as the standard library modules. You can just remove
them both from your build script, and it will then works.

On 3/22/09, Zorg 421 <zorglub421@gmail.com> wrote:
> Hello,
>
> I want to play/understand the caml AST, so I try using this code snippet:
>
> ---
> let factstring = "let rec fact n = if n < 1 then 0 else n * fact (n-1)" in
> let tree = Parse.implementation (Lexing.from_string factstring) in
> Printast.implementation (Format.formatter_of_out_channel stdout) tree
> ---
>
> and this build script (~15 minutes spent in ordering correctly the .cmx :-/
> )
>
> ---
> #!/bin/sh
> ocamlopt -I /opt/godi/lib/ocaml/compiler-lib/ misc.cmx linenum.cmx
> warnings.cmx location.cmx lexer.cmx syntaxerr.cmx config.cmx
> clflags.cmx parser.cmx parse.cmx printast.cmx lexing.cmx format.cmx
> factast.ml -o factast
> ---
>
> But the linker is confused by the Lexing module of stdlib:
>
> Files /opt/godi/lib/ocaml/std-lib/lexing.cmx
> and /opt/godi/lib/ocaml/std-lib/stdlib.cmxa both define a module named
> Lexing
>
> How can I prevent the linker to look in /opt/godi/lib/ocaml/std-lib/
> or /opt/godi/lib/ocaml/std-lib/stdlib.cmxa ?
>
> regards.
>
> _______________________________________________
> 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
>