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=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_POST,
SPF_NEUTRAL autolearn=disabled version=3.1.3
Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83])
by yquem.inria.fr (Postfix) with ESMTP id 1AD47BB84
for ; Tue, 6 Jan 2009 15:03:52 +0100 (CET)
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AocBAGnzYknRVdoUlGdsb2JhbACTQz4BAQEBCQkKCQ+tAIECjD0BAwEDhW8
X-IronPort-AV: E=Sophos;i="4.36,339,1228086000";
d="scan'208";a="19192653"
Received: from mail-bw0-f20.google.com ([209.85.218.20])
by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Jan 2009 15:03:51 +0100
Received: by bwz13 with SMTP id 13so21465437bwz.3
for ; Tue, 06 Jan 2009 06:03:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:received:received:message-id:date:from:to
:subject:mime-version:content-type:content-transfer-encoding
:content-disposition;
bh=CAJKXfdzsMCT+IZ1RCCJq2KYR5+2HMb50k0aw3ZCO9o=;
b=fgGHGEA2td/Ug4QEaJqFWaCs/fqTWT+lRzB0CivD8/VC3quE6rRohcKqGdEJjdVC29
LGf2DsRcih4lEXY4H5u8q9phH+JtdJsh+ZY1Jzeyb4kaSx5KkPBorBL1HSFGxaaE6lXq
g+veBmHfePMB9xKS/P6dF1zxj73WrqfdowICw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=message-id:date:from:to:subject:mime-version:content-type
:content-transfer-encoding:content-disposition;
b=CQ/b2IPrz0GFXrZdTY8i8IQExJkOj9lu5U+4H18p0iBsMWd8xHjS632UXvhI+ffW6T
7QdXypqrtS8dBZIbqNmi2tF5k/KWYMKadqs4yd2Qll58Lpn5P8wzvrcknc+U/xgU+p3Q
XSCsGrYdUaJsuy7DUFli2RllFNZxKIWMd//Qg=
Received: by 10.223.113.3 with SMTP id y3mr15456110fap.71.1231250631566;
Tue, 06 Jan 2009 06:03:51 -0800 (PST)
Received: by 10.223.113.73 with HTTP; Tue, 6 Jan 2009 06:03:51 -0800 (PST)
Message-ID: <4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com>
Date: Tue, 6 Jan 2009 15:03:51 +0100
From: "Paolo Donadeo"
To: "OCaml mailing list"
Subject: Parsing simple type expressions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-Spam: no; 0.00; serializer:01 ocaml:01 ocaml:01 bool:01 sscanf:01 genlex:01 camlp:01 char:01 parsing:01 functions:01 tuples:01 int:01 int:01 tuple:02 tuple:02
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