[antlr-interest] Is a bug if multiple groups comments

Thomas Brandon tbrandonau at gmail.com
Wed Aug 15 09:30:10 PDT 2007


On 8/16/07, 向秦贤 <fyaoxy at gmail.com> wrote:
> Thank you :)
> Do you think multiple comments in one rule is necessary?
> Sometimes people may wanna comment something just like which that
> piece represented.
Multiple comments certainly, and they are supported. The issue only
affects multiple javadoc comments. Multiple javadoc comments are a
different matter. Only one javadoc comment for each rule can be used
so multiple javadoc comments isn't really useful, and having
non-javadoc comments such as yours using the javadoc pattern probably
isn't the best approach. In your case the first rule in your commented
block would have the block comment as a javadoc comment, not what you
want.
Currently the javadoc handling is rather simplistic with anything but
a single javadoc comment immediately proceeding a rule causing an
error. It may be nicer if ANTLR ignored all but the last javadoc
comment for a rule, this is what javac seems to do, without any
warning. Perhaps a warning could be given though I don't know thats
necessary. At least ANTLR could give a better error message about the
problem.

Tom.
>
> 2007/8/15, Thomas Brandon <tbrandonau at gmail.com>:
> > On 8/15/07, 向秦贤 <fyaoxy at gmail.com> wrote:
> > > Hi, given this grammar piece:
> > > begin
> > > /*******************************************
> > > * keywords refine
> > > ********************************************/
> > > //keySTRING:{input.LT(1).getText().equals("string");}WORD;
> > >
> > > /*******************************************
> > > * all lexer rulers
> > > ********************************************/
> > > end;
> > >
> > > antlr report "unexpected token ....
> > > /*******************************************
> > > * all lexer rulers
> > > ********************************************/
> > > "
> > > is this a bug?
> > > I think it is acceptable to allow this style.
> > ANTLR's grammar does not handle multiple javadoc comments per rule. As
> > your comments start with /** ANTLR is treating them as javadoc
> > comments and as there is no rule in between them this causes an error.
> > Changing them to "//********..." or to "/* *****..." should work.
> > This could perhaps be improved in the antlr grammar rewrite, putting
> > javadoc comments on their own channel.
> >
> > Tom.
> > >
> > > --
> > > 致敬
> > > 向秦贤
> > >
> >
>
>
> --
> 致敬
> 向秦贤
>


More information about the antlr-interest mailing list