Re: Preserving line number information in Sage

>	However, I would like to generate the new source code  
>the line numbers from the original file (for debugging purposes).  
That is,
>new statements would have to be appended to existing lines so they  
>alter line numbers. 


this is impossible to do for two reasons:
-first, even if you do not modify the code in any way, but just run  
it through the parser and the unparser, the line numbers will be  
different. For example,

int i,

int foo();


int i, j;
int foo();

-second, there is no way to tell the unparser to unparse more than  
one statement into a single line.

However, if you just want something that will help in debugging, you  
might consider adding comments that, for example,  will tell you what  
file and line number each statement comes from (you could add those  
comments only to the statements from the original source and add  
different comments to statements that you have added). For the above  
example, the output might look something like:

      /* file x.c, line no. 1 */
int i, j;

      /* file x.c, line no. 4 */
int foo();

If you think that this "solution" is at all useful, let me know. I  
can send you a little demo code that inserts such comments. --Beata