[antlr-interest] compilation error on grammar

Warner Onstine warnero at gmail.com
Thu Aug 2 17:04:41 PDT 2007


On 8/2/07, Kay Roepke <kroepke at classdump.org> wrote:
>
> On Aug 3, 2007, at 1:52 AM, Warner Onstine wrote:
>
> >>>             pushFollow(FOLLOW_package_in_prog10);
> >>>             package();
> >>>             _fsp--;
> >>>
> >>> on the package(); call Eclipse (and a normal build) is telling me
> >>> that: illegal start of an expression
> >>> <identifier>(or this) expected
> >>> '(' expected
> >>
> >> I advise against using line comments in the actions of ANTLR
> >> grammars.
> >> All the lines of an action are passed through, without regard to
> >> whether they happen to be partially or fully commented. The problem
> >> comes from the fact that ANTLR (the target language-specific string
> >> templates, I guess) sometimes expand portions of the actions with
> >> content that includes a newline, thus prematurely terminating the
> >> comment.
> >>
> >> Instead, use only /* explicitly bounded */ comments inside actions.
> >>
> >
> > Ok, how do I turn this off? I'm not doing any comments in the Model.g
> > file itself, all of the comments that show up in Java are generated by
> > antlr. (If that's the problem you're referring to).
>
> You can't turn it off, and it is not causing your problem. The
> comments are
> just annotations and are comments after all.
>
> You do have a rule called 'package', right?

Correct.

>
> I guess that Java doesn't like that as a method name (which ANTLR
> will turn
> parser rule names into). I suggest renaming that rule.
>
> Please provide the complete error message in your posts (or at least
> the line number
> reported). It took me a while of hard staring to sort through the
> wrapped source code
> to actually figure out why this code would be invalid or where the
> error was supposed
> to be.

This did fix the problem, thanks much! Gotta watch those Java-naming
conventions (gotten me more than once!)

-warner

>
> HTH,
> -k
> --
> Kay Röpke
> http://classdump.org/
>
>
>
>
>


-- 
Warner Onstine - Programmer/Author
New book on Tapestry 4!
Tapestry 101 available at
http://sourcebeat.com/books/tapestrylive.html
warner at warneronstine.com
http://warneronstine.com/blog


More information about the antlr-interest mailing list