Browse thread
Parsing simple type expressions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Martin Jambon <martin.jambon@e...> |
| Subject: | Re: [Caml-list] Parsing simple type expressions |
David Allsopp wrote: > 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. Our json-wheel library is a complete example: http://martin.jambon.free.fr/json-wheel.html Martin >> -----Original Message----- >> From: caml-list-bounces@yquem.inria.fr [mailto:caml-list- >> bounces@yquem.inria.fr] On Behalf Of Paolo Donadeo >> Sent: 06 January 2009 14:04 >> To: OCaml mailing list >> Subject: [Caml-list] Parsing simple type expressions >> >> For a serializer I'm writing I need to parse simple OCaml type >> expressions composed by OCaml basic types, tuples, options and lists. >> Given a string like "(int * string option) list" and this type: >> >> type types = >> | Int >> | String >> | Float >> | Char >> | Bool >> | Option of types >> | List of types >> | Tuple of types list >> >> the function I need should return something like List (Tuple ([Int; >> Option(String)])) >> >> Before starting with low level sscanf functions I looked at the Genlex >> module, but it wasn't so inspiring. Then I tried with Camlp4 but the >> documentation doesn't really shine :-) >> >> So is there a simple way to write this function using some standard >> module? >> >> TIA, >> >> >> -- >> Paolo >> ~ >> ~ >> :wq -- http://mjambon.com/