[antlr-interest] ANTLR3 Capturing System.out.println

David Holroyd dave at badgers-in-foil.co.uk
Thu Mar 29 07:06:34 PDT 2007

On Thu, Mar 29, 2007 at 09:37:07AM -0400, Kailey Joanette wrote:
> So. I'm sticking to a syntactic translation for now, until I find that I
> definitely need semantic.
> I have a question though. how would I go about capturing things like
> System.out.println() and System.currentTimeMillis()?  I tried putting a
> matching block in 'statement' rule of the Java 1.5 grammar that would match
> 'System''.''out''.''println''(' outputExpression ')' but that ended up
> creating problems with other system calls. Because now when it reaches say
> System.currentTimeMillis I says there is no viable alternative when it
> reaches "System". which I don't understand because my rule doesn't deal with
> that so it should just default to the same rules it has always used.
> Is there a better way to capture things like this and get the desired
> output?

The 'ANTLR Way' would be to leave the syntax-recognition well alone;
have the parser generate an AST, and then do this kind of task in a



More information about the antlr-interest mailing list