From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "Hugo Ferreira" <hmf@inescporto.pt>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] camlp4: processing lists
Date: Tue, 20 Mar 2007 11:54:11 +0100 [thread overview]
Message-ID: <cd67f63a0703200354l354085ccy1604948031487288@mail.gmail.com> (raw)
In-Reply-To: <45FFB71B.3080002@inescporto.pt>
On 3/20/07, Hugo Ferreira <hmf@inescporto.pt> wrote:
> Hello,
>
> I have sent this post to the new ocaml-developer list but am resending
> it here in the hopes that someone can help me. I have come across a
> weirdness in camlp4. Maybe someone can explain this puzzle to me.
>
> I have the following extension:
>
> let expand_term_list loc l =
> let nl = <:expr< [] >> in
> let nl = List.fold_right (fun h t ->
> <:expr< [$h$::$t$] >>
> ) l nl in
> <:expr<
> do {
> List.iter (fun i -> print_endline i) $nl$
> }
> >>
>
> EXTEND
> Pcaml.expr: [
> [
> "|" ; "[" ; l = LIST0 Pcaml.expr SEP ";" ; "]" ; "|"->
Pcaml.expr is too greedy here. Since 1; 2 is a valid ocaml expression.
You need to choose another level ("expr1" in your case and "top" in 3.10).
> "|" ; "[" ; l = LIST0 Pcaml.expr LEVEL "expr1" SEP ";" ; "]" ; "|"->
> expand_term_list loc l ] ];
> END;;
>
[...]
>
> let t1 =
> do {
> print_string "Not implemented for list ";
Here you reached a bug (fixed for 3.10)
> List.iter (fun i -> print_endline i)
> [do { "1"; "f(X,Y)"; "g(X,Y)"; "4" }]
> }
> in
> ()
>
> which ... to say the least is *not* what I expected. I initially I
> though I had but one Pcaml.expr and not a list of those. What seems
> to be happening is that the revised syntax is used to generate the
> code and this is wrong.
The in revised 1; 2 is not a valid expression you need to add do { ...
} thus by printing it in the revised syntax you see that was not what
you want.
BTW it was a bug in camlp4 to print [1; 2] where it was [(1; 2)].
Hope this helps,
--
Nicolas Pouillard
next prev parent reply other threads:[~2007-03-20 10:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-20 10:27 Hugo Ferreira
2007-03-20 10:54 ` Nicolas Pouillard [this message]
2007-03-20 11:14 ` [Caml-list] " Hugo Ferreira
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=cd67f63a0703200354l354085ccy1604948031487288@mail.gmail.com \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=hmf@inescporto.pt \
/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).