<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/87d5f328c77313794e409877b61422fb"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-08T02:31:37"
  subject="Re: [Caml-list] type problem with camlp4"
  prev="2003/01/203d53f5ef719129cb2f7f8b230e4574"
  next="2003/01/09b5be7521e7f17f067191e491e4a57a"
  prev-in-thread="2003/01/676a8e37ee6228f5e1705ee7a8ffabb0"
  prev-thread="2003/01/43e79a58009853705b48ca36fcab5c69"
  next-thread="2003/01/8fb51787be19c5a51bde1b15e3640728"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] type problem with camlp4">
<msg 
  url="2003/01/ffa553f7b474e1e0d8832df3cc727cf6"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-01-07T03:59:05"
  subject="[Caml-list] type problem with camlp4">
<msg 
  url="2003/01/7fee1b5b613aa3d71ce448d60403241e"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-07T12:39:49"
  subject="Re: [Caml-list] type problem with camlp4">
<msg 
  url="2003/01/676a8e37ee6228f5e1705ee7a8ffabb0"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-01-07T22:36:50"
  subject="Re: [Caml-list] type problem with camlp4">
<msg 
  url="2003/01/87d5f328c77313794e409877b61422fb"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-08T02:31:37"
  subject="Re: [Caml-list] type problem with camlp4">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

On Wed, Jan 08, 2003 at 09:34:55AM +1100, Pietro Abate wrote:

&gt; 	[[ n = STRING -&gt;
&gt; 		let node = magic_function ( parse_string n ) in
&gt; 		let id = gen_id() in
&gt; 		(&lt;:patt&lt;$lid:id$&gt;&gt;,&lt;:expr&lt;$node$&gt;&gt;)
&gt; 	]];
&gt; 
&gt; who can I do that ? what is the magic function ?

let node = Grammar.Entry.parse Pcaml.expr (Stream.of_string n) in

You may need to enclose that with a good "try..with" in case of syntax
error in your string, because the error location raised would be relative
to it, and would highlight a wrong position. Moreover, the resulting
tree should be also re-located in case of semantic error for the
same reason.

Actually, it should be like the handling of quotations, but with that
above function as expander. But the code doing that in Camlp4 is in
several parts and may not be so easy to extract if you don't know the
internal code of Camlp4. I can do it if you want and possibly add a
new function in Camlp4 (module Pcaml) for that kind of usage.

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
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

</contents>

</message>

