[antlr-interest] Dumping source code into generated output code...

Rob Greene robgreene at gmail.com
Wed Nov 1 20:17:29 PST 2006


How would I go about emitting a line of source code into generated code as a
comment?  Is this possible?  What's the general strategy?

Something like this:
; x = x + 2      <-- original source line
    clc          <-- target assembly (or intermediate code) output
    lda x
    adc #2
    sta x

I've got a compiler functioning now (nowhere near complete) and it would be
really handy if I could have the original source code map into my output
assembly code.  That would give me visual signposts to identify where I am
in reference to the original source.

For reference, I use ANTLR to parse the language into ASTs and then into an
intermediate code (a three-address-ish type code) which is then optimized
and then I use StringTemplate to generate my target assembly.  At a minimum,
I'd like to dump the code references into my intermediate code with the hope
of passing it through to the target assembly code.

Thanks for any ideas!!
-Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061101/78866a44/attachment.html 


More information about the antlr-interest mailing list