[antlr-interest] Comments/newlines

Sohail Somani sohail at taggedtype.net
Thu Sep 29 22:48:28 PDT 2005


On Thu, 2005-29-09 at 19:26 -0400, Bryan Ewbank wrote:
> Given your sample file, is EOL by itself an acceptable statement, or
> is this an error?
> 
> One way to parse the comments is to consume from "//" up to, but not
> including, the next EOL character.  Or, use the EOL token to consume a
> literal EOL with an optional preceeding "//" style comment.
> 

Hi Bryan,

The grammar does allow for statements of (EOL)*. What I'm doing is
setting the type of SL_COMMENT to EOL.

I dont particularly like this method. Can you give me an example of a
single line comment lexer rule that will consume all but EOL?

Thanks

> 
> > x = y // some comment
> > // some comment
> > x = y
> >
> > I want to parse both obviously language statement as
> >     IDENTIFIER EQ IDENTIFIER EOL



More information about the antlr-interest mailing list