[antlr-interest] Grammar for block comments?
Jim Idle
jimi at temporal-wave.com
Thu Jul 17 09:37:41 PDT 2008
On Thu, 2008-07-17 at 20:38 +1200, Gavin Lambert wrote:
> At 19:56 17/07/2008, Andy Doddington wrote:
> >I haven't had a chance to test this in my app, but when I run it
>
> >inside AntlrWorks I get a:
> >
> > FailedPredicateException(COMMENT, {synpred1}?)
>
> ANTLRworks reacts strangely to predicates sometimes, so it could
> just be that. But another thing you could try is to reverse the
> order of the alts within the * block.
>
Well, with ANTLR Works 1.2b5, the following grammar works perfectly:
grammar test;
prog: (COMMENT | OTHER)+ ;
COMMENT
: '/*' (options {greedy = false;} : .)* '*/' ;
OTHER
: .
;
Using input:
/* XYZ * */
SOME OTHER STUF F*/
What version of ANTLR are you using again? I use this same construct in
quite a number of grammars and have not had problems with it. Perhaps
there is something else in your lexer spec that is interfering?
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080717/5a8abb89/attachment.html
More information about the antlr-interest
mailing list