From: "Paolo Donadeo" <p.donadeo@gmail.com>
To: "OCaml mailing list" <caml-list@yquem.inria.fr>
Subject: Parsing simple type expressions
Date: Tue, 6 Jan 2009 15:03:51 +0100 [thread overview]
Message-ID: <4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com> (raw)
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
next reply other threads:[~2009-01-06 14:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-06 14:03 Paolo Donadeo [this message]
2009-01-06 15:12 ` [Caml-list] " David Allsopp
2009-01-06 21:10 ` Martin Jambon
2009-01-06 22:49 ` Re : " Matthieu Wipliez
2009-01-07 22:50 ` Paolo Donadeo
2009-01-06 18:19 ` Jake Donham
2009-01-06 21:00 ` Paolo Donadeo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b5157c30901060603k6d0589d2m469b170dc5ec7c8e@mail.gmail.com \
--to=p.donadeo@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox