<?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="2009/01/0544a2b442f586defaedfcb8e169a9bf"
  from="David Allsopp &lt;dra-news@m...&gt;"
  author="David Allsopp"
  date="2009-01-06T15:12:45"
  subject="RE: [Caml-list] Parsing simple type expressions"
  prev="2009/01/aeedbe479141062a21fdf4ba4e50bd05"
  next="2009/01/f0e465fbb5618b70e907c5ce74cd79b9"
  prev-in-thread="2009/01/aeedbe479141062a21fdf4ba4e50bd05"
  next-in-thread="2009/01/b4e7d9b110b958e610c0cb09494a3d94"
  prev-thread="2009/01/6383f62ce2839d25bfa9517ddbb5e894"
  next-thread="2009/01/f5cd2134e6e753541b1fba3d79d51b18"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Parsing simple type expressions">
<msg 
  url="2009/01/aeedbe479141062a21fdf4ba4e50bd05"
  from="Paolo Donadeo &lt;p.donadeo@g...&gt;"
  author="Paolo Donadeo"
  date="2009-01-06T14:03:52"
  subject="Parsing simple type expressions">
<msg 
  url="2009/01/0544a2b442f586defaedfcb8e169a9bf"
  from="David Allsopp &lt;dra-news@m...&gt;"
  author="David Allsopp"
  date="2009-01-06T15:12:45"
  subject="RE: [Caml-list] Parsing simple type expressions">
<msg 
  url="2009/01/b4e7d9b110b958e610c0cb09494a3d94"
  from="Martin Jambon &lt;martin.jambon@e...&gt;"
  author="Martin Jambon"
  date="2009-01-06T21:11:19"
  subject="Re: [Caml-list] Parsing simple type expressions">
<msg 
  url="2009/01/01da1667c2c6fe8937d5f2a798c9816e"
  from="Matthieu Wipliez &lt;mwipliez@y...&gt;"
  author="Matthieu Wipliez"
  date="2009-01-06T22:50:10"
  subject="Re : [Caml-list] Parsing simple type expressions">
<msg 
  url="2009/01/a6043389411300c6b287bdae00efbe5d"
  from="Paolo Donadeo &lt;p.donadeo@g...&gt;"
  author="Paolo Donadeo"
  date="2009-01-07T22:50:46"
  subject="Re: [Caml-list] Parsing simple type expressions">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/01/f0e465fbb5618b70e907c5ce74cd79b9"
  from="Jake Donham &lt;jake@d...&gt;"
  author="Jake Donham"
  date="2009-01-06T18:19:02"
  subject="Re: [Caml-list] Parsing simple type expressions">
<msg 
  url="2009/01/e5076f52f057f4aad5ae55a4d1fa82fd"
  from="Paolo Donadeo &lt;p.donadeo@g...&gt;"
  author="Paolo Donadeo"
  date="2009-01-06T21:00:14"
  subject="Re: [Caml-list] Parsing simple type expressions">
</msg>
</msg>
</msg>
</thread>

<contents>
ocamlyacc - you can get most of it for free out of parsing/parser.mly in the OCaml sources... the section on type expressions starts at line 1144 for OCaml 3.11.0.


David

&gt; -----Original Message-----
&gt; From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-
&gt; bounces@yquem.inria.fr] On Behalf Of Paolo Donadeo
&gt; Sent: 06 January 2009 14:04
&gt; To: OCaml mailing list
&gt; Subject: [Caml-list] Parsing simple type expressions
&gt; 
&gt; For a serializer I'm writing I need to parse simple OCaml type
&gt; expressions composed by OCaml basic types, tuples, options and lists.
&gt; Given a string like "(int * string option) list" and this type:
&gt; 
&gt; type types =
&gt;   | Int
&gt;   | String
&gt;   | Float
&gt;   | Char
&gt;   | Bool
&gt;   | Option of types
&gt;   | List of types
&gt;   | Tuple of types list
&gt; 
&gt; the function I need should return something like List (Tuple ([Int;
&gt; Option(String)]))
&gt; 
&gt; Before starting with low level sscanf functions I looked at the Genlex
&gt; module, but it wasn't so inspiring. Then I tried with Camlp4 but the
&gt; documentation doesn't really shine :-)
&gt; 
&gt; So is there a simple way to write this function using some standard
&gt; module?
&gt; 
&gt; TIA,
&gt; 
&gt; 
&gt; --
&gt; Paolo
&gt; ~
&gt; ~
&gt; :wq
&gt; 
&gt; _______________________________________________
&gt; Caml-list mailing list. Subscription management:
&gt; http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
&gt; Archives: http://caml.inria.fr
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs

</contents>

</message>

