From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id DE1577F84F for ; Mon, 24 Feb 2014 18:55:26 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of andy.ray@ujamjar.com) identity=pra; client-ip=31.172.243.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andy.ray@ujamjar.com"; x-sender="andy.ray@ujamjar.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of andy.ray@ujamjar.com) identity=mailfrom; client-ip=31.172.243.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andy.ray@ujamjar.com"; x-sender="andy.ray@ujamjar.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@www.ujamjar.com) identity=helo; client-ip=31.172.243.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andy.ray@ujamjar.com"; x-sender="postmaster@www.ujamjar.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsYEAJSGC1MfrPMC/2dsb2JhbABZg0FXwQCBFB50giUBAQQBJ1IQCws7IhIBBQEcBogQCAQJmTysNRMEjmQHhDgEmDSKUYVpGCmBLIMt X-IPAS-Result: AsYEAJSGC1MfrPMC/2dsb2JhbABZg0FXwQCBFB50giUBAQQBJ1IQCws7IhIBBQEcBogQCAQJmTysNRMEjmQHhDgEmDSKUYVpGCmBLIMt X-IronPort-AV: E=Sophos;i="4.97,535,1389740400"; d="scan'208";a="60053345" Received: from vm12460.vps.tagadab.com (HELO www.ujamjar.com) ([31.172.243.2]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 24 Feb 2014 18:55:26 +0100 Received: from mail-qc0-f176.google.com (mail-qc0-f176.google.com [209.85.216.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by www.ujamjar.com (Postfix) with ESMTPSA id 755781243BA for ; Mon, 24 Feb 2014 17:55:12 +0000 (GMT) Received: by mail-qc0-f176.google.com with SMTP id r5so4702008qcx.35 for ; Mon, 24 Feb 2014 09:55:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=CEL13mJhzdcvFyKRBo8yHU8WdivHMkCUPvfnsnKBChY=; b=iu0GM1LEnteepNiP+CECTW5dkAJYC04ttPjIKlBT+A3mSmp34EaWYfeRlwQkIGdmRb aD52AEexu/3AFcu6bZ5gKTE4WWhrQH4Mx+/NifXOzmDo/alNVg3ESF8IzENQuL3C8PAu 3XEJDfMTJe5MS9HgpMITfqEnfhAVV1+fQbbuXP2nqfou2T/xvOLppFv2y3+kI6R26DH3 NZTPAh5GdFGY+cu97UEa0KtELsj6CB+VyZrkS0a15DGjMiXuiWSW1nrAXyM5WjMcHAkT a9sDcDOYcO/tWTtAnNJyhuJ7auDqypasyDiTz9A187f88aw+YMJ+bJxTybEkDB6vN3Mc 5ZZA== MIME-Version: 1.0 X-Received: by 10.224.11.196 with SMTP id u4mr32277369qau.4.1393264504015; Mon, 24 Feb 2014 09:55:04 -0800 (PST) Received: by 10.140.24.166 with HTTP; Mon, 24 Feb 2014 09:55:03 -0800 (PST) In-Reply-To: References: Date: Mon, 24 Feb 2014 17:55:03 +0000 Message-ID: From: Andy Ray To: Ocaml Mailing List Cc: Leo White , Anil Madhavapeddy Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] camlp4 for js_of_ocaml toplevels >> 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