caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* printing the AST of a caml function
@ 2009-03-22 16:24 Zorg 421
  2009-03-22 17:41 ` [Caml-list] " blue storm
  0 siblings, 1 reply; 2+ messages in thread
From: Zorg 421 @ 2009-03-22 16:24 UTC (permalink / raw)
  To: caml-list

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] printing the AST of a caml function
  2009-03-22 16:24 printing the AST of a caml function Zorg 421
@ 2009-03-22 17:41 ` blue storm
  0 siblings, 0 replies; 2+ messages in thread
From: blue storm @ 2009-03-22 17:41 UTC (permalink / raw)
  To: Zorg 421; +Cc: caml-list

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
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-22 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-22 16:24 printing the AST of a caml function Zorg 421
2009-03-22 17:41 ` [Caml-list] " blue storm

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).