[antlr-interest] Conditionally parsing comments in Java language?

John D. Mitchell johnm-antlr at non.net
Tue Apr 26 09:01:21 PDT 2005


>>>>> "Anton" == Anton Safonov <anton.safonov at refactorit.com> writes:
[...]

> I cannot let lexer to parse every comment, since the most of them are
> naturally not a Java code.  But at the same time some of the comments
> must be split into tokens to feed it to the parser.  So, the possible
> solution so fer: let comments pass to the parser, detect there that the
> comment can be parsed, kill leading "//--" and feed the block back to
> lexer etc.  Sounds weird, especially trying to keep the correct
> coordinates of the tokens/ASTs.

Seems like your case is very well structured so you could do a really
simple preprocessor to "uncomment" those lines.

Hope this helps,
		John



More information about the antlr-interest mailing list