[antlr-interest] Lexer Help, line-comment begins with a character that is also an operator

Jim Idle jimi at temporal-wave.com
Tue Sep 2 07:35:22 PDT 2008


On Tue, 2008-09-02 at 02:24 -0400, Anand.Vidyasagar at sungard.com wrote:

> Thanks for the help!!
> 
> I tried this new definition of LINE_COMMENT, I also changed the
> "operator" grammar definition to 
> operator
> options { k=2;}
>       :
>               STAR
>         |     '/'
>         |     '+'
>         |     '-'
>         |     DBLSTAR
>         |     '<<'
>         |     '>>'
>       ;
> 
> And now I get a different kind of exception. 
> 
> line 1:1 rule LINE_COMMENT failed predicate: { getCharPositionInLine()
> == 0 }?


You probably want a gated predicate here, not a simple semantic
predicate.

{ getCharPositionInLine() == 0 }?=> X Y Z....

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080902/318e4fe4/attachment.html 


More information about the antlr-interest mailing list