List Info

Thread: "ocaml_beginners"::[] Extending lists with camlp4




"ocaml_beginners"::[] Extending lists with camlp4
user name
2006-05-25 21:54:38
Martin wrote:
>
> I think it might work if camlp4 is able to guess which
rule to follow in 
> case of a conflict by looking only at the next *token*
at the position 
> where the conflict occurs. Since an expr (even in level
"simple") may be 
> made of an infinite sequence of tokens, the parser will
make a decision 
> or another, without warning you.

Indeed, as you suggest later, if I do:

EXTEND
  expr: LEVEL "simple" [ [ "[";
"+"; e1 = expr; "for"; p1 = patt;
"in"; e2 = expr; "if"; e3 = expr;
"]" ->
        <:expr< List.map (fun $p1$ -> $e1$)
(List.filter (fun $p1$ -> $e3$) $e2$) >> ] ];
END;;

then it works as expected.

It doesn't seem trivial to me to create an oracle to
differenciate both cases, as you basically have to rewrite a
parser for expr but without consuming the stream tokens (or
am I missing something?).

Thanks a lot for your reply and for your tutorial! It has
been extremelly useful!

Cheers,





------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Everything you need is one click away.  Make Yahoo! your
home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 


"ocaml_beginners"::[] Extending lists with camlp4
user name
2006-05-25 22:40:56
On Thu, 25 May 2006, Joaquin Cuenca Abela wrote:

> Martin wrote:
>>
>> I think it might work if camlp4 is able to guess
which rule to follow in
>> case of a conflict by looking only at the next
*token* at the position
>> where the conflict occurs. Since an expr (even in
level "simple") may be
>> made of an infinite sequence of tokens, the parser
will make a decision
>> or another, without warning you.
>
> Indeed, as you suggest later, if I do:
>
> EXTEND
>  expr: LEVEL "simple" [ [ "[";
"+"; e1 = expr; "for"; p1 = patt;
"in"; e2 = expr; "if"; e3 = expr;
"]" ->
>        <:expr< List.map (fun $p1$ -> $e1$)
(List.filter (fun $p1$ -> $e3$) $e2$) >> ] ];
> END;;
>
> then it works as expected.
>
> It doesn't seem trivial to me to create an oracle to
differenciate both cases, as you basically have to rewrite a
parser for expr but without consuming the stream tokens (or
am I missing something?).

Yes, it's really a do-it-yourself approach as described by
Hendrik Tews:
   http://wwwtcs.inf.tu-dresden.de/~tews/ocamlp4/cam
lp4-undoc.html
   or google for camlp4 undocumented


> Thanks a lot for your reply and for your tutorial! It
has been extremelly useful!

Thanks


Martin

--
Martin Jambon, PhD
http://martin.jambon.fre
e.fr

Edit http://wikiomics.org,
bioinformatics wiki


------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Everything you need is one click away.  Make Yahoo! your
home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )