[antlr-interest] Antlr grammar for regular expressions
Andy Tripp
antlr at jazillian.com
Tue Jul 31 10:14:05 PDT 2007
sr?an bejakovic' wrote:
> Hi all,
>
> does anyone know of an Antlr grammar for parsing (perl or java)
> regular expressions? I started implementing something like this, but I
> don't want to (suboptimally) reinvent something that probably already
> exists. Thanks,
>
> Srdan
Sun's JDK1.7 is under the GPL, and there's a regex parser in the
java.util.regex.Pattern class.
Just download the source for JDK1.7 and look at
src/share/classes/java/util/regex/Pattern.java
The recursive decent parser code starts at method a method called
expr(), and the code actually
looks pretty readable.
More information about the antlr-interest
mailing list