[antlr-interest] grammar for jdk1.5 parameterized types

Matthew Ford Matthew.Ford at forward.com.au
Thu Sep 18 12:05:18 PDT 2003


http://www.thecortex.net/clover/generics.html#grammar
An ANTLR Java grammar supporting Generics
The Clover team uses the ANTLR tool in order to parse your Java code. ANTLR
comes with an example grammar for parsing Java code, and we have spent some
time updating it so that it can parse JSR14 code.

This grammar is a work-in-progress, but you can download our most recent
efforts here: javaG.g.

If you are interested, Matt has written a blog entry that further explains
these changes.

matthew

----- Original Message ----- 
From: "John P N Pybus" <john-yahoo at pybus.org>
To: <antlr-interest at yahoogroups.com>
Sent: Friday, September 19, 2003 4:55 AM
Subject: Re: [antlr-interest] grammar for jdk1.5 parameterized types


> mzukowski at yci.com wrote:
> > You can't switch your lexer from the parser safely.  ANTLR doesn't work
that
> > way (infinite lookahead and all that).  I suggest getting rid of ">>" as
a
> > token and making the parser look for '>' '>' as GT.
> >
> > Monty
>
> Hmm, with the lexer ignoring Whitespace wouldn't the parser then allow
> "n > > 3" as well as "n >> 3"?
>
> I'd suggest using lookahead in the lexer to define 3 tokens GT_GT,
> GT_EQ, and GT corresponding to a '>' directly followed by another '>';
> '>' followed by '=' and all other '>' chars, respectively.
>
> You can use ( GT | GT_GT ) in your parser rules for generics, and can
> define the various shift operators as GT_GT GT; GT_GT GT_EQ EQ etc...
>
> I haven't done this with the antlr java grammar myself, but I believe
> I've seen this approach used in other java1.5 recognisers (sorry no
> reference handy).
>
> Hope this makes some sense.
>
> Yours,
>
> John
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list