[antlr-interest] compilation error on grammar

Warner Onstine warnero at gmail.com
Thu Aug 2 16:52:41 PDT 2007


On 8/2/07, Randall R Schulz <rschulz at sonic.net> wrote:
> On Thursday 02 August 2007 16:37, Warner Onstine wrote:
> > Hi all,
> > Just to preface this, I am very new to grammars (and ANTLR
> > specifically). I am attempting to convert a Groovy DSL that I wrote
> > to an external DSL piece by piece. Here is the current error I'm
> > running into with this grammar:
> > grammar Model;
> >
> > ...
> >
> > When I generate the java class files for the grammer I get an error
> > in my ModelParser.java file here:
> >     // $ANTLR start prog
> >     //
> > C:\\java\\projects\\chama-antlr\\src\\main\\antlr\\Model.g:3:1: prog
> > : package ( WS )? model ;
> >     public final void prog() throws RecognitionException {
> >         try {
> >             //
> > C:\\java\\projects\\chama-antlr\\src\\main\\antlr\\Model.g:3:8: (
> > package ( WS )? model )
> >             //
> > C:\\java\\projects\\chama-antlr\\src\\main\\antlr\\Model.g:3:8:
> > package ( WS )? model
> >             {
> >             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).

-warner

>
> > any help is greatly appreciated
>
>
> Randall Schulz
>


-- 
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