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: Paolo Donadeo <p.donadeo@g...>
Subject: 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