[antlr-interest] Need help regarding lexer
elango m
go2elango at gmail.com
Thu Mar 20 06:34:25 PDT 2008
I got it. Thanks Gavin for explaining so well.
Regards,
-EM-
On Thu, Mar 20, 2008 at 12:21 AM, Gavin Lambert <antlr at mirality.co.nz>
wrote:
> At 05:08 20/03/2008, elango m wrote:
> >I am just curious why STR_LITERAL : '\'' ('\'\'')* ~('\'')* '\''
> >; didn't worked???
>
> Because order is significant. If you expand out each element of
> that rule and see what it means:
>
> '\'' : match a single quote
> ('\'\')* : match zero or more sets of two single quotes
> ~('\'')* : this is actually illegal, but in theory it's "match
> zero or more characters that aren't single quotes".
> '\'' : match a single quote
>
> Follow that through in order, and it's obvious why it can't
> possibly match input such as "'a''bc'". It could, however, match
> something like "'''''''''abcd'.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080320/e551dc0e/attachment.html
More information about the antlr-interest
mailing list