English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
Extracting common information
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-05-24 (14:23)
From: Stephen Weeks <sweeks@s...>
Subject: Re: [Caml-list] Extracting common information
> I am working on a simple compiler in Ocaml, and having some difficulty
> settling on the best design for my AST.
> then I realized I would want to thread along some annotation to store the
> types, line numbers, and things like that.  Since these annotations will
> change between compiler passes,

I ran in to the same design problem when writing MLton.  My solution was to use
lisp-style property lists, but with appropriate ML static typing.  See


The essence of the solution is to use a dynamically extensible sum type.  Each
tree node holds a list ref of values in the sum type.  Each compiler pass builds
a new variant of the sum type and stores whatever it needs in the list.