[antlr-interest] Doc-comments in generated Java

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Fri Mar 13 06:22:19 PDT 2009


Hi all,

I seem to recall posting about this back in the ANTLR 2 days, but now I
found myself running into it again.

I'd like there to be some vague documentation generated by Javadoc for
my parser/lexer/etc. I've got a combined grammar, with a doc-comment on
the grammar itself. This gets attached to the generated parser class,
and not to the generated lexer class. Doc-comments on rules don't get
passed anywhere, and really, it probably wouldn't make sense for them to.

Is there any way to (easily, without me learning StringTemplate) make it
so that functions generated from rules have a doc-comment like:

/**
 * Generated from rule RULENAME (line LINENUM)
 */

and generated classes are like:

/**
 * Parser|Lexer generated from GRAMMAR-FILENAME
 */

And not pass through the doc-comment on the grammar itself? I'd probably
want them to say "generated by ANTLR version VERSION" rather than just
"generated", really, possibly with a linking tag and stuff, but that's
not difficult to change once I have some idea how to do this basic stuff.

Thanks for any help or guidance.

Sam


More information about the antlr-interest mailing list