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.1 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 20E28BB84 for ; Tue, 6 Jan 2009 16:12:45 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEBAI4DY0lRZ90xlGdsb2JhbACNRoY7AQEBAQkLCAkRA7sOhXI X-IronPort-AV: E=Sophos;i="4.36,339,1228086000"; d="scan'208";a="21104219" Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Jan 2009 16:12:44 +0100 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090106151243.ILQL7670.mtaout03-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com>; Tue, 6 Jan 2009 15:12:43 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090106151243.HVGI22934.aamtaout04-winn.ispmail.ntl.com@romulus.metastack.com>; Tue, 6 Jan 2009 15:12:43 +0000 Received: from Countertenor ([172.16.0.6]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id n06FCdDv025511 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 6 Jan 2009 15:12:41 GMT From: "David Allsopp" To: "'Paolo Donadeo'" , "'OCaml mailing list'" References: <4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com> In-Reply-To: <4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com> Subject: RE: [Caml-list] Parsing simple type expressions Date: Tue, 6 Jan 2009 15:12:31 -0000 Organization: MetaStack Solutions Ltd. Message-ID: <007001c97011$33012dc0$99038940$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AclwB50gE80EcS7RQEuVHP0pMNSriwACQS5Q Content-Language: en-gb X-Scanned-By: MIMEDefang 2.64 on 81.102.132.74 X-Cloudmark-Analysis: v=1.0 c=1 a=ksIsgvTcUK8A:10 a=DYP6lOVfTs8A:10 a=ZOzjf2MOAAAA:8 a=CjxXgO3LAAAA:8 a=lHnUEb31F_YzWxU6j9YA:9 a=tW2UA2BQf20YwPQDlYUA:7 a=fEgrKQ_a6aK-aJeOx144xvh2RV0A:4 a=pkLwLwoEMAkA:10 X-Spam: no; 0.00; ocamlyacc:01 parser:01 ocaml:01 ocaml:01 serializer:01 bool:01 sscanf:01 genlex:01 camlp:01 beginner's:01 bug:01 bounces:98 2009:98 char:01 beginners:01 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 > -----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 >=20 > 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: >=20 > type types =3D > | Int > | String > | Float > | Char > | Bool > | Option of types > | List of types > | Tuple of types list >=20 > the function I need should return something like List (Tuple ([Int; > Option(String)])) >=20 > 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 :-) >=20 > So is there a simple way to write this function using some standard > module? >=20 > TIA, >=20 >=20 > -- > Paolo > ~ > ~ > :wq >=20 > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs