[antlr-interest] Lexer rule for strings with quoted strings within

Jim Idle jimi at temporal-wave.com
Thu Mar 25 08:23:59 PDT 2010


1) Backtracking will not work in lexers
2) Don't advise people to use backtrack mode
3) That rule will give warnings anyway


BTW Guys, don't forget antlr.markmail.org !!!

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Bart Kiers
> Sent: Thursday, March 25, 2010 6:51 AM
> To: Anders Sollander
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Lexer rule for strings with quoted
> strings within
> 
> On Thu, Mar 25, 2010 at 2:01 PM, Anders Sollander <
> Anders.Sollander at mathworks.de> wrote:
> 
> > Hi,
> >
> > I've been trying to write a lexer rule for strings with strings in
> them,
> > like
> >
> >        "This has a ""quoted string"" within"
> >
> > Is there a simple lexer rule for this, or do I need some kind of look
> > ahead?
> >
> >
> You could enable the `backtrack` option:
> 
> String
> options { backtrack = true; }
>   :  '"' ('""' | ~'"')+ '"'
>   ;
> 
> Regards,
> 
> Bart.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list