[antlr-interest] Preserving ALL comments!

Damir Kirasić damir.kirasic at fer.hr
Mon Feb 20 02:34:27 PST 2006


Hello,

We want to constuct AST for the Standard C programs
and to have ALL comments preserverd.

We started with StdCParser.g from examples
(we use CommonHiddenStreamToken, CommonASTWithHiddenTokens
and all the stuff)
and it works fine but not ALL the comments
seem to be present in the AST.

For example, for the following snippet:

/* comment1 */
main()  /* comment2  */
{
	printf("Hello");
}
/* comment3 */


only comment1 can be found in the AST.

It seems that comment2 is tied to RPAREN
and comment3 to RCURLY.
RPAREN and RCURLY are not included in the AST
and comment2 and comment3 are lost.

Am I right?
How to get ALL the comments in AST?

Thank you for your time.


Damir


More information about the antlr-interest mailing list