Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] camlp4 question...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitry Lomov <dmitry.lomov@j...>
Subject: Re: [Caml-list] camlp4 question...
Pietro Abate wrote:

> Hi all,
> 
> I'd like to write a small extension to transform 
> 
> let f <a;b;c> = ...
> 
> in 
> 
> let f new_id =
> 	match new_id with
> 	|[a;b;c] -> ...
> 	|_ -> failwith "wrong arguments"
> 
> I've tried with something like:
>         expr: LEVEL "simple"
>         [[
>             "let"; OPT "rec"; "<"; l = LIST1 LIDENT; ">"; $list:pel$ "in" e = expr ->
>                 <:expr< let .... = function [] -> failwith "ffff" | $list:l$ -> $e$ >>
>         ]];
> 
> but I'm stuck... In particular, how can I parse $list:pel$ ?
> pel = LIST patt ?

Do check your syntax once again. $list:pel$ is an antiquotation, and not 
a parsing rule. As such, it cannot appear to the left of '->'.
The LHS should look about like that:

expr: LEVEL "let" (* sic! *)
[[ "let"; OPT "rec"; LIDENT; "<"; LIST patt; ">";"=";
      expr;"in" expr -> ....
]]

RHS should be quite straightforward (you should bind subparsing results, 
of course)

HTH,
Friendly,
Dmitry

-- 
Dmitry Lomov
JetBrains Inc.
http://www.jetbrains.com
"Develop With Pleasure!"

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners