From: Raphael Proust <raphlalou@gmail.com>
To: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] [Camlp4] Quotation expander with OCaml syntax
Date: Mon, 26 Jul 2010 17:41:58 +0200 [thread overview]
Message-ID: <AANLkTimuFz7A=QbNu7jvdvjFxHpY_1W0_tbeVyt-B21Y@mail.gmail.com> (raw)
In-Reply-To: <4c4da611.e8e9d80a.53b5.5b50@mx.google.com>
On Mon, Jul 26, 2010 at 5:13 PM, Nicolas Pouillard
<nicolas.pouillard@gmail.com> wrote:
> On Mon, 26 Jul 2010 16:41:46 +0200, Raphael Proust <raphlalou@gmail.com> wrote:
> > Hi all,
> Hi,
>
> > [...]
> >
> > (* Pre-parsed code: *)
> > let start = <:on< f $y$ >> in
> > let html_node =
> > span ~a:[onclick start] "some text" (* a is used for (html) attributes *)
> >
> > (* Server side post-parsed code: *)
> > let start _arg1 =
> > "call_closure(some_unique_name," ^ mymarshall _arg1 ")"
> > in
> > let html_node = span ~a:[onclick (start y)] "some text"
> >
> > (* Client side post-parsed code: *)
> > let _ = register_closure some_unique_name (fun _arg1 -> f _arg1)
> >
> >
> > I'm unsure of what is the standard way of doing such a thing in Camlp4. What
> > I
> > have in mind is to use the original Ocaml syntax for the quotation expander.
> > This would (IIUC) allow me to filter the AST to transform every
> > antiquotation
> > found inside the quotation itself.
> >
> > [...]
>
> If the <:on<...>> contents is valid OCaml syntax I would suggest you to not go
> in the quotations direction. You will avoid a ton of syntactic issues.
>
> What I suggest you is to directly use camlp4 filters, for instance by changing
> the meaning of some constructor application and labels for antiquotations:
>
> (* Pre-parsed code: *)
> let start = On (f ~y) in
> let html_node =
> span ~a:[onclick start] "some text" (* a is used for (html) attributes *)
I'd rather not use a constructor because it imposes a strong limitation on the
user (it basically reserves a keyword) whereas the <:on< ... >> solution does
not (<:smthg< ... >> is already "reserved").
And labeling antiquotations is far from ideal since it prevents complex
expressions from being inlined. You basically need to write:
let y = h a in
let z = g x z in
On (f ~y ~z)
instead of:
<:on< f $h a$ $g x z$ >>
What I basically need is to get an AST with antiquotations and quotations being
special nodes. How is this achievable w/o reimplementing a whole grammar?
The alternative solution is to use raw strings, to find antiquotation marks, to
split the string and to reinject it in the different files. Is there a way to
keep precise _loc information this way?
--
_______
Raphael
next prev parent reply other threads:[~2010-07-26 15:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTikuoN4H0Hsx74JwW66J9jmtq+usDxtQPpYfSGbd@mail.gmail.com>
2010-07-26 14:41 ` Raphael Proust
2010-07-26 15:13 ` [Caml-list] " Nicolas Pouillard
2010-07-26 15:41 ` Joel Reymont
2010-07-26 16:05 ` Jake Donham
2010-07-26 15:41 ` Raphael Proust [this message]
2010-07-26 16:27 ` Nicolas Pouillard
2010-07-26 16:30 ` Jake Donham
2010-07-27 7:57 ` Raphael Proust
2010-07-26 20:08 ` bluestorm
2010-07-26 20:53 ` Raphael Proust
2010-07-27 13:22 ` Thomas.Gazagnaire
2010-07-27 14:38 ` Raphael Proust
2010-07-27 14:47 ` Vincent Balat
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='AANLkTimuFz7A=QbNu7jvdvjFxHpY_1W0_tbeVyt-B21Y@mail.gmail.com' \
--to=raphlalou@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=nicolas.pouillard@gmail.com \
/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