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

Bart Kiers bkiers at gmail.com
Thu Mar 25 06:50:41 PDT 2010


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.


More information about the antlr-interest mailing list