[MLton] ML question

Matthew Fluet fluet@cs.cornell.edu
Sun, 23 Apr 2006 17:13:10 -0400 (EDT)


>> I would like to be able to get accurate identifier cross-reference
>> for an ML program.  That is, for every occurrence of every identifier,
>> I would like to know its source-code location, whether it's a binding
>> instance, and if not, the source-code location of the binding instances.
>> Do you have any idea what ML front end might be most readily adapted
>> to provide this information?
>
> MLton already provides all of this information, albeit you may need to 
> massage the output for your purposes (which is noweb, I'm guessing).  From 
> the mlton man page:
>
> -show-def-use file
>
>      Output def-use information to file. Each identifier that is defined
>      appears on a line, followed on subsequent lines by the position of
>      each use.
>
> It may be more efficient to modify MLton to output the def-use info in a 
> format more suitable for your purposes than it is massage the current output; 
> but, all of the info is there.

The relevant portion of the compiler is
  mlton/elaborate/elaborate-env.fun
specifically, the processDefUse function.