[antlr-interest] Comment rule matches links

Randall R Schulz rschulz at sonic.net
Tue Aug 26 07:07:06 PDT 2008


On Tuesday 26 August 2008 03:58, Gavin Lambert wrote:
> At 21:22 26/08/2008, Jenny Balfer wrote:
> ...
>
> Is there a good Perl grammar for v3 around somewhere?  That has
> the same kind of regexp literals, so that might give you some
> ideas.

I don't know about that, but Groovy has RE literals of this sort 
(including the slash delimiters) and uses an ANTLR parser, so you could 
check what they do.

I think, though, that their approach is that these things are a special 
kind of string notation, with different internal escaping rules (much 
more limited, so REs don't tend to require gobs of extra backslashes as 
they do in Java). Then the resulting "slashy string" (their 
terminology) is interpreted by the standard Java library RE code (when 
and if it ends up there).

Thus the parser can't tell whether they're proper REs or not and you 
don't know whether they are valid or not until you run the program. But 
Groovy's dynamic nature means  many bugs and errors are not detected 
until run-time.


Randall Schulz


More information about the antlr-interest mailing list