caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andy Ray <andy.ray@ujamjar.com>
To: Ocaml Mailing List <caml-list@inria.fr>
Cc: Leo White <lpw25@cam.ac.uk>, Anil Madhavapeddy <anil@recoil.org>
Subject: Re: [Caml-list] camlp4 for js_of_ocaml toplevels
Date: Mon, 24 Feb 2014 17:55:03 +0000	[thread overview]
Message-ID: <CAHYOizGtocS17dt8FcEo9QmOCZvA=Kzoknekk7a4QvbhVgftFA@mail.gmail.com> (raw)
In-Reply-To: <C660DE35-30BE-4A9E-A6A8-17B449E25C83@recoil.org>

>> Is anyone working on making camlp4 extensions available in a
>> js_of_ocaml toplevel?
>>
>> I have seen the work the OCamlPro guys have done to get pa_js going by
>> hacking the compiler itself - serious kudos for that!
>>
>> Is there a reason why that's easier than js_of_ocaml compiling a
>> (static) version of camlp4?
>
> Leo White put together a custom compiler frontend for just this use
> case a while back:
>
> https://github.com/lpw25/ocaml-with-pp
>
> The idea is that you build this with a static set of camlp4 extensions,
> and it runs the input through camlp4 and then passes the AST directly
> through to the compiler (via compiler-libs).
>
> It should be reasonably easy to adapt this to a toplevel model
> as well -- let us know if you need a hand.


A good amount of hacking and I have some camlp4 code running via js_of_ocaml.

I basically took the compilation process of camlp4orf, added pa_js.cmo
and slightly modified the driver program so it took a static command
line of the form `-str "let a = b##c"`.  Also needed a bit of hacking
around temp file generation.

My next step is to try and figure out a way to get camlp4 to transform
"string -> string" rather than "hacked js_of_ocaml psuedo file ->
hacked console log in browser".  Can't say I ever really wanted to
know much about the insides of camlp4, but there you go....

One thing I noticed was when I (accidentally) had unix_isatty
returning false, and presumably camlp4 attempting to marshal a
compiler ast the js_of_ocaml runtime would die with a JSON error.  I
presume this is an issue with js_of_ocaml's marshalling code?

Cheers,
Andy

  reply	other threads:[~2014-02-24 17:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-22  3:07 Andy Ray
2014-02-23 20:18 ` Anil Madhavapeddy
2014-02-24 17:55   ` Andy Ray [this message]
2014-02-24 23:31     ` Anil Madhavapeddy
2014-02-27  8:34     ` Olivier Levillain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYOizGtocS17dt8FcEo9QmOCZvA=Kzoknekk7a4QvbhVgftFA@mail.gmail.com' \
    --to=andy.ray@ujamjar.com \
    --cc=anil@recoil.org \
    --cc=caml-list@inria.fr \
    --cc=lpw25@cam.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).