[Haskell-cafe] Tiger compiler in Haskell: annotating abstract syntax tree

José Pedro Magalhães jpm at cs.uu.nl
Tue Jul 20 03:17:15 EDT 2010


Hi José,

2010/7/19 José Romildo Malaquias <j.romildo at gmail.com>

>
> I am writing here to ask suggestions on how to annotate an ast with
> types (or any other information that would be relevant in a compiler
> phase) in Haskell.
>
> As an example, consider the simplified ast types:
>
>  data Exp
>    = IntExp Integer
>    | VarExp Symbol
>    | AssignExp Symbol Exp
>    | IfExp Exp Exp (Maybe Exp)
>    | CallExp Symbol [Exp]
>    | LetExp [Dec] Exp
>
>  data Dec
>     = TypeDec Symbol Ty
>     | FunctionDec Symbol [(Symbol,Symbol)] (Mybe Symbol) Exp
>     | VarDec Symbol (Maybe Symbol) Exp
>
> Expressions can have type annotations, but declarations can not.
>
> Comments?
>

Indeed I would suggest the method described in our paper:

Martijn van Steenbergen, José Pedro Magalhães, and Johan Jeuring. Generic
selections of subexpressions.
Paper link: http://dreixel.net/research/pdf/gss_draft.pdf
Related hackage package: http://hackage.haskell.org/package/Annotations

Something like what Malcolm proposed (adding one extra constructor) would
also be possible generically, but it would be more similar to how we add
meta-variables in our generic rewriting library (ask for more details if
you're interested in this alternative).


Cheers,
Pedro


>
>
> Regards,
>
> Romildo
> --
> Computer Science Department
> Universidade Federal de Ouro Preto, Brasil
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100720/5a634c8a/attachment.html


More information about the Haskell-Cafe mailing list