From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 9F41FBB84 for ; Tue, 6 Jan 2009 22:11:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnwBAO5XY0lCbwQak2dsb2JhbACUBQEBAQEJCQoJEQS7VoV0 X-IronPort-AV: E=Sophos;i="4.37,221,1231110000"; d="scan'208";a="33376858" Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Jan 2009 22:11:19 +0100 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id E8740201313; Tue, 6 Jan 2009 16:11:17 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 06 Jan 2009 16:11:17 -0500 X-Sasl-enc: zfof0onpTnXFPnuQ6qq3KzZfbkvTHI3GnKkzdYfeNBT2 1231276277 Received: from [192.168.1.10] (ALyon-157-1-124-111.w90-42.abo.wanadoo.fr [90.42.19.111]) by mail.messagingengine.com (Postfix) with ESMTPSA id 0D14B23FD0; Tue, 6 Jan 2009 16:11:16 -0500 (EST) Message-ID: <4963C8AD.8010206@ens-lyon.org> Date: Tue, 06 Jan 2009 22:10:05 +0100 From: Martin Jambon User-Agent: Thunderbird 2.0.0.17 (X11/20081008) MIME-Version: 1.0 To: David Allsopp Cc: 'Paolo Donadeo' , 'OCaml mailing list' Subject: Re: [Caml-list] Parsing simple type expressions References: <4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com> <007001c97011$33012dc0$99038940$@com> In-Reply-To: <007001c97011$33012dc0$99038940$@com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 ocamlyacc:01 parser:01 ocaml:01 ocaml:01 serializer:01 bool:01 sscanf:01 genlex:01 camlp:01 bounces:98 2009:98 char:01 wrote:01 parsing:01 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/