caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: David Allsopp <dra-news@metastack.com>
Cc: 'Paolo Donadeo' <p.donadeo@gmail.com>,
	'OCaml mailing list' <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Parsing simple type expressions
Date: Tue, 06 Jan 2009 22:10:05 +0100	[thread overview]
Message-ID: <4963C8AD.8010206@ens-lyon.org> (raw)
In-Reply-To: <007001c97011$33012dc0$99038940$@com>

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/


  reply	other threads:[~2009-01-06 21:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-06 14:03 Paolo Donadeo
2009-01-06 15:12 ` [Caml-list] " David Allsopp
2009-01-06 21:10   ` Martin Jambon [this message]
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=4963C8AD.8010206@ens-lyon.org \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=dra-news@metastack.com \
    --cc=p.donadeo@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).