[antlr-interest] Lexing problem

Terence Parr parrt at cs.usfca.edu
Fri Oct 13 09:55:18 PDT 2006


On Oct 13, 2006, at 8:34 AM, Emond Papegaaij wrote:

> Hello,
>
> I'm trying to match a multiline c-style comment into a COMMENT token
> without the opening and closing '/*' and '*/'. This is how I would  
> do it
> in ANTLRv2:
> COMMENT: '/*'! ( options {greedy=false;} : . )*  '*/'!;
>
> However the '!' does not work in v3. So I tried all of the following:
>
> COMMENT: '/*' contents=COMMENT_BODY '*/' { setText($contents.text); };
> COMMENT_BODY: ( options {greedy=false;} : . )*;

Make that rule a "fragment".

Ter



More information about the antlr-interest mailing list