[antlr-interest] Retaining Comments after parsing the file

vasanthi a vasanthi.ak at gmail.com
Sun Apr 19 07:28:54 PDT 2009


 HI All

I am facing a problem, while I try to instrument a source file which is
having comment.

I am using the below source for checking the grammar.

// Single-line comments

SL_COMMENT

: "//" (~('\r'|'\n'))* {$setType(Token.SKIP);}
;

Once the grammar is checked, it skips this line and the instrumented code
the comments are not seen in the instrumented file

Can you please let me know to retain the comments in the instrumented file


For example (Before instrumentation the file looks as below)


//Test java

//Test the java source code

import java.io.*;

class A

{

public static void main(String args[])

{

System.out.println("Vasanthi");

}

}





After instrumentation  the file looks as below. Hence comment is lost..





import java.io.*;

import instrumentor.agent.java.PrfAgent;



class A

{

public static void main(String args[])

{

PrfAgent.writeToLog(2);

System.out.println("Vasanthi");

PrfAgent.writeToLog(-2);

}

}





Can you please let me know how to retain the comment in the instrumented
file.



Please reply



Thanks and regards

Vasanthi A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090419/e09403e7/attachment.html 


More information about the antlr-interest mailing list