I wrote a tutorial titled Compiling to JavaScript, and Debugging with Source Maps for the Mozilla Hacks blog:

This is a tutorial on how to write a compiler which generates JavaScript as its target language, and maintains line and column meta-data in source maps for debugging. Storing line and column coordinates in a source map allows the end-user of the compiler to debug the source code that they wrote, rather than the ugly, generated JavaScript they are not familiar with.

Go read it!