[antlr-interest] Unterminated html comments
Jim Idle
jimi at temporal-wave.com
Mon Feb 18 07:27:41 PST 2008
> -----Original Message-----
> From: Steve Bennett [mailto:stevagewp at gmail.com]
> Sent: Sunday, February 17, 2008 8:46 PM
> To: antlr-interest
> Subject: [antlr-interest] Unterminated html comments
>
> Can anyone think how to lex both terminated and unterminated HTML
> comments? That is:
>
> <!-- this should all be one token -->
>
> <!-- this should all be one token <EOF>
>
> I have this:
>
> HTML_COMMENT:
> (('<!--') => '<!--' .* ('-->' | EOF) { $channel=HIDDEN; })
> | '<' { $type=LT; };
>
> But it doesn't work. On a line like: <!-- foo -->, the "<!-- f" gets
> lost (doesn't form a token in ANTLRworks).
You probably want the greedy=false option on that .* rule: ( options
{greedy=false;} : . )*
Jim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Jim Idle.vcf
Type: text/x-vcard
Size: 1863 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080218/272a941e/attachment-0001.vcf
More information about the antlr-interest
mailing list