Version française
Home     About     Download     Resources     Contact us    
Browse thread
Parsing simple type expressions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Parsing simple type expressions
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
> 
> 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
> 
> _______________________________________________
> 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