Bernard James POPE (email@example.com.OZ.AU)
Fri, 18 Aug 2000 15:51:40 +1000 (EST)
Hi Olaf, > However, I don't understand why you want the position in the symboltable > at all. The first problem is which position to put there. An identifier > may occur several times in the program. Note also that the identifier > may occur in various(!) forms: unqualified and qualified with serveral > different module names (because of module renaming or because the > identifier is imported via different modules). Yes this is a good point. I soon realised after I sent the mail that the position information is not really that helpful for what I want to do. What I want to do is perform some source-to-source transformations on Haskell code. The transformations are type-directed, and certain structural properties of the original program must be retained in the output program. Actually I have given the problem some more thought, and it turns out that renaming doesn't bother me too much (although I would like the ability to return to the original name from the renamed version). So long as I can look up the type of (renamed) identifiers in the symbol table after type-checking has been performed. Perhaps more of a problem at the moment is the insertion of "| Prelude.True" guards into the syntax tree after parsing. If this is done uniformly, I assume I can remove them, however it is a concern to me that there may be other possible modifications to the syntax tree during parsing. This is perhaps a naive question, but why are the guards inserted? And can I simply remove/ignore them? > I also plan to make the intermediate outputs of nhc more readable and > Haskell-conformant as far as possible. So I am thinking about how to > preserve an original name in the tokenId. However, because an identifier > may occur in different forms and I haven't yet fully understood, what > the > Qualified2 and Qualified3 kinds of TokenId are used for, I haven't yet > done anything. It seems like some type of association table is needed, which links a unique name to the various forms from the original program, essentially an un-rename function. I have thought about trying to add this myself, however I am new to the compiler and adding this feature is not trivial. Thanks for your help. Regards, Bernie.