[antlr-interest] C# @members

Travis R Rogers travis at jerseyrogers.com
Fri Oct 26 20:09:18 PDT 2007


I believe that ANTLR recognizes // as a line comment regardless of it's
location, therefore you are commenting out the closing } and everything
after that is a failure.  Fortunately in addition to treating it like a
comment in ANTLR it does copy it to the generated code.

At least that's what it appears like when editing a grammar using
ANTLRWorks.

This is the little test I used:
grammar tester;

@members
{
//bob
int i;
}

prog	:	NUMBER;

NUMBER 	:	'0'..'9';

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Benjamin Niemann
Sent: Friday, October 26, 2007 10:41 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] C# @members

Gavin Lambert wrote:

> At 18:52 26/10/2007, de Jong, Ron wrote:
>  >@members { // hello }
>  >
>  >Basically nothing after this is correctly interpreted. I have  
> >tried every variation but the @members just doesn't seem to work.
> 
> I would be surprised if it did.  That's a line comment you've got 
> there, and you're putting everything all on the same line.  Don't do 
> that.
> 
> @members {
>    // hello
> }
> 
> will work.

Suprising that this make a difference. ANTLR does not now that // in an
action section has any special meaning, so it should not influence the
way the rest of the grammar is interpreted.
Or did the OP refer to the generated code being broken, which may be the
case when the template adds some significant code directly after it
without an additional LF.




More information about the antlr-interest mailing list